Skip to content

Commit 7aacf32

Browse files
committed
fix: initialize CT when resuming sessions
1 parent 9d4422a commit 7aacf32

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/LeanplumInternal.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,13 @@ export default class LeanplumInternal {
428428
this._internalState.hasStarted = true
429429
this._internalState.startSuccessful = true
430430

431+
432+
this._migration.getState((state: MigrationState) => {
433+
if (state === MigrationState.DUPLICATE || state === MigrationState.CLEVERTAP) {
434+
this._ct = this._migration.initCleverTap()
435+
}
436+
})
437+
431438
if (this._internalState.devMode) {
432439
this.connectSocket()
433440
}

test/specs/LeanplumInternal.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,17 @@ describe(LeanplumInternal, () => {
996996

997997
expect(clevertap.notifications.push).toHaveBeenCalledTimes(0)
998998
})
999+
1000+
it('initializes CT state from cache', () => {
1001+
jest.spyOn(clevertap, 'init')
1002+
1003+
migrationMock.getState.mockImplementationOnce(
1004+
(callback) => callback(MigrationState.CLEVERTAP)
1005+
)
1006+
lp.startFromCache(() => {
1007+
expect(migrationMock.initCleverTap).toHaveBeenCalledTimes(1)
1008+
})
1009+
})
9991010
})
10001011

10011012
describe('Misc', () => {

0 commit comments

Comments
 (0)