Skip to content

Commit 566248b

Browse files
authored
Merge pull request #15006 from artsy/dzucconi/fix/adds-experiment-viewed-event
fix(home): adds experiment tracking
2 parents 413968e + 38c8198 commit 566248b

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/Apps/Home/Components/HomeHeroUnits/HomeHeroUnitLoggedOut.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import * as React from "react"
22
import { HomeHeroUnitBase, HomeHeroUnitBaseProps } from "./HomeHeroUnit"
33
import { useDeviceDetection } from "Utils/Hooks/useDeviceDetection"
44
import { useFeatureVariant } from "System/Hooks/useFeatureFlag"
5+
import { useOnce } from "Utils/Hooks/useOnce"
6+
import { ActionType, ExperimentViewed, OwnerType } from "@artsy/cohesion"
7+
import { useTracking } from "react-tracking"
8+
9+
const EXPERIMENT_NAME = "diamond_hero-app-download"
510

611
export const HomeHeroUnitLoggedOut: React.FC<{ index: number }> = ({
712
index,
@@ -44,8 +49,23 @@ export const HomeHeroUnitLoggedOut: React.FC<{ index: number }> = ({
4449
},
4550
}
4651

47-
const featureVariant = useFeatureVariant("diamond_hero-app-download")
48-
const variant = variants[featureVariant?.name || "control"]
52+
const featureVariant = useFeatureVariant(EXPERIMENT_NAME)
53+
const variantName = featureVariant?.name || "control"
54+
const variant = variants[variantName]
55+
56+
const { trackEvent } = useTracking()
57+
58+
useOnce(() => {
59+
const payload: ExperimentViewed = {
60+
action: ActionType.experimentViewed,
61+
experiment_name: EXPERIMENT_NAME,
62+
service: "unleash",
63+
variant_name: variantName,
64+
context_owner_type: OwnerType.home,
65+
}
66+
67+
trackEvent(payload)
68+
})
4969

5070
return (
5171
<HomeHeroUnitBase

0 commit comments

Comments
 (0)