mixpanel-browser 2.66.0 → 2.67.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/.github/dependabot.yml +7 -0
- package/CHANGELOG.md +7 -0
- package/dist/mixpanel-core.cjs.js +48 -39
- package/dist/mixpanel-recorder.js +36 -12
- package/dist/mixpanel-recorder.min.js +1 -1
- package/dist/mixpanel-recorder.min.js.map +1 -1
- package/dist/mixpanel-with-async-recorder.cjs.js +48 -39
- package/dist/mixpanel-with-recorder.js +83 -50
- package/dist/mixpanel-with-recorder.min.js +1 -1
- package/dist/mixpanel.amd.js +83 -50
- package/dist/mixpanel.cjs.js +83 -50
- package/dist/mixpanel.globals.js +48 -39
- package/dist/mixpanel.min.js +139 -139
- package/dist/mixpanel.module.js +83 -50
- package/dist/mixpanel.umd.js +83 -50
- package/package.json +1 -1
- package/src/config.js +1 -1
- package/src/flags/index.js +29 -7
- package/src/mixpanel-core.js +18 -31
- package/src/recorder/session-recording.js +35 -11
|
@@ -63,6 +63,13 @@ function isUserEvent(ev) {
|
|
|
63
63
|
* @property {string} replayStartUrl
|
|
64
64
|
*/
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* @typedef {Object} UserIdInfo
|
|
68
|
+
* @property {string} distinct_id
|
|
69
|
+
* @property {string} user_id
|
|
70
|
+
* @property {string} device_id
|
|
71
|
+
*/
|
|
72
|
+
|
|
66
73
|
|
|
67
74
|
/**
|
|
68
75
|
* This class encapsulates a single session recording and its lifecycle.
|
|
@@ -118,6 +125,30 @@ var SessionRecording = function(options) {
|
|
|
118
125
|
});
|
|
119
126
|
};
|
|
120
127
|
|
|
128
|
+
/**
|
|
129
|
+
* @returns {UserIdInfo}
|
|
130
|
+
*/
|
|
131
|
+
SessionRecording.prototype.getUserIdInfo = function () {
|
|
132
|
+
if (this.finalFlushUserIdInfo) {
|
|
133
|
+
return this.finalFlushUserIdInfo;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var userIdInfo = {
|
|
137
|
+
'distinct_id': String(this._mixpanel.get_distinct_id()),
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// send ID management props if they exist
|
|
141
|
+
var deviceId = this._mixpanel.get_property('$device_id');
|
|
142
|
+
if (deviceId) {
|
|
143
|
+
userIdInfo['$device_id'] = deviceId;
|
|
144
|
+
}
|
|
145
|
+
var userId = this._mixpanel.get_property('$user_id');
|
|
146
|
+
if (userId) {
|
|
147
|
+
userIdInfo['$user_id'] = userId;
|
|
148
|
+
}
|
|
149
|
+
return userIdInfo;
|
|
150
|
+
};
|
|
151
|
+
|
|
121
152
|
SessionRecording.prototype.unloadPersistedData = function () {
|
|
122
153
|
this.batcher.stop();
|
|
123
154
|
return this.batcher.flush()
|
|
@@ -242,6 +273,9 @@ SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
|
|
|
242
273
|
};
|
|
243
274
|
|
|
244
275
|
SessionRecording.prototype.stopRecording = function (skipFlush) {
|
|
276
|
+
// store the user ID info in case this is getting called in mixpanel.reset()
|
|
277
|
+
this.finalFlushUserIdInfo = this.getUserIdInfo();
|
|
278
|
+
|
|
245
279
|
if (!this.isRrwebStopped()) {
|
|
246
280
|
try {
|
|
247
281
|
this._stopRecording();
|
|
@@ -407,7 +441,6 @@ SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (da
|
|
|
407
441
|
'$current_url': this.batchStartUrl,
|
|
408
442
|
'$lib_version': Config.LIB_VERSION,
|
|
409
443
|
'batch_start_time': batchStartTime / 1000,
|
|
410
|
-
'distinct_id': String(this._mixpanel.get_distinct_id()),
|
|
411
444
|
'mp_lib': 'web',
|
|
412
445
|
'replay_id': replayId,
|
|
413
446
|
'replay_length_ms': replayLengthMs,
|
|
@@ -416,16 +449,7 @@ SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (da
|
|
|
416
449
|
'seq': this.seqNo
|
|
417
450
|
};
|
|
418
451
|
var eventsJson = JSON.stringify(data);
|
|
419
|
-
|
|
420
|
-
// send ID management props if they exist
|
|
421
|
-
var deviceId = this._mixpanel.get_property('$device_id');
|
|
422
|
-
if (deviceId) {
|
|
423
|
-
reqParams['$device_id'] = deviceId;
|
|
424
|
-
}
|
|
425
|
-
var userId = this._mixpanel.get_property('$user_id');
|
|
426
|
-
if (userId) {
|
|
427
|
-
reqParams['$user_id'] = userId;
|
|
428
|
-
}
|
|
452
|
+
Object.assign(reqParams, this.getUserIdInfo());
|
|
429
453
|
|
|
430
454
|
if (CompressionStream) {
|
|
431
455
|
var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
|