posthog-js 1.166.1 → 1.166.2
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 +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/extensions/replay/sessionrecording-utils.js +2 -1
- package/lib/src/extensions/replay/sessionrecording-utils.js.map +1 -1
- package/lib/src/extensions/replay/sessionrecording.js +3 -6
- package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
- package/package.json +1 -1
package/lib/package.json
CHANGED
|
@@ -32,7 +32,8 @@ export function circularReferenceReplacer() {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
export function estimateSize(sizeable) {
|
|
35
|
-
|
|
35
|
+
var _a;
|
|
36
|
+
return ((_a = JSON.stringify(sizeable, circularReferenceReplacer())) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
36
37
|
}
|
|
37
38
|
export var replacementImageURI = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNOCAwSDE2TDAgMTZWOEw4IDBaIiBmaWxsPSIjMkQyRDJEIi8+CjxwYXRoIGQ9Ik0xNiA4VjE2SDhMMTYgOFoiIGZpbGw9IiMyRDJEMkQiLz4KPC9zdmc+Cg==';
|
|
38
39
|
export var FULL_SNAPSHOT_EVENT_TYPE = 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionrecording-utils.js","sourceRoot":"","sources":["../../../../src/extensions/replay/sessionrecording-utils.ts"],"names":[],"mappings":";;;;;;;;;;;AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAGjD,8HAA8H;AAC9H,MAAM,UAAU,yBAAyB;IACrC,IAAM,SAAS,GAAU,EAAE,CAAA;IAC3B,OAAO,UAAqB,IAAY,EAAE,KAAU;QAChD,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAClB,mDAAmD;YACnD,2BAA2B;YAC3B,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;gBACvD,SAAS,CAAC,GAAG,EAAE,CAAA;YACnB,CAAC;YACD,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,OAAO,YAAY,CAAA;YACvB,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACrB,OAAO,KAAK,CAAA;QAChB,CAAC;aAAM,CAAC;YACJ,OAAO,KAAK,CAAA;QAChB,CAAC;IACL,CAAC,CAAA;AACL,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAiB;IAC1C,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,yBAAyB,EAAE,CAAC,CAAC,MAAM,CAAA;AACvE,CAAC;AAED,MAAM,CAAC,IAAM,mBAAmB,GAC5B,4VAA4V,CAAA;AAEhW,MAAM,CAAC,IAAM,wBAAwB,GAAG,CAAC,CAAA;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AQ;aAC5B,CAAC;YACF,WAAW,CAAC;gBACR,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC;gBAC9B,IAAI,EAAE,UAAU;gBAChB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC5B,CAAC;SACL,CAAC,OAAO,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,EAAD,CAAC,CAAC,CAAA;IACvB,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,MAAM,CAAC,CAAA;IACnB,CAAC;AACL,CAAC","sourcesContent":["import type {\n blockClass,\n eventWithTime,\n hooksParam,\n KeepIframeSrcFn,\n listenerHandler,\n maskTextClass,\n pluginEvent,\n RecordPlugin,\n SamplingStrategy,\n} from '@rrweb/types'\nimport type { DataURLOptions, MaskInputFn, MaskInputOptions, MaskTextFn, Mirror, SlimDOMOptions } from 'rrweb-snapshot'\n\nimport { isObject } from '../../utils/type-utils'\nimport { SnapshotBuffer } from './sessionrecording'\n\n// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#circular_references\nexport function circularReferenceReplacer() {\n const ancestors: any[] = []\n return function (this: any, _key: string, value: any) {\n if (isObject(value)) {\n // `this` is the object that value is contained in,\n // i.e., its direct parent.\n while (ancestors.length > 0 && ancestors.at(-1) !== this) {\n ancestors.pop()\n }\n if (ancestors.includes(value)) {\n return '[Circular]'\n }\n ancestors.push(value)\n return value\n } else {\n return value\n }\n }\n}\n\nexport function estimateSize(sizeable: unknown): number {\n return JSON.stringify(sizeable, circularReferenceReplacer()).length\n}\n\nexport const replacementImageURI =\n 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNOCAwSDE2TDAgMTZWOEw4IDBaIiBmaWxsPSIjMkQyRDJEIi8+CjxwYXRoIGQ9Ik0xNiA4VjE2SDhMMTYgOFoiIGZpbGw9IiMyRDJEMkQiLz4KPC9zdmc+Cg=='\n\nexport const FULL_SNAPSHOT_EVENT_TYPE = 2\nexport const META_EVENT_TYPE = 4\nexport const INCREMENTAL_SNAPSHOT_EVENT_TYPE = 3\nexport const PLUGIN_EVENT_TYPE = 6\nexport const MUTATION_SOURCE_TYPE = 0\n\nexport const MAX_MESSAGE_SIZE = 5000000 // ~5mb\n\nexport type rrwebRecord = {\n (options: recordOptions<eventWithTime>): listenerHandler\n addCustomEvent: (tag: string, payload: any) => void\n takeFullSnapshot: () => void\n mirror: Mirror\n}\n\nexport declare type recordOptions<T> = {\n emit?: (e: T, isCheckout?: boolean) => void\n checkoutEveryNth?: number\n checkoutEveryNms?: number\n blockClass?: blockClass\n blockSelector?: string\n ignoreClass?: string\n maskTextClass?: maskTextClass\n maskTextSelector?: string\n maskAllInputs?: boolean\n maskInputOptions?: MaskInputOptions\n maskInputFn?: MaskInputFn\n maskTextFn?: MaskTextFn\n slimDOMOptions?: SlimDOMOptions | 'all' | true\n ignoreCSSAttributes?: Set<string>\n inlineStylesheet?: boolean\n hooks?: hooksParam\n // packFn?: PackFn\n sampling?: SamplingStrategy\n dataURLOptions?: DataURLOptions\n recordCanvas?: boolean\n recordCrossOriginIframes?: boolean\n recordAfter?: 'DOMContentLoaded' | 'load'\n userTriggeredOnInput?: boolean\n collectFonts?: boolean\n inlineImages?: boolean\n plugins?: RecordPlugin[]\n mousemoveWait?: number\n keepIframeSrcFn?: KeepIframeSrcFn\n // errorHandler?: ErrorHandler\n}\n\n/*\n * Check whether a data payload is nearing 5mb. If it is, it checks the data for\n * data URIs (the likely culprit for large payloads). If it finds data URIs, it either replaces\n * it with a generic image (if it's an image) or removes it.\n * @data {object} the rr-web data object\n * @returns {object} the rr-web data object with data uris filtered out\n */\nexport function ensureMaxMessageSize(data: eventWithTime): { event: eventWithTime; size: number } {\n let stringifiedData = JSON.stringify(data)\n // Note: with compression, this limit may be able to be increased\n // but we're assuming most of the size is from a data uri which\n // is unlikely to be compressed further\n\n if (stringifiedData.length > MAX_MESSAGE_SIZE) {\n // Regex that matches the pattern for a dataURI with the shape 'data:{mime type};{encoding},{data}'. It:\n // 1) Checks if the pattern starts with 'data:' (potentially, not at the start of the string)\n // 2) Extracts the mime type of the data uri in the first group\n // 3) Determines when the data URI ends.Depending on if it's used in the src tag or css, it can end with a ) or \"\n const dataURIRegex = /data:([\\w/\\-.]+);(\\w+),([^)\"]*)/gim\n const matches = stringifiedData.matchAll(dataURIRegex)\n for (const match of matches) {\n if (match[1].toLocaleLowerCase().slice(0, 6) === 'image/') {\n stringifiedData = stringifiedData.replace(match[0], replacementImageURI)\n } else {\n stringifiedData = stringifiedData.replace(match[0], '')\n }\n }\n }\n return { event: JSON.parse(stringifiedData), size: stringifiedData.length }\n}\n\nexport const CONSOLE_LOG_PLUGIN_NAME = 'rrweb/console@1' // The name of the rr-web plugin that emits console logs\n\n// Console logs can be really large. This function truncates large logs\n// It's a simple function that just truncates long strings.\n// TODO: Ideally this function would have better handling of objects + lists,\n// so they could still be rendered in a pretty way after truncation.\nexport function truncateLargeConsoleLogs(_event: eventWithTime) {\n const event = _event as pluginEvent<{ payload: string[] }>\n\n const MAX_STRING_SIZE = 2000 // Maximum number of characters allowed in a string\n const MAX_STRINGS_PER_LOG = 10 // A log can consist of multiple strings (e.g. consol.log('string1', 'string2'))\n\n if (\n event &&\n isObject(event) &&\n event.type === PLUGIN_EVENT_TYPE &&\n isObject(event.data) &&\n event.data.plugin === CONSOLE_LOG_PLUGIN_NAME\n ) {\n // Note: event.data.payload.payload comes from rr-web, and is an array of strings\n if (event.data.payload.payload.length > MAX_STRINGS_PER_LOG) {\n event.data.payload.payload = event.data.payload.payload.slice(0, MAX_STRINGS_PER_LOG)\n event.data.payload.payload.push('...[truncated]')\n }\n const updatedPayload = []\n for (let i = 0; i < event.data.payload.payload.length; i++) {\n if (\n event.data.payload.payload[i] && // Value can be null\n event.data.payload.payload[i].length > MAX_STRING_SIZE\n ) {\n updatedPayload.push(event.data.payload.payload[i].slice(0, MAX_STRING_SIZE) + '...[truncated]')\n } else {\n updatedPayload.push(event.data.payload.payload[i])\n }\n }\n event.data.payload.payload = updatedPayload\n // Return original type\n return _event\n }\n return _event\n}\n\nexport const SEVEN_MEGABYTES = 1024 * 1024 * 7 * 0.9 // ~7mb (with some wiggle room)\n\n// recursively splits large buffers into smaller ones\n// uses a pretty high size limit to avoid splitting too much\nexport function splitBuffer(buffer: SnapshotBuffer, sizeLimit: number = SEVEN_MEGABYTES): SnapshotBuffer[] {\n if (buffer.size >= sizeLimit && buffer.data.length > 1) {\n const half = Math.floor(buffer.data.length / 2)\n const firstHalf = buffer.data.slice(0, half)\n const secondHalf = buffer.data.slice(half)\n return [\n splitBuffer({\n size: estimateSize(firstHalf),\n data: firstHalf,\n sessionId: buffer.sessionId,\n windowId: buffer.windowId,\n }),\n splitBuffer({\n size: estimateSize(secondHalf),\n data: secondHalf,\n sessionId: buffer.sessionId,\n windowId: buffer.windowId,\n }),\n ].flatMap((x) => x)\n } else {\n return [buffer]\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sessionrecording-utils.js","sourceRoot":"","sources":["../../../../src/extensions/replay/sessionrecording-utils.ts"],"names":[],"mappings":";;;;;;;;;;;AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAGjD,8HAA8H;AAC9H,MAAM,UAAU,yBAAyB;IACrC,IAAM,SAAS,GAAU,EAAE,CAAA;IAC3B,OAAO,UAAqB,IAAY,EAAE,KAAU;QAChD,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAClB,mDAAmD;YACnD,2BAA2B;YAC3B,OAAO,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,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4D;AAC5D,MAAM,UAAU,WAAW,CAAC,MAAsB,EAAE,SAAmC;IAAnC,0BAAA,EAAA,2BAAmC;IACnF,IAAI,MAAM,CAAC,IAAI,IAAI,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC/C,IAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;QAC5C,IAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC1C,OAAO;YACH,WAAW,CAAC;gBACR,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC;gBAC7B,IAAI,EAAE,SAAS;gBACf,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC5B,CAAC;YACF,WAAW,CAAC;gBACR,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC;gBAC9B,IAAI,EAAE,UAAU;gBAChB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC5B,CAAC;SACL,CAAC,OAAO,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,EAAD,CAAC,CAAC,CAAA;IACvB,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,MAAM,CAAC,CAAA;IACnB,CAAC;AACL,CAAC","sourcesContent":["import type {\n blockClass,\n eventWithTime,\n hooksParam,\n KeepIframeSrcFn,\n listenerHandler,\n maskTextClass,\n pluginEvent,\n RecordPlugin,\n SamplingStrategy,\n} from '@rrweb/types'\nimport type { DataURLOptions, MaskInputFn, MaskInputOptions, MaskTextFn, Mirror, SlimDOMOptions } from 'rrweb-snapshot'\n\nimport { isObject } from '../../utils/type-utils'\nimport { SnapshotBuffer } from './sessionrecording'\n\n// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#circular_references\nexport function circularReferenceReplacer() {\n const ancestors: any[] = []\n return function (this: any, _key: string, value: any) {\n if (isObject(value)) {\n // `this` is the object that value is contained in,\n // i.e., its direct parent.\n while (ancestors.length > 0 && ancestors.at(-1) !== this) {\n ancestors.pop()\n }\n if (ancestors.includes(value)) {\n return '[Circular]'\n }\n ancestors.push(value)\n return value\n } else {\n return value\n }\n }\n}\n\nexport function estimateSize(sizeable: unknown): number {\n return JSON.stringify(sizeable, circularReferenceReplacer())?.length || 0\n}\n\nexport const replacementImageURI =\n 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNOCAwSDE2TDAgMTZWOEw4IDBaIiBmaWxsPSIjMkQyRDJEIi8+CjxwYXRoIGQ9Ik0xNiA4VjE2SDhMMTYgOFoiIGZpbGw9IiMyRDJEMkQiLz4KPC9zdmc+Cg=='\n\nexport const FULL_SNAPSHOT_EVENT_TYPE = 2\nexport const META_EVENT_TYPE = 4\nexport const INCREMENTAL_SNAPSHOT_EVENT_TYPE = 3\nexport const PLUGIN_EVENT_TYPE = 6\nexport const MUTATION_SOURCE_TYPE = 0\n\nexport const MAX_MESSAGE_SIZE = 5000000 // ~5mb\n\nexport type rrwebRecord = {\n (options: recordOptions<eventWithTime>): listenerHandler\n addCustomEvent: (tag: string, payload: any) => void\n takeFullSnapshot: () => void\n mirror: Mirror\n}\n\nexport declare type recordOptions<T> = {\n emit?: (e: T, isCheckout?: boolean) => void\n checkoutEveryNth?: number\n checkoutEveryNms?: number\n blockClass?: blockClass\n blockSelector?: string\n ignoreClass?: string\n maskTextClass?: maskTextClass\n maskTextSelector?: string\n maskAllInputs?: boolean\n maskInputOptions?: MaskInputOptions\n maskInputFn?: MaskInputFn\n maskTextFn?: MaskTextFn\n slimDOMOptions?: SlimDOMOptions | 'all' | true\n ignoreCSSAttributes?: Set<string>\n inlineStylesheet?: boolean\n hooks?: hooksParam\n // packFn?: PackFn\n sampling?: SamplingStrategy\n dataURLOptions?: DataURLOptions\n recordCanvas?: boolean\n recordCrossOriginIframes?: boolean\n recordAfter?: 'DOMContentLoaded' | 'load'\n userTriggeredOnInput?: boolean\n collectFonts?: boolean\n inlineImages?: boolean\n plugins?: RecordPlugin[]\n mousemoveWait?: number\n keepIframeSrcFn?: KeepIframeSrcFn\n // errorHandler?: ErrorHandler\n}\n\n/*\n * Check whether a data payload is nearing 5mb. If it is, it checks the data for\n * data URIs (the likely culprit for large payloads). If it finds data URIs, it either replaces\n * it with a generic image (if it's an image) or removes it.\n * @data {object} the rr-web data object\n * @returns {object} the rr-web data object with data uris filtered out\n */\nexport function ensureMaxMessageSize(data: eventWithTime): { event: eventWithTime; size: number } {\n let stringifiedData = JSON.stringify(data)\n // Note: with compression, this limit may be able to be increased\n // but we're assuming most of the size is from a data uri which\n // is unlikely to be compressed further\n\n if (stringifiedData.length > MAX_MESSAGE_SIZE) {\n // Regex that matches the pattern for a dataURI with the shape 'data:{mime type};{encoding},{data}'. It:\n // 1) Checks if the pattern starts with 'data:' (potentially, not at the start of the string)\n // 2) Extracts the mime type of the data uri in the first group\n // 3) Determines when the data URI ends.Depending on if it's used in the src tag or css, it can end with a ) or \"\n const dataURIRegex = /data:([\\w/\\-.]+);(\\w+),([^)\"]*)/gim\n const matches = stringifiedData.matchAll(dataURIRegex)\n for (const match of matches) {\n if (match[1].toLocaleLowerCase().slice(0, 6) === 'image/') {\n stringifiedData = stringifiedData.replace(match[0], replacementImageURI)\n } else {\n stringifiedData = stringifiedData.replace(match[0], '')\n }\n }\n }\n return { event: JSON.parse(stringifiedData), size: stringifiedData.length }\n}\n\nexport const CONSOLE_LOG_PLUGIN_NAME = 'rrweb/console@1' // The name of the rr-web plugin that emits console logs\n\n// Console logs can be really large. This function truncates large logs\n// It's a simple function that just truncates long strings.\n// TODO: Ideally this function would have better handling of objects + lists,\n// so they could still be rendered in a pretty way after truncation.\nexport function truncateLargeConsoleLogs(_event: eventWithTime) {\n const event = _event as pluginEvent<{ payload: string[] }>\n\n const MAX_STRING_SIZE = 2000 // Maximum number of characters allowed in a string\n const MAX_STRINGS_PER_LOG = 10 // A log can consist of multiple strings (e.g. consol.log('string1', 'string2'))\n\n if (\n event &&\n isObject(event) &&\n event.type === PLUGIN_EVENT_TYPE &&\n isObject(event.data) &&\n event.data.plugin === CONSOLE_LOG_PLUGIN_NAME\n ) {\n // Note: event.data.payload.payload comes from rr-web, and is an array of strings\n if (event.data.payload.payload.length > MAX_STRINGS_PER_LOG) {\n event.data.payload.payload = event.data.payload.payload.slice(0, MAX_STRINGS_PER_LOG)\n event.data.payload.payload.push('...[truncated]')\n }\n const updatedPayload = []\n for (let i = 0; i < event.data.payload.payload.length; i++) {\n if (\n event.data.payload.payload[i] && // Value can be null\n event.data.payload.payload[i].length > MAX_STRING_SIZE\n ) {\n updatedPayload.push(event.data.payload.payload[i].slice(0, MAX_STRING_SIZE) + '...[truncated]')\n } else {\n updatedPayload.push(event.data.payload.payload[i])\n }\n }\n event.data.payload.payload = updatedPayload\n // Return original type\n return _event\n }\n return _event\n}\n\nexport const SEVEN_MEGABYTES = 1024 * 1024 * 7 * 0.9 // ~7mb (with some wiggle room)\n\n// recursively splits large buffers into smaller ones\n// uses a pretty high size limit to avoid splitting too much\nexport function splitBuffer(buffer: SnapshotBuffer, sizeLimit: number = SEVEN_MEGABYTES): SnapshotBuffer[] {\n if (buffer.size >= sizeLimit && buffer.data.length > 1) {\n const half = Math.floor(buffer.data.length / 2)\n const firstHalf = buffer.data.slice(0, half)\n const secondHalf = buffer.data.slice(half)\n return [\n splitBuffer({\n size: estimateSize(firstHalf),\n data: firstHalf,\n sessionId: buffer.sessionId,\n windowId: buffer.windowId,\n }),\n splitBuffer({\n size: estimateSize(secondHalf),\n data: secondHalf,\n sessionId: buffer.sessionId,\n windowId: buffer.windowId,\n }),\n ].flatMap((x) => x)\n } else {\n return [buffer]\n }\n}\n"]}
|
|
@@ -89,7 +89,7 @@ function gzipToString(data) {
|
|
|
89
89
|
// rrweb's packer takes an event and returns a string or the reverse on unpact,
|
|
90
90
|
// but we want to be able to inspect metadata during ingestion, and don't want to compress the entire event
|
|
91
91
|
// so we have a custom packer that only compresses part of some events
|
|
92
|
-
function compressEvent(event
|
|
92
|
+
function compressEvent(event) {
|
|
93
93
|
var originalSize = estimateSize(event);
|
|
94
94
|
if (originalSize < PARTIAL_COMPRESSION_THRESHOLD) {
|
|
95
95
|
return event;
|
|
@@ -106,10 +106,7 @@ function compressEvent(event, ph) {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
catch (e) {
|
|
109
|
-
logger.error(LOGGER_PREFIX + ' could not compress event', e);
|
|
110
|
-
ph.captureException(e || 'e was not an error', {
|
|
111
|
-
attempted_event_type: (event === null || event === void 0 ? void 0 : event.type) || 'no event type',
|
|
112
|
-
});
|
|
109
|
+
logger.error(LOGGER_PREFIX + ' could not compress event - will use uncompressed event', e);
|
|
113
110
|
}
|
|
114
111
|
return event;
|
|
115
112
|
}
|
|
@@ -811,7 +808,7 @@ var SessionRecording = /** @class */ (function () {
|
|
|
811
808
|
event.timestamp = lastActivity + threshold;
|
|
812
809
|
}
|
|
813
810
|
}
|
|
814
|
-
var eventToSend = ((_a = this.instance.config.session_recording.compress_events) !== null && _a !== void 0 ? _a : true) ? compressEvent(event
|
|
811
|
+
var eventToSend = ((_a = this.instance.config.session_recording.compress_events) !== null && _a !== void 0 ? _a : true) ? compressEvent(event) : event;
|
|
815
812
|
var size = estimateSize(eventToSend);
|
|
816
813
|
var properties = {
|
|
817
814
|
$snapshot_bytes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zC,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;gBAC/B,KAAI,CAAC,YAAY,EAAE,CAAA;YACvB,CAAC,EAAE,wBAAwB,CAAC,CAAA;QAChC,CAAC;IACL,CAAC;IAEO,2CAAgB,GAAxB,UAAyB,UAAsB;QAC3C,oGAAoG;QACpG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE;YAC3C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;YACpE,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,2BAA2B;YACtC,yBAAyB,EAAE,IAAI;SAClC,CAAC,CAAA;IACN,CAAC;IAED;;;;;;SAMK;IACE,6CAAkB,GAAzB;QACI,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;IAC/B,CAAC;IACL,uBAAC;AAAD,CAAC,AAx4BD,IAw4BC","sourcesContent":["import {\n CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_CANVAS_RECORDING,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_IS_SAMPLED,\n SESSION_RECORDING_MINIMUM_DURATION,\n SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE,\n SESSION_RECORDING_SAMPLE_RATE,\n} from '../../constants'\nimport {\n estimateSize,\n INCREMENTAL_SNAPSHOT_EVENT_TYPE,\n recordOptions,\n rrwebRecord,\n splitBuffer,\n truncateLargeConsoleLogs,\n} from './sessionrecording-utils'\nimport { PostHog } from '../../posthog-core'\nimport { DecideResponse, FlagVariant, NetworkRecordOptions, NetworkRequest, Properties } from '../../types'\nimport {\n customEvent,\n EventType,\n type eventWithTime,\n IncrementalSource,\n type listenerHandler,\n RecordPlugin,\n} from '@rrweb/types'\n\nimport { isBoolean, isFunction, isNullish, isNumber, isObject, isString, isUndefined } from '../../utils/type-utils'\nimport { logger } from '../../utils/logger'\nimport { assignableWindow, document, window } from '../../utils/globals'\nimport { buildNetworkRequestOptions } from './config'\nimport { isLocalhost } from '../../utils/request-utils'\nimport { MutationRateLimiter } from './mutation-rate-limiter'\nimport { gzipSync, strFromU8, strToU8 } from 'fflate'\n\nconst BASE_ENDPOINT = '/s/'\n\nconst FIVE_MINUTES = 1000 * 60 * 5\nconst TWO_SECONDS = 2000\nexport const RECORDING_IDLE_THRESHOLD_MS = FIVE_MINUTES\nconst ONE_KB = 1024\nconst PARTIAL_COMPRESSION_THRESHOLD = ONE_KB\nexport const RECORDING_MAX_EVENT_SIZE = ONE_KB * ONE_KB * 0.9 // ~1mb (with some wiggle room)\nexport const RECORDING_BUFFER_TIMEOUT = 2000 // 2 seconds\nexport const SESSION_RECORDING_BATCH_KEY = 'recordings'\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\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\n/**\n * Session recording starts in buffering mode while waiting for decide response\n * Once the response is received it might be disabled, active or sampled\n * When sampled that means a sample rate is set and the last time the session id was rotated\n * the sample rate determined this session should be sent to the server.\n */\ntype SessionRecordingStatus = 'disabled' | 'sampled' | 'active' | 'buffering'\n\nexport interface SnapshotBuffer {\n size: number\n data: any[]\n sessionId: string\n windowId: string\n}\n\ninterface QueuedRRWebEvent {\n rrwebMethod: () => void\n attempt: number\n // the timestamp this was first put into this queue\n enqueuedAt: number\n}\n\ninterface SessionIdlePayload {\n eventTimestamp: number\n lastActivityTimestamp: number\n threshold: number\n bufferLength: number\n bufferSize: number\n}\n\nconst newQueuedEvent = (rrwebMethod: () => void): QueuedRRWebEvent => ({\n rrwebMethod,\n enqueuedAt: Date.now(),\n attempt: 1,\n})\n\nconst LOGGER_PREFIX = '[SessionRecording]'\n\ntype compressedFullSnapshotEvent = {\n type: EventType.FullSnapshot\n data: string\n}\n\ntype compressedIncrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot\n data: {\n source: IncrementalSource\n texts: string\n attributes: string\n removes: string\n adds: string\n }\n}\n\ntype compressedIncrementalStyleSnapshotEvent = {\n type: EventType.IncrementalSnapshot\n data: {\n source: IncrementalSource.StyleSheetRule\n id?: number\n styleId?: number\n replace?: string\n replaceSync?: string\n adds: string\n removes: string\n }\n}\n\nexport type compressedEvent =\n | compressedIncrementalStyleSnapshotEvent\n | compressedFullSnapshotEvent\n | compressedIncrementalSnapshotEvent\nexport type compressedEventWithTime = compressedEvent & {\n timestamp: number\n delay?: number\n // marker for compression version\n cv: '2024-10'\n}\n\nfunction gzipToString(data: unknown): string {\n return strFromU8(gzipSync(strToU8(JSON.stringify(data))), true)\n}\n\n// rrweb's packer takes an event and returns a string or the reverse on unpact,\n// but we want to be able to inspect metadata during ingestion, and don't want to compress the entire event\n// so we have a custom packer that only compresses part of some events\nfunction compressEvent(event: eventWithTime, ph: PostHog): eventWithTime | compressedEventWithTime {\n const originalSize = estimateSize(event)\n if (originalSize < PARTIAL_COMPRESSION_THRESHOLD) {\n return event\n }\n\n try {\n if (event.type === EventType.FullSnapshot) {\n return {\n ...event,\n data: gzipToString(event.data),\n cv: '2024-10',\n }\n }\n if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.Mutation) {\n return {\n ...event,\n cv: '2024-10',\n data: {\n ...event.data,\n texts: gzipToString(event.data.texts),\n attributes: gzipToString(event.data.attributes),\n removes: gzipToString(event.data.removes),\n adds: gzipToString(event.data.adds),\n },\n }\n }\n if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.StyleSheetRule) {\n return {\n ...event,\n cv: '2024-10',\n data: {\n ...event.data,\n adds: gzipToString(event.data.adds),\n removes: gzipToString(event.data.removes),\n },\n }\n }\n } catch (e) {\n logger.error(LOGGER_PREFIX + ' could not compress event', e)\n ph.captureException((e as Error) || 'e was not an error', {\n attempted_event_type: event?.type || 'no event type',\n })\n }\n return event\n}\n\nfunction isSessionIdleEvent(e: eventWithTime): e is eventWithTime & customEvent {\n return e.type === EventType.Custom && e.data.tag === 'sessionIdle'\n}\n\nexport class SessionRecording {\n private _endpoint: string\n private flushBufferTimer?: any\n\n // we have a buffer - that contains PostHog snapshot events ready to be sent to the server\n private buffer: SnapshotBuffer\n // and a queue - that contains rrweb events that we want to send to rrweb, but rrweb wasn't able to accept them yet\n private queuedRRWebEvents: QueuedRRWebEvent[] = []\n\n private mutationRateLimiter?: MutationRateLimiter\n private _captureStarted: boolean\n private stopRrweb: listenerHandler | undefined\n private receivedDecide: boolean\n private isIdle = false\n\n private _linkedFlagSeen: boolean = false\n private _lastActivityTimestamp: number = Date.now()\n private windowId: string\n private sessionId: string\n private _linkedFlag: string | FlagVariant | null = null\n\n private _fullSnapshotTimer?: ReturnType<typeof setInterval>\n\n private _removePageViewCaptureHook: (() => void) | undefined = undefined\n private _onSessionIdListener: (() => void) | undefined = undefined\n private _persistDecideOnSessionListener: (() => void) | undefined = undefined\n private _samplingSessionListener: (() => void) | undefined = undefined\n\n // if pageview capture is disabled\n // then we can manually track href changes\n private _lastHref?: string\n\n // Util to help developers working on this feature manually override\n _forceAllowLocalhostNetworkCapture = false\n\n private get sessionIdleThresholdMilliseconds(): number {\n return this.instance.config.session_recording.session_idle_threshold_ms || RECORDING_IDLE_THRESHOLD_MS\n }\n\n private get rrwebRecord(): rrwebRecord | undefined {\n return assignableWindow?.__PosthogExtensions__?.rrweb?.record\n }\n\n public get started(): boolean {\n // TODO could we use status instead of _captureStarted?\n return this._captureStarted\n }\n\n private get sessionManager() {\n if (!this.instance.sessionManager) {\n throw new Error(LOGGER_PREFIX + ' must be started with a valid sessionManager.')\n }\n\n return this.instance.sessionManager\n }\n\n private get fullSnapshotIntervalMillis(): number {\n return this.instance.config.session_recording?.full_snapshot_interval_millis || FIVE_MINUTES\n }\n\n private get isSampled(): boolean | null {\n const currentValue = this.instance.get_property(SESSION_RECORDING_IS_SAMPLED)\n return isBoolean(currentValue) ? currentValue : null\n }\n\n private get sessionDuration(): number | null {\n const mostRecentSnapshot = this.buffer?.data[this.buffer?.data.length - 1]\n const { sessionStartTimestamp } = this.sessionManager.checkAndGetSessionAndWindowId(true)\n return mostRecentSnapshot ? mostRecentSnapshot.timestamp - sessionStartTimestamp : null\n }\n\n private get isRecordingEnabled() {\n const enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = !this.instance.config.disable_session_recording\n return window && enabled_server_side && enabled_client_side\n }\n\n private get isConsoleLogCaptureEnabled() {\n const enabled_server_side = !!this.instance.get_property(CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = this.instance.config.enable_recording_console_log\n return enabled_client_side ?? enabled_server_side\n }\n\n private get canvasRecording(): { enabled: boolean; fps: number; quality: number } | undefined {\n const canvasRecording_server_side = this.instance.get_property(SESSION_RECORDING_CANVAS_RECORDING)\n return canvasRecording_server_side && canvasRecording_server_side.fps && canvasRecording_server_side.quality\n ? {\n enabled: canvasRecording_server_side.enabled,\n fps: canvasRecording_server_side.fps,\n quality: canvasRecording_server_side.quality,\n }\n : undefined\n }\n\n // network payload capture config has three parts\n // each can be configured server side or client side\n private get networkPayloadCapture():\n | Pick<NetworkRecordOptions, 'recordHeaders' | 'recordBody' | 'recordPerformance'>\n | undefined {\n const networkPayloadCapture_server_side = this.instance.get_property(SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE)\n const networkPayloadCapture_client_side = {\n recordHeaders: this.instance.config.session_recording?.recordHeaders,\n recordBody: this.instance.config.session_recording?.recordBody,\n }\n const headersEnabled =\n networkPayloadCapture_client_side?.recordHeaders || networkPayloadCapture_server_side?.recordHeaders\n const bodyEnabled =\n networkPayloadCapture_client_side?.recordBody || networkPayloadCapture_server_side?.recordBody\n const clientConfigForPerformanceCapture = isObject(this.instance.config.capture_performance)\n ? this.instance.config.capture_performance.network_timing\n : this.instance.config.capture_performance\n const networkTimingEnabled = !!(isBoolean(clientConfigForPerformanceCapture)\n ? clientConfigForPerformanceCapture\n : networkPayloadCapture_server_side?.capturePerformance)\n\n return headersEnabled || bodyEnabled || networkTimingEnabled\n ? { recordHeaders: headersEnabled, recordBody: bodyEnabled, recordPerformance: networkTimingEnabled }\n : undefined\n }\n\n private get sampleRate(): number | null {\n const rate = this.instance.get_property(SESSION_RECORDING_SAMPLE_RATE)\n return isNumber(rate) ? rate : null\n }\n\n private get minimumDuration(): number | null {\n const duration = this.instance.get_property(SESSION_RECORDING_MINIMUM_DURATION)\n return isNumber(duration) ? duration : null\n }\n\n /**\n * defaults to buffering mode until a decide response is received\n * once a decide response is received status can be disabled, active or sampled\n */\n private get status(): SessionRecordingStatus {\n if (!this.receivedDecide) {\n return 'buffering'\n }\n\n if (!this.isRecordingEnabled) {\n return 'disabled'\n }\n\n if (!isNullish(this._linkedFlag) && !this._linkedFlagSeen) {\n return 'buffering'\n }\n\n if (isBoolean(this.isSampled)) {\n return this.isSampled ? 'sampled' : 'disabled'\n } else {\n return 'active'\n }\n }\n\n constructor(private readonly instance: PostHog) {\n this._captureStarted = false\n this._endpoint = BASE_ENDPOINT\n this.stopRrweb = undefined\n this.receivedDecide = false\n\n if (!this.instance.sessionManager) {\n logger.error(LOGGER_PREFIX + ' started without valid sessionManager')\n throw new Error(LOGGER_PREFIX + ' started without valid sessionManager. This is a bug.')\n }\n\n // we know there's a sessionManager, so don't need to start without a session id\n const { sessionId, windowId } = this.sessionManager.checkAndGetSessionAndWindowId()\n this.sessionId = sessionId\n this.windowId = windowId\n\n this.buffer = this.clearBuffer()\n\n if (this.sessionIdleThresholdMilliseconds >= this.sessionManager.sessionTimeoutMs) {\n logger.warn(\n LOGGER_PREFIX +\n ` session_idle_threshold_ms (${this.sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this.sessionManager.sessionTimeoutMs}). Session will never be detected as idle`\n )\n }\n }\n\n private _onBeforeUnload = (): void => {\n this._flushBuffer()\n }\n\n private _onOffline = (): void => {\n this._tryAddCustomEvent('browser offline', {})\n }\n\n private _onOnline = (): void => {\n this._tryAddCustomEvent('browser online', {})\n }\n\n private _onVisibilityChange = (): void => {\n if (document?.visibilityState) {\n const label = 'window ' + document.visibilityState\n this._tryAddCustomEvent(label, {})\n }\n }\n\n startIfEnabledOrStop() {\n if (this.isRecordingEnabled) {\n this._startCapture()\n\n // calling addEventListener multiple times is safe and will not add duplicates\n window?.addEventListener('beforeunload', this._onBeforeUnload)\n window?.addEventListener('offline', this._onOffline)\n window?.addEventListener('online', this._onOnline)\n window?.addEventListener('visibilitychange', this._onVisibilityChange)\n\n // on reload there might be an already sampled session that should be continued before decide response,\n // so we call this here _and_ in the decide response\n this._setupSampling()\n\n if (isNullish(this._removePageViewCaptureHook)) {\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._removePageViewCaptureHook = this.instance._addCaptureHook((eventName) => {\n // If anything could go wrong here it has the potential to block the main loop,\n // so we catch all errors.\n try {\n if (eventName === '$pageview') {\n const href = window ? this._maskUrl(window.location.href) : ''\n if (!href) {\n return\n }\n this._tryAddCustomEvent('$pageview', { href })\n }\n } catch (e) {\n logger.error('Could not add $pageview to rrweb session', e)\n }\n })\n }\n\n if (!this._onSessionIdListener) {\n this._onSessionIdListener = this.sessionManager.onSessionId((sessionId, windowId, changeReason) => {\n if (changeReason) {\n this._tryAddCustomEvent('$session_id_change', { sessionId, windowId, changeReason })\n }\n })\n }\n } else {\n this.stopRecording()\n }\n }\n\n stopRecording() {\n if (this._captureStarted && this.stopRrweb) {\n this.stopRrweb()\n this.stopRrweb = undefined\n this._captureStarted = false\n\n window?.removeEventListener('beforeunload', this._onBeforeUnload)\n window?.removeEventListener('offline', this._onOffline)\n window?.removeEventListener('online', this._onOnline)\n window?.removeEventListener('visibilitychange', this._onVisibilityChange)\n\n this.clearBuffer()\n clearInterval(this._fullSnapshotTimer)\n\n this._removePageViewCaptureHook?.()\n this._removePageViewCaptureHook = undefined\n this._onSessionIdListener?.()\n this._onSessionIdListener = undefined\n this._samplingSessionListener?.()\n this._samplingSessionListener = undefined\n\n logger.info(LOGGER_PREFIX + ' stopped')\n }\n }\n\n private makeSamplingDecision(sessionId: string): void {\n const sessionIdChanged = this.sessionId !== sessionId\n\n // capture the current sample rate,\n // because it is re-used multiple times\n // and the bundler won't minimise any of the references\n const currentSampleRate = this.sampleRate\n\n if (!isNumber(currentSampleRate)) {\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: null,\n })\n return\n }\n\n const storedIsSampled = this.isSampled\n\n /**\n * if we get this far then we should make a sampling decision.\n * When the session id changes or there is no stored sampling decision for this session id\n * then we should make a new decision.\n *\n * Otherwise, we should use the stored decision.\n */\n let shouldSample: boolean\n const makeDecision = sessionIdChanged || !isBoolean(storedIsSampled)\n if (makeDecision) {\n const randomNumber = Math.random()\n shouldSample = randomNumber < currentSampleRate\n } else {\n shouldSample = storedIsSampled\n }\n\n if (!shouldSample && makeDecision) {\n logger.warn(\n LOGGER_PREFIX +\n ` Sample rate (${currentSampleRate}) has determined that this sessionId (${sessionId}) will not be sent to the server.`\n )\n }\n this._tryAddCustomEvent('samplingDecisionMade', {\n sampleRate: currentSampleRate,\n })\n\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: shouldSample,\n })\n }\n\n afterDecideResponse(response: DecideResponse) {\n this._persistDecideResponse(response)\n\n this._linkedFlag = response.sessionRecording?.linkedFlag || null\n\n if (response.sessionRecording?.endpoint) {\n this._endpoint = response.sessionRecording?.endpoint\n }\n\n this._setupSampling()\n\n if (!isNullish(this._linkedFlag) && !this._linkedFlagSeen) {\n const linkedFlag = isString(this._linkedFlag) ? this._linkedFlag : this._linkedFlag.flag\n const linkedVariant = isString(this._linkedFlag) ? null : this._linkedFlag.variant\n this.instance.onFeatureFlags((_flags, variants) => {\n const flagIsPresent = isObject(variants) && linkedFlag in variants\n const linkedFlagMatches = linkedVariant ? variants[linkedFlag] === linkedVariant : flagIsPresent\n if (linkedFlagMatches) {\n const payload = {\n linkedFlag,\n linkedVariant,\n }\n const tag = 'linked flag matched'\n logger.info(LOGGER_PREFIX + ' ' + tag, payload)\n this._tryAddCustomEvent(tag, payload)\n }\n this._linkedFlagSeen = linkedFlagMatches\n })\n }\n\n this.receivedDecide = true\n this.startIfEnabledOrStop()\n }\n\n /**\n * This might be called more than once so needs to be idempotent\n */\n private _setupSampling() {\n if (isNumber(this.sampleRate) && isNullish(this._samplingSessionListener)) {\n this._samplingSessionListener = this.sessionManager.onSessionId((sessionId) => {\n this.makeSamplingDecision(sessionId)\n })\n }\n }\n\n private _persistDecideResponse(response: DecideResponse): void {\n if (this.instance.persistence) {\n const persistence = this.instance.persistence\n\n const persistResponse = () => {\n const receivedSampleRate = response.sessionRecording?.sampleRate\n\n const parsedSampleRate = isNullish(receivedSampleRate) ? null : parseFloat(receivedSampleRate)\n const receivedMinimumDuration = response.sessionRecording?.minimumDurationMilliseconds\n\n persistence.register({\n [SESSION_RECORDING_ENABLED_SERVER_SIDE]: !!response['sessionRecording'],\n [CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE]: response.sessionRecording?.consoleLogRecordingEnabled,\n [SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE]: {\n capturePerformance: response.capturePerformance,\n ...response.sessionRecording?.networkPayloadCapture,\n },\n [SESSION_RECORDING_CANVAS_RECORDING]: {\n enabled: response.sessionRecording?.recordCanvas,\n fps: response.sessionRecording?.canvasFps,\n quality: response.sessionRecording?.canvasQuality,\n },\n [SESSION_RECORDING_SAMPLE_RATE]: parsedSampleRate,\n [SESSION_RECORDING_MINIMUM_DURATION]: isUndefined(receivedMinimumDuration)\n ? null\n : receivedMinimumDuration,\n })\n }\n\n persistResponse()\n\n // in case we see multiple decide responses, we should only listen with the response from the most recent one\n this._persistDecideOnSessionListener?.()\n this._persistDecideOnSessionListener = this.sessionManager.onSessionId(persistResponse)\n }\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 that's what rrweb expects\n payload: [JSON.stringify(message)],\n },\n },\n timestamp: Date.now(),\n })\n }\n\n private _startCapture() {\n if (isUndefined(Object.assign)) {\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 // do not start if explicitly disabled or if the user has opted out\n if (\n this._captureStarted ||\n this.instance.config.disable_session_recording ||\n this.instance.consent.isOptedOut()\n ) {\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.sessionManager.checkAndGetSessionAndWindowId()\n\n // If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is\n // imported), don't load script. Otherwise, remotely import recorder.js from cdn since it hasn't been loaded.\n if (!this.rrwebRecord) {\n assignableWindow.__PosthogExtensions__?.loadExternalDependency?.(this.instance, 'recorder', (err) => {\n if (err) {\n return logger.error(LOGGER_PREFIX + ` could not load recorder`, err)\n }\n\n this._onScriptLoaded()\n })\n } else {\n this._onScriptLoaded()\n }\n }\n\n private isInteractiveEvent(event: eventWithTime) {\n return (\n event.type === INCREMENTAL_SNAPSHOT_EVENT_TYPE &&\n ACTIVE_SOURCES.indexOf(event.data?.source as IncrementalSource) !== -1\n )\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 const timeSinceLastActivity = event.timestamp - this._lastActivityTimestamp\n if (timeSinceLastActivity > this.sessionIdleThresholdMilliseconds) {\n // we mark as idle right away,\n // or else we get multiple idle events\n // if there are lots of non-user activity events being emitted\n this.isIdle = true\n\n // don't take full snapshots while idle\n clearInterval(this._fullSnapshotTimer)\n\n this._tryAddCustomEvent('sessionIdle', {\n eventTimestamp: event.timestamp,\n lastActivityTimestamp: this._lastActivityTimestamp,\n threshold: this.sessionIdleThresholdMilliseconds,\n bufferLength: this.buffer.data.length,\n bufferSize: this.buffer.size,\n })\n\n // proactively flush the buffer in case the session is idle for a long time\n this._flushBuffer()\n }\n }\n\n let returningFromIdle = false\n if (isUserInteraction) {\n this._lastActivityTimestamp = event.timestamp\n if (this.isIdle) {\n // Remove the idle state\n this.isIdle = false\n this._tryAddCustomEvent('sessionNoLongerIdle', {\n reason: 'user activity',\n type: event.type,\n })\n returningFromIdle = true\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.sessionManager.checkAndGetSessionAndWindowId(\n !isUserInteraction,\n event.timestamp\n )\n\n const sessionIdChanged = this.sessionId !== sessionId\n const windowIdChanged = this.windowId !== windowId\n\n this.windowId = windowId\n this.sessionId = sessionId\n\n if (sessionIdChanged || windowIdChanged) {\n this.stopRecording()\n this.startIfEnabledOrStop()\n } else if (returningFromIdle) {\n this._scheduleFullSnapshot()\n }\n }\n\n private _tryRRWebMethod(queuedRRWebEvent: QueuedRRWebEvent): boolean {\n try {\n queuedRRWebEvent.rrwebMethod()\n return true\n } catch (e) {\n // Sometimes a race can occur where the recorder is not fully started yet\n if (this.queuedRRWebEvents.length < 10) {\n this.queuedRRWebEvents.push({\n enqueuedAt: queuedRRWebEvent.enqueuedAt || Date.now(),\n attempt: queuedRRWebEvent.attempt++,\n rrwebMethod: queuedRRWebEvent.rrwebMethod,\n })\n } else {\n logger.warn(LOGGER_PREFIX + ' could not emit queued rrweb event.', e, queuedRRWebEvent)\n }\n\n return false\n }\n }\n\n private _tryAddCustomEvent(tag: string, payload: any): boolean {\n return this._tryRRWebMethod(newQueuedEvent(() => this.rrwebRecord!.addCustomEvent(tag, payload)))\n }\n\n private _tryTakeFullSnapshot(): boolean {\n return this._tryRRWebMethod(newQueuedEvent(() => this.rrwebRecord!.takeFullSnapshot()))\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: { password: true },\n maskInputFn: undefined,\n slimDOMOptions: {},\n collectFonts: false,\n inlineStylesheet: true,\n recordCrossOriginIframes: false,\n }\n\n // only allows user to set our allow-listed options\n const userSessionRecordingOptions = this.instance.config.session_recording\n for (const [key, value] of Object.entries(userSessionRecordingOptions || {})) {\n if (key in sessionRecordingOptions) {\n if (key === 'maskInputOptions') {\n // ensure password is set if not included\n sessionRecordingOptions.maskInputOptions = { password: true, ...value }\n } else {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n sessionRecordingOptions[key] = value\n }\n }\n }\n\n if (this.canvasRecording && this.canvasRecording.enabled) {\n sessionRecordingOptions.recordCanvas = true\n sessionRecordingOptions.sampling = { canvas: this.canvasRecording.fps }\n sessionRecordingOptions.dataURLOptions = { type: 'image/webp', quality: this.canvasRecording.quality }\n }\n\n if (!this.rrwebRecord) {\n logger.error(\n LOGGER_PREFIX +\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.info(message, {\n node: node,\n })\n\n this.log(LOGGER_PREFIX + ' ' + message, 'warn')\n },\n })\n\n const activePlugins = this._gatherRRWebPlugins()\n this.stopRrweb = this.rrwebRecord({\n emit: (event) => {\n this.onRRwebEmit(event)\n },\n plugins: activePlugins,\n ...sessionRecordingOptions,\n })\n\n // We reset the last activity timestamp, resetting the idle timer\n this._lastActivityTimestamp = Date.now()\n this.isIdle = false\n\n this._tryAddCustomEvent('$session_options', {\n sessionRecordingOptions,\n activePlugins: activePlugins.map((p) => p?.name),\n })\n\n this._tryAddCustomEvent('$posthog_config', {\n config: this.instance.config,\n })\n\n logger.info(LOGGER_PREFIX + ' started', {\n idleThreshold: this.sessionIdleThresholdMilliseconds,\n maxIdleTime: this.sessionManager.sessionTimeoutMs,\n })\n }\n\n private _scheduleFullSnapshot(): void {\n if (this._fullSnapshotTimer) {\n clearInterval(this._fullSnapshotTimer)\n }\n // we don't schedule snapshots while idle\n if (this.isIdle) {\n return\n }\n\n const interval = this.fullSnapshotIntervalMillis\n if (!interval) {\n return\n }\n\n this._fullSnapshotTimer = setInterval(() => {\n this._tryTakeFullSnapshot()\n }, interval)\n }\n\n private _gatherRRWebPlugins() {\n const plugins: RecordPlugin<unknown>[] = []\n\n const recordConsolePlugin = assignableWindow.__PosthogExtensions__?.rrwebPlugins?.getRecordConsolePlugin\n if (recordConsolePlugin && this.isConsoleLogCaptureEnabled) {\n plugins.push(recordConsolePlugin())\n }\n\n const networkPlugin = assignableWindow.__PosthogExtensions__?.rrwebPlugins?.getRecordNetworkPlugin\n if (this.networkPayloadCapture && isFunction(networkPlugin)) {\n const canRecordNetwork = !isLocalhost() || this._forceAllowLocalhostNetworkCapture\n\n if (canRecordNetwork) {\n plugins.push(\n networkPlugin(buildNetworkRequestOptions(this.instance.config, this.networkPayloadCapture))\n )\n } else {\n logger.info(LOGGER_PREFIX + ' NetworkCapture not started because we are on localhost.')\n }\n }\n\n return plugins\n }\n\n onRRwebEmit(rawEvent: eventWithTime) {\n this._processQueuedEvents()\n\n if (!rawEvent || !isObject(rawEvent)) {\n return\n }\n\n if (rawEvent.type === EventType.Meta) {\n const href = this._maskUrl(rawEvent.data.href)\n this._lastHref = href\n if (!href) {\n return\n }\n rawEvent.data.href = href\n } else {\n this._pageViewFallBack()\n }\n\n // we're processing a full snapshot, so we should reset the timer\n if (rawEvent.type === EventType.FullSnapshot) {\n this._scheduleFullSnapshot()\n }\n\n const throttledEvent = this.mutationRateLimiter\n ? this.mutationRateLimiter.throttleMutations(rawEvent)\n : rawEvent\n\n if (!throttledEvent) {\n return\n }\n\n // TODO: Re-add ensureMaxMessageSize once we are confident in it\n const event = truncateLargeConsoleLogs(throttledEvent)\n\n this._updateWindowAndSessionIds(event)\n\n // When in an idle state we keep recording, but don't capture the events,\n if (this.isIdle && !isSessionIdleEvent(event)) {\n return\n }\n\n if (isSessionIdleEvent(event)) {\n // session idle events have a timestamp when rrweb sees them\n // which can artificially lengthen a session\n // we know when we detected it based on the payload and can correct the timestamp\n const payload = event.data.payload as SessionIdlePayload\n if (payload) {\n const lastActivity = payload.lastActivityTimestamp\n const threshold = payload.threshold\n event.timestamp = lastActivity + threshold\n }\n }\n\n const eventToSend =\n this.instance.config.session_recording.compress_events ?? true ? compressEvent(event, this.instance) : event\n const size = estimateSize(eventToSend)\n\n const properties = {\n $snapshot_bytes: size,\n $snapshot_data: eventToSend,\n $session_id: this.sessionId,\n $window_id: this.windowId,\n }\n\n if (this.status !== 'disabled') {\n this._captureSnapshotBuffered(properties)\n } else {\n this.clearBuffer()\n }\n }\n\n private _pageViewFallBack() {\n if (this.instance.config.capture_pageview || !window) {\n return\n }\n const currentUrl = this._maskUrl(window.location.href)\n if (this._lastHref !== currentUrl) {\n this._tryAddCustomEvent('$url_changed', { href: currentUrl })\n this._lastHref = currentUrl\n }\n }\n\n private _processQueuedEvents() {\n if (this.queuedRRWebEvents.length) {\n // if rrweb isn't ready to accept events earlier then we queued them up\n // now that emit has been called rrweb should be ready to accept them\n // so, before we process this event, we try our queued events _once_ each\n // we don't want to risk queuing more things and never exiting this loop!\n // if they fail here, they'll be pushed into a new queue,\n // and tried on the next loop.\n // there is a risk of this queue growing in an uncontrolled manner,\n // so its length is limited elsewhere\n // for now this is to help us ensure we can capture events that happen\n // and try to identify more about when it is failing\n const itemsToProcess = [...this.queuedRRWebEvents]\n this.queuedRRWebEvents = []\n itemsToProcess.forEach((queuedRRWebEvent) => {\n if (Date.now() - queuedRRWebEvent.enqueuedAt <= TWO_SECONDS) {\n this._tryRRWebMethod(queuedRRWebEvent)\n }\n })\n }\n }\n\n private _maskUrl(url: string): string | undefined {\n const userSessionRecordingOptions = this.instance.config.session_recording\n\n if (userSessionRecordingOptions.maskNetworkRequestFn) {\n let networkRequest: NetworkRequest | null | undefined = {\n url,\n }\n\n // TODO we should deprecate this and use the same function for this masking and the rrweb/network plugin\n // TODO or deprecate this and provide a new clearer name so this would be `maskURLPerformanceFn` or similar\n networkRequest = userSessionRecordingOptions.maskNetworkRequestFn(networkRequest)\n\n return networkRequest?.url\n }\n\n return url\n }\n\n private clearBuffer(): SnapshotBuffer {\n this.buffer = {\n size: 0,\n data: [],\n sessionId: this.sessionId,\n windowId: this.windowId,\n }\n return this.buffer\n }\n\n private _flushBuffer(): SnapshotBuffer {\n if (this.flushBufferTimer) {\n clearTimeout(this.flushBufferTimer)\n this.flushBufferTimer = undefined\n }\n\n const minimumDuration = this.minimumDuration\n const sessionDuration = this.sessionDuration\n // if we have old data in the buffer but the session has rotated then the\n // session duration might be negative, in that case we want to flush the buffer\n const isPositiveSessionDuration = isNumber(sessionDuration) && sessionDuration >= 0\n const isBelowMinimumDuration =\n isNumber(minimumDuration) && isPositiveSessionDuration && sessionDuration < minimumDuration\n\n if (this.status === 'buffering' || isBelowMinimumDuration) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n return this.buffer\n }\n\n if (this.buffer.data.length > 0) {\n const snapshotEvents = splitBuffer(this.buffer)\n snapshotEvents.forEach((snapshotBuffer) => {\n this._captureSnapshot({\n $snapshot_bytes: snapshotBuffer.size,\n $snapshot_data: snapshotBuffer.data,\n $session_id: snapshotBuffer.sessionId,\n $window_id: snapshotBuffer.windowId,\n })\n })\n }\n\n // buffer is empty, we clear it in case the session id has changed\n return this.clearBuffer()\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.isIdle && // we never want to flush when idle\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 && !this.isIdle) {\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 _url: this.instance.requestRouter.endpointFor('api', this._endpoint),\n _noTruncate: true,\n _batchKey: SESSION_RECORDING_BATCH_KEY,\n skip_client_rate_limiting: true,\n })\n }\n\n /**\n * this ignores the linked flag config and causes capture to start\n * (if recording would have started had the flag been received i.e. it does not override other config).\n *\n * It is not usual to call this directly,\n * instead call `posthog.startSessionRecording({linked_flag: true})`\n * */\n public overrideLinkedFlag() {\n this._linkedFlagSeen = true\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sessionrecording.js","sourceRoot":"","sources":["../../../../src/extensions/replay/sessionrecording.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACH,yCAAyC,EACzC,kCAAkC,EAClC,qCAAqC,EACrC,4BAA4B,EAC5B,kCAAkC,EAClC,yCAAyC,EACzC,6BAA6B,GAChC,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACH,YAAY,EACZ,+BAA+B,EAG/B,WAAW,EACX,wBAAwB,GAC3B,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAEH,SAAS,EAET,iBAAiB,GAGpB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErD,IAAM,aAAa,GAAG,KAAK,CAAA;AAE3B,IAAM,YAAY,GAAG,IAAI,GAAG,EAAE,GAAG,CAAC,CAAA;AAClC,IAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,CAAC,IAAM,2BAA2B,GAAG,YAAY,CAAA;AACvD,IAAM,MAAM,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AChC,CAAC;IACL,CAAC;IAEO,2CAAgB,GAAxB,UAAyB,UAAsB;QAC3C,oGAAoG;QACpG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE;YAC3C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC;YACpE,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,2BAA2B;YACtC,yBAAyB,EAAE,IAAI;SAClC,CAAC,CAAA;IACN,CAAC;IAED;;;;;;SAMK;IACE,6CAAkB,GAAzB;QACI,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;IAC/B,CAAC;IACL,uBAAC;AAAD,CAAC,AAx4BD,IAw4BC","sourcesContent":["import {\n CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_CANVAS_RECORDING,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_IS_SAMPLED,\n SESSION_RECORDING_MINIMUM_DURATION,\n SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE,\n SESSION_RECORDING_SAMPLE_RATE,\n} from '../../constants'\nimport {\n estimateSize,\n INCREMENTAL_SNAPSHOT_EVENT_TYPE,\n recordOptions,\n rrwebRecord,\n splitBuffer,\n truncateLargeConsoleLogs,\n} from './sessionrecording-utils'\nimport { PostHog } from '../../posthog-core'\nimport { DecideResponse, FlagVariant, NetworkRecordOptions, NetworkRequest, Properties } from '../../types'\nimport {\n customEvent,\n EventType,\n type eventWithTime,\n IncrementalSource,\n type listenerHandler,\n RecordPlugin,\n} from '@rrweb/types'\n\nimport { isBoolean, isFunction, isNullish, isNumber, isObject, isString, isUndefined } from '../../utils/type-utils'\nimport { logger } from '../../utils/logger'\nimport { assignableWindow, document, window } from '../../utils/globals'\nimport { buildNetworkRequestOptions } from './config'\nimport { isLocalhost } from '../../utils/request-utils'\nimport { MutationRateLimiter } from './mutation-rate-limiter'\nimport { gzipSync, strFromU8, strToU8 } from 'fflate'\n\nconst BASE_ENDPOINT = '/s/'\n\nconst FIVE_MINUTES = 1000 * 60 * 5\nconst TWO_SECONDS = 2000\nexport const RECORDING_IDLE_THRESHOLD_MS = FIVE_MINUTES\nconst ONE_KB = 1024\nconst PARTIAL_COMPRESSION_THRESHOLD = ONE_KB\nexport const RECORDING_MAX_EVENT_SIZE = ONE_KB * ONE_KB * 0.9 // ~1mb (with some wiggle room)\nexport const RECORDING_BUFFER_TIMEOUT = 2000 // 2 seconds\nexport const SESSION_RECORDING_BATCH_KEY = 'recordings'\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\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\n/**\n * Session recording starts in buffering mode while waiting for decide response\n * Once the response is received it might be disabled, active or sampled\n * When sampled that means a sample rate is set and the last time the session id was rotated\n * the sample rate determined this session should be sent to the server.\n */\ntype SessionRecordingStatus = 'disabled' | 'sampled' | 'active' | 'buffering'\n\nexport interface SnapshotBuffer {\n size: number\n data: any[]\n sessionId: string\n windowId: string\n}\n\ninterface QueuedRRWebEvent {\n rrwebMethod: () => void\n attempt: number\n // the timestamp this was first put into this queue\n enqueuedAt: number\n}\n\ninterface SessionIdlePayload {\n eventTimestamp: number\n lastActivityTimestamp: number\n threshold: number\n bufferLength: number\n bufferSize: number\n}\n\nconst newQueuedEvent = (rrwebMethod: () => void): QueuedRRWebEvent => ({\n rrwebMethod,\n enqueuedAt: Date.now(),\n attempt: 1,\n})\n\nconst LOGGER_PREFIX = '[SessionRecording]'\n\ntype compressedFullSnapshotEvent = {\n type: EventType.FullSnapshot\n data: string\n}\n\ntype compressedIncrementalSnapshotEvent = {\n type: EventType.IncrementalSnapshot\n data: {\n source: IncrementalSource\n texts: string\n attributes: string\n removes: string\n adds: string\n }\n}\n\ntype compressedIncrementalStyleSnapshotEvent = {\n type: EventType.IncrementalSnapshot\n data: {\n source: IncrementalSource.StyleSheetRule\n id?: number\n styleId?: number\n replace?: string\n replaceSync?: string\n adds: string\n removes: string\n }\n}\n\nexport type compressedEvent =\n | compressedIncrementalStyleSnapshotEvent\n | compressedFullSnapshotEvent\n | compressedIncrementalSnapshotEvent\nexport type compressedEventWithTime = compressedEvent & {\n timestamp: number\n delay?: number\n // marker for compression version\n cv: '2024-10'\n}\n\nfunction gzipToString(data: unknown): string {\n return strFromU8(gzipSync(strToU8(JSON.stringify(data))), true)\n}\n\n// rrweb's packer takes an event and returns a string or the reverse on unpact,\n// but we want to be able to inspect metadata during ingestion, and don't want to compress the entire event\n// so we have a custom packer that only compresses part of some events\nfunction compressEvent(event: eventWithTime): eventWithTime | compressedEventWithTime {\n const originalSize = estimateSize(event)\n if (originalSize < PARTIAL_COMPRESSION_THRESHOLD) {\n return event\n }\n\n try {\n if (event.type === EventType.FullSnapshot) {\n return {\n ...event,\n data: gzipToString(event.data),\n cv: '2024-10',\n }\n }\n if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.Mutation) {\n return {\n ...event,\n cv: '2024-10',\n data: {\n ...event.data,\n texts: gzipToString(event.data.texts),\n attributes: gzipToString(event.data.attributes),\n removes: gzipToString(event.data.removes),\n adds: gzipToString(event.data.adds),\n },\n }\n }\n if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.StyleSheetRule) {\n return {\n ...event,\n cv: '2024-10',\n data: {\n ...event.data,\n adds: gzipToString(event.data.adds),\n removes: gzipToString(event.data.removes),\n },\n }\n }\n } catch (e) {\n logger.error(LOGGER_PREFIX + ' could not compress event - will use uncompressed event', e)\n }\n return event\n}\n\nfunction isSessionIdleEvent(e: eventWithTime): e is eventWithTime & customEvent {\n return e.type === EventType.Custom && e.data.tag === 'sessionIdle'\n}\n\nexport class SessionRecording {\n private _endpoint: string\n private flushBufferTimer?: any\n\n // we have a buffer - that contains PostHog snapshot events ready to be sent to the server\n private buffer: SnapshotBuffer\n // and a queue - that contains rrweb events that we want to send to rrweb, but rrweb wasn't able to accept them yet\n private queuedRRWebEvents: QueuedRRWebEvent[] = []\n\n private mutationRateLimiter?: MutationRateLimiter\n private _captureStarted: boolean\n private stopRrweb: listenerHandler | undefined\n private receivedDecide: boolean\n private isIdle = false\n\n private _linkedFlagSeen: boolean = false\n private _lastActivityTimestamp: number = Date.now()\n private windowId: string\n private sessionId: string\n private _linkedFlag: string | FlagVariant | null = null\n\n private _fullSnapshotTimer?: ReturnType<typeof setInterval>\n\n private _removePageViewCaptureHook: (() => void) | undefined = undefined\n private _onSessionIdListener: (() => void) | undefined = undefined\n private _persistDecideOnSessionListener: (() => void) | undefined = undefined\n private _samplingSessionListener: (() => void) | undefined = undefined\n\n // if pageview capture is disabled\n // then we can manually track href changes\n private _lastHref?: string\n\n // Util to help developers working on this feature manually override\n _forceAllowLocalhostNetworkCapture = false\n\n private get sessionIdleThresholdMilliseconds(): number {\n return this.instance.config.session_recording.session_idle_threshold_ms || RECORDING_IDLE_THRESHOLD_MS\n }\n\n private get rrwebRecord(): rrwebRecord | undefined {\n return assignableWindow?.__PosthogExtensions__?.rrweb?.record\n }\n\n public get started(): boolean {\n // TODO could we use status instead of _captureStarted?\n return this._captureStarted\n }\n\n private get sessionManager() {\n if (!this.instance.sessionManager) {\n throw new Error(LOGGER_PREFIX + ' must be started with a valid sessionManager.')\n }\n\n return this.instance.sessionManager\n }\n\n private get fullSnapshotIntervalMillis(): number {\n return this.instance.config.session_recording?.full_snapshot_interval_millis || FIVE_MINUTES\n }\n\n private get isSampled(): boolean | null {\n const currentValue = this.instance.get_property(SESSION_RECORDING_IS_SAMPLED)\n return isBoolean(currentValue) ? currentValue : null\n }\n\n private get sessionDuration(): number | null {\n const mostRecentSnapshot = this.buffer?.data[this.buffer?.data.length - 1]\n const { sessionStartTimestamp } = this.sessionManager.checkAndGetSessionAndWindowId(true)\n return mostRecentSnapshot ? mostRecentSnapshot.timestamp - sessionStartTimestamp : null\n }\n\n private get isRecordingEnabled() {\n const enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = !this.instance.config.disable_session_recording\n return window && enabled_server_side && enabled_client_side\n }\n\n private get isConsoleLogCaptureEnabled() {\n const enabled_server_side = !!this.instance.get_property(CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = this.instance.config.enable_recording_console_log\n return enabled_client_side ?? enabled_server_side\n }\n\n private get canvasRecording(): { enabled: boolean; fps: number; quality: number } | undefined {\n const canvasRecording_server_side = this.instance.get_property(SESSION_RECORDING_CANVAS_RECORDING)\n return canvasRecording_server_side && canvasRecording_server_side.fps && canvasRecording_server_side.quality\n ? {\n enabled: canvasRecording_server_side.enabled,\n fps: canvasRecording_server_side.fps,\n quality: canvasRecording_server_side.quality,\n }\n : undefined\n }\n\n // network payload capture config has three parts\n // each can be configured server side or client side\n private get networkPayloadCapture():\n | Pick<NetworkRecordOptions, 'recordHeaders' | 'recordBody' | 'recordPerformance'>\n | undefined {\n const networkPayloadCapture_server_side = this.instance.get_property(SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE)\n const networkPayloadCapture_client_side = {\n recordHeaders: this.instance.config.session_recording?.recordHeaders,\n recordBody: this.instance.config.session_recording?.recordBody,\n }\n const headersEnabled =\n networkPayloadCapture_client_side?.recordHeaders || networkPayloadCapture_server_side?.recordHeaders\n const bodyEnabled =\n networkPayloadCapture_client_side?.recordBody || networkPayloadCapture_server_side?.recordBody\n const clientConfigForPerformanceCapture = isObject(this.instance.config.capture_performance)\n ? this.instance.config.capture_performance.network_timing\n : this.instance.config.capture_performance\n const networkTimingEnabled = !!(isBoolean(clientConfigForPerformanceCapture)\n ? clientConfigForPerformanceCapture\n : networkPayloadCapture_server_side?.capturePerformance)\n\n return headersEnabled || bodyEnabled || networkTimingEnabled\n ? { recordHeaders: headersEnabled, recordBody: bodyEnabled, recordPerformance: networkTimingEnabled }\n : undefined\n }\n\n private get sampleRate(): number | null {\n const rate = this.instance.get_property(SESSION_RECORDING_SAMPLE_RATE)\n return isNumber(rate) ? rate : null\n }\n\n private get minimumDuration(): number | null {\n const duration = this.instance.get_property(SESSION_RECORDING_MINIMUM_DURATION)\n return isNumber(duration) ? duration : null\n }\n\n /**\n * defaults to buffering mode until a decide response is received\n * once a decide response is received status can be disabled, active or sampled\n */\n private get status(): SessionRecordingStatus {\n if (!this.receivedDecide) {\n return 'buffering'\n }\n\n if (!this.isRecordingEnabled) {\n return 'disabled'\n }\n\n if (!isNullish(this._linkedFlag) && !this._linkedFlagSeen) {\n return 'buffering'\n }\n\n if (isBoolean(this.isSampled)) {\n return this.isSampled ? 'sampled' : 'disabled'\n } else {\n return 'active'\n }\n }\n\n constructor(private readonly instance: PostHog) {\n this._captureStarted = false\n this._endpoint = BASE_ENDPOINT\n this.stopRrweb = undefined\n this.receivedDecide = false\n\n if (!this.instance.sessionManager) {\n logger.error(LOGGER_PREFIX + ' started without valid sessionManager')\n throw new Error(LOGGER_PREFIX + ' started without valid sessionManager. This is a bug.')\n }\n\n // we know there's a sessionManager, so don't need to start without a session id\n const { sessionId, windowId } = this.sessionManager.checkAndGetSessionAndWindowId()\n this.sessionId = sessionId\n this.windowId = windowId\n\n this.buffer = this.clearBuffer()\n\n if (this.sessionIdleThresholdMilliseconds >= this.sessionManager.sessionTimeoutMs) {\n logger.warn(\n LOGGER_PREFIX +\n ` session_idle_threshold_ms (${this.sessionIdleThresholdMilliseconds}) is greater than the session timeout (${this.sessionManager.sessionTimeoutMs}). Session will never be detected as idle`\n )\n }\n }\n\n private _onBeforeUnload = (): void => {\n this._flushBuffer()\n }\n\n private _onOffline = (): void => {\n this._tryAddCustomEvent('browser offline', {})\n }\n\n private _onOnline = (): void => {\n this._tryAddCustomEvent('browser online', {})\n }\n\n private _onVisibilityChange = (): void => {\n if (document?.visibilityState) {\n const label = 'window ' + document.visibilityState\n this._tryAddCustomEvent(label, {})\n }\n }\n\n startIfEnabledOrStop() {\n if (this.isRecordingEnabled) {\n this._startCapture()\n\n // calling addEventListener multiple times is safe and will not add duplicates\n window?.addEventListener('beforeunload', this._onBeforeUnload)\n window?.addEventListener('offline', this._onOffline)\n window?.addEventListener('online', this._onOnline)\n window?.addEventListener('visibilitychange', this._onVisibilityChange)\n\n // on reload there might be an already sampled session that should be continued before decide response,\n // so we call this here _and_ in the decide response\n this._setupSampling()\n\n if (isNullish(this._removePageViewCaptureHook)) {\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._removePageViewCaptureHook = this.instance._addCaptureHook((eventName) => {\n // If anything could go wrong here it has the potential to block the main loop,\n // so we catch all errors.\n try {\n if (eventName === '$pageview') {\n const href = window ? this._maskUrl(window.location.href) : ''\n if (!href) {\n return\n }\n this._tryAddCustomEvent('$pageview', { href })\n }\n } catch (e) {\n logger.error('Could not add $pageview to rrweb session', e)\n }\n })\n }\n\n if (!this._onSessionIdListener) {\n this._onSessionIdListener = this.sessionManager.onSessionId((sessionId, windowId, changeReason) => {\n if (changeReason) {\n this._tryAddCustomEvent('$session_id_change', { sessionId, windowId, changeReason })\n }\n })\n }\n } else {\n this.stopRecording()\n }\n }\n\n stopRecording() {\n if (this._captureStarted && this.stopRrweb) {\n this.stopRrweb()\n this.stopRrweb = undefined\n this._captureStarted = false\n\n window?.removeEventListener('beforeunload', this._onBeforeUnload)\n window?.removeEventListener('offline', this._onOffline)\n window?.removeEventListener('online', this._onOnline)\n window?.removeEventListener('visibilitychange', this._onVisibilityChange)\n\n this.clearBuffer()\n clearInterval(this._fullSnapshotTimer)\n\n this._removePageViewCaptureHook?.()\n this._removePageViewCaptureHook = undefined\n this._onSessionIdListener?.()\n this._onSessionIdListener = undefined\n this._samplingSessionListener?.()\n this._samplingSessionListener = undefined\n\n logger.info(LOGGER_PREFIX + ' stopped')\n }\n }\n\n private makeSamplingDecision(sessionId: string): void {\n const sessionIdChanged = this.sessionId !== sessionId\n\n // capture the current sample rate,\n // because it is re-used multiple times\n // and the bundler won't minimise any of the references\n const currentSampleRate = this.sampleRate\n\n if (!isNumber(currentSampleRate)) {\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: null,\n })\n return\n }\n\n const storedIsSampled = this.isSampled\n\n /**\n * if we get this far then we should make a sampling decision.\n * When the session id changes or there is no stored sampling decision for this session id\n * then we should make a new decision.\n *\n * Otherwise, we should use the stored decision.\n */\n let shouldSample: boolean\n const makeDecision = sessionIdChanged || !isBoolean(storedIsSampled)\n if (makeDecision) {\n const randomNumber = Math.random()\n shouldSample = randomNumber < currentSampleRate\n } else {\n shouldSample = storedIsSampled\n }\n\n if (!shouldSample && makeDecision) {\n logger.warn(\n LOGGER_PREFIX +\n ` Sample rate (${currentSampleRate}) has determined that this sessionId (${sessionId}) will not be sent to the server.`\n )\n }\n this._tryAddCustomEvent('samplingDecisionMade', {\n sampleRate: currentSampleRate,\n })\n\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: shouldSample,\n })\n }\n\n afterDecideResponse(response: DecideResponse) {\n this._persistDecideResponse(response)\n\n this._linkedFlag = response.sessionRecording?.linkedFlag || null\n\n if (response.sessionRecording?.endpoint) {\n this._endpoint = response.sessionRecording?.endpoint\n }\n\n this._setupSampling()\n\n if (!isNullish(this._linkedFlag) && !this._linkedFlagSeen) {\n const linkedFlag = isString(this._linkedFlag) ? this._linkedFlag : this._linkedFlag.flag\n const linkedVariant = isString(this._linkedFlag) ? null : this._linkedFlag.variant\n this.instance.onFeatureFlags((_flags, variants) => {\n const flagIsPresent = isObject(variants) && linkedFlag in variants\n const linkedFlagMatches = linkedVariant ? variants[linkedFlag] === linkedVariant : flagIsPresent\n if (linkedFlagMatches) {\n const payload = {\n linkedFlag,\n linkedVariant,\n }\n const tag = 'linked flag matched'\n logger.info(LOGGER_PREFIX + ' ' + tag, payload)\n this._tryAddCustomEvent(tag, payload)\n }\n this._linkedFlagSeen = linkedFlagMatches\n })\n }\n\n this.receivedDecide = true\n this.startIfEnabledOrStop()\n }\n\n /**\n * This might be called more than once so needs to be idempotent\n */\n private _setupSampling() {\n if (isNumber(this.sampleRate) && isNullish(this._samplingSessionListener)) {\n this._samplingSessionListener = this.sessionManager.onSessionId((sessionId) => {\n this.makeSamplingDecision(sessionId)\n })\n }\n }\n\n private _persistDecideResponse(response: DecideResponse): void {\n if (this.instance.persistence) {\n const persistence = this.instance.persistence\n\n const persistResponse = () => {\n const receivedSampleRate = response.sessionRecording?.sampleRate\n\n const parsedSampleRate = isNullish(receivedSampleRate) ? null : parseFloat(receivedSampleRate)\n const receivedMinimumDuration = response.sessionRecording?.minimumDurationMilliseconds\n\n persistence.register({\n [SESSION_RECORDING_ENABLED_SERVER_SIDE]: !!response['sessionRecording'],\n [CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE]: response.sessionRecording?.consoleLogRecordingEnabled,\n [SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE]: {\n capturePerformance: response.capturePerformance,\n ...response.sessionRecording?.networkPayloadCapture,\n },\n [SESSION_RECORDING_CANVAS_RECORDING]: {\n enabled: response.sessionRecording?.recordCanvas,\n fps: response.sessionRecording?.canvasFps,\n quality: response.sessionRecording?.canvasQuality,\n },\n [SESSION_RECORDING_SAMPLE_RATE]: parsedSampleRate,\n [SESSION_RECORDING_MINIMUM_DURATION]: isUndefined(receivedMinimumDuration)\n ? null\n : receivedMinimumDuration,\n })\n }\n\n persistResponse()\n\n // in case we see multiple decide responses, we should only listen with the response from the most recent one\n this._persistDecideOnSessionListener?.()\n this._persistDecideOnSessionListener = this.sessionManager.onSessionId(persistResponse)\n }\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 that's what rrweb expects\n payload: [JSON.stringify(message)],\n },\n },\n timestamp: Date.now(),\n })\n }\n\n private _startCapture() {\n if (isUndefined(Object.assign)) {\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 // do not start if explicitly disabled or if the user has opted out\n if (\n this._captureStarted ||\n this.instance.config.disable_session_recording ||\n this.instance.consent.isOptedOut()\n ) {\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.sessionManager.checkAndGetSessionAndWindowId()\n\n // If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is\n // imported), don't load script. Otherwise, remotely import recorder.js from cdn since it hasn't been loaded.\n if (!this.rrwebRecord) {\n assignableWindow.__PosthogExtensions__?.loadExternalDependency?.(this.instance, 'recorder', (err) => {\n if (err) {\n return logger.error(LOGGER_PREFIX + ` could not load recorder`, err)\n }\n\n this._onScriptLoaded()\n })\n } else {\n this._onScriptLoaded()\n }\n }\n\n private isInteractiveEvent(event: eventWithTime) {\n return (\n event.type === INCREMENTAL_SNAPSHOT_EVENT_TYPE &&\n ACTIVE_SOURCES.indexOf(event.data?.source as IncrementalSource) !== -1\n )\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 const timeSinceLastActivity = event.timestamp - this._lastActivityTimestamp\n if (timeSinceLastActivity > this.sessionIdleThresholdMilliseconds) {\n // we mark as idle right away,\n // or else we get multiple idle events\n // if there are lots of non-user activity events being emitted\n this.isIdle = true\n\n // don't take full snapshots while idle\n clearInterval(this._fullSnapshotTimer)\n\n this._tryAddCustomEvent('sessionIdle', {\n eventTimestamp: event.timestamp,\n lastActivityTimestamp: this._lastActivityTimestamp,\n threshold: this.sessionIdleThresholdMilliseconds,\n bufferLength: this.buffer.data.length,\n bufferSize: this.buffer.size,\n })\n\n // proactively flush the buffer in case the session is idle for a long time\n this._flushBuffer()\n }\n }\n\n let returningFromIdle = false\n if (isUserInteraction) {\n this._lastActivityTimestamp = event.timestamp\n if (this.isIdle) {\n // Remove the idle state\n this.isIdle = false\n this._tryAddCustomEvent('sessionNoLongerIdle', {\n reason: 'user activity',\n type: event.type,\n })\n returningFromIdle = true\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.sessionManager.checkAndGetSessionAndWindowId(\n !isUserInteraction,\n event.timestamp\n )\n\n const sessionIdChanged = this.sessionId !== sessionId\n const windowIdChanged = this.windowId !== windowId\n\n this.windowId = windowId\n this.sessionId = sessionId\n\n if (sessionIdChanged || windowIdChanged) {\n this.stopRecording()\n this.startIfEnabledOrStop()\n } else if (returningFromIdle) {\n this._scheduleFullSnapshot()\n }\n }\n\n private _tryRRWebMethod(queuedRRWebEvent: QueuedRRWebEvent): boolean {\n try {\n queuedRRWebEvent.rrwebMethod()\n return true\n } catch (e) {\n // Sometimes a race can occur where the recorder is not fully started yet\n if (this.queuedRRWebEvents.length < 10) {\n this.queuedRRWebEvents.push({\n enqueuedAt: queuedRRWebEvent.enqueuedAt || Date.now(),\n attempt: queuedRRWebEvent.attempt++,\n rrwebMethod: queuedRRWebEvent.rrwebMethod,\n })\n } else {\n logger.warn(LOGGER_PREFIX + ' could not emit queued rrweb event.', e, queuedRRWebEvent)\n }\n\n return false\n }\n }\n\n private _tryAddCustomEvent(tag: string, payload: any): boolean {\n return this._tryRRWebMethod(newQueuedEvent(() => this.rrwebRecord!.addCustomEvent(tag, payload)))\n }\n\n private _tryTakeFullSnapshot(): boolean {\n return this._tryRRWebMethod(newQueuedEvent(() => this.rrwebRecord!.takeFullSnapshot()))\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: { password: true },\n maskInputFn: undefined,\n slimDOMOptions: {},\n collectFonts: false,\n inlineStylesheet: true,\n recordCrossOriginIframes: false,\n }\n\n // only allows user to set our allow-listed options\n const userSessionRecordingOptions = this.instance.config.session_recording\n for (const [key, value] of Object.entries(userSessionRecordingOptions || {})) {\n if (key in sessionRecordingOptions) {\n if (key === 'maskInputOptions') {\n // ensure password is set if not included\n sessionRecordingOptions.maskInputOptions = { password: true, ...value }\n } else {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n sessionRecordingOptions[key] = value\n }\n }\n }\n\n if (this.canvasRecording && this.canvasRecording.enabled) {\n sessionRecordingOptions.recordCanvas = true\n sessionRecordingOptions.sampling = { canvas: this.canvasRecording.fps }\n sessionRecordingOptions.dataURLOptions = { type: 'image/webp', quality: this.canvasRecording.quality }\n }\n\n if (!this.rrwebRecord) {\n logger.error(\n LOGGER_PREFIX +\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.info(message, {\n node: node,\n })\n\n this.log(LOGGER_PREFIX + ' ' + message, 'warn')\n },\n })\n\n const activePlugins = this._gatherRRWebPlugins()\n this.stopRrweb = this.rrwebRecord({\n emit: (event) => {\n this.onRRwebEmit(event)\n },\n plugins: activePlugins,\n ...sessionRecordingOptions,\n })\n\n // We reset the last activity timestamp, resetting the idle timer\n this._lastActivityTimestamp = Date.now()\n this.isIdle = false\n\n this._tryAddCustomEvent('$session_options', {\n sessionRecordingOptions,\n activePlugins: activePlugins.map((p) => p?.name),\n })\n\n this._tryAddCustomEvent('$posthog_config', {\n config: this.instance.config,\n })\n\n logger.info(LOGGER_PREFIX + ' started', {\n idleThreshold: this.sessionIdleThresholdMilliseconds,\n maxIdleTime: this.sessionManager.sessionTimeoutMs,\n })\n }\n\n private _scheduleFullSnapshot(): void {\n if (this._fullSnapshotTimer) {\n clearInterval(this._fullSnapshotTimer)\n }\n // we don't schedule snapshots while idle\n if (this.isIdle) {\n return\n }\n\n const interval = this.fullSnapshotIntervalMillis\n if (!interval) {\n return\n }\n\n this._fullSnapshotTimer = setInterval(() => {\n this._tryTakeFullSnapshot()\n }, interval)\n }\n\n private _gatherRRWebPlugins() {\n const plugins: RecordPlugin<unknown>[] = []\n\n const recordConsolePlugin = assignableWindow.__PosthogExtensions__?.rrwebPlugins?.getRecordConsolePlugin\n if (recordConsolePlugin && this.isConsoleLogCaptureEnabled) {\n plugins.push(recordConsolePlugin())\n }\n\n const networkPlugin = assignableWindow.__PosthogExtensions__?.rrwebPlugins?.getRecordNetworkPlugin\n if (this.networkPayloadCapture && isFunction(networkPlugin)) {\n const canRecordNetwork = !isLocalhost() || this._forceAllowLocalhostNetworkCapture\n\n if (canRecordNetwork) {\n plugins.push(\n networkPlugin(buildNetworkRequestOptions(this.instance.config, this.networkPayloadCapture))\n )\n } else {\n logger.info(LOGGER_PREFIX + ' NetworkCapture not started because we are on localhost.')\n }\n }\n\n return plugins\n }\n\n onRRwebEmit(rawEvent: eventWithTime) {\n this._processQueuedEvents()\n\n if (!rawEvent || !isObject(rawEvent)) {\n return\n }\n\n if (rawEvent.type === EventType.Meta) {\n const href = this._maskUrl(rawEvent.data.href)\n this._lastHref = href\n if (!href) {\n return\n }\n rawEvent.data.href = href\n } else {\n this._pageViewFallBack()\n }\n\n // we're processing a full snapshot, so we should reset the timer\n if (rawEvent.type === EventType.FullSnapshot) {\n this._scheduleFullSnapshot()\n }\n\n const throttledEvent = this.mutationRateLimiter\n ? this.mutationRateLimiter.throttleMutations(rawEvent)\n : rawEvent\n\n if (!throttledEvent) {\n return\n }\n\n // TODO: Re-add ensureMaxMessageSize once we are confident in it\n const event = truncateLargeConsoleLogs(throttledEvent)\n\n this._updateWindowAndSessionIds(event)\n\n // When in an idle state we keep recording, but don't capture the events,\n if (this.isIdle && !isSessionIdleEvent(event)) {\n return\n }\n\n if (isSessionIdleEvent(event)) {\n // session idle events have a timestamp when rrweb sees them\n // which can artificially lengthen a session\n // we know when we detected it based on the payload and can correct the timestamp\n const payload = event.data.payload as SessionIdlePayload\n if (payload) {\n const lastActivity = payload.lastActivityTimestamp\n const threshold = payload.threshold\n event.timestamp = lastActivity + threshold\n }\n }\n\n const eventToSend =\n this.instance.config.session_recording.compress_events ?? true ? compressEvent(event) : event\n const size = estimateSize(eventToSend)\n\n const properties = {\n $snapshot_bytes: size,\n $snapshot_data: eventToSend,\n $session_id: this.sessionId,\n $window_id: this.windowId,\n }\n\n if (this.status !== 'disabled') {\n this._captureSnapshotBuffered(properties)\n } else {\n this.clearBuffer()\n }\n }\n\n private _pageViewFallBack() {\n if (this.instance.config.capture_pageview || !window) {\n return\n }\n const currentUrl = this._maskUrl(window.location.href)\n if (this._lastHref !== currentUrl) {\n this._tryAddCustomEvent('$url_changed', { href: currentUrl })\n this._lastHref = currentUrl\n }\n }\n\n private _processQueuedEvents() {\n if (this.queuedRRWebEvents.length) {\n // if rrweb isn't ready to accept events earlier then we queued them up\n // now that emit has been called rrweb should be ready to accept them\n // so, before we process this event, we try our queued events _once_ each\n // we don't want to risk queuing more things and never exiting this loop!\n // if they fail here, they'll be pushed into a new queue,\n // and tried on the next loop.\n // there is a risk of this queue growing in an uncontrolled manner,\n // so its length is limited elsewhere\n // for now this is to help us ensure we can capture events that happen\n // and try to identify more about when it is failing\n const itemsToProcess = [...this.queuedRRWebEvents]\n this.queuedRRWebEvents = []\n itemsToProcess.forEach((queuedRRWebEvent) => {\n if (Date.now() - queuedRRWebEvent.enqueuedAt <= TWO_SECONDS) {\n this._tryRRWebMethod(queuedRRWebEvent)\n }\n })\n }\n }\n\n private _maskUrl(url: string): string | undefined {\n const userSessionRecordingOptions = this.instance.config.session_recording\n\n if (userSessionRecordingOptions.maskNetworkRequestFn) {\n let networkRequest: NetworkRequest | null | undefined = {\n url,\n }\n\n // TODO we should deprecate this and use the same function for this masking and the rrweb/network plugin\n // TODO or deprecate this and provide a new clearer name so this would be `maskURLPerformanceFn` or similar\n networkRequest = userSessionRecordingOptions.maskNetworkRequestFn(networkRequest)\n\n return networkRequest?.url\n }\n\n return url\n }\n\n private clearBuffer(): SnapshotBuffer {\n this.buffer = {\n size: 0,\n data: [],\n sessionId: this.sessionId,\n windowId: this.windowId,\n }\n return this.buffer\n }\n\n private _flushBuffer(): SnapshotBuffer {\n if (this.flushBufferTimer) {\n clearTimeout(this.flushBufferTimer)\n this.flushBufferTimer = undefined\n }\n\n const minimumDuration = this.minimumDuration\n const sessionDuration = this.sessionDuration\n // if we have old data in the buffer but the session has rotated then the\n // session duration might be negative, in that case we want to flush the buffer\n const isPositiveSessionDuration = isNumber(sessionDuration) && sessionDuration >= 0\n const isBelowMinimumDuration =\n isNumber(minimumDuration) && isPositiveSessionDuration && sessionDuration < minimumDuration\n\n if (this.status === 'buffering' || isBelowMinimumDuration) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n return this.buffer\n }\n\n if (this.buffer.data.length > 0) {\n const snapshotEvents = splitBuffer(this.buffer)\n snapshotEvents.forEach((snapshotBuffer) => {\n this._captureSnapshot({\n $snapshot_bytes: snapshotBuffer.size,\n $snapshot_data: snapshotBuffer.data,\n $session_id: snapshotBuffer.sessionId,\n $window_id: snapshotBuffer.windowId,\n })\n })\n }\n\n // buffer is empty, we clear it in case the session id has changed\n return this.clearBuffer()\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.isIdle && // we never want to flush when idle\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 && !this.isIdle) {\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 _url: this.instance.requestRouter.endpointFor('api', this._endpoint),\n _noTruncate: true,\n _batchKey: SESSION_RECORDING_BATCH_KEY,\n skip_client_rate_limiting: true,\n })\n }\n\n /**\n * this ignores the linked flag config and causes capture to start\n * (if recording would have started had the flag been received i.e. it does not override other config).\n *\n * It is not usual to call this directly,\n * instead call `posthog.startSessionRecording({linked_flag: true})`\n * */\n public overrideLinkedFlag() {\n this._linkedFlagSeen = true\n }\n}\n"]}
|
package/package.json
CHANGED