From 7c8f1a765c766dcf7e817ca4a4d69861f5b06557 Mon Sep 17 00:00:00 2001 From: Robbie Coomber Date: Fri, 3 Nov 2023 10:23:33 +0000 Subject: [PATCH] Update tests and shorten storage key --- src/__tests__/session-props.test.ts | 38 ++++++++++++++--------------- src/constants.ts | 2 +- src/session-props.ts | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/__tests__/session-props.test.ts b/src/__tests__/session-props.test.ts index f96062924..946aeeef1 100644 --- a/src/__tests__/session-props.test.ts +++ b/src/__tests__/session-props.test.ts @@ -1,4 +1,4 @@ -import { SessionPropsManager } from '../session-props' +import { SessionPropsManager, StoredSessionSourceProps } from '../session-props' import { SessionIdManager } from '../sessionid' import { PostHogPersistence } from '../posthog-persistence' @@ -46,12 +46,12 @@ describe('Session Props Manager', () => { expect(generateProps).toHaveBeenCalledTimes(1) expect(persistenceRegister).toBeCalledWith({ - $client_session_props: { - props: { - utm_source: 'some-utm-source', + $cl_ses_p: { + p: { + s: 'some-utm-source', }, - sessionId: 'session-id', - }, + s: 'session-id', + } as StoredSessionSourceProps, }) }) @@ -60,10 +60,10 @@ describe('Session Props Manager', () => { const sessionId1 = 'session-id-1' const { onSessionId, persistence, generateProps, persistenceRegister } = createSessionPropsManager() persistence.props = { - $client_session_props: { - props: {}, - sessionId: sessionId1, - }, + $cl_ses_p: { + p: {}, + s: sessionId1, + } as StoredSessionSourceProps, } const callback = onSessionId.mock.calls[0][0] @@ -82,10 +82,10 @@ describe('Session Props Manager', () => { const { onSessionId, persistence, generateProps, persistenceRegister } = createSessionPropsManager() persistence.props = { - $client_session_props: { - props: {}, - sessionId: sessionId1, - }, + $cl_ses_p: { + p: {}, + s: sessionId1, + } as StoredSessionSourceProps, } const callback = onSessionId.mock.calls[0][0] @@ -101,12 +101,12 @@ describe('Session Props Manager', () => { // arrange const { persistence, sessionPropsManager } = createSessionPropsManager() persistence.props = { - $client_session_props: { - props: { - utm_source: 'some-utm-source', + $cl_ses_p: { + p: { + s: 'some-utm-source', }, - sessionId: 'session-id', - }, + s: 'session-id', + } as StoredSessionSourceProps, } // act diff --git a/src/constants.ts b/src/constants.ts index ec9cbddc9..e288175ab 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -24,7 +24,7 @@ export const SURVEYS = '$surveys' export const FLAG_CALL_REPORTED = '$flag_call_reported' export const USER_STATE = '$user_state' export const POSTHOG_QUOTA_LIMITED = '$posthog_quota_limited' -export const CLIENT_SESSION_PROPS = '$client_session_props' +export const CLIENT_SESSION_PROPS = '$cl_ses_p' // These are properties that are reserved and will not be automatically included in events export const PERSISTENCE_RESERVED_PROPERTIES = [ diff --git a/src/session-props.ts b/src/session-props.ts index b021af920..aa317d980 100644 --- a/src/session-props.ts +++ b/src/session-props.ts @@ -23,7 +23,7 @@ interface SessionSourceProps { t?: string // utm term } -interface StoredSessionSourceProps { +export interface StoredSessionSourceProps { s: string // session id p: SessionSourceProps }