Skip to content

Commit 6bc7e18

Browse files
MounirDhahriMrSltun
authored andcommitted
chore: add experiment viewed tracking to inquiry modal (#13217)
chore: add tracking to inquiry modal chore: address feedback chore: use onShow
1 parent 6c402a6 commit 6bc7e18

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/app/Scenes/Artwork/Components/CommercialButtons/InquiryModal.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { OwnerType } from "@artsy/cohesion"
12
import { InfoIcon } from "@artsy/icons/native"
23
import { Box, Flex, Input, Screen, Text, useColor } from "@artsy/palette-mobile"
34
import { InquiryModal_artwork$key } from "__generated__/InquiryModal_artwork.graphql"
@@ -32,7 +33,10 @@ interface InquiryModalProps {
3233
}
3334

3435
export const InquiryModal: React.FC<InquiryModalProps> = ({ artwork: _artwork, me }) => {
35-
const { variant } = useExperimentVariant("topaz_retire-inquiry-template-messages")
36+
const { variant, trackExperiment } = useExperimentVariant(
37+
"topaz_retire-inquiry-template-messages"
38+
)
39+
3640
const { state, dispatch } = useArtworkInquiryContext()
3741
const color = useColor()
3842
const scrollViewRef = useRef<KeyboardAwareScrollViewRef>(null)
@@ -135,6 +139,14 @@ export const InquiryModal: React.FC<InquiryModalProps> = ({ artwork: _artwork, m
135139
statusBarTranslucent
136140
navigationBarTranslucent
137141
animationType="slide"
142+
onShow={() => {
143+
trackExperiment({
144+
context_owner_type: OwnerType.artwork,
145+
context_owner_screen: OwnerType.artwork,
146+
context_owner_id: artwork.internalID,
147+
context_owner_slug: artwork.slug,
148+
})
149+
}}
138150
>
139151
<Screen>
140152
<NavigationHeader

src/app/Scenes/Artwork/Components/CommercialButtons/__tests__/InquiryModal.tests.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ describe("inquiry modal", () => {
4848

4949
beforeEach(() => {
5050
initialState = { ...initialArtworkInquiryState, inquiryModalVisible: true }
51-
;(useExperimentVariant as jest.Mock).mockReturnValue({ variant: {} })
51+
;(useExperimentVariant as jest.Mock).mockReturnValue({
52+
variant: {},
53+
trackExperiment: jest.fn(),
54+
})
5255
})
5356

5457
it("renders", () => {
@@ -187,6 +190,7 @@ describe("inquiry modal", () => {
187190
// mock experiment as "control"
188191
;(useExperimentVariant as jest.Mock).mockReturnValue({
189192
variant: { enabled: true, name: "control" },
193+
trackExperiment: jest.fn(),
190194
})
191195
})
192196

@@ -202,6 +206,7 @@ describe("inquiry modal", () => {
202206
// mock experiment as "experiment"
203207
;(useExperimentVariant as jest.Mock).mockReturnValue({
204208
variant: { enabled: true, name: "experiment" },
209+
trackExperiment: jest.fn(),
205210
})
206211
})
207212

0 commit comments

Comments
 (0)