Skip to content

Commit 2653c1c

Browse files
authored
Merge pull request #7101 from Countly/ar2rsawseen/master2
Add content filtering for in app messages
2 parents 3bc945e + 81bcf3e commit 2653c1c

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

frontend/express/views/dashboard.html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,36 @@ <h4><a href="#/analytics/events/key/{{encodeURIComponent this.name}}">{{this.nam
20052005
if (countlyGlobal.tracking.server_feedback) {
20062006
//display in app messages
20072007
if (Countly.content && Countly.content.enterContentZone) {
2008-
Countly.content.enterContentZone();
2008+
Countly.user_details({custom:{content_messages:true}}); // Ensure user is eligible for content messages
2009+
Countly.content.enterContentZone(function(params){
2010+
if (params.journeyId && (params.widget_id || params.id)) {
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) || "[]");
2021+
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
2033+
return false;
2034+
}
2035+
}
2036+
return false;
2037+
});
20092038
}
20102039
}
20112040
}

0 commit comments

Comments
 (0)