Skip to content

Commit

Permalink
chore: Rename cklsh constants to cookieless (#1647)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c authored Jan 13, 2025
1 parent f2e2834 commit b53a47c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/__tests__/cookieless.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ describe('cookieless', () => {
posthog.capture(eventName, eventProperties)
expect(beforeSendMock).toBeCalledTimes(1)
let event = beforeSendMock.mock.calls[0][0]
expect(event.properties.distinct_id).toBe('$posthog_cklsh')
expect(event.properties.distinct_id).toBe('$posthog_cookieless')
expect(event.properties.$anon_distinct_id).toBe(undefined)
expect(event.properties.$device_id).toBe(null)
expect(event.properties.$session_id).toBe(undefined)
expect(event.properties.$window_id).toBe(undefined)
expect(event.properties.$cklsh_mode).toEqual(true)
expect(event.properties.$cookieless_mode).toEqual(true)
expect(document.cookie).toBe('')

// simulate user giving cookie consent
Expand All @@ -39,24 +39,24 @@ describe('cookieless', () => {
posthog.capture(eventName, eventProperties)
expect(beforeSendMock).toBeCalledTimes(2)
event = beforeSendMock.mock.calls[1][0]
expect(event.properties.distinct_id).toBe('$posthog_cklsh')
expect(event.properties.distinct_id).toBe('$posthog_cookieless')
expect(event.properties.$anon_distinct_id).toBe(undefined)
expect(event.properties.$device_id).toBe(null)
expect(event.properties.$session_id).toBe(undefined)
expect(event.properties.$window_id).toBe(undefined)
expect(event.properties.$cklsh_mode).toEqual(true)
expect(event.properties.$cookieless_mode).toEqual(true)
expect(document.cookie).not.toBe('')

// a user identifying
posthog.identify(identifiedDistinctId)
expect(beforeSendMock).toBeCalledTimes(3)
event = beforeSendMock.mock.calls[2][0]
expect(event.properties.distinct_id).toBe(identifiedDistinctId)
expect(event.properties.$anon_distinct_id).toBe('$posthog_cklsh')
expect(event.properties.$anon_distinct_id).toBe('$posthog_cookieless')
expect(event.properties.$device_id).toBe(null)
expect(event.properties.$session_id).toBe(undefined)
expect(event.properties.$window_id).toBe(undefined)
expect(event.properties.$cklsh_mode).toEqual(true)
expect(event.properties.$cookieless_mode).toEqual(true)

// an event after identifying
posthog.capture(eventName, eventProperties)
Expand All @@ -67,7 +67,7 @@ describe('cookieless', () => {
expect(event.properties.$device_id).toBe(null)
expect(event.properties.$session_id).toBe(undefined)
expect(event.properties.$window_id).toBe(undefined)
expect(event.properties.$cklsh_mode).toEqual(true)
expect(event.properties.$cookieless_mode).toEqual(true)

// reset
posthog.reset()
Expand All @@ -77,12 +77,12 @@ describe('cookieless', () => {
posthog.capture(eventName, eventProperties)
expect(beforeSendMock).toBeCalledTimes(5)
event = beforeSendMock.mock.calls[4][0]
expect(event.properties.distinct_id).toBe('$posthog_cklsh')
expect(event.properties.distinct_id).toBe('$posthog_cookieless')
expect(event.properties.$anon_distinct_id).toBe(undefined)
expect(event.properties.$device_id).toBe(null)
expect(event.properties.$session_id).toBe(undefined)
expect(event.properties.$window_id).toBe(undefined)
expect(event.properties.$cklsh_mode).toEqual(true)
expect(event.properties.$cookieless_mode).toEqual(true)
expect(document.cookie).toBe('')
})
})
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const TOOLBAR_CONTAINER_CLASS = 'toolbar-global-fade-container'
* PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
* Sentinel value for distinct id, device id, session id. Signals that the server should generate the value
* */
export const COOKIELESS_SENTINEL_VALUE = '$posthog_cklsh'
export const COOKIELESS_MODE_FLAG_PROPERTY = '$cklsh_mode'
export const COOKIELESS_SENTINEL_VALUE = '$posthog_cookieless'
export const COOKIELESS_MODE_FLAG_PROPERTY = '$cookieless_mode'

export const WEB_EXPERIMENTS = '$web_experiments'

Expand Down

0 comments on commit b53a47c

Please sign in to comment.