Skip to content

Commit

Permalink
Rename the sentinel const
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Dec 10, 2024
1 parent 1d859d2 commit a9bd6a0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export const TOOLBAR_CONTAINER_CLASS = 'toolbar-global-fade-container'

/**
* PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
* sentinel value for distinct id, signals that the server should replace it with a hash
* Sentinel value for distinct id, device id, session id. Signals that the server should generate the value
* */
export const SENTINEL_COOKIELESS_SERVER_HASH = '$sentinel_cookieless_server_hash'
export const COOKIELESS_SENTINEL_VALUE = '$posthog_cklsh'

export const WEB_EXPERIMENTS = '$web_experiments'

Expand Down
6 changes: 3 additions & 3 deletions src/posthog-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
PEOPLE_DISTINCT_ID_KEY,
USER_STATE,
ENABLE_PERSON_PROCESSING,
SENTINEL_COOKIELESS_SERVER_HASH,
COOKIELESS_SENTINEL_VALUE,
} from './constants'
import { SessionRecording } from './extensions/replay/sessionrecording'
import { Decide } from './decide'
Expand Down Expand Up @@ -1538,7 +1538,7 @@ export class PostHog {
this.persistence?.set_property(USER_STATE, 'anonymous')
this.sessionManager?.resetSessionId()
const uuid = this.config.__use_cookieless_server_hash
? SENTINEL_COOKIELESS_SERVER_HASH
? COOKIELESS_SENTINEL_VALUE
: this.config.get_device_id(uuidv7())
this.register_once(
{
Expand Down Expand Up @@ -2058,7 +2058,7 @@ export class PostHog {

private _create_device_id(): string {
if (this.config.__use_cookieless_server_hash) {
return SENTINEL_COOKIELESS_SERVER_HASH
return COOKIELESS_SENTINEL_VALUE
}
return this.config.get_device_id(uuidv7())
}
Expand Down
4 changes: 2 additions & 2 deletions src/sessionid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PostHogPersistence } from './posthog-persistence'
import { SENTINEL_COOKIELESS_SERVER_HASH, SESSION_ID } from './constants'
import { COOKIELESS_SENTINEL_VALUE, SESSION_ID } from './constants'
import { sessionStore } from './storage'
import { PostHogConfig, SessionIdChangedCallback } from './types'
import { uuid7ToTimestampMs, uuidv7 } from './uuidv7'
Expand Down Expand Up @@ -231,7 +231,7 @@ export class SessionIdManager {
const activityTimeout = !readOnly && Math.abs(timestamp - lastTimestamp) > this.sessionTimeoutMs
if (noSessionId || activityTimeout || sessionPastMaximumLength) {
if (this.config.__use_cookieless_server_hash) {
sessionId = SENTINEL_COOKIELESS_SERVER_HASH
sessionId = COOKIELESS_SENTINEL_VALUE
} else {
sessionId = this._sessionIdGenerator()
}
Expand Down

0 comments on commit a9bd6a0

Please sign in to comment.