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/es.js CHANGED
@@ -917,7 +917,7 @@ var LZString = {
917
917
  }
918
918
  };
919
919
 
920
- var version = "1.45.1";
920
+ var version = "1.46.0";
921
921
 
922
922
  // e.g. Config.DEBUG = Config.DEBUG || instance.get_config('debug')
923
923
 
@@ -3990,7 +3990,7 @@ var SessionRecording = /*#__PURE__*/function () {
3990
3990
  }, {
3991
3991
  key: "afterDecideResponse",
3992
3992
  value: function afterDecideResponse(response) {
3993
- var _response$sessionReco2;
3993
+ var _response$sessionReco2, _response$sessionReco4;
3994
3994
 
3995
3995
  this.receivedDecide = true;
3996
3996
 
@@ -4006,6 +4006,10 @@ var SessionRecording = /*#__PURE__*/function () {
4006
4006
  this.endpoint = (_response$sessionReco3 = response.sessionRecording) === null || _response$sessionReco3 === void 0 ? void 0 : _response$sessionReco3.endpoint;
4007
4007
  }
4008
4008
 
4009
+ if ((_response$sessionReco4 = response.sessionRecording) !== null && _response$sessionReco4 !== void 0 && _response$sessionReco4.recorderVersion) {
4010
+ this.recorderVersion = response.sessionRecording.recorderVersion;
4011
+ }
4012
+
4009
4013
  this.startRecordingIfEnabled();
4010
4014
  }
4011
4015
  }, {
@@ -4039,11 +4043,15 @@ var SessionRecording = /*#__PURE__*/function () {
4039
4043
  }
4040
4044
 
4041
4045
  if (!this.captureStarted && !this.instance.get_config('disable_session_recording')) {
4046
+ var userSessionRecordingOptions = this.instance.get_config('session_recording'); // Always use the client side setting if given, otherwise use the server side setting
4047
+
4048
+ this.recorderVersion = (userSessionRecordingOptions === null || userSessionRecordingOptions === void 0 ? void 0 : userSessionRecordingOptions.recorderVersion) || this.recorderVersion;
4049
+ var recorderJS = this.recorderVersion === 'v2' ? 'recorder-v2.js' : 'recorder.js';
4042
4050
  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.
4043
4051
  // Otherwise, remotely import recorder.js from cdn since it hasn't been loaded
4044
4052
 
4045
4053
  if (!this.instance.__loaded_recorder) {
4046
- loadScript(this.instance.get_config('api_host') + '/static/recorder.js?v=' + Config.LIB_VERSION, this._onScriptLoaded.bind(this));
4054
+ loadScript(this.instance.get_config('api_host') + "/static/".concat(recorderJS, "?v=").concat(Config.LIB_VERSION), this._onScriptLoaded.bind(this));
4047
4055
  }
4048
4056
 
4049
4057
  this._onScriptLoaded();