-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: capture analytics on consent screen only by default, closes #2784
- Loading branch information
Showing
21 changed files
with
167 additions
and
140 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,49 @@ | ||
import { useCallback } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useCallback, useEffect } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
|
||
import { RouteUrls } from '@shared/route-urls'; | ||
import { initSegment, initSentry } from '@shared/utils/analytics'; | ||
|
||
import { useAnalytics } from '@app/common/hooks/analytics/use-analytics'; | ||
import { useRouteHeader } from '@app/common/hooks/use-route-header'; | ||
import { Header } from '@app/components/header'; | ||
import { useHasAllowedDiagnostics } from '@app/store/onboarding/onboarding.hooks'; | ||
import { settingsActions } from '@app/store/settings/settings.actions'; | ||
|
||
import { AllowDiagnosticsLayout } from './allow-diagnostics-layout'; | ||
|
||
export const AllowDiagnosticsPage = () => { | ||
const navigate = useNavigate(); | ||
const [, setHasAllowedDiagnostics] = useHasAllowedDiagnostics(); | ||
const dispatch = useDispatch(); | ||
const analytics = useAnalytics(); | ||
const { pathname } = useLocation(); | ||
|
||
useEffect(() => void analytics.page('view', `${pathname}`), [analytics, pathname]); | ||
|
||
useRouteHeader(<Header hideActions />); | ||
|
||
const goToOnboardingAndSetDiagnosticsPermissionTo = useCallback( | ||
(areDiagnosticsAllowed: boolean | undefined) => { | ||
if (typeof areDiagnosticsAllowed === undefined) return; | ||
setHasAllowedDiagnostics(areDiagnosticsAllowed); | ||
if (areDiagnosticsAllowed) { | ||
initSentry(); | ||
void initSegment(); | ||
} | ||
const setDiagnosticsPermissionsAndGoToOnboarding = useCallback( | ||
(areDiagnosticsAllowed: boolean) => { | ||
dispatch(settingsActions.setHasAllowedAnalytics(areDiagnosticsAllowed)); | ||
|
||
navigate(RouteUrls.Onboarding); | ||
}, | ||
[navigate, setHasAllowedDiagnostics] | ||
[navigate, dispatch] | ||
); | ||
|
||
return ( | ||
<AllowDiagnosticsLayout | ||
onUserDenyDiagnosticsPermissions={() => goToOnboardingAndSetDiagnosticsPermissionTo(false)} | ||
onUserAllowDiagnostics={() => goToOnboardingAndSetDiagnosticsPermissionTo(true)} | ||
onUserDenyDiagnostics={() => { | ||
void analytics.track('respond_diagnostics_consent', { | ||
areDiagnosticsAllowed: false, | ||
}); | ||
setDiagnosticsPermissionsAndGoToOnboarding(false); | ||
}} | ||
onUserAllowDiagnostics={() => { | ||
void analytics.track('respond_diagnostics_consent', { | ||
areDiagnosticsAllowed: true, | ||
}); | ||
setDiagnosticsPermissionsAndGoToOnboarding(true); | ||
}} | ||
/> | ||
); | ||
}; |
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 |
---|---|---|
@@ -1,12 +1,4 @@ | ||
import { atom } from 'jotai'; | ||
import { atomWithStorage } from 'jotai/utils'; | ||
|
||
import { userHasAllowedDiagnosticsKey } from '@shared/utils/storage'; | ||
|
||
export const seedInputErrorState = atom<string | undefined>(undefined); | ||
export const secretKeyState = atom(null); | ||
|
||
export const hasAllowedDiagnosticsState = atomWithStorage<boolean | undefined>( | ||
userHasAllowedDiagnosticsKey, | ||
undefined | ||
); |
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.