55 SESSION_RECORDING_OVERRIDE_EVENT_TRIGGER ,
66 SESSION_RECORDING_OVERRIDE_URL_TRIGGER ,
77 SESSION_RECORDING_REMOTE_CONFIG ,
8+ COOKIELESS_ALWAYS ,
89} from '../../constants'
910import { PostHog } from '../../posthog-core'
1011import { RemoteConfigLoader } from '../../remote-config'
@@ -38,6 +39,14 @@ export class SessionRecording implements Extension {
3839
3940 private _recordingStatus : SessionRecordingStatus = DISABLED
4041
42+ private get _config ( ) {
43+ return this . _instance . config
44+ }
45+
46+ private get _persistence ( ) {
47+ return this . _instance . persistence
48+ }
49+
4150 private _persistFlagsOnSessionListener : ( ( ) => void ) | undefined = undefined
4251 private _lazyLoadedSessionRecording : LazyLoadedSessionRecordingInterface | undefined
4352
@@ -58,7 +67,7 @@ export class SessionRecording implements Extension {
5867 throw new Error ( LOGGER_PREFIX + ' started without valid sessionManager. This is a bug.' )
5968 }
6069
61- if ( this . _instance . config . cookieless_mode === 'always' ) {
70+ if ( this . _config . cookieless_mode === COOKIELESS_ALWAYS ) {
6271 throw new Error ( LOGGER_PREFIX + ' cannot be used with cookieless_mode="always"' )
6372 }
6473 }
@@ -69,8 +78,8 @@ export class SessionRecording implements Extension {
6978
7079 private get _isRecordingEnabled ( ) {
7180 const enabled_server_side = ! ! this . _instance . get_property ( SESSION_RECORDING_REMOTE_CONFIG ) ?. enabled
72- const enabled_client_side = ! this . _instance . config . disable_session_recording
73- const isDisabled = this . _instance . config . disable_session_recording || this . _instance . consent . isOptedOut ( )
81+ const enabled_client_side = ! this . _config . disable_session_recording
82+ const isDisabled = this . _config . disable_session_recording || this . _instance . consent . isOptedOut ( )
7483 return window && enabled_server_side && enabled_client_side && ! isDisabled
7584 }
7685
@@ -148,7 +157,7 @@ export class SessionRecording implements Extension {
148157 }
149158
150159 private _resetSampling ( ) {
151- this . _instance . persistence ?. unregister ( SESSION_RECORDING_IS_SAMPLED )
160+ this . _persistence ?. unregister ( SESSION_RECORDING_IS_SAMPLED )
152161 }
153162
154163 private _validateSampleRate ( rate : unknown , source : string ) : number | null {
@@ -164,15 +173,15 @@ export class SessionRecording implements Extension {
164173 }
165174
166175 private _persistRemoteConfig ( response : RemoteConfig ) : void {
167- if ( this . _instance . persistence ) {
168- const persistence = this . _instance . persistence
176+ if ( this . _persistence ) {
177+ const persistence = this . _persistence
169178
170179 const persistResponse = ( ) => {
171180 const sessionRecordingConfigResponse =
172181 response . sessionRecording === false ? undefined : response . sessionRecording
173182
174183 const localSampleRate = this . _validateSampleRate (
175- this . _instance . config . session_recording ?. sampleRate ,
184+ this . _config . session_recording ?. sampleRate ,
176185 'session_recording.sampleRate'
177186 )
178187 const remoteSampleRate = this . _validateSampleRate (
@@ -317,7 +326,7 @@ export class SessionRecording implements Extension {
317326 * */
318327 public overrideLinkedFlag ( ) {
319328 if ( ! this . _lazyLoadedSessionRecording ) {
320- this . _instance . persistence ?. register ( {
329+ this . _persistence ?. register ( {
321330 [ SESSION_RECORDING_OVERRIDE_LINKED_FLAG ] : true ,
322331 } )
323332 }
@@ -333,7 +342,7 @@ export class SessionRecording implements Extension {
333342 * */
334343 public overrideSampling ( ) {
335344 if ( ! this . _lazyLoadedSessionRecording ) {
336- this . _instance . persistence ?. register ( {
345+ this . _persistence ?. register ( {
337346 [ SESSION_RECORDING_OVERRIDE_SAMPLING ] : true ,
338347 } )
339348 }
@@ -349,7 +358,7 @@ export class SessionRecording implements Extension {
349358 * */
350359 public overrideTrigger ( triggerType : TriggerType ) {
351360 if ( ! this . _lazyLoadedSessionRecording ) {
352- this . _instance . persistence ?. register ( {
361+ this . _persistence ?. register ( {
353362 [ triggerType === 'url'
354363 ? SESSION_RECORDING_OVERRIDE_URL_TRIGGER
355364 : SESSION_RECORDING_OVERRIDE_EVENT_TRIGGER ] : true ,
0 commit comments