From b5244a9242ac5c65945a5ab61c2e9767355ca6c2 Mon Sep 17 00:00:00 2001 From: aswathy-deriv Date: Wed, 18 Sep 2024 16:46:16 +0400 Subject: [PATCH 1/4] fix: removed the and condition for loggedin --- src/analytics.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/analytics.ts b/src/analytics.ts index 31ae5c5..0d36024 100644 --- a/src/analytics.ts +++ b/src/analytics.ts @@ -58,8 +58,8 @@ export function createAnalyticsInstance(options?: Options) { device_type: growthbookOptions?.attributes.device_type, }), ...(growthbookOptions?.attributes?.url && { url: growthbookOptions?.attributes.url }), - ...(growthbookOptions?.attributes?.loggedIn && { - loggedIn: growthbookOptions?.attributes.loggedIn, + ...(growthbookOptions?.attributes && { + loggedIn: growthbookOptions?.attributes?.loggedIn, }), } growthbookOptions ??= {} From 24a3b526a9228b450b0bf52c77c7af6af7e2c113 Mon Sep 17 00:00:00 2001 From: aswathy Date: Wed, 18 Dec 2024 12:23:06 +0400 Subject: [PATCH 2/4] fix: added the domain for deriv team --- src/rudderstack.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rudderstack.ts b/src/rudderstack.ts index 4a522f2..b027e22 100644 --- a/src/rudderstack.ts +++ b/src/rudderstack.ts @@ -44,6 +44,7 @@ export class RudderStack { /** For caching mechanism, Rudderstack SDK, first page load */ handleCachedEvents = () => { + const domain = window.location.hostname.includes('deriv.team') ? '.deriv.team' : '.deriv.com' const storedEventsString: string | undefined = Cookies.get('cached_analytics_events') const storedPagesString: string | undefined = Cookies.get('cached_analytics_page_views') @@ -58,7 +59,7 @@ export class RudderStack { }) // Clear the stored events cookie - Cookies.remove('cached_analytics_events', { domain: '.deriv.com' }) + Cookies.remove('cached_analytics_events', { domain }) } } @@ -72,7 +73,7 @@ export class RudderStack { }) // Clear the stored page views cookie - Cookies.remove('cached_analytics_page_views', { domain: '.deriv.com' }) + Cookies.remove('cached_analytics_page_views', { domain }) } } } catch (error) { From f64e0195636a75f622cc18e7689038075047f72c Mon Sep 17 00:00:00 2001 From: aswathy Date: Wed, 18 Dec 2024 12:23:06 +0400 Subject: [PATCH 3/4] fix: added the domain for deriv team --- src/rudderstack.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rudderstack.ts b/src/rudderstack.ts index 4a522f2..b027e22 100644 --- a/src/rudderstack.ts +++ b/src/rudderstack.ts @@ -44,6 +44,7 @@ export class RudderStack { /** For caching mechanism, Rudderstack SDK, first page load */ handleCachedEvents = () => { + const domain = window.location.hostname.includes('deriv.team') ? '.deriv.team' : '.deriv.com' const storedEventsString: string | undefined = Cookies.get('cached_analytics_events') const storedPagesString: string | undefined = Cookies.get('cached_analytics_page_views') @@ -58,7 +59,7 @@ export class RudderStack { }) // Clear the stored events cookie - Cookies.remove('cached_analytics_events', { domain: '.deriv.com' }) + Cookies.remove('cached_analytics_events', { domain }) } } @@ -72,7 +73,7 @@ export class RudderStack { }) // Clear the stored page views cookie - Cookies.remove('cached_analytics_page_views', { domain: '.deriv.com' }) + Cookies.remove('cached_analytics_page_views', { domain }) } } } catch (error) { From 598e9f2e971513453afd04327ec6eed3255b48a7 Mon Sep 17 00:00:00 2001 From: aswathy Date: Wed, 18 Dec 2024 13:06:40 +0400 Subject: [PATCH 4/4] fix: peer comments --- src/rudderstack.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rudderstack.ts b/src/rudderstack.ts index b027e22..1a19bce 100644 --- a/src/rudderstack.ts +++ b/src/rudderstack.ts @@ -44,7 +44,10 @@ export class RudderStack { /** For caching mechanism, Rudderstack SDK, first page load */ handleCachedEvents = () => { - const domain = window.location.hostname.includes('deriv.team') ? '.deriv.team' : '.deriv.com' + const allowedDomains = ['deriv.com', 'deriv.team'] + const domain = allowedDomains.some(d => window.location.hostname.includes(d)) + ? `.${allowedDomains.find(d => window.location.hostname.includes(d))}` + : `.${allowedDomains[0]}` const storedEventsString: string | undefined = Cookies.get('cached_analytics_events') const storedPagesString: string | undefined = Cookies.get('cached_analytics_page_views')