posthog-js 1.45.0 → 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/CHANGELOG.md +10 -0
- package/dist/array.full.js +12 -12
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/es.js +40 -25
- package/dist/es.js.map +1 -1
- package/dist/module.d.ts +30 -18
- package/dist/module.js +40 -25
- package/dist/module.js.map +1 -1
- package/dist/recorder-v2.js +19 -0
- package/dist/recorder-v2.js.map +1 -0
- package/dist/recorder.js +12 -12
- package/dist/recorder.js.map +1 -1
- package/lib/package.json +3 -2
- package/package.json +3 -2
- package/react/package.json +3 -0
package/dist/es.js
CHANGED
|
@@ -917,7 +917,7 @@ var LZString = {
|
|
|
917
917
|
}
|
|
918
918
|
};
|
|
919
919
|
|
|
920
|
-
var version = "1.
|
|
920
|
+
var version = "1.46.0";
|
|
921
921
|
|
|
922
922
|
// e.g. Config.DEBUG = Config.DEBUG || instance.get_config('debug')
|
|
923
923
|
|
|
@@ -3581,7 +3581,7 @@ var PostHogPersistence = /*#__PURE__*/function () {
|
|
|
3581
3581
|
this.storage = cookieStore;
|
|
3582
3582
|
}
|
|
3583
3583
|
|
|
3584
|
-
this.user_state =
|
|
3584
|
+
this.user_state = 'anonymous';
|
|
3585
3585
|
this.load();
|
|
3586
3586
|
this.update_config(config);
|
|
3587
3587
|
this.save();
|
|
@@ -3830,7 +3830,7 @@ var PostHogPersistence = /*#__PURE__*/function () {
|
|
|
3830
3830
|
}, {
|
|
3831
3831
|
key: "get_user_state",
|
|
3832
3832
|
value: function get_user_state() {
|
|
3833
|
-
return this.props[USER_STATE];
|
|
3833
|
+
return this.props[USER_STATE] || 'anonymous';
|
|
3834
3834
|
}
|
|
3835
3835
|
}, {
|
|
3836
3836
|
key: "set_user_state",
|
|
@@ -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') +
|
|
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();
|
|
@@ -7386,7 +7394,7 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
7386
7394
|
/**
|
|
7387
7395
|
* Identify a user with a unique ID instead of a PostHog
|
|
7388
7396
|
* randomly generated distinct_id. If the method is never called,
|
|
7389
|
-
* then unique visitors will be identified by a UUID generated
|
|
7397
|
+
* then unique visitors will be identified by a UUID that is generated
|
|
7390
7398
|
* the first time they visit the site.
|
|
7391
7399
|
*
|
|
7392
7400
|
* If user properties are passed, they are also sent to posthog.
|
|
@@ -7400,21 +7408,30 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
7400
7408
|
* ### Notes:
|
|
7401
7409
|
*
|
|
7402
7410
|
* You can call this function to overwrite a previously set
|
|
7403
|
-
* unique ID for the current user.
|
|
7404
|
-
*
|
|
7405
|
-
*
|
|
7406
|
-
*
|
|
7407
|
-
*
|
|
7408
|
-
*
|
|
7409
|
-
*
|
|
7410
|
-
*
|
|
7411
|
-
*
|
|
7412
|
-
*
|
|
7413
|
-
*
|
|
7414
|
-
*
|
|
7415
|
-
*
|
|
7416
|
-
*
|
|
7417
|
-
*
|
|
7411
|
+
* unique ID for the current user.
|
|
7412
|
+
*
|
|
7413
|
+
* If the user has been identified ($user_state in persistence is set to 'identified'),
|
|
7414
|
+
* then capture of $identify is skipped to avoid merging users. For example,
|
|
7415
|
+
* if your system allows an admin user to impersonate another user.
|
|
7416
|
+
*
|
|
7417
|
+
* Then a single browser instance can have:
|
|
7418
|
+
*
|
|
7419
|
+
* `identify('a') -> capture(1) -> identify('b') -> capture(2)`
|
|
7420
|
+
*
|
|
7421
|
+
* and capture 1 and capture 2 will have the correct distinct_id.
|
|
7422
|
+
* but users a and b will NOT be merged in posthog.
|
|
7423
|
+
*
|
|
7424
|
+
* However, if reset is called then:
|
|
7425
|
+
*
|
|
7426
|
+
* `identify('a') -> capture(1) -> reset() -> capture(2) -> identify('b') -> capture(3)`
|
|
7427
|
+
*
|
|
7428
|
+
* users a and b are not merged.
|
|
7429
|
+
* Capture 1 is associated with user a.
|
|
7430
|
+
* A new distinct id is generated for capture 2.
|
|
7431
|
+
* which is merged with user b.
|
|
7432
|
+
* So, capture 2 and 3 are associated with user b.
|
|
7433
|
+
*
|
|
7434
|
+
* If you want to merge two identified users, you can call posthog.alias
|
|
7418
7435
|
*
|
|
7419
7436
|
* @param {String} [new_distinct_id] A string that uniquely identifies a user. If not provided, the distinct_id currently in the persistent store (cookie or localStorage) will be used.
|
|
7420
7437
|
* @param {Object} [userPropertiesToSet] Optional: An associative array of properties to store about the user
|
|
@@ -7445,8 +7462,7 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
7445
7462
|
$had_persisted_distinct_id: true,
|
|
7446
7463
|
$device_id: device_id
|
|
7447
7464
|
}, '');
|
|
7448
|
-
} //
|
|
7449
|
-
// if it's new, blow away the alias as well.
|
|
7465
|
+
} // if the previous distinct id had an alias stored, then we clear it
|
|
7450
7466
|
|
|
7451
7467
|
|
|
7452
7468
|
if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
|
|
@@ -7456,11 +7472,10 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
7456
7472
|
});
|
|
7457
7473
|
}
|
|
7458
7474
|
|
|
7459
|
-
var deviceIdMarksForIdentify = !this.get_property('$device_id');
|
|
7460
7475
|
var isKnownAnonymous = this.persistence.get_user_state() === 'anonymous'; // send an $identify event any time the distinct_id is changing and the old ID is an anoymous ID
|
|
7461
7476
|
// - logic on the server will determine whether or not to do anything with it.
|
|
7462
7477
|
|
|
7463
|
-
if (new_distinct_id !== previous_distinct_id &&
|
|
7478
|
+
if (new_distinct_id !== previous_distinct_id && isKnownAnonymous) {
|
|
7464
7479
|
this.persistence.set_user_state('identified');
|
|
7465
7480
|
this.capture('$identify', {
|
|
7466
7481
|
distinct_id: new_distinct_id,
|