-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ako/ CRO-724/ Pass growthbook attributes on initialisation #16713
Changes from 9 commits
6be8e9e
ff8a73b
62f031e
f66cb03
76e080f
c66bc1e
e8dcc9e
67445cb
706a729
3dbebd2
650ee96
e7e11f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1767,8 +1767,7 @@ export default class ClientStore extends BaseStore { | |
?.match(/[a-zA-Z]+/g) | ||
?.join(''); | ||
setTimeout(() => { | ||
Analytics.setAttributes({ | ||
user_id: this.user_id, | ||
const analytics_config = { | ||
account_type: broker === 'null' ? 'unlogged' : broker, | ||
residence_country: this.residence, | ||
app_id: String(getAppId()), | ||
|
@@ -1782,7 +1781,9 @@ export default class ClientStore extends BaseStore { | |
utm_campaign: ppc_campaign_cookies?.utm_campaign, | ||
utm_content: ppc_campaign_cookies?.utm_content, | ||
domain: window.location.hostname, | ||
}); | ||
}; | ||
if (this.user_id) analytics_config.user_id = this.user_id; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make sure that we are not passing empty string to analytics package as it can override the current one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For that I need to bump up the analytics package again. |
||
Analytics.setAttributes(analytics_config); | ||
}, 4); | ||
|
||
return { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,6 @@ export const AnalyticsInitializer = async () => { | |
.then(res => res.json()) | ||
.catch(() => FIREBASE_INIT_DATA); | ||
if (process.env.RUDDERSTACK_KEY && flags?.tracking_rudderstack) { | ||
const config = { | ||
growthbookKey: flags.marketing_growthbook ? process.env.GROWTHBOOK_CLIENT_KEY : undefined, | ||
growthbookDecryptionKey: flags.marketing_growthbook ? process.env.GROWTHBOOK_DECRYPTION_KEY : undefined, | ||
rudderstackKey: process.env.RUDDERSTACK_KEY, | ||
}; | ||
await Analytics?.initialise(config); | ||
await Analytics?.getInstances()?.ab?.GrowthBook?.loadFeatures(); | ||
const ppc_campaign_cookies = | ||
Cookies.getJSON('utm_data') === 'null' | ||
? { | ||
|
@@ -30,20 +23,26 @@ export const AnalyticsInitializer = async () => { | |
utm_content: 'no content', | ||
} | ||
: Cookies.getJSON('utm_data'); | ||
|
||
Analytics.setAttributes({ | ||
account_type: account_type === 'null' ? 'unlogged' : account_type, | ||
app_id: String(getAppId()), | ||
device_type: window.innerWidth <= MAX_MOBILE_WIDTH ? 'mobile' : 'desktop', | ||
device_language: navigator?.language || 'en-EN', | ||
user_language: getLanguage().toLowerCase(), | ||
country: Cookies.get('clients_country') || Cookies?.getJSON('website_status')?.clients_country, | ||
utm_source: ppc_campaign_cookies?.utm_source, | ||
utm_medium: ppc_campaign_cookies?.utm_medium, | ||
utm_campaign: ppc_campaign_cookies?.utm_campaign, | ||
utm_content: ppc_campaign_cookies?.utm_content, | ||
domain: window.location.hostname, | ||
}); | ||
const config = { | ||
growthbookKey: flags.marketing_growthbook ? process.env.GROWTHBOOK_CLIENT_KEY : undefined, | ||
growthbookDecryptionKey: flags.marketing_growthbook ? process.env.GROWTHBOOK_DECRYPTION_KEY : undefined, | ||
rudderstackKey: process.env.RUDDERSTACK_KEY, | ||
growthbookOptions: { | ||
attributes: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to pass the attributes in init config of Growthbook |
||
account_type: account_type === 'null' ? 'unlogged' : account_type, | ||
app_id: String(getAppId()), | ||
device_type: window.innerWidth <= MAX_MOBILE_WIDTH ? 'mobile' : 'desktop', | ||
device_language: navigator?.language || 'en-EN', | ||
user_language: getLanguage().toLowerCase(), | ||
utm_source: ppc_campaign_cookies?.utm_source, | ||
utm_medium: ppc_campaign_cookies?.utm_medium, | ||
utm_campaign: ppc_campaign_cookies?.utm_campaign, | ||
utm_content: ppc_campaign_cookies?.utm_content, | ||
domain: window.location.hostname, | ||
}, | ||
}, | ||
}; | ||
await Analytics?.initialise(config); | ||
} | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,11 @@ | |
"typescript": "^4.6.3" | ||
}, | ||
"dependencies": { | ||
"@deriv-com/analytics": "1.12.1", | ||
"@deriv-com/analytics": "1.15.0", | ||
"@deriv/quill-icons": "1.23.3", | ||
"@deriv/api-types": "1.0.172", | ||
"@deriv/translations": "^1.0.0", | ||
"@types/js-cookie": "^3.0.1", | ||
"@types/js-cookie": "^2.2.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To match the types with the package it self |
||
"@types/react-loadable": "^5.5.6", | ||
"canvas-toBlob": "^1.0.0", | ||
"extend": "^3.0.2", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed