posthog-js 1.77.3 → 1.78.0
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/array.full.js +2 -2
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +2 -2
- package/dist/array.js.map +1 -1
- package/dist/es.js +2 -2
- package/dist/es.js.map +1 -1
- package/dist/module.d.ts +9 -8
- package/dist/module.js +2 -2
- package/dist/module.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/sessionrecording.d.ts +1 -0
- package/lib/src/extensions/sessionrecording.js +24 -9
- package/lib/src/extensions/sessionrecording.js.map +1 -1
- package/lib/src/posthog-core.d.ts +8 -8
- package/lib/src/posthog-core.js +53 -34
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/posthog-featureflags.js +13 -4
- package/lib/src/posthog-featureflags.js.map +1 -1
- package/lib/src/posthog-surveys.js +2 -1
- package/lib/src/posthog-surveys.js.map +1 -1
- package/lib/src/utils.d.ts +1 -0
- package/lib/src/utils.js +5 -0
- package/lib/src/utils.js.map +1 -1
- package/package.json +1 -1
package/lib/package.json
CHANGED
|
@@ -96,6 +96,13 @@ var SessionRecording = /** @class */ (function () {
|
|
|
96
96
|
_this._flushBuffer();
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
+
SessionRecording.prototype.getSessionManager = function () {
|
|
100
|
+
if (!this.instance.sessionManager) {
|
|
101
|
+
logger.error('Session recording started without valid sessionManager');
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
return this.instance.sessionManager;
|
|
105
|
+
};
|
|
99
106
|
SessionRecording.prototype.startRecordingIfEnabled = function () {
|
|
100
107
|
if (this.isRecordingEnabled()) {
|
|
101
108
|
this.startCaptureAndTrySendingQueuedSnapshots();
|
|
@@ -178,14 +185,18 @@ var SessionRecording = /** @class */ (function () {
|
|
|
178
185
|
};
|
|
179
186
|
SessionRecording.prototype._startCapture = function () {
|
|
180
187
|
var _this = this;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.
|
|
186
|
-
// Instead, when we load "recorder.js", the first JS error is about "Object.assign" being undefined.
|
|
187
|
-
// Thus instead of MutationObserver, we look for this function and block recording if it's undefined.
|
|
188
|
+
var sessionManager = this.getSessionManager();
|
|
189
|
+
if (!sessionManager) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
188
192
|
if (typeof Object.assign === 'undefined') {
|
|
193
|
+
// According to the rrweb docs, rrweb is not supported on IE11 and below:
|
|
194
|
+
// "rrweb does not support IE11 and below because it uses the MutationObserver API which was supported by these browsers."
|
|
195
|
+
// https://github.com/rrweb-io/rrweb/blob/master/guide.md#compatibility-note
|
|
196
|
+
//
|
|
197
|
+
// However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.
|
|
198
|
+
// Instead, when we load "recorder.js", the first JS error is about "Object.assign" being undefined.
|
|
199
|
+
// Thus instead of MutationObserver, we look for this function and block recording if it's undefined.
|
|
189
200
|
return;
|
|
190
201
|
}
|
|
191
202
|
// We do not switch recorder versions midway through a recording.
|
|
@@ -194,7 +205,7 @@ var SessionRecording = /** @class */ (function () {
|
|
|
194
205
|
}
|
|
195
206
|
this.captureStarted = true;
|
|
196
207
|
// We want to ensure the sessionManager is reset if necessary on load of the recorder
|
|
197
|
-
|
|
208
|
+
sessionManager.checkAndGetSessionAndWindowId();
|
|
198
209
|
var recorderJS = this.getRecordingVersion() === 'v2' ? 'recorder-v2.js' : 'recorder.js';
|
|
199
210
|
// If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is
|
|
200
211
|
// imported) or matches the requested recorder version, don't load script. Otherwise, remotely import
|
|
@@ -216,6 +227,10 @@ var SessionRecording = /** @class */ (function () {
|
|
|
216
227
|
return event.type === INCREMENTAL_SNAPSHOT_EVENT_TYPE && ACTIVE_SOURCES.indexOf((_a = event.data) === null || _a === void 0 ? void 0 : _a.source) !== -1;
|
|
217
228
|
};
|
|
218
229
|
SessionRecording.prototype._updateWindowAndSessionIds = function (event) {
|
|
230
|
+
var sessionManager = this.getSessionManager();
|
|
231
|
+
if (!sessionManager) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
219
234
|
// Some recording events are triggered by non-user events (e.g. "X minutes ago" text updating on the screen).
|
|
220
235
|
// We don't want to extend the session or trigger a new session in these cases. These events are designated by event
|
|
221
236
|
// type -> incremental update, and source -> mutation.
|
|
@@ -238,7 +253,7 @@ var SessionRecording = /** @class */ (function () {
|
|
|
238
253
|
return;
|
|
239
254
|
}
|
|
240
255
|
// We only want to extend the session if it is an interactive event.
|
|
241
|
-
var _a =
|
|
256
|
+
var _a = sessionManager.checkAndGetSessionAndWindowId(!isUserInteraction, event.timestamp), windowId = _a.windowId, sessionId = _a.sessionId;
|
|
242
257
|
if ([FULL_SNAPSHOT_EVENT_TYPE, META_EVENT_TYPE].indexOf(event.type) === -1 &&
|
|
243
258
|
(this.windowId !== windowId || this.sessionId !== sessionId)) {
|
|
244
259
|
this._tryTakeFullSnapshot();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionrecording.js","sourceRoot":"","sources":["../../../src/extensions/sessionrecording.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACH,yCAAyC,EACzC,qCAAqC,EACrC,8CAA8C,GACjD,MAAM,cAAc,CAAA;AACrB,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,+BAA+B,EAC/B,eAAe,EACf,mBAAmB,EAGnB,wBAAwB,GAC3B,MAAM,0BAA0B,CAAA;AAIjC,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAEzD,IAAM,aAAa,GAAG,KAAK,CAAA;AAE3B,MAAM,CAAC,IAAM,kCAAkC,GAAG,CAAC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ApZD,IAoZC","sourcesContent":["import {\n CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE,\n} from '../constants'\nimport {\n ensureMaxMessageSize,\n FULL_SNAPSHOT_EVENT_TYPE,\n INCREMENTAL_SNAPSHOT_EVENT_TYPE,\n META_EVENT_TYPE,\n MutationRateLimiter,\n recordOptions,\n rrwebRecord,\n truncateLargeConsoleLogs,\n} from './sessionrecording-utils'\nimport { PostHog } from '../posthog-core'\nimport { DecideResponse, Properties } from '../types'\nimport type { eventWithTime, listenerHandler } from '@rrweb/types'\nimport Config from '../config'\nimport { logger, loadScript, _timestamp } from '../utils'\n\nconst BASE_ENDPOINT = '/s/'\n\nexport const RECORDING_IDLE_ACTIVITY_TIMEOUT_MS = 5 * 60 * 1000 // 5 minutes\nexport const RECORDING_MAX_EVENT_SIZE = 1024 * 1024 * 0.9 // ~1mb (with some wiggle room)\nexport const RECORDING_BUFFER_TIMEOUT = 2000 // 2 seconds\nexport const SESSION_RECORDING_BATCH_KEY = 'sessionRecording'\n\n// NOTE: Importing this type is problematic as we can't safely bundle it to a TS definition so, instead we redefine.\n// import type { record } from 'rrweb2/typings'\n// import type { recordOptions } from 'rrweb/typings/types'\n\n// Copied from rrweb typings to avoid import\nenum IncrementalSource {\n Mutation = 0,\n MouseMove = 1,\n MouseInteraction = 2,\n Scroll = 3,\n ViewportResize = 4,\n Input = 5,\n TouchMove = 6,\n MediaInteraction = 7,\n StyleSheetRule = 8,\n CanvasMutation = 9,\n Font = 10,\n Log = 11,\n Drag = 12,\n StyleDeclaration = 13,\n Selection = 14,\n AdoptedStyleSheet = 15,\n}\n\nconst ACTIVE_SOURCES = [\n IncrementalSource.MouseMove,\n IncrementalSource.MouseInteraction,\n IncrementalSource.Scroll,\n IncrementalSource.ViewportResize,\n IncrementalSource.Input,\n IncrementalSource.TouchMove,\n IncrementalSource.MediaInteraction,\n IncrementalSource.Drag,\n]\n\nexport class SessionRecording {\n private instance: PostHog\n private emit: boolean\n private endpoint: string\n private windowId: string | null\n private sessionId: string | null\n private lastActivityTimestamp: number = Date.now()\n private flushBufferTimer?: any\n private buffer?: {\n size: number\n data: any[]\n sessionId: string | null\n windowId: string | null\n }\n private mutationRateLimiter?: MutationRateLimiter\n\n captureStarted: boolean\n snapshots: any[]\n stopRrweb: listenerHandler | undefined\n receivedDecide: boolean\n rrwebRecord: rrwebRecord | undefined\n recorderVersion?: string\n isIdle = false\n\n constructor(instance: PostHog) {\n this.instance = instance\n this.captureStarted = false\n this.snapshots = []\n this.emit = false // Controls whether data is sent to the server or not\n this.endpoint = BASE_ENDPOINT\n this.stopRrweb = undefined\n this.windowId = null\n this.sessionId = null\n this.receivedDecide = false\n\n window.addEventListener('beforeunload', () => {\n this._flushBuffer()\n })\n }\n\n startRecordingIfEnabled() {\n if (this.isRecordingEnabled()) {\n this.startCaptureAndTrySendingQueuedSnapshots()\n } else {\n this.stopRecording()\n }\n }\n\n started() {\n return this.captureStarted\n }\n\n stopRecording() {\n if (this.captureStarted && this.stopRrweb) {\n this.stopRrweb()\n this.stopRrweb = undefined\n this.captureStarted = false\n }\n }\n\n isRecordingEnabled() {\n const enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = !this.instance.get_config('disable_session_recording')\n return enabled_server_side && enabled_client_side\n }\n\n isConsoleLogCaptureEnabled() {\n const enabled_server_side = !!this.instance.get_property(CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = this.instance.get_config('enable_recording_console_log')\n return enabled_client_side ?? enabled_server_side\n }\n\n getRecordingVersion() {\n const recordingVersion_server_side = this.instance.get_property(SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE)\n const recordingVersion_client_side = this.instance.get_config('session_recording')?.recorderVersion\n return recordingVersion_client_side || recordingVersion_server_side || 'v1'\n }\n\n afterDecideResponse(response: DecideResponse) {\n this.receivedDecide = true\n if (this.instance.persistence) {\n this.instance.persistence.register({\n [SESSION_RECORDING_ENABLED_SERVER_SIDE]: !!response['sessionRecording'],\n [CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE]: response.sessionRecording?.consoleLogRecordingEnabled,\n [SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE]: response.sessionRecording?.recorderVersion,\n })\n }\n if (response.sessionRecording?.endpoint) {\n this.endpoint = response.sessionRecording?.endpoint\n }\n\n if (response.sessionRecording?.recorderVersion) {\n this.recorderVersion = response.sessionRecording.recorderVersion\n }\n this.startRecordingIfEnabled()\n }\n\n log(message: string, level: 'log' | 'warn' | 'error' = 'log') {\n this.instance.sessionRecording?.onRRwebEmit({\n type: 6,\n data: {\n plugin: 'rrweb/console@1',\n payload: {\n level,\n trace: [],\n // Even though it is a string we stringify it as thats what rrweb expects\n payload: [JSON.stringify(message)],\n },\n },\n timestamp: _timestamp(),\n })\n }\n\n private startCaptureAndTrySendingQueuedSnapshots() {\n // Only submit data after we've received a decide response to account for\n // changing endpoints and the feature being disabled on the server side.\n if (this.receivedDecide) {\n this.emit = true\n this.snapshots.forEach((properties) => this._captureSnapshotBuffered(properties))\n }\n this._startCapture()\n }\n\n private _startCapture() {\n // According to the rrweb docs, rrweb is not supported on IE11 and below:\n // \"rrweb does not support IE11 and below because it uses the MutationObserver API which was supported by these browsers.\"\n // https://github.com/rrweb-io/rrweb/blob/master/guide.md#compatibility-note\n //\n // However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.\n // Instead, when we load \"recorder.js\", the first JS error is about \"Object.assign\" being undefined.\n // Thus instead of MutationObserver, we look for this function and block recording if it's undefined.\n if (typeof Object.assign === 'undefined') {\n return\n }\n\n // We do not switch recorder versions midway through a recording.\n if (this.captureStarted || this.instance.get_config('disable_session_recording')) {\n return\n }\n\n this.captureStarted = true\n // We want to ensure the sessionManager is reset if necessary on load of the recorder\n this.instance.sessionManager.checkAndGetSessionAndWindowId()\n\n const recorderJS = this.getRecordingVersion() === 'v2' ? 'recorder-v2.js' : 'recorder.js'\n\n // If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is\n // imported) or matches the requested recorder version, don't load script. Otherwise, remotely import\n // recorder.js from cdn since it hasn't been loaded.\n if (this.instance.__loaded_recorder_version !== this.getRecordingVersion()) {\n loadScript(\n this.instance.get_config('api_host') + `/static/${recorderJS}?v=${Config.LIB_VERSION}`,\n (err) => {\n if (err) {\n return logger.error(`Could not load ${recorderJS}`, err)\n }\n\n this._onScriptLoaded()\n }\n )\n } else {\n this._onScriptLoaded()\n }\n }\n\n private _isInteractiveEvent(event: eventWithTime) {\n return event.type === INCREMENTAL_SNAPSHOT_EVENT_TYPE && ACTIVE_SOURCES.indexOf(event.data?.source) !== -1\n }\n\n private _updateWindowAndSessionIds(event: eventWithTime) {\n // Some recording events are triggered by non-user events (e.g. \"X minutes ago\" text updating on the screen).\n // We don't want to extend the session or trigger a new session in these cases. These events are designated by event\n // type -> incremental update, and source -> mutation.\n\n const isUserInteraction = this._isInteractiveEvent(event)\n\n if (!isUserInteraction && !this.isIdle) {\n // We check if the lastActivityTimestamp is old enough to go idle\n if (event.timestamp - this.lastActivityTimestamp > RECORDING_IDLE_ACTIVITY_TIMEOUT_MS) {\n this.isIdle = true\n }\n }\n\n if (isUserInteraction) {\n this.lastActivityTimestamp = event.timestamp\n if (this.isIdle) {\n // Remove the idle state if set and trigger a full snapshot as we will have ingored previous mutations\n this.isIdle = false\n this._tryTakeFullSnapshot()\n }\n }\n\n if (this.isIdle) {\n return\n }\n\n // We only want to extend the session if it is an interactive event.\n const { windowId, sessionId } = this.instance.sessionManager.checkAndGetSessionAndWindowId(\n !isUserInteraction,\n event.timestamp\n )\n\n if (\n [FULL_SNAPSHOT_EVENT_TYPE, META_EVENT_TYPE].indexOf(event.type) === -1 &&\n (this.windowId !== windowId || this.sessionId !== sessionId)\n ) {\n this._tryTakeFullSnapshot()\n }\n this.windowId = windowId\n this.sessionId = sessionId\n }\n\n private _tryTakeFullSnapshot(): boolean {\n if (!this.captureStarted) {\n return false\n }\n try {\n this.rrwebRecord?.takeFullSnapshot()\n return true\n } catch (e) {\n // Sometimes a race can occur where the recorder is not fully started yet, so we can't take a full snapshot.\n logger.error('Error taking full snapshot.', e)\n return false\n }\n }\n\n private _onScriptLoaded() {\n // rrweb config info: https://github.com/rrweb-io/rrweb/blob/7d5d0033258d6c29599fb08412202d9a2c7b9413/src/record/index.ts#L28\n const sessionRecordingOptions: recordOptions<eventWithTime> = {\n // select set of rrweb config options we expose to our users\n // see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n blockClass: 'ph-no-capture',\n blockSelector: undefined,\n ignoreClass: 'ph-ignore-input',\n maskTextClass: 'ph-mask',\n maskTextSelector: undefined,\n maskTextFn: undefined,\n maskAllInputs: true,\n maskInputOptions: {},\n maskInputFn: undefined,\n slimDOMOptions: {},\n collectFonts: false,\n inlineStylesheet: true,\n recordCrossOriginIframes: false,\n }\n // We switched from loading all of rrweb to just the record part, but\n // keep backwards compatibility if someone hasn't upgraded PostHog\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.rrwebRecord = window.rrweb ? window.rrweb.record : window.rrwebRecord\n\n // only allows user to set our 'allowlisted' options\n const userSessionRecordingOptions = this.instance.get_config('session_recording')\n for (const [key, value] of Object.entries(userSessionRecordingOptions || {})) {\n if (key in sessionRecordingOptions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n sessionRecordingOptions[key] = value\n }\n }\n\n if (!this.rrwebRecord) {\n logger.error(\n 'onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.'\n )\n return\n }\n\n this.mutationRateLimiter =\n this.mutationRateLimiter ??\n new MutationRateLimiter(this.rrwebRecord!, {\n onBlockedNode: (id, node) => {\n const message = `Too many mutations on node '${id}'. Rate limiting. This could be due to SVG animations or something similar`\n logger.log(message, {\n node: node,\n })\n\n this.log('[PostHog Recorder] ' + message, 'warn')\n },\n })\n\n this.stopRrweb = this.rrwebRecord({\n emit: (event) => {\n this.onRRwebEmit(event)\n },\n plugins:\n (window as any).rrwebConsoleRecord && this.isConsoleLogCaptureEnabled()\n ? [(window as any).rrwebConsoleRecord.getRecordConsolePlugin()]\n : [],\n ...sessionRecordingOptions,\n })\n\n // :TRICKY: rrweb does not capture navigation within SPA-s, so hook into our $pageview events to get access to all events.\n // Dropping the initial event is fine (it's always captured by rrweb).\n this.instance._addCaptureHook((eventName) => {\n // If anything could go wrong here it has the potential to block the main loop so we catch all errors.\n try {\n if (eventName === '$pageview') {\n this.rrwebRecord?.addCustomEvent('$pageview', { href: window.location.href })\n }\n } catch (e) {\n logger.error('Could not add $pageview to rrweb session', e)\n }\n })\n\n // We reset the last activity timestamp, resetting the idle timer\n this.lastActivityTimestamp = Date.now()\n this.isIdle = false\n }\n\n onRRwebEmit(rawEvent: eventWithTime) {\n if (!rawEvent || typeof rawEvent !== 'object') {\n return\n }\n\n const throttledEvent = this.mutationRateLimiter\n ? this.mutationRateLimiter.throttleMutations(rawEvent)\n : rawEvent\n\n if (!throttledEvent) {\n return\n }\n\n const { event, size } = ensureMaxMessageSize(truncateLargeConsoleLogs(throttledEvent))\n\n this._updateWindowAndSessionIds(event)\n\n if (this.isIdle) {\n // When in an idle state we keep recording, but don't capture the events\n return\n }\n\n const properties = {\n $snapshot_bytes: size,\n $snapshot_data: event,\n $session_id: this.sessionId,\n $window_id: this.windowId,\n }\n\n if (this.emit) {\n this._captureSnapshotBuffered(properties)\n } else {\n this.snapshots.push(properties)\n }\n }\n\n private _flushBuffer() {\n if (this.flushBufferTimer) {\n clearTimeout(this.flushBufferTimer)\n this.flushBufferTimer = undefined\n }\n\n if (this.buffer && this.buffer.data.length !== 0) {\n this._captureSnapshot({\n $snapshot_bytes: this.buffer.size,\n $snapshot_data: this.buffer.data,\n $session_id: this.buffer.sessionId,\n $window_id: this.buffer.windowId,\n })\n }\n\n this.buffer = undefined\n\n return {\n size: 0,\n data: [],\n sessionId: this.sessionId,\n windowId: this.windowId,\n }\n }\n\n private _captureSnapshotBuffered(properties: Properties) {\n const additionalBytes = 2 + (this.buffer?.data.length || 0) // 2 bytes for the array brackets and 1 byte for each comma\n if (\n !this.buffer ||\n this.buffer.size + properties.$snapshot_bytes + additionalBytes > RECORDING_MAX_EVENT_SIZE ||\n this.buffer.sessionId !== this.sessionId\n ) {\n this.buffer = this._flushBuffer()\n }\n\n this.buffer.size += properties.$snapshot_bytes\n this.buffer.data.push(properties.$snapshot_data)\n\n if (!this.flushBufferTimer) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n }\n }\n\n private _captureSnapshot(properties: Properties) {\n // :TRICKY: Make sure we batch these requests, use a custom endpoint and don't truncate the strings.\n this.instance.capture('$snapshot', properties, {\n transport: 'XHR',\n method: 'POST',\n endpoint: this.endpoint,\n _noTruncate: true,\n _batchKey: SESSION_RECORDING_BATCH_KEY,\n _metrics: {\n rrweb_full_snapshot: properties.$snapshot_data.type === FULL_SNAPSHOT_EVENT_TYPE,\n },\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sessionrecording.js","sourceRoot":"","sources":["../../../src/extensions/sessionrecording.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACH,yCAAyC,EACzC,qCAAqC,EACrC,8CAA8C,GACjD,MAAM,cAAc,CAAA;AACrB,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,+BAA+B,EAC/B,eAAe,EACf,mBAAmB,EAGnB,wBAAwB,GAC3B,MAAM,0BAA0B,CAAA;AAIjC,OAAO,MAAM,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAEzD,IAAM,aAAa,GAAG,KAAK,CAAA;AAE3B,MAAM,CAAC,IAAM,kCAAkC,GA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AsB;QAC3C,oGAAoG;QACpG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE;YAC3C,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,2BAA2B;YACtC,QAAQ,EAAE;gBACN,mBAAmB,EAAE,UAAU,CAAC,cAAc,CAAC,IAAI,KAAK,wBAAwB;aACnF;SACJ,CAAC,CAAA;IACN,CAAC;IACL,uBAAC;AAAD,CAAC,AAraD,IAqaC","sourcesContent":["import {\n CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE,\n} from '../constants'\nimport {\n ensureMaxMessageSize,\n FULL_SNAPSHOT_EVENT_TYPE,\n INCREMENTAL_SNAPSHOT_EVENT_TYPE,\n META_EVENT_TYPE,\n MutationRateLimiter,\n recordOptions,\n rrwebRecord,\n truncateLargeConsoleLogs,\n} from './sessionrecording-utils'\nimport { PostHog } from '../posthog-core'\nimport { DecideResponse, Properties } from '../types'\nimport type { eventWithTime, listenerHandler } from '@rrweb/types'\nimport Config from '../config'\nimport { logger, loadScript, _timestamp } from '../utils'\n\nconst BASE_ENDPOINT = '/s/'\n\nexport const RECORDING_IDLE_ACTIVITY_TIMEOUT_MS = 5 * 60 * 1000 // 5 minutes\nexport const RECORDING_MAX_EVENT_SIZE = 1024 * 1024 * 0.9 // ~1mb (with some wiggle room)\nexport const RECORDING_BUFFER_TIMEOUT = 2000 // 2 seconds\nexport const SESSION_RECORDING_BATCH_KEY = 'sessionRecording'\n\n// NOTE: Importing this type is problematic as we can't safely bundle it to a TS definition so, instead we redefine.\n// import type { record } from 'rrweb2/typings'\n// import type { recordOptions } from 'rrweb/typings/types'\n\n// Copied from rrweb typings to avoid import\nenum IncrementalSource {\n Mutation = 0,\n MouseMove = 1,\n MouseInteraction = 2,\n Scroll = 3,\n ViewportResize = 4,\n Input = 5,\n TouchMove = 6,\n MediaInteraction = 7,\n StyleSheetRule = 8,\n CanvasMutation = 9,\n Font = 10,\n Log = 11,\n Drag = 12,\n StyleDeclaration = 13,\n Selection = 14,\n AdoptedStyleSheet = 15,\n}\n\nconst ACTIVE_SOURCES = [\n IncrementalSource.MouseMove,\n IncrementalSource.MouseInteraction,\n IncrementalSource.Scroll,\n IncrementalSource.ViewportResize,\n IncrementalSource.Input,\n IncrementalSource.TouchMove,\n IncrementalSource.MediaInteraction,\n IncrementalSource.Drag,\n]\n\nexport class SessionRecording {\n private instance: PostHog\n private emit: boolean\n private endpoint: string\n private windowId: string | null\n private sessionId: string | null\n private lastActivityTimestamp: number = Date.now()\n private flushBufferTimer?: any\n private buffer?: {\n size: number\n data: any[]\n sessionId: string | null\n windowId: string | null\n }\n private mutationRateLimiter?: MutationRateLimiter\n\n captureStarted: boolean\n snapshots: any[]\n stopRrweb: listenerHandler | undefined\n receivedDecide: boolean\n rrwebRecord: rrwebRecord | undefined\n recorderVersion?: string\n isIdle = false\n\n constructor(instance: PostHog) {\n this.instance = instance\n this.captureStarted = false\n this.snapshots = []\n this.emit = false // Controls whether data is sent to the server or not\n this.endpoint = BASE_ENDPOINT\n this.stopRrweb = undefined\n this.windowId = null\n this.sessionId = null\n this.receivedDecide = false\n\n window.addEventListener('beforeunload', () => {\n this._flushBuffer()\n })\n }\n\n private getSessionManager() {\n if (!this.instance.sessionManager) {\n logger.error('Session recording started without valid sessionManager')\n return\n }\n\n return this.instance.sessionManager\n }\n\n startRecordingIfEnabled() {\n if (this.isRecordingEnabled()) {\n this.startCaptureAndTrySendingQueuedSnapshots()\n } else {\n this.stopRecording()\n }\n }\n\n started() {\n return this.captureStarted\n }\n\n stopRecording() {\n if (this.captureStarted && this.stopRrweb) {\n this.stopRrweb()\n this.stopRrweb = undefined\n this.captureStarted = false\n }\n }\n\n isRecordingEnabled() {\n const enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = !this.instance.get_config('disable_session_recording')\n return enabled_server_side && enabled_client_side\n }\n\n isConsoleLogCaptureEnabled() {\n const enabled_server_side = !!this.instance.get_property(CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = this.instance.get_config('enable_recording_console_log')\n return enabled_client_side ?? enabled_server_side\n }\n\n getRecordingVersion() {\n const recordingVersion_server_side = this.instance.get_property(SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE)\n const recordingVersion_client_side = this.instance.get_config('session_recording')?.recorderVersion\n return recordingVersion_client_side || recordingVersion_server_side || 'v1'\n }\n\n afterDecideResponse(response: DecideResponse) {\n this.receivedDecide = true\n if (this.instance.persistence) {\n this.instance.persistence.register({\n [SESSION_RECORDING_ENABLED_SERVER_SIDE]: !!response['sessionRecording'],\n [CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE]: response.sessionRecording?.consoleLogRecordingEnabled,\n [SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE]: response.sessionRecording?.recorderVersion,\n })\n }\n if (response.sessionRecording?.endpoint) {\n this.endpoint = response.sessionRecording?.endpoint\n }\n\n if (response.sessionRecording?.recorderVersion) {\n this.recorderVersion = response.sessionRecording.recorderVersion\n }\n this.startRecordingIfEnabled()\n }\n\n log(message: string, level: 'log' | 'warn' | 'error' = 'log') {\n this.instance.sessionRecording?.onRRwebEmit({\n type: 6,\n data: {\n plugin: 'rrweb/console@1',\n payload: {\n level,\n trace: [],\n // Even though it is a string we stringify it as thats what rrweb expects\n payload: [JSON.stringify(message)],\n },\n },\n timestamp: _timestamp(),\n })\n }\n\n private startCaptureAndTrySendingQueuedSnapshots() {\n // Only submit data after we've received a decide response to account for\n // changing endpoints and the feature being disabled on the server side.\n if (this.receivedDecide) {\n this.emit = true\n this.snapshots.forEach((properties) => this._captureSnapshotBuffered(properties))\n }\n this._startCapture()\n }\n\n private _startCapture() {\n const sessionManager = this.getSessionManager()\n if (!sessionManager) {\n return\n }\n if (typeof Object.assign === 'undefined') {\n // According to the rrweb docs, rrweb is not supported on IE11 and below:\n // \"rrweb does not support IE11 and below because it uses the MutationObserver API which was supported by these browsers.\"\n // https://github.com/rrweb-io/rrweb/blob/master/guide.md#compatibility-note\n //\n // However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.\n // Instead, when we load \"recorder.js\", the first JS error is about \"Object.assign\" being undefined.\n // Thus instead of MutationObserver, we look for this function and block recording if it's undefined.\n return\n }\n\n // We do not switch recorder versions midway through a recording.\n if (this.captureStarted || this.instance.get_config('disable_session_recording')) {\n return\n }\n\n this.captureStarted = true\n // We want to ensure the sessionManager is reset if necessary on load of the recorder\n sessionManager.checkAndGetSessionAndWindowId()\n\n const recorderJS = this.getRecordingVersion() === 'v2' ? 'recorder-v2.js' : 'recorder.js'\n\n // If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is\n // imported) or matches the requested recorder version, don't load script. Otherwise, remotely import\n // recorder.js from cdn since it hasn't been loaded.\n if (this.instance.__loaded_recorder_version !== this.getRecordingVersion()) {\n loadScript(\n this.instance.get_config('api_host') + `/static/${recorderJS}?v=${Config.LIB_VERSION}`,\n (err) => {\n if (err) {\n return logger.error(`Could not load ${recorderJS}`, err)\n }\n\n this._onScriptLoaded()\n }\n )\n } else {\n this._onScriptLoaded()\n }\n }\n\n private _isInteractiveEvent(event: eventWithTime) {\n return event.type === INCREMENTAL_SNAPSHOT_EVENT_TYPE && ACTIVE_SOURCES.indexOf(event.data?.source) !== -1\n }\n\n private _updateWindowAndSessionIds(event: eventWithTime) {\n const sessionManager = this.getSessionManager()\n if (!sessionManager) {\n return\n }\n // Some recording events are triggered by non-user events (e.g. \"X minutes ago\" text updating on the screen).\n // We don't want to extend the session or trigger a new session in these cases. These events are designated by event\n // type -> incremental update, and source -> mutation.\n\n const isUserInteraction = this._isInteractiveEvent(event)\n\n if (!isUserInteraction && !this.isIdle) {\n // We check if the lastActivityTimestamp is old enough to go idle\n if (event.timestamp - this.lastActivityTimestamp > RECORDING_IDLE_ACTIVITY_TIMEOUT_MS) {\n this.isIdle = true\n }\n }\n\n if (isUserInteraction) {\n this.lastActivityTimestamp = event.timestamp\n if (this.isIdle) {\n // Remove the idle state if set and trigger a full snapshot as we will have ingored previous mutations\n this.isIdle = false\n this._tryTakeFullSnapshot()\n }\n }\n\n if (this.isIdle) {\n return\n }\n\n // We only want to extend the session if it is an interactive event.\n const { windowId, sessionId } = sessionManager.checkAndGetSessionAndWindowId(\n !isUserInteraction,\n event.timestamp\n )\n\n if (\n [FULL_SNAPSHOT_EVENT_TYPE, META_EVENT_TYPE].indexOf(event.type) === -1 &&\n (this.windowId !== windowId || this.sessionId !== sessionId)\n ) {\n this._tryTakeFullSnapshot()\n }\n this.windowId = windowId\n this.sessionId = sessionId\n }\n\n private _tryTakeFullSnapshot(): boolean {\n if (!this.captureStarted) {\n return false\n }\n try {\n this.rrwebRecord?.takeFullSnapshot()\n return true\n } catch (e) {\n // Sometimes a race can occur where the recorder is not fully started yet, so we can't take a full snapshot.\n logger.error('Error taking full snapshot.', e)\n return false\n }\n }\n\n private _onScriptLoaded() {\n // rrweb config info: https://github.com/rrweb-io/rrweb/blob/7d5d0033258d6c29599fb08412202d9a2c7b9413/src/record/index.ts#L28\n const sessionRecordingOptions: recordOptions<eventWithTime> = {\n // select set of rrweb config options we expose to our users\n // see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n blockClass: 'ph-no-capture',\n blockSelector: undefined,\n ignoreClass: 'ph-ignore-input',\n maskTextClass: 'ph-mask',\n maskTextSelector: undefined,\n maskTextFn: undefined,\n maskAllInputs: true,\n maskInputOptions: {},\n maskInputFn: undefined,\n slimDOMOptions: {},\n collectFonts: false,\n inlineStylesheet: true,\n recordCrossOriginIframes: false,\n }\n // We switched from loading all of rrweb to just the record part, but\n // keep backwards compatibility if someone hasn't upgraded PostHog\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.rrwebRecord = window.rrweb ? window.rrweb.record : window.rrwebRecord\n\n // only allows user to set our 'allowlisted' options\n const userSessionRecordingOptions = this.instance.get_config('session_recording')\n for (const [key, value] of Object.entries(userSessionRecordingOptions || {})) {\n if (key in sessionRecordingOptions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n sessionRecordingOptions[key] = value\n }\n }\n\n if (!this.rrwebRecord) {\n logger.error(\n 'onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.'\n )\n return\n }\n\n this.mutationRateLimiter =\n this.mutationRateLimiter ??\n new MutationRateLimiter(this.rrwebRecord!, {\n onBlockedNode: (id, node) => {\n const message = `Too many mutations on node '${id}'. Rate limiting. This could be due to SVG animations or something similar`\n logger.log(message, {\n node: node,\n })\n\n this.log('[PostHog Recorder] ' + message, 'warn')\n },\n })\n\n this.stopRrweb = this.rrwebRecord({\n emit: (event) => {\n this.onRRwebEmit(event)\n },\n plugins:\n (window as any).rrwebConsoleRecord && this.isConsoleLogCaptureEnabled()\n ? [(window as any).rrwebConsoleRecord.getRecordConsolePlugin()]\n : [],\n ...sessionRecordingOptions,\n })\n\n // :TRICKY: rrweb does not capture navigation within SPA-s, so hook into our $pageview events to get access to all events.\n // Dropping the initial event is fine (it's always captured by rrweb).\n this.instance._addCaptureHook((eventName) => {\n // If anything could go wrong here it has the potential to block the main loop so we catch all errors.\n try {\n if (eventName === '$pageview') {\n this.rrwebRecord?.addCustomEvent('$pageview', { href: window.location.href })\n }\n } catch (e) {\n logger.error('Could not add $pageview to rrweb session', e)\n }\n })\n\n // We reset the last activity timestamp, resetting the idle timer\n this.lastActivityTimestamp = Date.now()\n this.isIdle = false\n }\n\n onRRwebEmit(rawEvent: eventWithTime) {\n if (!rawEvent || typeof rawEvent !== 'object') {\n return\n }\n\n const throttledEvent = this.mutationRateLimiter\n ? this.mutationRateLimiter.throttleMutations(rawEvent)\n : rawEvent\n\n if (!throttledEvent) {\n return\n }\n\n const { event, size } = ensureMaxMessageSize(truncateLargeConsoleLogs(throttledEvent))\n\n this._updateWindowAndSessionIds(event)\n\n if (this.isIdle) {\n // When in an idle state we keep recording, but don't capture the events\n return\n }\n\n const properties = {\n $snapshot_bytes: size,\n $snapshot_data: event,\n $session_id: this.sessionId,\n $window_id: this.windowId,\n }\n\n if (this.emit) {\n this._captureSnapshotBuffered(properties)\n } else {\n this.snapshots.push(properties)\n }\n }\n\n private _flushBuffer() {\n if (this.flushBufferTimer) {\n clearTimeout(this.flushBufferTimer)\n this.flushBufferTimer = undefined\n }\n\n if (this.buffer && this.buffer.data.length !== 0) {\n this._captureSnapshot({\n $snapshot_bytes: this.buffer.size,\n $snapshot_data: this.buffer.data,\n $session_id: this.buffer.sessionId,\n $window_id: this.buffer.windowId,\n })\n }\n\n this.buffer = undefined\n\n return {\n size: 0,\n data: [],\n sessionId: this.sessionId,\n windowId: this.windowId,\n }\n }\n\n private _captureSnapshotBuffered(properties: Properties) {\n const additionalBytes = 2 + (this.buffer?.data.length || 0) // 2 bytes for the array brackets and 1 byte for each comma\n if (\n !this.buffer ||\n this.buffer.size + properties.$snapshot_bytes + additionalBytes > RECORDING_MAX_EVENT_SIZE ||\n this.buffer.sessionId !== this.sessionId\n ) {\n this.buffer = this._flushBuffer()\n }\n\n this.buffer.size += properties.$snapshot_bytes\n this.buffer.data.push(properties.$snapshot_data)\n\n if (!this.flushBufferTimer) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n }\n }\n\n private _captureSnapshot(properties: Properties) {\n // :TRICKY: Make sure we batch these requests, use a custom endpoint and don't truncate the strings.\n this.instance.capture('$snapshot', properties, {\n transport: 'XHR',\n method: 'POST',\n endpoint: this.endpoint,\n _noTruncate: true,\n _batchKey: SESSION_RECORDING_BATCH_KEY,\n _metrics: {\n rrweb_full_snapshot: properties.$snapshot_data.type === FULL_SNAPSHOT_EVENT_TYPE,\n },\n })\n }\n}\n"]}
|
|
@@ -20,19 +20,19 @@ export declare class PostHog {
|
|
|
20
20
|
__loaded: boolean;
|
|
21
21
|
__loaded_recorder_version: 'v1' | 'v2' | undefined;
|
|
22
22
|
config: PostHogConfig;
|
|
23
|
-
persistence: PostHogPersistence;
|
|
24
23
|
rateLimiter: RateLimiter;
|
|
25
|
-
sessionPersistence: PostHogPersistence;
|
|
26
|
-
sessionManager: SessionIdManager;
|
|
27
24
|
pageViewManager: PageViewManager;
|
|
28
25
|
featureFlags: PostHogFeatureFlags;
|
|
29
26
|
surveys: PostHogSurveys;
|
|
30
27
|
toolbar: Toolbar;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_requestQueue
|
|
35
|
-
_retryQueue
|
|
28
|
+
persistence?: PostHogPersistence;
|
|
29
|
+
sessionPersistence?: PostHogPersistence;
|
|
30
|
+
sessionManager?: SessionIdManager;
|
|
31
|
+
_requestQueue?: RequestQueue;
|
|
32
|
+
_retryQueue?: RetryQueue;
|
|
33
|
+
sessionRecording?: SessionRecording;
|
|
34
|
+
webPerformance?: WebPerformanceObserver;
|
|
35
|
+
exceptionAutocapture?: ExceptionObserver;
|
|
36
36
|
_triggered_notifs: any;
|
|
37
37
|
compression: Partial<Record<Compression, boolean>>;
|
|
38
38
|
_jsc: JSC;
|
package/lib/src/posthog-core.js
CHANGED
|
@@ -257,12 +257,6 @@ var PostHog = /** @class */ (function () {
|
|
|
257
257
|
this.pageViewManager = new PageViewManager();
|
|
258
258
|
this.surveys = new PostHogSurveys(this);
|
|
259
259
|
this.rateLimiter = new RateLimiter();
|
|
260
|
-
// these are created in _init() after we have the config
|
|
261
|
-
this._requestQueue = undefined;
|
|
262
|
-
this._retryQueue = undefined;
|
|
263
|
-
this.persistence = undefined;
|
|
264
|
-
this.sessionPersistence = undefined;
|
|
265
|
-
this.sessionManager = undefined;
|
|
266
260
|
// NOTE: See the property definition for deprecation notice
|
|
267
261
|
this.people = {
|
|
268
262
|
set: function (prop, to, callback) {
|
|
@@ -464,9 +458,10 @@ var PostHog = /** @class */ (function () {
|
|
|
464
458
|
this.featureFlags.setReloadingPaused(false);
|
|
465
459
|
};
|
|
466
460
|
PostHog.prototype._start_queue_if_opted_in = function () {
|
|
461
|
+
var _a;
|
|
467
462
|
if (!this.has_opted_out_capturing()) {
|
|
468
463
|
if (this.get_config('request_batching')) {
|
|
469
|
-
this._requestQueue.poll();
|
|
464
|
+
(_a = this._requestQueue) === null || _a === void 0 ? void 0 : _a.poll();
|
|
470
465
|
}
|
|
471
466
|
}
|
|
472
467
|
};
|
|
@@ -514,6 +509,7 @@ var PostHog = /** @class */ (function () {
|
|
|
514
509
|
}
|
|
515
510
|
};
|
|
516
511
|
PostHog.prototype._handle_unload = function () {
|
|
512
|
+
var _a, _b;
|
|
517
513
|
if (!this.get_config('request_batching')) {
|
|
518
514
|
if (this.get_config('capture_pageview') && this.get_config('capture_pageleave')) {
|
|
519
515
|
this.capture('$pageleave', null, { transport: 'sendBeacon' });
|
|
@@ -523,8 +519,8 @@ var PostHog = /** @class */ (function () {
|
|
|
523
519
|
if (this.get_config('capture_pageview') && this.get_config('capture_pageleave')) {
|
|
524
520
|
this.capture('$pageleave');
|
|
525
521
|
}
|
|
526
|
-
this._requestQueue.unload();
|
|
527
|
-
this._retryQueue.unload();
|
|
522
|
+
(_a = this._requestQueue) === null || _a === void 0 ? void 0 : _a.unload();
|
|
523
|
+
(_b = this._retryQueue) === null || _b === void 0 ? void 0 : _b.unload();
|
|
528
524
|
};
|
|
529
525
|
PostHog.prototype._handle_queued_event = function (url, data, options) {
|
|
530
526
|
var jsonData = JSON.stringify(data);
|
|
@@ -536,6 +532,9 @@ var PostHog = /** @class */ (function () {
|
|
|
536
532
|
};
|
|
537
533
|
PostHog.prototype._send_request = function (url, data, options, callback) {
|
|
538
534
|
var _a;
|
|
535
|
+
if (!this.__loaded || !this._retryQueue) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
539
538
|
if (this.rateLimiter.isRateLimited(options._batchKey)) {
|
|
540
539
|
if (this.get_config('debug')) {
|
|
541
540
|
console.warn('[PostHog SendRequest] is quota limited. Dropping request.');
|
|
@@ -715,8 +714,8 @@ var PostHog = /** @class */ (function () {
|
|
|
715
714
|
if (options === void 0) { options = __NOOPTIONS; }
|
|
716
715
|
// While developing, a developer might purposefully _not_ call init(),
|
|
717
716
|
// in this case, we would like capture to be a noop.
|
|
718
|
-
if (!this.__loaded) {
|
|
719
|
-
return;
|
|
717
|
+
if (!this.__loaded || !this.sessionPersistence || !this._requestQueue) {
|
|
718
|
+
return logger.unintializedWarning('posthog.capture');
|
|
720
719
|
}
|
|
721
720
|
if (userOptedOut(this, false)) {
|
|
722
721
|
return;
|
|
@@ -778,6 +777,9 @@ var PostHog = /** @class */ (function () {
|
|
|
778
777
|
_each(this.__captureHooks, function (callback) { return callback(eventName); });
|
|
779
778
|
};
|
|
780
779
|
PostHog.prototype._calculate_event_properties = function (event_name, event_properties) {
|
|
780
|
+
if (!this.persistence || !this.sessionPersistence) {
|
|
781
|
+
return event_properties;
|
|
782
|
+
}
|
|
781
783
|
// set defaults
|
|
782
784
|
var start_timestamp = this.persistence.remove_event_timer(event_name);
|
|
783
785
|
var properties = __assign({}, event_properties);
|
|
@@ -861,7 +863,8 @@ var PostHog = /** @class */ (function () {
|
|
|
861
863
|
* @param {Number} [days] How many days since the user's last visit to store the super properties
|
|
862
864
|
*/
|
|
863
865
|
PostHog.prototype.register = function (properties, days) {
|
|
864
|
-
|
|
866
|
+
var _a;
|
|
867
|
+
(_a = this.persistence) === null || _a === void 0 ? void 0 : _a.register(properties, days);
|
|
865
868
|
};
|
|
866
869
|
/**
|
|
867
870
|
* Register a set of super properties only once. These will not
|
|
@@ -887,7 +890,8 @@ var PostHog = /** @class */ (function () {
|
|
|
887
890
|
* @param {Number} [days] How many days since the users last visit to store the super properties
|
|
888
891
|
*/
|
|
889
892
|
PostHog.prototype.register_once = function (properties, default_value, days) {
|
|
890
|
-
|
|
893
|
+
var _a;
|
|
894
|
+
(_a = this.persistence) === null || _a === void 0 ? void 0 : _a.register_once(properties, default_value, days);
|
|
891
895
|
};
|
|
892
896
|
/**
|
|
893
897
|
* Register a set of super properties, which are included with all events, but only
|
|
@@ -913,7 +917,8 @@ var PostHog = /** @class */ (function () {
|
|
|
913
917
|
* @param {Object} properties An associative array of properties to store about the user
|
|
914
918
|
*/
|
|
915
919
|
PostHog.prototype.register_for_session = function (properties) {
|
|
916
|
-
|
|
920
|
+
var _a;
|
|
921
|
+
(_a = this.sessionPersistence) === null || _a === void 0 ? void 0 : _a.register(properties);
|
|
917
922
|
};
|
|
918
923
|
/**
|
|
919
924
|
* Delete a super property stored with the current user.
|
|
@@ -921,7 +926,8 @@ var PostHog = /** @class */ (function () {
|
|
|
921
926
|
* @param {String} property The name of the super property to remove
|
|
922
927
|
*/
|
|
923
928
|
PostHog.prototype.unregister = function (property) {
|
|
924
|
-
|
|
929
|
+
var _a;
|
|
930
|
+
(_a = this.persistence) === null || _a === void 0 ? void 0 : _a.unregister(property);
|
|
925
931
|
};
|
|
926
932
|
/**
|
|
927
933
|
* Delete a session super property stored with the current user.
|
|
@@ -929,7 +935,8 @@ var PostHog = /** @class */ (function () {
|
|
|
929
935
|
* @param {String} property The name of the session super property to remove
|
|
930
936
|
*/
|
|
931
937
|
PostHog.prototype.unregister_for_session = function (property) {
|
|
932
|
-
|
|
938
|
+
var _a;
|
|
939
|
+
(_a = this.sessionPersistence) === null || _a === void 0 ? void 0 : _a.unregister(property);
|
|
933
940
|
};
|
|
934
941
|
PostHog.prototype._register_single = function (prop, value) {
|
|
935
942
|
var _a;
|
|
@@ -1023,7 +1030,8 @@ var PostHog = /** @class */ (function () {
|
|
|
1023
1030
|
* @returns {Function} A function that can be called to unsubscribe the listener. E.g. Used by useEffect when the component unmounts.
|
|
1024
1031
|
*/
|
|
1025
1032
|
PostHog.prototype.onSessionId = function (callback) {
|
|
1026
|
-
|
|
1033
|
+
var _a, _b;
|
|
1034
|
+
return (_b = (_a = this.sessionManager) === null || _a === void 0 ? void 0 : _a.onSessionId(callback)) !== null && _b !== void 0 ? _b : (function () { });
|
|
1027
1035
|
};
|
|
1028
1036
|
/** Get list of all surveys. */
|
|
1029
1037
|
PostHog.prototype.getSurveys = function (callback, forceReload) {
|
|
@@ -1082,6 +1090,9 @@ var PostHog = /** @class */ (function () {
|
|
|
1082
1090
|
* @param {Object} [userPropertiesToSetOnce] Optional: An associative array of properties to store about the user. If property is previously set, this does not override that value.
|
|
1083
1091
|
*/
|
|
1084
1092
|
PostHog.prototype.identify = function (new_distinct_id, userPropertiesToSet, userPropertiesToSetOnce) {
|
|
1093
|
+
if (!this.__loaded || !this.persistence) {
|
|
1094
|
+
return logger.unintializedWarning('posthog.identify');
|
|
1095
|
+
}
|
|
1085
1096
|
//if the new_distinct_id has not been set ignore the identify event
|
|
1086
1097
|
if (!new_distinct_id) {
|
|
1087
1098
|
console.error('Unique user id has not been set in posthog.identify');
|
|
@@ -1221,11 +1232,15 @@ var PostHog = /** @class */ (function () {
|
|
|
1221
1232
|
* Useful for clearing data when a user logs out.
|
|
1222
1233
|
*/
|
|
1223
1234
|
PostHog.prototype.reset = function (reset_device_id) {
|
|
1235
|
+
var _a, _b, _c, _d;
|
|
1236
|
+
if (!this.__loaded) {
|
|
1237
|
+
return logger.unintializedWarning('posthog.reset');
|
|
1238
|
+
}
|
|
1224
1239
|
var device_id = this.get_property('$device_id');
|
|
1225
|
-
this.persistence.clear();
|
|
1226
|
-
this.sessionPersistence.clear();
|
|
1227
|
-
this.persistence.set_user_state('anonymous');
|
|
1228
|
-
this.sessionManager.resetSessionId();
|
|
1240
|
+
(_a = this.persistence) === null || _a === void 0 ? void 0 : _a.clear();
|
|
1241
|
+
(_b = this.sessionPersistence) === null || _b === void 0 ? void 0 : _b.clear();
|
|
1242
|
+
(_c = this.persistence) === null || _c === void 0 ? void 0 : _c.set_user_state('anonymous');
|
|
1243
|
+
(_d = this.sessionManager) === null || _d === void 0 ? void 0 : _d.resetSessionId();
|
|
1229
1244
|
var uuid = this.get_config('get_device_id')(uuidv7());
|
|
1230
1245
|
this.register_once({
|
|
1231
1246
|
distinct_id: uuid,
|
|
@@ -1261,7 +1276,8 @@ var PostHog = /** @class */ (function () {
|
|
|
1261
1276
|
* Any actual internal use case for the session_id should be handled by the sessionManager.
|
|
1262
1277
|
*/
|
|
1263
1278
|
PostHog.prototype.get_session_id = function () {
|
|
1264
|
-
|
|
1279
|
+
var _a, _b;
|
|
1280
|
+
return (_b = (_a = this.sessionManager) === null || _a === void 0 ? void 0 : _a.checkAndGetSessionAndWindowId(true).sessionId) !== null && _b !== void 0 ? _b : '';
|
|
1265
1281
|
};
|
|
1266
1282
|
/**
|
|
1267
1283
|
* Returns the Replay url for the current session.
|
|
@@ -1272,6 +1288,9 @@ var PostHog = /** @class */ (function () {
|
|
|
1272
1288
|
*/
|
|
1273
1289
|
PostHog.prototype.get_session_replay_url = function (options) {
|
|
1274
1290
|
var _a;
|
|
1291
|
+
if (!this.sessionManager) {
|
|
1292
|
+
return '';
|
|
1293
|
+
}
|
|
1275
1294
|
var host = this.config.ui_host || this.config.api_host;
|
|
1276
1295
|
var _b = this.sessionManager.checkAndGetSessionAndWindowId(true), sessionId = _b.sessionId, sessionStartTimestamp = _b.sessionStartTimestamp;
|
|
1277
1296
|
var url = host + '/replay/' + sessionId;
|
|
@@ -1460,6 +1479,7 @@ var PostHog = /** @class */ (function () {
|
|
|
1460
1479
|
* @param {Object} config A dictionary of new configuration values to update
|
|
1461
1480
|
*/
|
|
1462
1481
|
PostHog.prototype.set_config = function (config) {
|
|
1482
|
+
var _a, _b;
|
|
1463
1483
|
var oldConfig = __assign({}, this.config);
|
|
1464
1484
|
if (_isObject(config)) {
|
|
1465
1485
|
_extend(this.config, config);
|
|
@@ -1469,12 +1489,8 @@ var PostHog = /** @class */ (function () {
|
|
|
1469
1489
|
if (!this.get_config('disable_persistence')) {
|
|
1470
1490
|
this.config.disable_persistence = this.config.disable_cookie;
|
|
1471
1491
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
}
|
|
1475
|
-
if (this.sessionPersistence) {
|
|
1476
|
-
this.sessionPersistence.update_config(this.config);
|
|
1477
|
-
}
|
|
1492
|
+
(_a = this.persistence) === null || _a === void 0 ? void 0 : _a.update_config(this.config);
|
|
1493
|
+
(_b = this.sessionPersistence) === null || _b === void 0 ? void 0 : _b.update_config(this.config);
|
|
1478
1494
|
if (localStore.is_supported() && localStore.get('ph_debug') === 'true') {
|
|
1479
1495
|
this.config.debug = true;
|
|
1480
1496
|
}
|
|
@@ -1548,7 +1564,8 @@ var PostHog = /** @class */ (function () {
|
|
|
1548
1564
|
* @param {String} property_name The name of the super property you want to retrieve
|
|
1549
1565
|
*/
|
|
1550
1566
|
PostHog.prototype.get_property = function (property_name) {
|
|
1551
|
-
|
|
1567
|
+
var _a;
|
|
1568
|
+
return (_a = this.persistence) === null || _a === void 0 ? void 0 : _a['props'][property_name];
|
|
1552
1569
|
};
|
|
1553
1570
|
/**
|
|
1554
1571
|
* Returns the value of the session super property named property_name. If no such
|
|
@@ -1570,7 +1587,8 @@ var PostHog = /** @class */ (function () {
|
|
|
1570
1587
|
* @param {String} property_name The name of the session super property you want to retrieve
|
|
1571
1588
|
*/
|
|
1572
1589
|
PostHog.prototype.getSessionProperty = function (property_name) {
|
|
1573
|
-
|
|
1590
|
+
var _a;
|
|
1591
|
+
return (_a = this.sessionPersistence) === null || _a === void 0 ? void 0 : _a['props'][property_name];
|
|
1574
1592
|
};
|
|
1575
1593
|
PostHog.prototype.toString = function () {
|
|
1576
1594
|
var _a;
|
|
@@ -1618,6 +1636,7 @@ var PostHog = /** @class */ (function () {
|
|
|
1618
1636
|
* @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
|
|
1619
1637
|
*/
|
|
1620
1638
|
PostHog.prototype._gdpr_update_persistence = function (options) {
|
|
1639
|
+
var _a, _b, _c, _d;
|
|
1621
1640
|
var disabled;
|
|
1622
1641
|
if (options && options['clear_persistence']) {
|
|
1623
1642
|
disabled = true;
|
|
@@ -1628,11 +1647,11 @@ var PostHog = /** @class */ (function () {
|
|
|
1628
1647
|
else {
|
|
1629
1648
|
return;
|
|
1630
1649
|
}
|
|
1631
|
-
if (!this.get_config('disable_persistence') && this.persistence.disabled !== disabled) {
|
|
1632
|
-
this.persistence.set_disabled(disabled);
|
|
1650
|
+
if (!this.get_config('disable_persistence') && ((_a = this.persistence) === null || _a === void 0 ? void 0 : _a.disabled) !== disabled) {
|
|
1651
|
+
(_b = this.persistence) === null || _b === void 0 ? void 0 : _b.set_disabled(disabled);
|
|
1633
1652
|
}
|
|
1634
|
-
if (!this.get_config('disable_persistence') && this.sessionPersistence.disabled !== disabled) {
|
|
1635
|
-
this.sessionPersistence.set_disabled(disabled);
|
|
1653
|
+
if (!this.get_config('disable_persistence') && ((_c = this.sessionPersistence) === null || _c === void 0 ? void 0 : _c.disabled) !== disabled) {
|
|
1654
|
+
(_d = this.sessionPersistence) === null || _d === void 0 ? void 0 : _d.set_disabled(disabled);
|
|
1636
1655
|
}
|
|
1637
1656
|
};
|
|
1638
1657
|
// call a base gdpr function after constructing the appropriate token and options args
|