posthog-js 1.45.1 → 1.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.d.ts CHANGED
@@ -252,6 +252,7 @@ interface SessionRecordingOptions {
252
252
  slimDOMOptions?: SlimDOMOptions | 'all' | true;
253
253
  collectFonts?: boolean;
254
254
  inlineStylesheet?: boolean;
255
+ recorderVersion?: 'v1' | 'v2';
255
256
  }
256
257
  declare enum Compression {
257
258
  GZipJS = "gzip-js",
@@ -310,6 +311,7 @@ interface DecideResponse {
310
311
  sessionRecording?: {
311
312
  endpoint?: string;
312
313
  consoleLogRecordingEnabled?: boolean;
314
+ recorderVersion?: 'v1' | 'v2';
313
315
  };
314
316
  toolbarParams: ToolbarParams;
315
317
  editorParams?: ToolbarParams; /** @deprecated, renamed to toolbarParams, still present on older API responses */
@@ -849,6 +851,7 @@ declare class SessionRecording {
849
851
  sessionId: string | null;
850
852
  receivedDecide: boolean;
851
853
  rrwebRecord: typeof record | undefined;
854
+ recorderVersion?: string;
852
855
  constructor(instance: PostHog);
853
856
  startRecordingIfEnabled(): void;
854
857
  started(): boolean;
package/dist/module.js CHANGED
@@ -921,7 +921,7 @@ var LZString = {
921
921
  }
922
922
  };
923
923
 
924
- var version = "1.45.1";
924
+ var version = "1.46.0";
925
925
 
926
926
  // e.g. Config.DEBUG = Config.DEBUG || instance.get_config('debug')
927
927
 
@@ -3994,7 +3994,7 @@ var SessionRecording = /*#__PURE__*/function () {
3994
3994
  }, {
3995
3995
  key: "afterDecideResponse",
3996
3996
  value: function afterDecideResponse(response) {
3997
- var _response$sessionReco2;
3997
+ var _response$sessionReco2, _response$sessionReco4;
3998
3998
 
3999
3999
  this.receivedDecide = true;
4000
4000
 
@@ -4010,6 +4010,10 @@ var SessionRecording = /*#__PURE__*/function () {
4010
4010
  this.endpoint = (_response$sessionReco3 = response.sessionRecording) === null || _response$sessionReco3 === void 0 ? void 0 : _response$sessionReco3.endpoint;
4011
4011
  }
4012
4012
 
4013
+ if ((_response$sessionReco4 = response.sessionRecording) !== null && _response$sessionReco4 !== void 0 && _response$sessionReco4.recorderVersion) {
4014
+ this.recorderVersion = response.sessionRecording.recorderVersion;
4015
+ }
4016
+
4013
4017
  this.startRecordingIfEnabled();
4014
4018
  }
4015
4019
  }, {
@@ -4043,11 +4047,15 @@ var SessionRecording = /*#__PURE__*/function () {
4043
4047
  }
4044
4048
 
4045
4049
  if (!this.captureStarted && !this.instance.get_config('disable_session_recording')) {
4050
+ var userSessionRecordingOptions = this.instance.get_config('session_recording'); // Always use the client side setting if given, otherwise use the server side setting
4051
+
4052
+ this.recorderVersion = (userSessionRecordingOptions === null || userSessionRecordingOptions === void 0 ? void 0 : userSessionRecordingOptions.recorderVersion) || this.recorderVersion;
4053
+ var recorderJS = this.recorderVersion === 'v2' ? 'recorder-v2.js' : 'recorder.js';
4046
4054
  this.captureStarted = true; // If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is imported), don't load script.
4047
4055
  // Otherwise, remotely import recorder.js from cdn since it hasn't been loaded
4048
4056
 
4049
4057
  if (!this.instance.__loaded_recorder) {
4050
- loadScript(this.instance.get_config('api_host') + '/static/recorder.js?v=' + Config.LIB_VERSION, this._onScriptLoaded.bind(this));
4058
+ loadScript(this.instance.get_config('api_host') + "/static/".concat(recorderJS, "?v=").concat(Config.LIB_VERSION), this._onScriptLoaded.bind(this));
4051
4059
  }
4052
4060
 
4053
4061
  this._onScriptLoaded();