From acd9d979acab1a16b3c10d229b87594ca860fa0e Mon Sep 17 00:00:00 2001 From: Alex Gyoshev Date: Fri, 29 Oct 2021 15:38:14 +0200 Subject: [PATCH 1/2] fix: always start sessions in dev mode resolves issue where development device is not identified by the API --- src/LeanplumInternal.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LeanplumInternal.ts b/src/LeanplumInternal.ts index 49a0431..a2be241 100644 --- a/src/LeanplumInternal.ts +++ b/src/LeanplumInternal.ts @@ -275,7 +275,7 @@ export default class LeanplumInternal { userAttributes = {} } - if (this.hasActiveSession()) { + if (this.hasActiveSession() && !this._internalState.devMode) { return this.startFromCache(userId, userAttributes, callback) } From 26d12999117c35dae30d379f38327fb2607a9709 Mon Sep 17 00:00:00 2001 From: Alex Gyoshev Date: Wed, 3 Nov 2021 19:50:48 +0100 Subject: [PATCH 2/2] test: add test --- test/specs/LeanplumInternal.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/specs/LeanplumInternal.test.ts b/test/specs/LeanplumInternal.test.ts index fadd087..9573a0e 100644 --- a/test/specs/LeanplumInternal.test.ts +++ b/test/specs/LeanplumInternal.test.ts @@ -228,6 +228,23 @@ describe(LeanplumInternal, () => { expect(lpRequestMock.request).toHaveBeenCalledTimes(3) }) + + it('always start new session in dev mode', () => { + lp.setAppIdForDevelopmentMode(APP_ID, KEY_DEV) + + let currentTime = 0 + jest.spyOn(Date, 'now').mockImplementation(() => currentTime) + lp.useSessionLength(2) + + mockNextResponse({ response: [{ success: true }] }) + lp.start() + + currentTime = 500 + mockNextResponse({ response: [{ success: true }] }) + lp.start() + + expect(lpRequestMock.request).toHaveBeenCalledTimes(2) + }) }) })