forked from binary-com/deriv-com
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use new analytics library (binary-com#5310)
* refactor: use new analytics library * chore: trigger build * chore: trigger build * chore: trigger build * fix: revert cpu core increase * chore: remove unnessisary rudderstack dependency * feat: remove init and use anonymousid * feat: use unrelease analytics package * feat: make an aa test and upgrade analytics package * feat: pull growthbook key into constants * feat: add homepage test * fix: translations * feat: move client key to environment variable * feat: rename environment variable to match convention * feat: abstract growthbook context into own file * fix: move into useEffect * feat: add environment variable to workflows
- Loading branch information
1 parent
66bd5db
commit 2565059
Showing
10 changed files
with
136 additions
and
11 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
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
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,44 @@ | ||
import React, { useEffect, useRef } from 'react' | ||
import { GrowthBook, GrowthBookProvider } from '@growthbook/growthbook-react' | ||
import { getClientInformation, getDomain, getLanguage } from 'common/utility' | ||
import { growthbook_client_key } from 'common/constants' | ||
|
||
const DerivGrowthBookProvider = ({ children }: { children: React.ReactNode }) => { | ||
const growthbook = useRef<GrowthBook>(); | ||
useEffect(() => { | ||
import('@deriv/analytics').then(({ RudderStack }) => { | ||
const anonymousId = RudderStack.getAnonymousId() | ||
growthbook.current = new GrowthBook({ | ||
apiHost: 'https://cdn.growthbook.io', | ||
clientKey: growthbook_client_key, | ||
enableDevMode: true, | ||
attributes: { | ||
id: anonymousId, | ||
}, | ||
trackingCallback: (experiment, result) => { | ||
RudderStack.track('experiment_viewed', { | ||
experimentId: experiment.key, | ||
variationId: result.variationId, | ||
}) | ||
}, | ||
}) | ||
growthbook.current.loadFeatures({ | ||
autoRefresh: true, | ||
}) | ||
|
||
const language = getLanguage() | ||
const domain = getDomain() | ||
const client_information = getClientInformation(domain) | ||
|
||
if (client_information) { | ||
RudderStack.identifyEvent(client_information.loginid, { | ||
language, | ||
}) | ||
} | ||
}) | ||
}, []); | ||
|
||
return <GrowthBookProvider growthbook={growthbook.current}>{children}</GrowthBookProvider> | ||
} | ||
|
||
export default DerivGrowthBookProvider |