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/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 */
|
|
@@ -417,7 +419,7 @@ declare class PostHogPersistence {
|
|
|
417
419
|
expire_days: number | undefined;
|
|
418
420
|
default_expiry: number | undefined;
|
|
419
421
|
cross_subdomain: boolean | undefined;
|
|
420
|
-
user_state: 'anonymous' | 'identified'
|
|
422
|
+
user_state: 'anonymous' | 'identified';
|
|
421
423
|
constructor(config: PostHogConfig);
|
|
422
424
|
properties(): Properties;
|
|
423
425
|
load(): void;
|
|
@@ -453,7 +455,7 @@ declare class PostHogPersistence {
|
|
|
453
455
|
set_secure(secure: boolean): void;
|
|
454
456
|
set_event_timer(event_name: string, timestamp: number): void;
|
|
455
457
|
remove_event_timer(event_name: string): number;
|
|
456
|
-
get_user_state(): 'anonymous' | 'identified'
|
|
458
|
+
get_user_state(): 'anonymous' | 'identified';
|
|
457
459
|
set_user_state(state: 'anonymous' | 'identified'): void;
|
|
458
460
|
}
|
|
459
461
|
|
|
@@ -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;
|
|
@@ -1132,7 +1135,7 @@ declare class PostHog {
|
|
|
1132
1135
|
/**
|
|
1133
1136
|
* Identify a user with a unique ID instead of a PostHog
|
|
1134
1137
|
* randomly generated distinct_id. If the method is never called,
|
|
1135
|
-
* then unique visitors will be identified by a UUID generated
|
|
1138
|
+
* then unique visitors will be identified by a UUID that is generated
|
|
1136
1139
|
* the first time they visit the site.
|
|
1137
1140
|
*
|
|
1138
1141
|
* If user properties are passed, they are also sent to posthog.
|
|
@@ -1146,21 +1149,30 @@ declare class PostHog {
|
|
|
1146
1149
|
* ### Notes:
|
|
1147
1150
|
*
|
|
1148
1151
|
* You can call this function to overwrite a previously set
|
|
1149
|
-
* unique ID for the current user.
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1160
|
-
*
|
|
1161
|
-
*
|
|
1162
|
-
*
|
|
1163
|
-
*
|
|
1152
|
+
* unique ID for the current user.
|
|
1153
|
+
*
|
|
1154
|
+
* If the user has been identified ($user_state in persistence is set to 'identified'),
|
|
1155
|
+
* then capture of $identify is skipped to avoid merging users. For example,
|
|
1156
|
+
* if your system allows an admin user to impersonate another user.
|
|
1157
|
+
*
|
|
1158
|
+
* Then a single browser instance can have:
|
|
1159
|
+
*
|
|
1160
|
+
* `identify('a') -> capture(1) -> identify('b') -> capture(2)`
|
|
1161
|
+
*
|
|
1162
|
+
* and capture 1 and capture 2 will have the correct distinct_id.
|
|
1163
|
+
* but users a and b will NOT be merged in posthog.
|
|
1164
|
+
*
|
|
1165
|
+
* However, if reset is called then:
|
|
1166
|
+
*
|
|
1167
|
+
* `identify('a') -> capture(1) -> reset() -> capture(2) -> identify('b') -> capture(3)`
|
|
1168
|
+
*
|
|
1169
|
+
* users a and b are not merged.
|
|
1170
|
+
* Capture 1 is associated with user a.
|
|
1171
|
+
* A new distinct id is generated for capture 2.
|
|
1172
|
+
* which is merged with user b.
|
|
1173
|
+
* So, capture 2 and 3 are associated with user b.
|
|
1174
|
+
*
|
|
1175
|
+
* If you want to merge two identified users, you can call posthog.alias
|
|
1164
1176
|
*
|
|
1165
1177
|
* @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.
|
|
1166
1178
|
* @param {Object} [userPropertiesToSet] Optional: An associative array of properties to store about the user
|
package/dist/module.js
CHANGED
|
@@ -921,7 +921,7 @@ var LZString = {
|
|
|
921
921
|
}
|
|
922
922
|
};
|
|
923
923
|
|
|
924
|
-
var version = "1.
|
|
924
|
+
var version = "1.46.0";
|
|
925
925
|
|
|
926
926
|
// e.g. Config.DEBUG = Config.DEBUG || instance.get_config('debug')
|
|
927
927
|
|
|
@@ -3585,7 +3585,7 @@ var PostHogPersistence = /*#__PURE__*/function () {
|
|
|
3585
3585
|
this.storage = cookieStore;
|
|
3586
3586
|
}
|
|
3587
3587
|
|
|
3588
|
-
this.user_state =
|
|
3588
|
+
this.user_state = 'anonymous';
|
|
3589
3589
|
this.load();
|
|
3590
3590
|
this.update_config(config);
|
|
3591
3591
|
this.save();
|
|
@@ -3834,7 +3834,7 @@ var PostHogPersistence = /*#__PURE__*/function () {
|
|
|
3834
3834
|
}, {
|
|
3835
3835
|
key: "get_user_state",
|
|
3836
3836
|
value: function get_user_state() {
|
|
3837
|
-
return this.props[USER_STATE];
|
|
3837
|
+
return this.props[USER_STATE] || 'anonymous';
|
|
3838
3838
|
}
|
|
3839
3839
|
}, {
|
|
3840
3840
|
key: "set_user_state",
|
|
@@ -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') +
|
|
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();
|
|
@@ -7390,7 +7398,7 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
7390
7398
|
/**
|
|
7391
7399
|
* Identify a user with a unique ID instead of a PostHog
|
|
7392
7400
|
* randomly generated distinct_id. If the method is never called,
|
|
7393
|
-
* then unique visitors will be identified by a UUID generated
|
|
7401
|
+
* then unique visitors will be identified by a UUID that is generated
|
|
7394
7402
|
* the first time they visit the site.
|
|
7395
7403
|
*
|
|
7396
7404
|
* If user properties are passed, they are also sent to posthog.
|
|
@@ -7404,21 +7412,30 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
7404
7412
|
* ### Notes:
|
|
7405
7413
|
*
|
|
7406
7414
|
* You can call this function to overwrite a previously set
|
|
7407
|
-
* unique ID for the current user.
|
|
7408
|
-
*
|
|
7409
|
-
*
|
|
7410
|
-
*
|
|
7411
|
-
*
|
|
7412
|
-
*
|
|
7413
|
-
*
|
|
7414
|
-
*
|
|
7415
|
-
*
|
|
7416
|
-
*
|
|
7417
|
-
*
|
|
7418
|
-
*
|
|
7419
|
-
*
|
|
7420
|
-
*
|
|
7421
|
-
*
|
|
7415
|
+
* unique ID for the current user.
|
|
7416
|
+
*
|
|
7417
|
+
* If the user has been identified ($user_state in persistence is set to 'identified'),
|
|
7418
|
+
* then capture of $identify is skipped to avoid merging users. For example,
|
|
7419
|
+
* if your system allows an admin user to impersonate another user.
|
|
7420
|
+
*
|
|
7421
|
+
* Then a single browser instance can have:
|
|
7422
|
+
*
|
|
7423
|
+
* `identify('a') -> capture(1) -> identify('b') -> capture(2)`
|
|
7424
|
+
*
|
|
7425
|
+
* and capture 1 and capture 2 will have the correct distinct_id.
|
|
7426
|
+
* but users a and b will NOT be merged in posthog.
|
|
7427
|
+
*
|
|
7428
|
+
* However, if reset is called then:
|
|
7429
|
+
*
|
|
7430
|
+
* `identify('a') -> capture(1) -> reset() -> capture(2) -> identify('b') -> capture(3)`
|
|
7431
|
+
*
|
|
7432
|
+
* users a and b are not merged.
|
|
7433
|
+
* Capture 1 is associated with user a.
|
|
7434
|
+
* A new distinct id is generated for capture 2.
|
|
7435
|
+
* which is merged with user b.
|
|
7436
|
+
* So, capture 2 and 3 are associated with user b.
|
|
7437
|
+
*
|
|
7438
|
+
* If you want to merge two identified users, you can call posthog.alias
|
|
7422
7439
|
*
|
|
7423
7440
|
* @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.
|
|
7424
7441
|
* @param {Object} [userPropertiesToSet] Optional: An associative array of properties to store about the user
|
|
@@ -7449,8 +7466,7 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
7449
7466
|
$had_persisted_distinct_id: true,
|
|
7450
7467
|
$device_id: device_id
|
|
7451
7468
|
}, '');
|
|
7452
|
-
} //
|
|
7453
|
-
// if it's new, blow away the alias as well.
|
|
7469
|
+
} // if the previous distinct id had an alias stored, then we clear it
|
|
7454
7470
|
|
|
7455
7471
|
|
|
7456
7472
|
if (new_distinct_id !== previous_distinct_id && new_distinct_id !== this.get_property(ALIAS_ID_KEY)) {
|
|
@@ -7460,11 +7476,10 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
7460
7476
|
});
|
|
7461
7477
|
}
|
|
7462
7478
|
|
|
7463
|
-
var deviceIdMarksForIdentify = !this.get_property('$device_id');
|
|
7464
7479
|
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
|
|
7465
7480
|
// - logic on the server will determine whether or not to do anything with it.
|
|
7466
7481
|
|
|
7467
|
-
if (new_distinct_id !== previous_distinct_id &&
|
|
7482
|
+
if (new_distinct_id !== previous_distinct_id && isKnownAnonymous) {
|
|
7468
7483
|
this.persistence.set_user_state('identified');
|
|
7469
7484
|
this.capture('$identify', {
|
|
7470
7485
|
distinct_id: new_distinct_id,
|