Skip to content
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

CRO/490: Real sign up Tracking: nulls, CR, MF, ML, nu? data quality #14301

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions packages/core/src/App/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,31 @@ const AppContent: React.FC<{ passthrough: unknown }> = observer(({ passthrough }
rudderstackKey: process.env.RUDDERSTACK_KEY,
};
Analytics.initialise(config);
const ppc_campaign_cookies =
Cookies.getJSON('utm_data') === 'null'
? {
utm_source: 'no source',
utm_medium: 'no medium',
utm_campaign: 'no campaign',
utm_content: 'no content',
}
: Cookies.getJSON('utm_data');
const account_type = LocalStore?.get('active_loginid')
?.match(/[a-zA-Z]+/g)
?.join('');
Analytics.setAttributes({
account_type: LocalStore?.get('active_loginid')?.substring(0, 2) ?? 'unlogged',
account_type: account_type === 'null' ? 'unlogged' : account_type,
app_id: String(getAppId()),
device_type: store?.ui?.is_mobile ? 'mobile' : 'desktop',
device_language: navigator?.language || 'en-EN',
user_language: getLanguage().toLowerCase(),
country: Cookies.get('clients_country') || Cookies?.getJSON('website_status'),
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,
});
}

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data.marketing_growthbook, tracking_rudderstack]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import Cookies from 'js-cookie';
import { withRouter } from 'react-router';
import {
Button,
Expand All @@ -17,10 +16,9 @@ import {
Loading,
} from '@deriv/components';
import { observer, useStore } from '@deriv/stores';
import { routes, formatMoney, ContentFlag, getStaticUrl, getAppId, LocalStore } from '@deriv/shared';
import { getLanguage, localize, Localize } from '@deriv/translations';
import { routes, formatMoney, ContentFlag, getStaticUrl } from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';
import { useHasSetCurrency } from '@deriv/hooks';
import { Analytics } from '@deriv-com/analytics';
import { getAccountTitle } from 'App/Containers/RealAccountSignup/helpers/constants';
import { BinaryLink } from 'App/Components/Routes';
import AccountList from './account-switcher-account-list.jsx';
Expand Down Expand Up @@ -124,14 +122,6 @@ const AccountSwitcher = observer(({ history, is_mobile, is_visible }) => {
closeAccountsDialog();
if (account_loginid === loginid) return;
await switchAccount(loginid);
Analytics.setAttributes({
account_type: LocalStore?.get('active_loginid')?.substring(0, 2) ?? 'unlogged',
app_id: getAppId(),
device_type: is_mobile ? 'mobile' : 'desktop',
device_language: navigator?.language || 'en-EN',
user_language: getLanguage().toLowerCase(),
country: Cookies.get('clients_country') || Cookies.getJSON('website_status'),
});
};

const resetBalance = async () => {
Expand Down
30 changes: 30 additions & 0 deletions packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getUrlSmartTrader,
isCryptocurrency,
isDesktopOs,
isMobile,
isEmptyObject,
isLocal,
isProduction,
Expand All @@ -27,6 +28,7 @@ import {
State,
toMoment,
urlForLanguage,
getAppId,
} from '@deriv/shared';
import { Analytics } from '@deriv-com/analytics';
import { getLanguage, localize, getRedirectionLanguage } from '@deriv/translations';
Expand Down Expand Up @@ -1770,6 +1772,34 @@ export default class ClientStore extends BaseStore {
const is_virtual = account.is_virtual;
const account_type = !is_virtual && currency ? currency : this.account_title;

const ppc_campaign_cookies =
Cookies.getJSON('utm_data') === 'null'
? {
utm_source: 'no source',
utm_medium: 'no medium',
utm_campaign: 'no campaign',
utm_content: 'no content',
}
: Cookies.getJSON('utm_data');
const broker = LocalStore?.get('active_loginid')
?.match(/[a-zA-Z]+/g)
?.join('');
setTimeout(() => {
Analytics.setAttributes({
account_type: broker === 'null' ? 'unlogged' : broker,
app_id: String(getAppId()),
device_type: isMobile() ? 'mobile' : 'desktop',
language: getLanguage(),
device_language: navigator?.language || 'en-EN',
user_language: getLanguage().toLowerCase(),
country: Cookies.get('clients_country') || Cookies?.getJSON('website_status'),
utm_source: ppc_campaign_cookies?.utm_source,
utm_medium: ppc_campaign_cookies?.utm_medium,
utm_campaign: ppc_campaign_cookies?.utm_campaign,
NikitK-deriv marked this conversation as resolved.
Show resolved Hide resolved
utm_content: ppc_campaign_cookies?.utm_content,
});
}, 4);

return {
loginid,
is_disabled,
Expand Down
Loading