Skip to content

Commit baf7282

Browse files
author
Gleap Coder Agent
committed
Coder Agent: # Task: Fix the reported bug
Please read the customer report below carefully, find the **root cause** in the code (not just the symptom), and ship a clean fix. Treat the customer's description as a r
1 parent c615e3f commit baf7282

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/Gleap.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ class Gleap {
365365
GleapSession.getInstance().useCookies = useCookies;
366366
}
367367

368+
static disableLocalStorage() {
369+
GleapSession.getInstance().localStorageDisabled = true;
370+
}
371+
368372
/**
369373
* Indentifies the user session
370374
* @param {string} userId

src/GleapSession.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default class GleapSession {
2424
sdkKey = null;
2525
updatingSession = false;
2626
useCookies = true;
27+
localStorageDisabled = false;
2728
session = {
2829
gleapId: null,
2930
gleapHash: null,
@@ -171,10 +172,11 @@ export default class GleapSession {
171172
GleapEventManager.notifyEvent('unregister-pushmessage-group', `gleapuser-${this.session.gleapHash}`);
172173
}
173174

175+
if (!this.localStorageDisabled) {
176+
saveToGleapCache(`session-${this.sdkKey}`, session);
177+
}
174178
if (this.useCookies) {
175179
setGleapCookie(`session-${this.sdkKey}`, encodeURIComponent(JSON.stringify(session)), 365);
176-
} else {
177-
saveToGleapCache(`session-${this.sdkKey}`, session);
178180
}
179181

180182
this.session = session;
@@ -225,7 +227,7 @@ export default class GleapSession {
225227
} catch (exp) {}
226228

227229
// Try to load session from local storage, if not already loaded.
228-
if (!this.useCookies && !(this.session && this.session.gleapId && this.session.gleapId.length > 0)) {
230+
if (!this.localStorageDisabled && !(this.session && this.session.gleapId && this.session.gleapId.length > 0)) {
229231
const cachedSession = loadFromGleapCache(`session-${this.sdkKey}`);
230232
if (cachedSession) {
231233
this.validateSession(cachedSession);

0 commit comments

Comments
 (0)