@leanbase-giangnd/js 0.2.4 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1171,7 +1171,7 @@ const detectDeviceType = function (user_agent) {
1171
1171
  }
1172
1172
  };
1173
1173
 
1174
- var version = "0.2.4";
1174
+ var version = "0.3.1";
1175
1175
  var packageInfo = {
1176
1176
  version: version};
1177
1177
 
@@ -3110,117 +3110,20 @@ const isLikelyBot = function (navigator, customBlockedUserAgents) {
3110
3110
  };
3111
3111
 
3112
3112
  /* eslint-disable @typescript-eslint/no-unused-vars */
3113
- // We avoid importing '@rrweb/record' at module load time to prevent IIFE builds
3114
- // from requiring a top-level global. Instead, expose a lazy proxy that will
3115
- // dynamically import the module the first time it's used.
3116
- let _cachedRRWeb = null;
3117
- async function _loadRRWebModule() {
3118
- if (_cachedRRWeb) return _cachedRRWeb;
3119
- try {
3120
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3121
- const mod = await import('@rrweb/record');
3122
- _cachedRRWeb = mod;
3123
- return _cachedRRWeb;
3124
- } catch (e) {
3125
- return null;
3126
- }
3127
- }
3128
- // queue for method calls before rrweb loads
3129
- const _queuedCalls = [];
3130
- // Create a proxy function that delegates to the real rrweb.record when called
3131
- const rrwebRecordProxy = function (...args) {
3132
- let realStop;
3133
- let calledReal = false;
3134
- // Start loading asynchronously and call the real record when available
3135
- void (async () => {
3136
- const mod = await _loadRRWebModule();
3137
- const real = mod && (mod.record ?? mod.default?.record);
3138
- if (real) {
3139
- try {
3140
- calledReal = true;
3141
- realStop = real(...args);
3142
- // flush any queued calls that were waiting for rrweb
3143
- while (_queuedCalls.length) {
3144
- try {
3145
- const fn = _queuedCalls.shift();
3146
- fn();
3147
- } catch (e) {
3148
- // ignore
3149
- }
3150
- }
3151
- } catch (e) {
3152
- // ignore
3153
- }
3154
- }
3155
- })();
3156
- // return a stop function that will call the real stop when available
3157
- return () => {
3158
- if (realStop) {
3159
- try {
3160
- realStop();
3161
- } catch (e) {
3162
- // ignore
3163
- }
3164
- } else if (!calledReal) {
3165
- // If rrweb hasn't been initialised yet, queue a stop request that will
3166
- // call the real stop once available.
3167
- _queuedCalls.push(() => {
3168
- try {
3169
- realStop?.();
3170
- } catch (e) {
3171
- // ignore
3172
- }
3173
- });
3174
- }
3175
- };
3176
- };
3177
- // methods that can be called on the rrweb.record object - queue until real module is available
3178
- rrwebRecordProxy.addCustomEvent = function (tag, payload) {
3179
- const call = () => {
3180
- try {
3181
- const real = _cachedRRWeb && (_cachedRRWeb.record ?? _cachedRRWeb.default?.record);
3182
- real?.addCustomEvent?.(tag, payload);
3183
- } catch (e) {
3184
- // ignore
3185
- }
3186
- };
3187
- if (_cachedRRWeb) call();else _queuedCalls.push(call);
3188
- };
3189
- rrwebRecordProxy.takeFullSnapshot = function () {
3190
- const call = () => {
3191
- try {
3192
- const real = _cachedRRWeb && (_cachedRRWeb.record ?? _cachedRRWeb.default?.record);
3193
- real?.takeFullSnapshot?.();
3194
- } catch (e) {
3195
- // ignore
3196
- }
3197
- };
3198
- if (_cachedRRWeb) call();else _queuedCalls.push(call);
3199
- };
3200
- // Use a safe global target (prefer `win`, fallback to globalThis)
3201
3113
  const _target = win ?? globalThis;
3202
3114
  _target.__PosthogExtensions__ = _target.__PosthogExtensions__ || {};
3203
- // Expose rrweb.record under the same contract. We provide a lazy proxy so
3204
- // builds that execute this file don't require rrweb at module evaluation time.
3205
- _target.__PosthogExtensions__.rrweb = _target.__PosthogExtensions__.rrweb || {
3206
- record: rrwebRecordProxy
3207
- };
3208
- // Provide initSessionRecording if not present — return a new LazyLoadedSessionRecording when called
3115
+ _target.__PosthogExtensions__.rrweb = _target.__PosthogExtensions__.rrweb || {};
3209
3116
  _target.__PosthogExtensions__.initSessionRecording = _target.__PosthogExtensions__.initSessionRecording || (instance => {
3210
3117
  const factory = _target.__PosthogExtensions__._initSessionRecordingFactory;
3211
3118
  if (factory) {
3212
3119
  return factory(instance);
3213
3120
  }
3214
- // If no factory is registered yet, return undefined — callers should handle lazy-loading.
3215
3121
  return undefined;
3216
3122
  });
3217
- // Provide a no-op loadExternalDependency that calls the callback immediately (since rrweb is bundled)
3218
3123
  _target.__PosthogExtensions__.loadExternalDependency = _target.__PosthogExtensions__.loadExternalDependency || ((instance, scriptName, cb) => {
3219
3124
  if (cb) cb(undefined);
3220
3125
  });
3221
- // Provide rrwebPlugins object with network plugin factory if not present
3222
3126
  _target.__PosthogExtensions__.rrwebPlugins = _target.__PosthogExtensions__.rrwebPlugins || {};
3223
- // Default to undefined; the lazy-loaded recorder will register the real factory when it initializes.
3224
3127
  _target.__PosthogExtensions__.rrwebPlugins.getRecordNetworkPlugin = _target.__PosthogExtensions__.rrwebPlugins.getRecordNetworkPlugin || (() => undefined);
3225
3128
 
3226
3129
  // Type definitions copied from @rrweb/types@2.0.0-alpha.17 and rrweb-snapshot@2.0.0-alpha.17
@@ -3891,10 +3794,8 @@ class MutationThrottler {
3891
3794
  return event;
3892
3795
  }
3893
3796
  };
3894
- const configuredBucketSize = this._options.bucketSize ?? 100;
3895
- const effectiveBucketSize = Math.max(configuredBucketSize - 1, 1);
3896
3797
  this._rateLimiter = new core.BucketedRateLimiter({
3897
- bucketSize: effectiveBucketSize,
3798
+ bucketSize: this._options.bucketSize ?? 100,
3898
3799
  refillRate: this._options.refillRate ?? 10,
3899
3800
  refillInterval: 1000,
3900
3801
  // one second
@@ -4090,6 +3991,23 @@ class LazyLoadedSessionRecording {
4090
3991
  get sessionId() {
4091
3992
  return this._sessionId;
4092
3993
  }
3994
+ _disablePermanently(reason, error) {
3995
+ this._permanentlyDisabled = true;
3996
+ this._isFullyReady = false;
3997
+ this._mutationThrottler?.stop();
3998
+ this._mutationThrottler = undefined;
3999
+ this._queuedRRWebEvents = [];
4000
+ this._recording = undefined;
4001
+ this._stopRrweb = undefined;
4002
+ if (!this._loggedPermanentlyDisabled) {
4003
+ this._loggedPermanentlyDisabled = true;
4004
+ if (error) {
4005
+ logger.error(`replay disabled: ${reason}`, error);
4006
+ } else {
4007
+ logger.error(`replay disabled: ${reason}`);
4008
+ }
4009
+ }
4010
+ }
4093
4011
  get _sessionManager() {
4094
4012
  if (!this._instance.sessionManager) {
4095
4013
  throw new Error(LOGGER_PREFIX$1 + ' must be started with a valid sessionManager.');
@@ -4121,6 +4039,8 @@ class LazyLoadedSessionRecording {
4121
4039
  */
4122
4040
  this._forceAllowLocalhostNetworkCapture = false;
4123
4041
  this._stopRrweb = undefined;
4042
+ this._permanentlyDisabled = false;
4043
+ this._loggedPermanentlyDisabled = false;
4124
4044
  this._lastActivityTimestamp = Date.now();
4125
4045
  /**
4126
4046
  * and a queue - that contains rrweb events that we want to send to rrweb, but rrweb wasn't able to accept them yet
@@ -4310,6 +4230,9 @@ class LazyLoadedSessionRecording {
4310
4230
  }
4311
4231
  }
4312
4232
  _tryAddCustomEvent(tag, payload) {
4233
+ if (!this.isStarted || !this._recording) {
4234
+ return false;
4235
+ }
4313
4236
  const rrwebRecord = getRRWebRecord();
4314
4237
  if (!rrwebRecord || typeof rrwebRecord.addCustomEvent !== 'function') {
4315
4238
  return false;
@@ -4339,6 +4262,10 @@ class LazyLoadedSessionRecording {
4339
4262
  }
4340
4263
  }
4341
4264
  _processQueuedEvents() {
4265
+ if (!this.isStarted || !this._recording) {
4266
+ this._queuedRRWebEvents = [];
4267
+ return;
4268
+ }
4342
4269
  if (this._queuedRRWebEvents.length) {
4343
4270
  // if rrweb isn't ready to accept events earlier, then we queued them up.
4344
4271
  // now that `emit` has been called rrweb should be ready to accept them.
@@ -4360,6 +4287,9 @@ class LazyLoadedSessionRecording {
4360
4287
  }
4361
4288
  }
4362
4289
  _tryTakeFullSnapshot() {
4290
+ if (!this.isStarted || !this._recording) {
4291
+ return false;
4292
+ }
4363
4293
  const rrwebRecord = getRRWebRecord();
4364
4294
  if (!rrwebRecord || typeof rrwebRecord.takeFullSnapshot !== 'function') {
4365
4295
  return false;
@@ -4373,6 +4303,9 @@ class LazyLoadedSessionRecording {
4373
4303
  return this._instance.config.session_recording?.full_snapshot_interval_millis ?? FIVE_MINUTES;
4374
4304
  }
4375
4305
  _scheduleFullSnapshot() {
4306
+ if (!this.isStarted || !this._recording) {
4307
+ return;
4308
+ }
4376
4309
  if (this._fullSnapshotTimer) {
4377
4310
  clearInterval(this._fullSnapshotTimer);
4378
4311
  }
@@ -4389,6 +4322,9 @@ class LazyLoadedSessionRecording {
4389
4322
  }, interval);
4390
4323
  }
4391
4324
  _pauseRecording() {
4325
+ if (!this.isStarted || !this._recording) {
4326
+ return;
4327
+ }
4392
4328
  // we check _urlBlocked not status, since more than one thing can affect status
4393
4329
  if (this._urlTriggerMatching.urlBlocked) {
4394
4330
  return;
@@ -4406,6 +4342,9 @@ class LazyLoadedSessionRecording {
4406
4342
  });
4407
4343
  }
4408
4344
  _resumeRecording() {
4345
+ if (!this.isStarted || !this._recording) {
4346
+ return;
4347
+ }
4409
4348
  // we check _urlBlocked not status, since more than one thing can affect status
4410
4349
  if (!this._urlTriggerMatching.urlBlocked) {
4411
4350
  return;
@@ -4419,6 +4358,9 @@ class LazyLoadedSessionRecording {
4419
4358
  logger.info('recording resumed');
4420
4359
  }
4421
4360
  _activateTrigger(triggerType) {
4361
+ if (!this.isStarted || !this._recording || !this._isFullyReady) {
4362
+ return;
4363
+ }
4422
4364
  if (this._triggerMatching.triggerStatus(this.sessionId) === TRIGGER_PENDING) {
4423
4365
  // status is stored separately for URL and event triggers
4424
4366
  this._instance?.persistence?.register({
@@ -4429,7 +4371,7 @@ class LazyLoadedSessionRecording {
4429
4371
  }
4430
4372
  }
4431
4373
  get isStarted() {
4432
- return !!this._stopRrweb;
4374
+ return !!this._recording?.stop;
4433
4375
  }
4434
4376
  get _remoteConfig() {
4435
4377
  const persistedConfig = this._instance.get_property(SESSION_RECORDING_REMOTE_CONFIG);
@@ -4440,6 +4382,9 @@ class LazyLoadedSessionRecording {
4440
4382
  return parsedConfig;
4441
4383
  }
4442
4384
  async start(startReason) {
4385
+ if (this._permanentlyDisabled) {
4386
+ return;
4387
+ }
4443
4388
  this._isFullyReady = false;
4444
4389
  const config = this._remoteConfig;
4445
4390
  if (!config) {
@@ -4465,8 +4410,14 @@ class LazyLoadedSessionRecording {
4465
4410
  });
4466
4411
  this._urlTriggerMatching.onConfig(config);
4467
4412
  this._eventTriggerMatching.onConfig(config);
4468
- this._removeEventTriggerCaptureHook?.();
4469
- this._addEventTriggerListener();
4413
+ // Start rrweb first; only once we have a valid recorder do we install any listeners/timers.
4414
+ await this._startRecorder();
4415
+ // If rrweb failed to load/start, do not proceed further.
4416
+ // This prevents installing listeners that assume rrweb is active.
4417
+ if (!this.isStarted) {
4418
+ return;
4419
+ }
4420
+ // Now that rrweb has started, we can safely install replay side-effects.
4470
4421
  this._linkedFlagMatching.onConfig(config, (flag, variant) => {
4471
4422
  this._reportStarted('linked_flag_matched', {
4472
4423
  flag,
@@ -4474,12 +4425,8 @@ class LazyLoadedSessionRecording {
4474
4425
  });
4475
4426
  });
4476
4427
  this._makeSamplingDecision(this.sessionId);
4477
- await this._startRecorder();
4478
- // If rrweb failed to load/start, do not proceed further.
4479
- // This prevents installing listeners that assume rrweb is active.
4480
- if (!this.isStarted) {
4481
- return;
4482
- }
4428
+ this._removeEventTriggerCaptureHook?.();
4429
+ this._addEventTriggerListener();
4483
4430
  // Only start processing rrweb emits once the ingestion endpoint is available.
4484
4431
  // If it isn't available, we must degrade to a no-op (never crash the host app).
4485
4432
  this._isFullyReady = this._canCaptureSnapshots();
@@ -4558,7 +4505,8 @@ class LazyLoadedSessionRecording {
4558
4505
  this._mutationThrottler?.stop();
4559
4506
  // Clear any queued rrweb events to prevent memory leaks from closures
4560
4507
  this._queuedRRWebEvents = [];
4561
- this._stopRrweb?.();
4508
+ this._recording?.stop?.();
4509
+ this._recording = undefined;
4562
4510
  this._stopRrweb = undefined;
4563
4511
  this._isFullyReady = false;
4564
4512
  logger.info('stopped');
@@ -4578,8 +4526,12 @@ class LazyLoadedSessionRecording {
4578
4526
  return !!this._snapshotIngestionUrl();
4579
4527
  }
4580
4528
  onRRwebEmit(rawEvent) {
4529
+ // First-line invariant gate: drop everything unless replay is truly started.
4530
+ if (!this.isStarted || !this._recording) {
4531
+ return;
4532
+ }
4581
4533
  // Never process rrweb emits until we're fully ready.
4582
- if (!this._isFullyReady || !this.isStarted) {
4534
+ if (!this._isFullyReady) {
4583
4535
  return;
4584
4536
  }
4585
4537
  try {
@@ -4684,6 +4636,9 @@ class LazyLoadedSessionRecording {
4684
4636
  });
4685
4637
  }
4686
4638
  overrideLinkedFlag() {
4639
+ if (!this.isStarted || !this._recording || !this._isFullyReady) {
4640
+ return;
4641
+ }
4687
4642
  this._linkedFlagMatching.linkedFlagSeen = true;
4688
4643
  this._tryTakeFullSnapshot();
4689
4644
  this._reportStarted('linked_flag_overridden');
@@ -4695,6 +4650,9 @@ class LazyLoadedSessionRecording {
4695
4650
  * instead call `posthog.startSessionRecording({sampling: true})`
4696
4651
  * */
4697
4652
  overrideSampling() {
4653
+ if (!this.isStarted || !this._recording || !this._isFullyReady) {
4654
+ return;
4655
+ }
4698
4656
  this._instance.persistence?.register({
4699
4657
  // short-circuits the `makeSamplingDecision` function in the session recording module
4700
4658
  [SESSION_RECORDING_IS_SAMPLED]: this.sessionId
@@ -4709,6 +4667,9 @@ class LazyLoadedSessionRecording {
4709
4667
  * instead call `posthog.startSessionRecording({trigger: 'url' | 'event'})`
4710
4668
  * */
4711
4669
  overrideTrigger(triggerType) {
4670
+ if (!this.isStarted || !this._recording || !this._isFullyReady) {
4671
+ return;
4672
+ }
4712
4673
  this._activateTrigger(triggerType);
4713
4674
  }
4714
4675
  _clearFlushBufferTimer() {
@@ -4841,6 +4802,9 @@ class LazyLoadedSessionRecording {
4841
4802
  return this._buffer;
4842
4803
  }
4843
4804
  _reportStarted(startReason, tagPayload) {
4805
+ if (!this.isStarted || !this._recording) {
4806
+ return;
4807
+ }
4844
4808
  this._instance.registerForSession({
4845
4809
  $session_recording_start_reason: startReason
4846
4810
  });
@@ -4984,7 +4948,7 @@ class LazyLoadedSessionRecording {
4984
4948
  };
4985
4949
  }
4986
4950
  async _startRecorder() {
4987
- if (this._stopRrweb) {
4951
+ if (this._permanentlyDisabled || this._recording) {
4988
4952
  return;
4989
4953
  }
4990
4954
  // rrweb config info: https://github.com/rrweb-io/rrweb/blob/7d5d0033258d6c29599fb08412202d9a2c7b9413/src/record/index.ts#L28
@@ -5046,27 +5010,18 @@ class LazyLoadedSessionRecording {
5046
5010
  rrwebRecord = loaded ?? undefined;
5047
5011
  }
5048
5012
  if (!rrwebRecord) {
5049
- logger.error('_startRecorder was called but rrwebRecord is not available. This indicates something has gone wrong.');
5013
+ this._disablePermanently('rrweb record function unavailable');
5050
5014
  return;
5051
5015
  }
5052
- this._mutationThrottler = this._mutationThrottler ?? new MutationThrottler(rrwebRecord, {
5053
- refillRate: this._instance.config.session_recording?.__mutationThrottlerRefillRate,
5054
- bucketSize: this._instance.config.session_recording?.__mutationThrottlerBucketSize,
5055
- onBlockedNode: (id, node) => {
5056
- const message = `Too many mutations on node '${id}'. Rate limiting. This could be due to SVG animations or something similar`;
5057
- logger.info(message, {
5058
- node: node
5059
- });
5060
- this.log(LOGGER_PREFIX$1 + ' ' + message, 'warn');
5061
- }
5062
- });
5063
5016
  const activePlugins = this._gatherRRWebPlugins();
5017
+ let stopHandler;
5064
5018
  try {
5065
- this._stopRrweb = rrwebRecord({
5019
+ stopHandler = rrwebRecord({
5066
5020
  emit: event => {
5067
5021
  try {
5068
5022
  this.onRRwebEmit(event);
5069
5023
  } catch (e) {
5024
+ // never throw from rrweb emit handler
5070
5025
  logger.error('error in rrweb emit handler', e);
5071
5026
  }
5072
5027
  },
@@ -5074,10 +5029,30 @@ class LazyLoadedSessionRecording {
5074
5029
  ...sessionRecordingOptions
5075
5030
  });
5076
5031
  } catch (e) {
5077
- logger.error('failed to start rrweb recorder', e);
5078
- this._stopRrweb = undefined;
5032
+ this._disablePermanently('rrweb recorder threw during initialization', e);
5033
+ return;
5034
+ }
5035
+ if (typeof stopHandler !== 'function') {
5036
+ this._disablePermanently('rrweb recorder returned an invalid stop handler');
5079
5037
  return;
5080
5038
  }
5039
+ // Mark replay started only after rrweb has successfully returned a valid stop handler.
5040
+ this._recording = {
5041
+ stop: stopHandler
5042
+ };
5043
+ this._stopRrweb = stopHandler;
5044
+ // Only create mutation throttler once replay is truly started.
5045
+ this._mutationThrottler = this._mutationThrottler ?? new MutationThrottler(rrwebRecord, {
5046
+ refillRate: this._instance.config.session_recording?.__mutationThrottlerRefillRate,
5047
+ bucketSize: this._instance.config.session_recording?.__mutationThrottlerBucketSize,
5048
+ onBlockedNode: (id, node) => {
5049
+ const message = `Too many mutations on node '${id}'. Rate limiting. This could be due to SVG animations or something similar`;
5050
+ logger.info(message, {
5051
+ node: node
5052
+ });
5053
+ this.log(LOGGER_PREFIX$1 + ' ' + message, 'warn');
5054
+ }
5055
+ });
5081
5056
  // We reset the last activity timestamp, resetting the idle timer
5082
5057
  this._lastActivityTimestamp = Date.now();
5083
5058
  // stay unknown if we're not sure if we're idle or not
@@ -5107,10 +5082,6 @@ class SessionRecording {
5107
5082
  get started() {
5108
5083
  return !!this._lazyLoadedSessionRecording?.isStarted;
5109
5084
  }
5110
- /**
5111
- * defaults to buffering mode until a flags response is received
5112
- * once a flags response is received status can be disabled, active or sampled
5113
- */
5114
5085
  get status() {
5115
5086
  if (this._lazyLoadedSessionRecording) {
5116
5087
  return this._lazyLoadedSessionRecording.status;
@@ -5124,7 +5095,6 @@ class SessionRecording {
5124
5095
  this._instance = _instance;
5125
5096
  this._forceAllowLocalhostNetworkCapture = false;
5126
5097
  this._receivedFlags = false;
5127
- this._serverRecordingEnabled = false;
5128
5098
  this._persistFlagsOnSessionListener = undefined;
5129
5099
  if (!this._instance.sessionManager) {
5130
5100
  log.error('started without valid sessionManager');
@@ -5147,26 +5117,14 @@ class SessionRecording {
5147
5117
  const canRunReplay = !core.isUndefined(Object.assign) && !core.isUndefined(Array.from);
5148
5118
  if (this._isRecordingEnabled && canRunReplay) {
5149
5119
  this._lazyLoadAndStart(startReason);
5150
- log.info('starting');
5151
5120
  } else {
5152
5121
  this.stopRecording();
5153
5122
  }
5154
5123
  }
5155
- /**
5156
- * session recording waits until it receives remote config before loading the script
5157
- * this is to ensure we can control the script name remotely
5158
- * and because we wait until we have local and remote config to determine if we should start at all
5159
- * if start is called and there is no remote config then we wait until there is
5160
- */
5161
5124
  _lazyLoadAndStart(startReason) {
5162
- // by checking `_isRecordingEnabled` here we know that
5163
- // we have stored remote config and client config to read
5164
- // replay waits for both local and remote config before starting
5165
5125
  if (!this._isRecordingEnabled) {
5166
5126
  return;
5167
5127
  }
5168
- // If extensions provide a loader, use it. Otherwise fallback to the local _onScriptLoaded which
5169
- // will create the local LazyLoadedSessionRecording (so tests that mock it work correctly).
5170
5128
  const loader = assignableWindow.__PosthogExtensions__?.loadExternalDependency;
5171
5129
  if (typeof loader === 'function') {
5172
5130
  loader(this._instance, this._scriptName, err => {
@@ -5221,16 +5179,10 @@ class SessionRecording {
5221
5179
  });
5222
5180
  };
5223
5181
  persistResponse();
5224
- // in case we see multiple flags responses, we should only use the response from the most recent one
5225
5182
  this._persistFlagsOnSessionListener?.();
5226
- // we 100% know there is a session manager by this point
5227
5183
  this._persistFlagsOnSessionListener = this._instance.sessionManager?.onSessionId(persistResponse);
5228
5184
  }
5229
5185
  }
5230
- _clearRemoteConfig() {
5231
- this._instance.persistence?.unregister(SESSION_RECORDING_REMOTE_CONFIG);
5232
- this._resetSampling();
5233
- }
5234
5186
  onRemoteConfig(response) {
5235
5187
  if (!('sessionRecording' in response)) {
5236
5188
  // if sessionRecording is not in the response, we do nothing
@@ -5239,12 +5191,8 @@ class SessionRecording {
5239
5191
  }
5240
5192
  this._receivedFlags = true;
5241
5193
  if (response.sessionRecording === false) {
5242
- this._serverRecordingEnabled = false;
5243
- this._clearRemoteConfig();
5244
- this.stopRecording();
5245
5194
  return;
5246
5195
  }
5247
- this._serverRecordingEnabled = true;
5248
5196
  this._persistRemoteConfig(response);
5249
5197
  this.startIfEnabledOrStop();
5250
5198
  }
@@ -5305,54 +5253,23 @@ class SessionRecording {
5305
5253
  onRRwebEmit(rawEvent) {
5306
5254
  this._lazyLoadedSessionRecording?.onRRwebEmit?.(rawEvent);
5307
5255
  }
5308
- /**
5309
- * this ignores the linked flag config and (if other conditions are met) causes capture to start
5310
- *
5311
- * It is not usual to call this directly,
5312
- * instead call `posthog.startSessionRecording({linked_flag: true})`
5313
- * */
5314
5256
  overrideLinkedFlag() {
5315
5257
  // TODO what if this gets called before lazy loading is done
5316
5258
  this._lazyLoadedSessionRecording?.overrideLinkedFlag();
5317
5259
  }
5318
- /**
5319
- * this ignores the sampling config and (if other conditions are met) causes capture to start
5320
- *
5321
- * It is not usual to call this directly,
5322
- * instead call `posthog.startSessionRecording({sampling: true})`
5323
- * */
5324
5260
  overrideSampling() {
5325
5261
  // TODO what if this gets called before lazy loading is done
5326
5262
  this._lazyLoadedSessionRecording?.overrideSampling();
5327
5263
  }
5328
- /**
5329
- * this ignores the URL/Event trigger config and (if other conditions are met) causes capture to start
5330
- *
5331
- * It is not usual to call this directly,
5332
- * instead call `posthog.startSessionRecording({trigger: 'url' | 'event'})`
5333
- * */
5334
5264
  overrideTrigger(triggerType) {
5335
5265
  // TODO what if this gets called before lazy loading is done
5336
5266
  this._lazyLoadedSessionRecording?.overrideTrigger(triggerType);
5337
5267
  }
5338
- /*
5339
- * whenever we capture an event, we add these properties to the event
5340
- * these are used to debug issues with the session recording
5341
- * when looking at the event feed for a session
5342
- */
5343
5268
  get sdkDebugProperties() {
5344
5269
  return this._lazyLoadedSessionRecording?.sdkDebugProperties || {
5345
5270
  $recording_status: this.status
5346
5271
  };
5347
5272
  }
5348
- /**
5349
- * This adds a custom event to the session recording
5350
- *
5351
- * It is not intended for arbitrary public use - playback only displays known custom events
5352
- * And is exposed on the public interface only so that other parts of the SDK are able to use it
5353
- *
5354
- * if you are calling this from client code, you're probably looking for `posthog.capture('$custom_event', {...})`
5355
- */
5356
5273
  tryAddCustomEvent(tag, payload) {
5357
5274
  return !!this._lazyLoadedSessionRecording?.tryAddCustomEvent(tag, payload);
5358
5275
  }