forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Amir/CRO-284/Add tracking for tradershub onboarding flow (deriv-com#1…
…1550) * feat: add tracking for tradershub onboarding flow * chore: remove analytics package from appstore package * chore: update analytics pakage * chore: move tradershub tracking hook to appstore package * fix: import path issue on test cases * chore: use event name variable instead of string literal * chore: remove unnecessary depenedcy from array
- Loading branch information
1 parent
9e82f3c
commit 100fb60
Showing
23 changed files
with
217 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './use-tradershub-tracking'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { Analytics } from '@deriv/analytics'; | ||
import { useStore } from '@deriv/stores'; | ||
import { useCallback, useEffect, useMemo } from 'react'; | ||
|
||
// This hook is used to track the onboarding form in TradersHub | ||
export const useTradersHubTracking = () => { | ||
const { traders_hub, ui, client } = useStore(); | ||
|
||
const { is_mobile } = ui; | ||
|
||
const { loginid } = client; | ||
|
||
const { is_first_time_visit } = traders_hub; | ||
|
||
const form_source = useMemo( | ||
() => (is_first_time_visit ? 'tradershub_first_entrance' : 'tradershub_dashboard_form'), | ||
[is_first_time_visit] | ||
); | ||
|
||
const event_name = 'ce_tradershub_onboarding_form'; | ||
|
||
useEffect(() => { | ||
Analytics.setAttributes({ | ||
device_type: is_mobile ? 'mobile' : 'desktop', | ||
account_type: loginid?.slice(0, 2), | ||
}); | ||
}, [is_mobile, loginid]); | ||
|
||
const trackDotNavigation = useCallback( | ||
(step: number) => { | ||
Analytics.trackEvent(event_name, { | ||
action: 'choose_step_navigation', | ||
form_source, | ||
step_num: step, | ||
step_codename: `${step}_step`, | ||
}); | ||
}, | ||
[form_source] | ||
); | ||
|
||
const trackLastStep = useCallback(() => { | ||
Analytics.trackEvent(event_name, { | ||
action: 'close', | ||
form_source, | ||
step_num: 7, | ||
step_codename: '7_step', | ||
}); | ||
}, [form_source]); | ||
|
||
const trackStepBack = useCallback( | ||
(new_step: number) => { | ||
Analytics.trackEvent(event_name, { | ||
action: 'step_back', | ||
form_source, | ||
step_num: new_step, | ||
step_codename: `${new_step}_step`, | ||
}); | ||
}, | ||
[form_source] | ||
); | ||
|
||
const trackStepForward = useCallback( | ||
(new_step: number) => { | ||
Analytics.trackEvent(event_name, { | ||
action: 'step_passed', | ||
form_source, | ||
step_num: new_step, | ||
step_codename: `${new_step}_step`, | ||
}); | ||
}, | ||
[form_source] | ||
); | ||
|
||
const trackOnboardingClose = useCallback( | ||
(current_step: number) => { | ||
Analytics.trackEvent(event_name, { | ||
action: 'close', | ||
form_source, | ||
step_num: current_step, | ||
step_codename: `${current_step}_step`, | ||
}); | ||
}, | ||
[form_source] | ||
); | ||
|
||
const trackOnboardingRestart = useCallback(() => { | ||
Analytics.trackEvent(event_name, { | ||
action: 'open', | ||
form_source: 'repeat_tour', | ||
step_num: 7, | ||
step_codename: `7_step`, | ||
}); | ||
}, []); | ||
|
||
const trackOnboardingOpen = useCallback(() => { | ||
Analytics.trackEvent(event_name, { | ||
action: 'open', | ||
form_source, | ||
step_num: 1, | ||
step_codename: '1_step', | ||
}); | ||
}, [form_source]); | ||
|
||
return { | ||
trackDotNavigation, | ||
trackLastStep, | ||
trackStepBack, | ||
trackStepForward, | ||
trackOnboardingClose, | ||
trackOnboardingOpen, | ||
trackOnboardingRestart, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.