Skip to content

Commit

Permalink
Merge pull request #147 from aswathy-deriv/update_cachedpage_cookies
Browse files Browse the repository at this point in the history
Aswathy/Added the domain for deriv team also for handling the cached events for tracking and pageviews
  • Loading branch information
prince-deriv authored Dec 18, 2024
2 parents a2f328b + 30f2dd7 commit 1e23afe
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/rudderstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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 })
}
}

Expand All @@ -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) {
Expand Down

0 comments on commit 1e23afe

Please sign in to comment.