From cd6e6387d97bdb8d22638cab2367bb3bf325c4dc Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Thu, 3 Oct 2024 15:36:01 +0200 Subject: [PATCH 01/12] if there are trigger patterns, don't start until we match them --- src/extensions/replay/sessionrecording.ts | 34 +++++++++++++++++++++++ src/types.ts | 1 + 2 files changed, 35 insertions(+) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index f7c6d5162..e9d2e5598 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -228,6 +228,9 @@ export class SessionRecording { // then we can manually track href changes private _lastHref?: string + private _urlTriggerPatterns: string[] = [] + private _urlTriggerActivated: boolean = false + // Util to help developers working on this feature manually override _forceAllowLocalhostNetworkCapture = false @@ -343,6 +346,10 @@ export class SessionRecording { return 'buffering' } + if (this._urlTriggerPatterns.length > 0 && !this._urlTriggerActivated) { + return 'buffering' + } + if (isBoolean(this.isSampled)) { return this.isSampled ? 'sampled' : 'disabled' } else { @@ -544,6 +551,10 @@ export class SessionRecording { }) } + if (response.sessionRecording?.urlTriggerPatterns) { + this._urlTriggerPatterns = response.sessionRecording.urlTriggerPatterns + } + this.receivedDecide = true this.startIfEnabledOrStop() } @@ -909,6 +920,9 @@ export class SessionRecording { this._pageViewFallBack() } + // Check if the URL matches any trigger patterns + this._checkUrlTrigger() + // we're processing a full snapshot, so we should reset the timer if (rawEvent.type === EventType.FullSnapshot) { this._scheduleFullSnapshot() @@ -1090,6 +1104,26 @@ export class SessionRecording { }) } + private _checkUrlTrigger() { + if (typeof window === 'undefined' || !window.location.href) { + return + } + + const url = window.location.href + + if (this._urlTriggerPatterns.some((pattern) => new RegExp(pattern).test(url))) { + this._activateUrlTrigger() + } + } + + private _activateUrlTrigger() { + if (!this._urlTriggerActivated) { + this._urlTriggerActivated = true + this._flushBuffer() + logger.info(LOGGER_PREFIX + ' recording triggered by URL pattern match') + } + } + /** * this ignores the linked flag config and causes capture to start * (if recording would have started had the flag been received i.e. it does not override other config). diff --git a/src/types.ts b/src/types.ts index 9133fad89..8c0dd4844 100644 --- a/src/types.ts +++ b/src/types.ts @@ -390,6 +390,7 @@ export interface DecideResponse { canvasQuality?: string | null linkedFlag?: string | FlagVariant | null networkPayloadCapture?: Pick + urlTriggerPatterns?: string[] } surveys?: boolean toolbarParams: ToolbarParams From 2e1e5abb474459f0c1b34ccef0dc27a0231ce905 Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Thu, 3 Oct 2024 15:36:27 +0200 Subject: [PATCH 02/12] persist the trigger activation --- src/constants.ts | 1 + src/extensions/replay/sessionrecording.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index fc3154879..505672d19 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -24,6 +24,7 @@ export const SESSION_RECORDING_SAMPLE_RATE = '$replay_sample_rate' export const SESSION_RECORDING_MINIMUM_DURATION = '$replay_minimum_duration' export const SESSION_ID = '$sesid' export const SESSION_RECORDING_IS_SAMPLED = '$session_is_sampled' +export const SESSION_RECORDING_URL_TRIGGER_ACTIVATED = '$session_recording_url_trigger_activated' export const ENABLED_FEATURE_FLAGS = '$enabled_feature_flags' export const PERSISTENCE_EARLY_ACCESS_FEATURES = '$early_access_features' export const STORED_PERSON_PROPERTIES_KEY = '$stored_person_properties' diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index e9d2e5598..194b25b33 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -6,6 +6,7 @@ import { SESSION_RECORDING_MINIMUM_DURATION, SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE, SESSION_RECORDING_SAMPLE_RATE, + SESSION_RECORDING_URL_TRIGGER_ACTIVATED, } from '../../constants' import { estimateSize, @@ -229,7 +230,6 @@ export class SessionRecording { private _lastHref?: string private _urlTriggerPatterns: string[] = [] - private _urlTriggerActivated: boolean = false // Util to help developers working on this feature manually override _forceAllowLocalhostNetworkCapture = false @@ -346,7 +346,7 @@ export class SessionRecording { return 'buffering' } - if (this._urlTriggerPatterns.length > 0 && !this._urlTriggerActivated) { + if (this._urlTriggerPatterns.length > 0 && !this.isUrlTriggerActivated) { return 'buffering' } @@ -357,6 +357,11 @@ export class SessionRecording { } } + private get isUrlTriggerActivated(): boolean | null { + const currentValue = this.instance?.get_property(SESSION_RECORDING_URL_TRIGGER_ACTIVATED) + return isBoolean(currentValue) ? currentValue : null + } + constructor(private readonly instance: PostHog) { this._captureStarted = false this._endpoint = BASE_ENDPOINT @@ -1117,8 +1122,10 @@ export class SessionRecording { } private _activateUrlTrigger() { - if (!this._urlTriggerActivated) { - this._urlTriggerActivated = true + if (!this.isUrlTriggerActivated) { + this.instance.persistence?.register({ + [SESSION_RECORDING_URL_TRIGGER_ACTIVATED]: true, + }) this._flushBuffer() logger.info(LOGGER_PREFIX + ' recording triggered by URL pattern match') } From 8f45411647559d3020e20412fdc2111f0edee32d Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Thu, 3 Oct 2024 15:36:32 +0200 Subject: [PATCH 03/12] move handling to setter/getter --- src/extensions/replay/sessionrecording.ts | 30 +++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 194b25b33..8f121a2b2 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -61,6 +61,9 @@ const ACTIVE_SOURCES = [ IncrementalSource.Drag, ] +const TRIGGER_STATUSES = ['activated', 'pending', 'disabled'] as const +type TriggerStatus = typeof TRIGGER_STATUSES[number] + /** * Session recording starts in buffering mode while waiting for decide response * Once the response is received it might be disabled, active or sampled @@ -346,7 +349,7 @@ export class SessionRecording { return 'buffering' } - if (this._urlTriggerPatterns.length > 0 && !this.isUrlTriggerActivated) { + if (this.urlTriggerStatus === 'pending') { return 'buffering' } @@ -357,9 +360,24 @@ export class SessionRecording { } } - private get isUrlTriggerActivated(): boolean | null { + private get urlTriggerStatus(): 'activated' | 'pending' | 'disabled' { + if (this.receivedDecide && this._urlTriggerPatterns.length === 0) { + return 'disabled' + } + const currentValue = this.instance?.get_property(SESSION_RECORDING_URL_TRIGGER_ACTIVATED) - return isBoolean(currentValue) ? currentValue : null + + if (TRIGGER_STATUSES.includes(currentValue)) { + return currentValue as TriggerStatus + } + + return 'pending' + } + + private set urlTriggerStatus(status: TriggerStatus) { + this.instance?.persistence?.register({ + [SESSION_RECORDING_URL_TRIGGER_ACTIVATED]: status, + }) } constructor(private readonly instance: PostHog) { @@ -1122,10 +1140,8 @@ export class SessionRecording { } private _activateUrlTrigger() { - if (!this.isUrlTriggerActivated) { - this.instance.persistence?.register({ - [SESSION_RECORDING_URL_TRIGGER_ACTIVATED]: true, - }) + if (this.urlTriggerStatus === 'pending') { + this.urlTriggerStatus = 'activated' this._flushBuffer() logger.info(LOGGER_PREFIX + ' recording triggered by URL pattern match') } From c5169e65947f1ac912216a71778778832f7de456 Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Thu, 3 Oct 2024 15:36:34 +0200 Subject: [PATCH 04/12] if we're waiting for a trigger, lower the full snapshot interval --- src/extensions/replay/sessionrecording.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 8f121a2b2..96d1a84cc 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -37,6 +37,7 @@ import { gzipSync, strFromU8, strToU8 } from 'fflate' const BASE_ENDPOINT = '/s/' +const ONE_MINUTE = 1000 * 60 const FIVE_MINUTES = 1000 * 60 * 5 const TWO_SECONDS = 2000 export const RECORDING_IDLE_THRESHOLD_MS = FIVE_MINUTES @@ -259,7 +260,11 @@ export class SessionRecording { } private get fullSnapshotIntervalMillis(): number { - return this.instance.config.session_recording?.full_snapshot_interval_millis || FIVE_MINUTES + if (this.urlTriggerStatus === 'pending') { + return ONE_MINUTE + } + + return this.instance.config.session_recording?.full_snapshot_interval_millis ?? FIVE_MINUTES } private get isSampled(): boolean | null { From d7463624ff8cddf5b32e1ea60920836dddd7b320 Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Thu, 3 Oct 2024 15:36:36 +0200 Subject: [PATCH 05/12] send custom even when trigger is activated --- src/extensions/replay/sessionrecording.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 96d1a84cc..9892432c7 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -1147,6 +1147,7 @@ export class SessionRecording { private _activateUrlTrigger() { if (this.urlTriggerStatus === 'pending') { this.urlTriggerStatus = 'activated' + this._tryAddCustomEvent('url trigger activated', {}) this._flushBuffer() logger.info(LOGGER_PREFIX + ' recording triggered by URL pattern match') } From 5097b9b18ac67944fcc29299d92c64bbe6aed424 Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Thu, 3 Oct 2024 15:36:39 +0200 Subject: [PATCH 06/12] only keep the latest full snapshot --- src/extensions/replay/sessionrecording.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 9892432c7..70c950e13 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -956,6 +956,11 @@ export class SessionRecording { this._scheduleFullSnapshot() } + // Clear the buffer if waiting for a trigger, and only keep data from after the current full snapshot + if (rawEvent.type === EventType.FullSnapshot && this.urlTriggerStatus === 'pending') { + this.clearBuffer() + } + const throttledEvent = this.mutationRateLimiter ? this.mutationRateLimiter.throttleMutations(rawEvent) : rawEvent From 1a1c12a9b021014840551ad048acb3ec77c450cd Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Fri, 4 Oct 2024 10:13:21 +0200 Subject: [PATCH 07/12] switch to using object triggers with matcher --- src/extensions/replay/sessionrecording.ts | 28 ++++++++++++++++++----- src/types.ts | 7 +++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 70c950e13..4d4c19518 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -17,7 +17,14 @@ import { truncateLargeConsoleLogs, } from './sessionrecording-utils' import { PostHog } from '../../posthog-core' -import { DecideResponse, FlagVariant, NetworkRecordOptions, NetworkRequest, Properties } from '../../types' +import { + DecideResponse, + FlagVariant, + NetworkRecordOptions, + NetworkRequest, + Properties, + SessionRecordingUrlTrigger, +} from '../../types' import { customEvent, EventType, @@ -233,7 +240,7 @@ export class SessionRecording { // then we can manually track href changes private _lastHref?: string - private _urlTriggerPatterns: string[] = [] + private _urlTriggers: SessionRecordingUrlTrigger[] = [] // Util to help developers working on this feature manually override _forceAllowLocalhostNetworkCapture = false @@ -366,7 +373,7 @@ export class SessionRecording { } private get urlTriggerStatus(): 'activated' | 'pending' | 'disabled' { - if (this.receivedDecide && this._urlTriggerPatterns.length === 0) { + if (this.receivedDecide && this._urlTriggers.length === 0) { return 'disabled' } @@ -579,8 +586,8 @@ export class SessionRecording { }) } - if (response.sessionRecording?.urlTriggerPatterns) { - this._urlTriggerPatterns = response.sessionRecording.urlTriggerPatterns + if (response.sessionRecording?.urlTriggers) { + this._urlTriggers = response.sessionRecording.urlTriggers } this.receivedDecide = true @@ -1144,7 +1151,16 @@ export class SessionRecording { const url = window.location.href - if (this._urlTriggerPatterns.some((pattern) => new RegExp(pattern).test(url))) { + if ( + this._urlTriggers.some((trigger) => { + switch (trigger.matching) { + case 'regex': + return new RegExp(trigger.url).test(url) + default: + return false + } + }) + ) { this._activateUrlTrigger() } } diff --git a/src/types.ts b/src/types.ts index 8c0dd4844..2ecbe9a5b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -390,7 +390,7 @@ export interface DecideResponse { canvasQuality?: string | null linkedFlag?: string | FlagVariant | null networkPayloadCapture?: Pick - urlTriggerPatterns?: string[] + urlTriggers?: SessionRecordingUrlTrigger[] } surveys?: boolean toolbarParams: ToolbarParams @@ -595,3 +595,8 @@ export interface ErrorConversions { errorToProperties: (args: ErrorEventArgs) => ErrorProperties unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties } + +export interface SessionRecordingUrlTrigger { + url: string + matching: 'regex' +} From c8633a10bb4ff7cf148c67018405d024aedcef81 Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Mon, 14 Oct 2024 10:21:42 +0200 Subject: [PATCH 08/12] refactor: distinguish trigger and recording status --- src/extensions/replay/sessionrecording.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 4d4c19518..f9bd76727 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -69,7 +69,7 @@ const ACTIVE_SOURCES = [ IncrementalSource.Drag, ] -const TRIGGER_STATUSES = ['activated', 'pending', 'disabled'] as const +const TRIGGER_STATUSES = ['trigger_activated', 'trigger_pending', 'trigger_disabled'] as const type TriggerStatus = typeof TRIGGER_STATUSES[number] /** @@ -361,7 +361,7 @@ export class SessionRecording { return 'buffering' } - if (this.urlTriggerStatus === 'pending') { + if (this.urlTriggerStatus === 'trigger_pending') { return 'buffering' } @@ -372,9 +372,9 @@ export class SessionRecording { } } - private get urlTriggerStatus(): 'activated' | 'pending' | 'disabled' { + private get urlTriggerStatus(): TriggerStatus { if (this.receivedDecide && this._urlTriggers.length === 0) { - return 'disabled' + return 'trigger_disabled' } const currentValue = this.instance?.get_property(SESSION_RECORDING_URL_TRIGGER_ACTIVATED) @@ -383,7 +383,7 @@ export class SessionRecording { return currentValue as TriggerStatus } - return 'pending' + return 'trigger_pending' } private set urlTriggerStatus(status: TriggerStatus) { From 9a4b88eaa969d3b7a08b00d426ef8a51476cd2d2 Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Mon, 14 Oct 2024 10:27:12 +0200 Subject: [PATCH 09/12] feat: handle session id changes --- src/constants.ts | 3 ++- src/extensions/replay/sessionrecording.ts | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 505672d19..ac85e6936 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -24,7 +24,8 @@ export const SESSION_RECORDING_SAMPLE_RATE = '$replay_sample_rate' export const SESSION_RECORDING_MINIMUM_DURATION = '$replay_minimum_duration' export const SESSION_ID = '$sesid' export const SESSION_RECORDING_IS_SAMPLED = '$session_is_sampled' -export const SESSION_RECORDING_URL_TRIGGER_ACTIVATED = '$session_recording_url_trigger_activated' +export const SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION = '$session_recording_url_trigger_activated_session' +export const SESSION_RECORDING_URL_TRIGGER_STATUS = '$session_recording_url_trigger_status' export const ENABLED_FEATURE_FLAGS = '$enabled_feature_flags' export const PERSISTENCE_EARLY_ACCESS_FEATURES = '$early_access_features' export const STORED_PERSON_PROPERTIES_KEY = '$stored_person_properties' diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index f9bd76727..9e0e1b817 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -7,6 +7,8 @@ import { SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE, SESSION_RECORDING_SAMPLE_RATE, SESSION_RECORDING_URL_TRIGGER_ACTIVATED, + SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION, + SESSION_RECORDING_URL_TRIGGER_STATUS, } from '../../constants' import { estimateSize, @@ -377,10 +379,17 @@ export class SessionRecording { return 'trigger_disabled' } - const currentValue = this.instance?.get_property(SESSION_RECORDING_URL_TRIGGER_ACTIVATED) + const currentStatus = this.instance?.get_property(SESSION_RECORDING_URL_TRIGGER_STATUS) + const currentTriggerSession = this.instance?.get_property(SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION) - if (TRIGGER_STATUSES.includes(currentValue)) { - return currentValue as TriggerStatus + if (currentTriggerSession !== this.sessionId) { + this.instance?.persistence?.unregister(SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION) + this.instance?.persistence?.unregister(SESSION_RECORDING_URL_TRIGGER_STATUS) + return 'trigger_pending' + } + + if (TRIGGER_STATUSES.includes(currentStatus)) { + return currentStatus as TriggerStatus } return 'trigger_pending' @@ -388,7 +397,8 @@ export class SessionRecording { private set urlTriggerStatus(status: TriggerStatus) { this.instance?.persistence?.register({ - [SESSION_RECORDING_URL_TRIGGER_ACTIVATED]: status, + [SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION]: this.sessionId, + [SESSION_RECORDING_URL_TRIGGER_STATUS]: status, }) } @@ -475,6 +485,9 @@ export class SessionRecording { this._onSessionIdListener = this.sessionManager.onSessionId((sessionId, windowId, changeReason) => { if (changeReason) { this._tryAddCustomEvent('$session_id_change', { sessionId, windowId, changeReason }) + + this.instance?.persistence?.unregister(SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION) + this.instance?.persistence?.unregister(SESSION_RECORDING_URL_TRIGGER_STATUS) } }) } From 4217e6615bdef333bd867fdaf0ac81dd0a10b316 Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Mon, 14 Oct 2024 10:28:43 +0200 Subject: [PATCH 10/12] bundle size golf --- src/extensions/replay/sessionrecording.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 9e0e1b817..fff91ca05 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -47,7 +47,7 @@ import { gzipSync, strFromU8, strToU8 } from 'fflate' const BASE_ENDPOINT = '/s/' const ONE_MINUTE = 1000 * 60 -const FIVE_MINUTES = 1000 * 60 * 5 +const FIVE_MINUTES = ONE_MINUTE * 5 const TWO_SECONDS = 2000 export const RECORDING_IDLE_THRESHOLD_MS = FIVE_MINUTES const ONE_KB = 1024 From f99471a8c8e7472e2eff18fa66a483b755b47e6b Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Mon, 14 Oct 2024 10:32:10 +0200 Subject: [PATCH 11/12] remove unused import --- src/extensions/replay/sessionrecording.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index fff91ca05..d37a9a05e 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -6,7 +6,6 @@ import { SESSION_RECORDING_MINIMUM_DURATION, SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE, SESSION_RECORDING_SAMPLE_RATE, - SESSION_RECORDING_URL_TRIGGER_ACTIVATED, SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION, SESSION_RECORDING_URL_TRIGGER_STATUS, } from '../../constants' From e0a2e8274ad9b992b851d8bd5466a101611a731c Mon Sep 17 00:00:00 2001 From: Richard Borcsik Date: Mon, 14 Oct 2024 10:41:03 +0200 Subject: [PATCH 12/12] fix: use trigger statuses correctly --- src/extensions/replay/sessionrecording.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index d1bb83798..b2e8ce253 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -265,7 +265,7 @@ export class SessionRecording { } private get fullSnapshotIntervalMillis(): number { - if (this.urlTriggerStatus === 'pending') { + if (this.urlTriggerStatus === 'trigger_pending') { return ONE_MINUTE } @@ -973,7 +973,7 @@ export class SessionRecording { } // Clear the buffer if waiting for a trigger, and only keep data from after the current full snapshot - if (rawEvent.type === EventType.FullSnapshot && this.urlTriggerStatus === 'pending') { + if (rawEvent.type === EventType.FullSnapshot && this.urlTriggerStatus === 'trigger_pending') { this.clearBuffer() } @@ -1175,8 +1175,8 @@ export class SessionRecording { } private _activateUrlTrigger() { - if (this.urlTriggerStatus === 'pending') { - this.urlTriggerStatus = 'activated' + if (this.urlTriggerStatus === 'trigger_pending') { + this.urlTriggerStatus = 'trigger_activated' this._tryAddCustomEvent('url trigger activated', {}) this._flushBuffer() logger.info(LOGGER_PREFIX + ' recording triggered by URL pattern match')