Skip to content

Commit c2f0670

Browse files
committed
Remove getSessionProps
1 parent e3c4569 commit c2f0670

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

src/__tests__/posthog-core.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,13 @@ describe('posthog core', () => {
529529
)
530530

531531
posthog.persistence.get_initial_props = () => ({ initial: 'prop' })
532+
posthog.sessionPropsManager.getSetOnceInitialSessionPropsProps = () => ({ session: 'prop' })
532533
posthog.persistence.props[ENABLE_PERSON_PROCESSING] = true // person processing is needed for $set_once
533534
expect(posthog._calculate_set_once_properties({ key: 'prop' })).toEqual({
534535
event_name: '$set_once',
535536
token: undefined,
536537
initial: 'prop',
538+
session: 'prop',
537539
key: 'prop',
538540
})
539541
})

src/__tests__/session-props.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ describe('Session Props Manager', () => {
117117
}
118118

119119
// act
120-
const properties = sessionPropsManager.getSessionProps()
120+
const properties = sessionPropsManager.getSetOnceInitialSessionPropsProps()
121121

122122
//assert
123123
expect(properties).toEqual({
124-
$client_session_initial_utm_source: 'some-utm-source',
124+
utm_source: 'some-utm-source',
125125
})
126126
})
127127
})

src/session-props.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import type { SessionIdManager } from './sessionid'
1111
import type { PostHogPersistence } from './posthog-persistence'
1212
import { CLIENT_SESSION_PROPS } from './constants'
1313
import type { PostHog } from './posthog-core'
14-
import { each } from './utils'
15-
import { stripLeadingDollar } from './utils/string-utils'
1614

1715
interface LegacySessionSourceProps {
1816
initialPathName: string
@@ -80,10 +78,7 @@ export class SessionPropsManager {
8078
this._persistence.register({ [CLIENT_SESSION_PROPS]: newProps })
8179
}
8280

83-
/**
84-
* Return all available props. Might want to be filtered depending on the use case.
85-
*/
86-
_props() {
81+
getSetOnceInitialSessionPropsProps() {
8782
const p = this._getStored()?.props
8883
if (!p) {
8984
return {}
@@ -102,16 +97,4 @@ export class SessionPropsManager {
10297
}
10398
}
10499
}
105-
106-
getSessionProps() {
107-
const result: Record<string, any> = {}
108-
const p = this._props()
109-
each(p, function (v, k) {
110-
result['$client_session_' + stripLeadingDollar(k)] = v
111-
})
112-
}
113-
114-
getSetOnceInitialSessionPropsProps() {
115-
return this._props()
116-
}
117100
}

0 commit comments

Comments
 (0)