Skip to content

Commit 6024655

Browse files
authored
Merge pull request #102 from GleapSDK/gleap-code/69ef75836eac35243fb454d8-7c4cb684-74fa-4f6a-9d41-b983f4770708
Coder Agent: # Task: Fix the reported bug Please read the customer report below carefully, find the **root cause
2 parents c6d30cf + baf7282 commit 6024655

2 files changed

Lines changed: 9 additions & 2 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 & 2 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,7 +172,9 @@ export default class GleapSession {
171172
GleapEventManager.notifyEvent('unregister-pushmessage-group', `gleapuser-${this.session.gleapHash}`);
172173
}
173174

174-
saveToGleapCache(`session-${this.sdkKey}`, session);
175+
if (!this.localStorageDisabled) {
176+
saveToGleapCache(`session-${this.sdkKey}`, session);
177+
}
175178
if (this.useCookies) {
176179
setGleapCookie(`session-${this.sdkKey}`, encodeURIComponent(JSON.stringify(session)), 365);
177180
}
@@ -224,7 +227,7 @@ export default class GleapSession {
224227
} catch (exp) {}
225228

226229
// Try to load session from local storage, if not already loaded.
227-
if (!(this.session && this.session.gleapId && this.session.gleapId.length > 0)) {
230+
if (!this.localStorageDisabled && !(this.session && this.session.gleapId && this.session.gleapId.length > 0)) {
228231
const cachedSession = loadFromGleapCache(`session-${this.sdkKey}`);
229232
if (cachedSession) {
230233
this.validateSession(cachedSession);

0 commit comments

Comments
 (0)