Skip to content

Commit 5f95156

Browse files
authored
chore: add clickedCompleteYourProfile tracking (#16167)
1 parent 186fa28 commit 5f95156

File tree

3 files changed

+70
-5
lines changed

3 files changed

+70
-5
lines changed

src/Apps/Order/Routes/Details/Components/OrderDetailsMessage.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ const MessageContent = ({
103103
<Spacer y={2} />
104104
<Text variant="sm">
105105
The gallery will confirm by <b>{formattedStateExpireTime}</b>.
106-
{hasIncompleteProfile && <CompleteCollectorProfilePrompt />}
106+
{hasIncompleteProfile && (
107+
<CompleteCollectorProfilePrompt tracking={tracking} />
108+
)}
107109
</Text>
108110
<Spacer y={2} />
109111
<Text variant="sm">
@@ -123,7 +125,9 @@ const MessageContent = ({
123125
<Text variant="sm">
124126
The gallery will respond to your offer by{" "}
125127
<b>{formattedStateExpireTime}</b>.
126-
{hasIncompleteProfile && <CompleteCollectorProfilePrompt />}
128+
{hasIncompleteProfile && (
129+
<CompleteCollectorProfilePrompt tracking={tracking} />
130+
)}
127131
</Text>
128132
<Spacer y={2} />
129133
<Text variant="sm">
@@ -409,11 +413,24 @@ const MessageContent = ({
409413
}
410414
}
411415

412-
const CompleteCollectorProfilePrompt: React.FC = () => (
416+
interface CompleteCollectorProfilePromptProps {
417+
tracking: ReturnType<typeof useOrder2Tracking>
418+
}
419+
420+
const CompleteCollectorProfilePrompt: React.FC<
421+
CompleteCollectorProfilePromptProps
422+
> = ({ tracking }) => (
413423
<>
414424
{" "}
415425
You're more likely to receive quick responses from galleries by{" "}
416-
<RouterLink to="/settings/edit-profile" target="_blank" display="inline">
426+
<RouterLink
427+
onClick={() => {
428+
tracking.clickedCompleteYourProfile()
429+
}}
430+
to="/settings/edit-profile"
431+
target="_blank"
432+
display="inline"
433+
>
417434
completing your profile
418435
</RouterLink>
419436
.

src/Apps/Order/Routes/Details/Components/__tests__/OrderDetailsMessage.jest.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import { OrderDetailsMessage } from "../OrderDetailsMessage"
77

88
jest.mock("react-tracking")
99

10+
jest.mock("System/Hooks/useAnalyticsContext", () => ({
11+
useAnalyticsContext: jest.fn(() => ({
12+
contextPageOwnerId: "test-id",
13+
contextPageOwnerType: "orders-detail",
14+
})),
15+
}))
16+
1017
jest.unmock("react-relay")
1118
const trackEvent = jest.fn()
1219

@@ -95,6 +102,36 @@ describe("OrderDetailsMessage", () => {
95102
).toHaveAttribute("href", "/settings/edit-profile")
96103
})
97104

105+
it("tracks complete your profile click", () => {
106+
renderWithRelay({
107+
Order: () => ({
108+
buyerStateExpiresAt: mockDate,
109+
code: "123",
110+
internalID: "test-id",
111+
displayTexts: {
112+
messageType: "SUBMITTED_OFFER",
113+
},
114+
impulseConversationId: "conv-123",
115+
}),
116+
Me: () => ({
117+
collectorProfile: { bio: "" },
118+
}),
119+
})
120+
121+
const profileLink = screen.getByRole("link", {
122+
name: "completing your profile",
123+
})
124+
125+
profileLink.click()
126+
127+
expect(trackEvent).toBeCalledWith({
128+
action: "clickedCompleteYourProfile",
129+
context_module: "ordersDetail",
130+
context_page_owner_type: "orders-detail",
131+
context_page_owner_id: "test-id",
132+
})
133+
})
134+
98135
it("renders collector profile prompt for SUBMITTED_ORDER with incomplete profile", () => {
99136
renderWithRelay({
100137
Order: () => ({

src/Apps/Order2/Hooks/useOrder2Tracking.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import {
22
ActionType,
33
type ClickedAskSpecialist,
44
type ClickedBuyerProtection,
5+
type ClickedCompleteYourProfile,
56
type ClickedContactGallery,
67
type ClickedImportFees,
78
type ClickedVisitHelpCenter,
8-
type ContextModule,
9+
ContextModule,
910
type OrderDetailsViewed,
1011
OwnerType,
1112
type PageOwnerType,
@@ -107,6 +108,16 @@ export const useOrder2Tracking = (
107108
message_type: messageType,
108109
}
109110

111+
trackEvent(payload)
112+
},
113+
clickedCompleteYourProfile: () => {
114+
const payload: ClickedCompleteYourProfile = {
115+
action: ActionType.clickedCompleteYourProfile,
116+
context_module: ContextModule.ordersDetail,
117+
context_page_owner_type: contextPageOwnerType,
118+
context_page_owner_id: contextPageOwnerId,
119+
}
120+
110121
trackEvent(payload)
111122
},
112123
}

0 commit comments

Comments
 (0)