Skip to content

Commit

Permalink
Remove getSessionProps
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Feb 14, 2025
1 parent e3c4569 commit c2f0670
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/__tests__/posthog-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,13 @@ describe('posthog core', () => {
)

posthog.persistence.get_initial_props = () => ({ initial: 'prop' })
posthog.sessionPropsManager.getSetOnceInitialSessionPropsProps = () => ({ session: 'prop' })
posthog.persistence.props[ENABLE_PERSON_PROCESSING] = true // person processing is needed for $set_once
expect(posthog._calculate_set_once_properties({ key: 'prop' })).toEqual({
event_name: '$set_once',
token: undefined,
initial: 'prop',
session: 'prop',
key: 'prop',
})
})
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/session-props.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ describe('Session Props Manager', () => {
}

// act
const properties = sessionPropsManager.getSessionProps()
const properties = sessionPropsManager.getSetOnceInitialSessionPropsProps()

//assert
expect(properties).toEqual({
$client_session_initial_utm_source: 'some-utm-source',
utm_source: 'some-utm-source',
})
})
})
19 changes: 1 addition & 18 deletions src/session-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import type { SessionIdManager } from './sessionid'
import type { PostHogPersistence } from './posthog-persistence'
import { CLIENT_SESSION_PROPS } from './constants'
import type { PostHog } from './posthog-core'
import { each } from './utils'
import { stripLeadingDollar } from './utils/string-utils'

interface LegacySessionSourceProps {
initialPathName: string
Expand Down Expand Up @@ -80,10 +78,7 @@ export class SessionPropsManager {
this._persistence.register({ [CLIENT_SESSION_PROPS]: newProps })
}

/**
* Return all available props. Might want to be filtered depending on the use case.
*/
_props() {
getSetOnceInitialSessionPropsProps() {
const p = this._getStored()?.props
if (!p) {
return {}
Expand All @@ -102,16 +97,4 @@ export class SessionPropsManager {
}
}
}

getSessionProps() {
const result: Record<string, any> = {}
const p = this._props()
each(p, function (v, k) {
result['$client_session_' + stripLeadingDollar(k)] = v
})
}

getSetOnceInitialSessionPropsProps() {
return this._props()
}
}

0 comments on commit c2f0670

Please sign in to comment.