Skip to content

Commit 004090a

Browse files
committed
try catch on local storage
1 parent 8271665 commit 004090a

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

frontend/express/views/dashboard.html

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,23 +2008,30 @@ <h4><a href="#/analytics/events/key/{{encodeURIComponent this.name}}">{{this.nam
20082008
Countly.user_details({custom:{content_messages:true}}); // Ensure user is eligible for content messages
20092009
Countly.content.enterContentZone(function(params){
20102010
if (params.journeyId && (params.widget_id || params.id)) {
2011-
var check = params.journeyId + "_";
2012-
if (params.widget_id) {
2013-
check += "widget_" + params.widget_id;
2014-
}
2015-
else {
2016-
check += "content_" + params.id;
2017-
}
2018-
var key = "cly_seenJourneyIds_c2VlbkpvdXJuZXlJZHM"; // Base64 for 'seenJourneyIds' to avoid potential key conflicts
2019-
var seen = JSON.parse(localStorage.getItem(key) || "[]");
2011+
try {
2012+
var check = params.journeyId + "_";
2013+
if (params.widget_id) {
2014+
check += "widget_" + params.widget_id;
2015+
}
2016+
else {
2017+
check += "content_" + params.id;
2018+
}
2019+
var key = "cly_seenJourneyIds_c2VlbkpvdXJuZXlJZHM"; // Base64 for 'seenJourneyIds' to avoid potential key conflicts
2020+
var seen = JSON.parse(localStorage.getItem(key) || "[]");
20202021

2021-
if (seen.includes(check)) {
2022+
if (seen.includes(check)) {
2023+
return false;
2024+
}
2025+
2026+
seen.push(check);
2027+
localStorage.setItem(key, JSON.stringify(seen));
2028+
return true;
2029+
}
2030+
catch (e) {
2031+
// Handle localStorage errors (disabled, full, security exceptions in private browsing)
2032+
// Fail open - allow content to be shown if we can't track it
20222033
return false;
20232034
}
2024-
2025-
seen.push(check);
2026-
localStorage.setItem(key, JSON.stringify(seen));
2027-
return true;
20282035
}
20292036
return false;
20302037
});

0 commit comments

Comments
 (0)