From 2db61f435bea35044f05b2aad9bf902fd0c2e0d5 Mon Sep 17 00:00:00 2001 From: cdibble Date: Tue, 23 Jan 2024 11:05:37 -0800 Subject: [PATCH] add back in stickysession once belter updated --- src/session.js | 3 ++- src/session.test.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/session.js b/src/session.js index 9ce98044..3ce88eff 100644 --- a/src/session.js +++ b/src/session.js @@ -9,9 +9,10 @@ export function getClientMetadataID(): ?string { return getSDKAttribute(SDK_SETTINGS.CLIENT_METADATA_ID); } -function getSDKStorage(): Storage { +export function getSDKStorage(): Storage { return getStorage({ name: getNamespace(), + stickySessionId: getClientMetadataID() || "", }); } diff --git a/src/session.test.js b/src/session.test.js index cede0215..c0bf14ea 100644 --- a/src/session.test.js +++ b/src/session.test.js @@ -1,6 +1,6 @@ /* @flow */ import { describe, it, afterEach, expect, vi } from "vitest"; -import { getCurrentScript, memoize } from "@krakenjs/belter/src"; +import { getCurrentScript, memoize, getStorage } from "@krakenjs/belter/src"; import { makeMockScriptElement } from "../test/helpers"; @@ -9,6 +9,7 @@ import { getStorageID, getSessionState, getClientMetadataID, + getSDKStorage, } from "./session"; const clientId = "foobar123"; @@ -64,4 +65,15 @@ describe("session cases", () => { const result = getClientMetadataID(); expect(result).toEqual(mockMerchantIds); }); + + it("uses getStorage to retrieve the storage", () => { + // $FlowIgnore + getStorage = vi.fn(); + getSDKStorage(); + + expect(getStorage).toBeCalledWith({ + name: expect.any(String), + stickySessionId: expect.any(String), + }); + }); });