Skip to content

Commit

Permalink
fix: track js error
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-deriv committed Oct 22, 2024
1 parent 8471f18 commit 5c33a4b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions public/scripts/analytics/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Version 1.0.7
// Version 1.0.8
const cacheTrackEvents = {
interval: null,
responses: [],
Expand Down Expand Up @@ -101,7 +101,12 @@ const cacheTrackEvents = {
return acc;
}, {});

return JSON.parse(cookies[cookieName] || null);
try {
return cookies[cookieName] ? JSON.parse(cookies[cookieName]) : null;
} catch (error) {
console.error(`Error parsing JSON for cookie "${cookieName}":`, error);
return null;
}
},
isPageViewSent: () =>
!!cacheTrackEvents.responses.find(
Expand Down

0 comments on commit 5c33a4b

Please sign in to comment.