posthog-js
Version:
Posthog-js allows you to automatically capture usage and send events to PostHog.
491 lines • 28.6 kB
JavaScript
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionRecording = void 0;
var constants_1 = require("../../constants");
var remote_config_1 = require("../../remote-config");
var core_1 = require("@posthog/core");
var logger_1 = require("@posthog/browser-common/utils/logger");
var globals_1 = require("@posthog/browser-common/utils/globals");
var general_utils_1 = require("@posthog/browser-common/utils/general-utils");
var globals_2 = require("../../utils/globals");
var triggerMatching_1 = require("./external/triggerMatching");
var LOGGER_PREFIX = '[SessionRecording]';
var logger = (0, logger_1.createLogger)(LOGGER_PREFIX);
// Read these outside super properties so optional diagnostics can be throttled.
var SESSION_DEBUG_PROPERTY_KEYS = [
constants_1.SDK_DEBUG_RECORDING_SCRIPT_NOT_LOADED,
constants_1.SDK_DEBUG_REPLAY_STALE_CONFIG,
constants_1.SDK_DEBUG_REPLAY_EVENT_TRIGGER_STATUS,
constants_1.SDK_DEBUG_REPLAY_LINKED_FLAG_TRIGGER_STATUS,
constants_1.SDK_DEBUG_REPLAY_MATCHED_RECORDING_TRIGGER_GROUPS,
constants_1.SDK_DEBUG_REPLAY_PENDING_TRIGGER_CONDITIONS,
constants_1.SDK_DEBUG_REPLAY_REMOTE_TRIGGER_MATCHING_CONFIG,
constants_1.SDK_DEBUG_REPLAY_TRIGGER_GROUPS_COUNT,
constants_1.SDK_DEBUG_REPLAY_URL_TRIGGER_STATUS,
];
var hasDocumentEverBeenVisible = function () {
var _a, _b;
if (!(globals_1.document === null || globals_1.document === void 0 ? void 0 : globals_1.document.visibilityState) || globals_1.document.visibilityState === 'visible') {
return true;
}
var visibilityEntries = (_b = (_a = globals_1.window === null || globals_1.window === void 0 ? void 0 : globals_1.window.performance) === null || _a === void 0 ? void 0 : _a.getEntriesByType) === null || _b === void 0 ? void 0 : _b.call(_a, 'visibility-state');
return !(visibilityEntries === null || visibilityEntries === void 0 ? void 0 : visibilityEntries.length) || visibilityEntries.some(function (entry) { return entry.name === 'visible'; });
};
var SessionRecording = /** @class */ (function () {
function SessionRecording(_instance) {
var _this = this;
this._instance = _instance;
this._forceAllowLocalhostNetworkCapture = false;
this._recordingStatus = triggerMatching_1.DISABLED;
this._persistFlagsOnSessionListener = undefined;
this._sessionRecordingDisposed = false;
this._documentWasEverVisible = hasDocumentEverBeenVisible();
this._onVisibilityChange = function () {
var _a, _b;
if ((globals_1.document === null || globals_1.document === void 0 ? void 0 : globals_1.document.visibilityState) === 'visible') {
_this._documentWasEverVisible = true;
(_b = (_a = _this._lazyLoadedSessionRecording) === null || _a === void 0 ? void 0 : _a.setDocumentWasEverVisible) === null || _b === void 0 ? void 0 : _b.call(_a, true);
}
};
if (!this._instance.sessionManager) {
logger.error('started without valid sessionManager');
throw new Error(LOGGER_PREFIX + ' started without valid sessionManager. This is a bug.');
}
if (this._config.cookieless_mode === constants_1.COOKIELESS_ALWAYS) {
throw new Error(LOGGER_PREFIX + ' cannot be used with cookieless_mode="always"');
}
// Start before the recorder chunk loads so a visible -> hidden transition during
// lazy loading is not mistaken for a document that was never foregrounded.
if (globals_1.document === null || globals_1.document === void 0 ? void 0 : globals_1.document.addEventListener) {
(0, general_utils_1.addEventListener)(globals_1.document, 'visibilitychange', this._onVisibilityChange);
}
}
Object.defineProperty(SessionRecording.prototype, "_config", {
get: function () {
return this._instance.config;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SessionRecording.prototype, "_persistence", {
get: function () {
return this._instance.persistence;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SessionRecording.prototype, "started", {
get: function () {
var _a;
return !!((_a = this._lazyLoadedSessionRecording) === null || _a === void 0 ? void 0 : _a.isStarted);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SessionRecording.prototype, "status", {
get: function () {
var _a, _b;
if (this._recordingStatus === triggerMatching_1.AWAITING_CONFIG || this._recordingStatus === triggerMatching_1.MISSING_CONFIG) {
return this._recordingStatus;
}
return (_b = (_a = this._lazyLoadedSessionRecording) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : this._recordingStatus;
},
enumerable: false,
configurable: true
});
SessionRecording.prototype.initialize = function () {
this.startIfEnabledOrStop();
};
SessionRecording.prototype.dispose = function (_a) {
var _b;
var _c = _a === void 0 ? {} : _a, _d = _c.discardBufferedEvents, discardBufferedEvents = _d === void 0 ? false : _d;
this._sessionRecordingDisposed = true;
(_b = globals_1.document === null || globals_1.document === void 0 ? void 0 : globals_1.document.removeEventListener) === null || _b === void 0 ? void 0 : _b.call(globals_1.document, 'visibilitychange', this._onVisibilityChange);
if (discardBufferedEvents) {
this._discardRecording(true);
}
else {
this.stopRecording();
}
};
Object.defineProperty(SessionRecording.prototype, "_isRecordingEnabled", {
get: function () {
var _a;
var enabled_server_side = !!((_a = this._instance.get_property(constants_1.SESSION_RECORDING_REMOTE_CONFIG)) === null || _a === void 0 ? void 0 : _a.enabled);
var enabled_client_side = !this._config.disable_session_recording;
var isDisabled = this._config.disable_session_recording || this._instance.consent.isOptedOut();
return globals_1.window && enabled_server_side && enabled_client_side && !isDisabled;
},
enumerable: false,
configurable: true
});
SessionRecording.prototype.startIfEnabledOrStop = function (startReason) {
var _a;
if (this._sessionRecordingDisposed) {
return;
}
if (this._isRecordingEnabled && ((_a = this._lazyLoadedSessionRecording) === null || _a === void 0 ? void 0 : _a.isStarted)) {
return;
}
// According to the rrweb docs, rrweb is not supported on IE11 and below:
// "rrweb does not support IE11 and below because it uses the MutationObserver API, which was supported by these browsers."
// https://github.com/rrweb-io/rrweb/blob/master/guide.md#compatibility-note
//
// However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.
// Instead, when we load "recorder.js", the first JS error is about "Object.assign" and "Array.from" being undefined.
// Thus instead of MutationObserver, we look for this function and block recording if it's undefined.
var canRunReplay = !(0, core_1.isUndefined)(Object.assign) && !(0, core_1.isUndefined)(Array.from);
if (this._isRecordingEnabled && canRunReplay) {
this._lazyLoadAndStart(startReason);
logger.info('starting');
}
else {
this._recordingStatus = triggerMatching_1.DISABLED;
this.stopRecording();
}
};
/**
* session recording waits until it receives remote config before loading the script
* this is to ensure we can control the script name remotely
* and because we wait until we have local and remote config to determine if we should start at all
* if start is called and there is no remote config then we wait until there is
*/
SessionRecording.prototype._lazyLoadAndStart = function (startReason) {
var _this = this;
var _a, _b, _c, _d, _e;
// by checking `_isRecordingEnabled` here we know that
// we have stored remote config and client config to read
// replay waits for both local and remote config before starting
if (!this._isRecordingEnabled) {
return;
}
if (this._recordingStatus !== triggerMatching_1.AWAITING_CONFIG && this._recordingStatus !== triggerMatching_1.MISSING_CONFIG) {
this._recordingStatus = triggerMatching_1.LAZY_LOADING;
}
// If the recorder is already loaded, don't load the script. Both halves are needed:
// `rrweb.record` is the recorder itself, `initSessionRecording` is the code that drives it.
// The `.full` bundles and `posthog-js/dist/posthog-recorder` (or `dist/lazy-recorder`) define both,
// so nothing is fetched. Otherwise remotely import the recorder from the cdn.
if (!((_b = (_a = globals_2.assignableWindow === null || globals_2.assignableWindow === void 0 ? void 0 : globals_2.assignableWindow.__PosthogExtensions__) === null || _a === void 0 ? void 0 : _a.rrweb) === null || _b === void 0 ? void 0 : _b.record) ||
!((_c = globals_2.assignableWindow.__PosthogExtensions__) === null || _c === void 0 ? void 0 : _c.initSessionRecording)) {
// Consent and session state can change while the recorder chunk is loading.
// Only the recorder that initiated this load may finish starting with its manager.
var sessionManager_1 = this._instance.sessionManager;
(_e = (_d = globals_2.assignableWindow.__PosthogExtensions__) === null || _d === void 0 ? void 0 : _d.loadExternalDependency) === null || _e === void 0 ? void 0 : _e.call(_d, this._instance, this._scriptName, function (err) {
var _a;
if (_this._sessionRecordingDisposed ||
!_this._isRecordingEnabled ||
_this._instance.sessionManager !== sessionManager_1) {
_this._recordingStatus = triggerMatching_1.DISABLED;
return;
}
if (err) {
// most often this is an ad blocker matching the `/static/<script>.js` path.
// flag it on the session so a blocked recorder is visible in analytics
// instead of only in the browser console
_this._instance.register_for_session((_a = {},
_a[constants_1.SDK_DEBUG_RECORDING_SCRIPT_NOT_LOADED] = true,
_a));
return logger.error('could not load recorder', err);
}
_this._onScriptLoaded(startReason);
});
}
else {
this._onScriptLoaded(startReason);
}
};
SessionRecording.prototype.stopRecording = function () {
var _a, _b;
(_a = this._persistFlagsOnSessionListener) === null || _a === void 0 ? void 0 : _a.call(this);
this._persistFlagsOnSessionListener = undefined;
(_b = this._lazyLoadedSessionRecording) === null || _b === void 0 ? void 0 : _b.stop();
};
SessionRecording.prototype._discardRecording = function (discardProducerEvents) {
var _a, _b;
if (discardProducerEvents === void 0) { discardProducerEvents = false; }
(_a = this._persistFlagsOnSessionListener) === null || _a === void 0 ? void 0 : _a.call(this);
this._persistFlagsOnSessionListener = undefined;
(_b = this._lazyLoadedSessionRecording) === null || _b === void 0 ? void 0 : _b.discard({ discardProducerEvents: discardProducerEvents });
};
SessionRecording.prototype._resetSampling = function () {
var _a, _b;
(_a = this._persistence) === null || _a === void 0 ? void 0 : _a.unregister(constants_1.SESSION_RECORDING_IS_SAMPLED);
(_b = this._persistence) === null || _b === void 0 ? void 0 : _b.unregister(constants_1.SESSION_RECORDING_SAMPLE_RATE);
};
SessionRecording.prototype._validateSampleRate = function (rate, source) {
if ((0, core_1.isNullish)(rate)) {
return null;
}
var parsed = (0, core_1.isNumber)(rate) ? rate : parseFloat(rate);
if (!(0, core_1.isValidSampleRate)(parsed)) {
logger.warn("".concat(source, " must be between 0 and 1. Ignoring invalid value:"), rate);
return null;
}
return parsed;
};
SessionRecording.prototype._persistRemoteConfig = function (response) {
var _this = this;
var _a, _b;
if (this._persistence) {
var persistence_1 = this._persistence;
var persistResponse = function () {
var _a;
var _b;
var sessionRecordingConfigResponse = response.sessionRecording === false ? undefined : response.sessionRecording;
var localSampleRate = _this._validateSampleRate((_b = _this._config.session_recording) === null || _b === void 0 ? void 0 : _b.sampleRate, 'session_recording.sampleRate');
var remoteSampleRate = _this._validateSampleRate(sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.sampleRate, 'remote config sampleRate');
var parsedSampleRate = localSampleRate !== null && localSampleRate !== void 0 ? localSampleRate : remoteSampleRate;
if ((0, core_1.isNullish)(parsedSampleRate)) {
_this._resetSampling();
}
var receivedMinimumDuration = sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.minimumDurationMilliseconds;
persistence_1.register((_a = {},
_a[constants_1.SESSION_RECORDING_REMOTE_CONFIG] = __assign(__assign({ cache_timestamp: Date.now(), enabled: !!sessionRecordingConfigResponse }, sessionRecordingConfigResponse), { networkPayloadCapture: __assign({ capturePerformance: response.capturePerformance }, sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.networkPayloadCapture), canvasRecording: {
enabled: sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.recordCanvas,
fps: sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.canvasFps,
quality: sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.canvasQuality,
}, sampleRate: parsedSampleRate, minimumDurationMilliseconds: (0, core_1.isUndefined)(receivedMinimumDuration)
? null
: receivedMinimumDuration, endpoint: sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.endpoint, triggerMatchType: sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.triggerMatchType, masking: sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.masking, urlTriggers: sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.urlTriggers,
// V2 fields - will be undefined for V1 configs
version: sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.version, triggerGroups: sessionRecordingConfigResponse === null || sessionRecordingConfigResponse === void 0 ? void 0 : sessionRecordingConfigResponse.triggerGroups }),
_a));
};
persistResponse();
// in case we see multiple flags responses, we should only use the response from the most recent one
(_a = this._persistFlagsOnSessionListener) === null || _a === void 0 ? void 0 : _a.call(this);
// we 100% know there is a session manager by this point
this._persistFlagsOnSessionListener = (_b = this._instance.sessionManager) === null || _b === void 0 ? void 0 : _b.onSessionId(persistResponse);
}
};
SessionRecording.prototype.onRemoteConfig = function (result) {
var _a;
// A failed fetch and a response without a sessionRecording key behave the same:
// no fresh server config arrived, so fall back to whatever is already persisted.
var response = result.ok ? result.config : undefined;
if (!response || !('sessionRecording' in response)) {
if (this._recordingStatus === triggerMatching_1.AWAITING_CONFIG) {
this._recordingStatus = triggerMatching_1.MISSING_CONFIG;
this._instance.register_for_session((_a = {},
_a[constants_1.SDK_DEBUG_REPLAY_STALE_CONFIG] = true,
_a));
logger.warn('config refresh failed, recording will not start until page reload');
}
this.startIfEnabledOrStop();
return;
}
if (response.sessionRecording === false) {
this._persistRemoteConfig(response);
this._discardRecording();
return;
}
this._persistRemoteConfig(response);
this.startIfEnabledOrStop();
};
SessionRecording.prototype.log = function (message, level) {
var _a;
if (level === void 0) { level = 'log'; }
if ((_a = this._lazyLoadedSessionRecording) === null || _a === void 0 ? void 0 : _a.log) {
this._lazyLoadedSessionRecording.log(message, level);
}
else {
logger.warn('log called before recorder was ready');
}
};
Object.defineProperty(SessionRecording.prototype, "_scriptName", {
get: function () {
var _a, _b, _c;
var remoteConfig = (_b = (_a = this._instance) === null || _a === void 0 ? void 0 : _a.persistence) === null || _b === void 0 ? void 0 : _b.get_property(constants_1.SESSION_RECORDING_REMOTE_CONFIG);
return ((_c = remoteConfig === null || remoteConfig === void 0 ? void 0 : remoteConfig.scriptConfig) === null || _c === void 0 ? void 0 : _c.script) || 'lazy-recorder';
},
enumerable: false,
configurable: true
});
SessionRecording.prototype._isRemoteConfigFresh = function () {
var persistedConfig = this._instance.get_property(constants_1.SESSION_RECORDING_REMOTE_CONFIG);
if (!persistedConfig) {
return false;
}
var config;
try {
config = typeof persistedConfig === 'object' ? persistedConfig : JSON.parse(persistedConfig);
}
catch (e) {
// Do not unregister here: the SDK only registers structured configs, and this read path should
// ignore corrupt legacy/external values without mutating persistence.
logger.warn('persisted remote config for session recording is invalid and will be ignored', e);
return false;
}
// configs persisted by SDK versions that predate cache_timestamp have unknown age.
// Treat them as stale so recording waits for a fresh config instead of starting
// under arbitrarily old trigger/sampling settings.
if ((0, core_1.isNullish)(config.cache_timestamp)) {
return false;
}
return Date.now() - config.cache_timestamp <= constants_1.RECORDING_REMOTE_CONFIG_TTL_MS;
};
SessionRecording.prototype._onScriptLoaded = function (startReason) {
var _a;
var _b, _c, _d, _e;
if (this._sessionRecordingDisposed || !this._isRecordingEnabled || !this._instance.sessionManager) {
this._recordingStatus = triggerMatching_1.DISABLED;
return;
}
if (!((_b = globals_2.assignableWindow.__PosthogExtensions__) === null || _b === void 0 ? void 0 : _b.initSessionRecording)) {
logger.warn('Called on script loaded before session recording is available. This can be caused by adblockers.');
this._instance.register_for_session((_a = {},
_a[constants_1.SDK_DEBUG_RECORDING_SCRIPT_NOT_LOADED] = true,
_a));
return;
}
if (!this._lazyLoadedSessionRecording) {
this._lazyLoadedSessionRecording = (_c = globals_2.assignableWindow.__PosthogExtensions__) === null || _c === void 0 ? void 0 : _c.initSessionRecording(this._instance, this._documentWasEverVisible);
this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture =
this._forceAllowLocalhostNetworkCapture;
}
if (!this._isRemoteConfigFresh()) {
if (this._recordingStatus === triggerMatching_1.MISSING_CONFIG || this._recordingStatus === triggerMatching_1.AWAITING_CONFIG) {
return;
}
this._recordingStatus = triggerMatching_1.AWAITING_CONFIG;
logger.info('persisted remote config is stale, requesting fresh config before starting');
new remote_config_1.RemoteConfigLoader(this._instance).load();
return;
}
this._recordingStatus = triggerMatching_1.LAZY_LOADING;
(_e = (_d = this._lazyLoadedSessionRecording).setDocumentWasEverVisible) === null || _e === void 0 ? void 0 : _e.call(_d, this._documentWasEverVisible);
this._lazyLoadedSessionRecording.start(startReason);
};
/**
* this is maintained on the public API only because it has always been on the public API
* if you are calling this directly you are certainly doing something wrong
* @deprecated
*/
SessionRecording.prototype.onRRwebEmit = function (rawEvent) {
var _a, _b;
(_b = (_a = this._lazyLoadedSessionRecording) === null || _a === void 0 ? void 0 : _a.onRRwebEmit) === null || _b === void 0 ? void 0 : _b.call(_a, rawEvent);
};
/**
* this ignores the linked flag config and (if other conditions are met) causes capture to start
*
* It is not usual to call this directly,
* instead call `posthog.startSessionRecording({linked_flag: true})`
* */
SessionRecording.prototype.overrideLinkedFlag = function () {
var _a;
var _b, _c;
if (!this._lazyLoadedSessionRecording) {
(_b = this._persistence) === null || _b === void 0 ? void 0 : _b.register((_a = {},
_a[constants_1.SESSION_RECORDING_OVERRIDE_LINKED_FLAG] = true,
_a));
}
(_c = this._lazyLoadedSessionRecording) === null || _c === void 0 ? void 0 : _c.overrideLinkedFlag();
};
/**
* this ignores the sampling config and (if other conditions are met) causes capture to start
*
* It is not usual to call this directly,
* instead call `posthog.startSessionRecording({sampling: true})`
* */
SessionRecording.prototype.overrideSampling = function () {
var _a;
var _b, _c;
if (!this._lazyLoadedSessionRecording) {
(_b = this._persistence) === null || _b === void 0 ? void 0 : _b.register((_a = {},
_a[constants_1.SESSION_RECORDING_OVERRIDE_SAMPLING] = true,
_a));
}
(_c = this._lazyLoadedSessionRecording) === null || _c === void 0 ? void 0 : _c.overrideSampling();
};
/**
* this ignores the URL/Event trigger config and (if other conditions are met) causes capture to start
*
* It is not usual to call this directly,
* instead call `posthog.startSessionRecording({trigger: 'url' | 'event'})`
* */
SessionRecording.prototype.overrideTrigger = function (triggerType) {
var _a;
var _b, _c;
if (!this._lazyLoadedSessionRecording) {
(_b = this._persistence) === null || _b === void 0 ? void 0 : _b.register((_a = {},
_a[triggerType === 'url'
? constants_1.SESSION_RECORDING_OVERRIDE_URL_TRIGGER
: constants_1.SESSION_RECORDING_OVERRIDE_EVENT_TRIGGER] = true,
_a));
}
(_c = this._lazyLoadedSessionRecording) === null || _c === void 0 ? void 0 : _c.overrideTrigger(triggerType);
};
Object.defineProperty(SessionRecording.prototype, "sdkDebugProperties", {
/*
* whenever we capture an event, we add these properties to the event
* these are used to debug issues with the session recording
* when looking at the event feed for a session
*/
get: function () {
var e_1, _a;
var _b, _c;
var properties = {};
try {
for (var SESSION_DEBUG_PROPERTY_KEYS_1 = __values(SESSION_DEBUG_PROPERTY_KEYS), SESSION_DEBUG_PROPERTY_KEYS_1_1 = SESSION_DEBUG_PROPERTY_KEYS_1.next(); !SESSION_DEBUG_PROPERTY_KEYS_1_1.done; SESSION_DEBUG_PROPERTY_KEYS_1_1 = SESSION_DEBUG_PROPERTY_KEYS_1.next()) {
var key = SESSION_DEBUG_PROPERTY_KEYS_1_1.value;
var value = (_b = this._instance.sessionPersistence) === null || _b === void 0 ? void 0 : _b.get_property(key);
if (!(0, core_1.isUndefined)(value)) {
properties[key] = value;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (SESSION_DEBUG_PROPERTY_KEYS_1_1 && !SESSION_DEBUG_PROPERTY_KEYS_1_1.done && (_a = SESSION_DEBUG_PROPERTY_KEYS_1.return)) _a.call(SESSION_DEBUG_PROPERTY_KEYS_1);
}
finally { if (e_1) throw e_1.error; }
}
return __assign(__assign({}, properties), (((_c = this._lazyLoadedSessionRecording) === null || _c === void 0 ? void 0 : _c.sdkDebugProperties) || { $recording_status: this.status }));
},
enumerable: false,
configurable: true
});
/**
* This adds a custom event to the session recording
*
* It is not intended for arbitrary public use - playback only displays known custom events
* And is exposed on the public interface only so that other parts of the SDK are able to use it
*
* if you are calling this from client code, you're probably looking for `posthog.capture('$custom_event', {...})`
*/
SessionRecording.prototype.tryAddCustomEvent = function (tag, payload) {
var _a;
return !!((_a = this._lazyLoadedSessionRecording) === null || _a === void 0 ? void 0 : _a.tryAddCustomEvent(tag, payload));
};
SessionRecording.prototype.flushBeforeIdentityReset = function () {
var _a, _b;
(_b = (_a = this._lazyLoadedSessionRecording) === null || _a === void 0 ? void 0 : _a.flushBeforeIdentityReset) === null || _b === void 0 ? void 0 : _b.call(_a);
};
return SessionRecording;
}());
exports.SessionRecording = SessionRecording;
//# sourceMappingURL=session-recording.js.map