Skip to content

Commit

Permalink
chore: updated cache track event script
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-deriv committed Oct 11, 2024
1 parent 251c8b9 commit 874be9c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions public/scripts/analytics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const cacheTrackEvents = {

return combined.substring(0, desiredLength);
},
getCookie: (name) => {
getCookies: (name) => {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) {
Expand Down Expand Up @@ -121,20 +121,20 @@ const cacheTrackEvents = {
)}; path=/; Domain=.deriv.com`;
},
processEvent: (event) => {
const clientInfo = getCookies("client_information");
const clientInfo = cacheTrackEvents.getCookies("client_information");

if (clientInfo) {
const { email = null } = clientInfo;

if (email) {
event.properties.email_hash = cacheTrackEvents.hash(email);
}
}

if (event?.properties?.email) {
const email = event.properties.email;
delete event.properties.email;
event.properties.email_hash = cacheTrackEvents.hash(email);
} else {
if (event?.properties?.email) {
const email = event.properties.email;
delete event.properties.email;
event.properties.email_hash = cacheTrackEvents.hash(email);
}
}

return event;
Expand Down

0 comments on commit 874be9c

Please sign in to comment.