diff --git a/src/rudderstack.ts b/src/rudderstack.ts index 4a522f2..1a19bce 100644 --- a/src/rudderstack.ts +++ b/src/rudderstack.ts @@ -44,6 +44,10 @@ export class RudderStack { /** For caching mechanism, Rudderstack SDK, first page load */ handleCachedEvents = () => { + 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') @@ -58,7 +62,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 +76,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) {