posthog-js 1.17.7 → 1.18.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 +14 -0
- package/dist/array.js +9 -9
- package/dist/es.js +117 -64
- package/dist/module.js +117 -64
- package/package.json +5 -4
package/dist/es.js
CHANGED
|
@@ -863,7 +863,7 @@ var LZString = {
|
|
|
863
863
|
}
|
|
864
864
|
};
|
|
865
865
|
|
|
866
|
-
var version = "1.
|
|
866
|
+
var version = "1.18.0";
|
|
867
867
|
|
|
868
868
|
var Config$1 = {
|
|
869
869
|
DEBUG: false,
|
|
@@ -900,15 +900,18 @@ var _ = {
|
|
|
900
900
|
}
|
|
901
901
|
}; // Console override
|
|
902
902
|
|
|
903
|
-
var
|
|
903
|
+
var logger = {
|
|
904
904
|
/** @type {function(...*)} */
|
|
905
905
|
log: function log() {
|
|
906
906
|
if (Config$1.DEBUG && !_.isUndefined(window.console) && window.console) {
|
|
907
|
+
// Don't log PostHog debug messages in rrweb
|
|
908
|
+
var log = window.console.log['__rrweb_original__'] ? window.console.log['__rrweb_original__'] : window.console.log;
|
|
909
|
+
|
|
907
910
|
try {
|
|
908
|
-
|
|
911
|
+
log.apply(window.console, arguments);
|
|
909
912
|
} catch (err) {
|
|
910
913
|
_.each(arguments, function (arg) {
|
|
911
|
-
|
|
914
|
+
log(arg);
|
|
912
915
|
});
|
|
913
916
|
}
|
|
914
917
|
}
|
|
@@ -917,13 +920,15 @@ var console$1 = {
|
|
|
917
920
|
/** @type {function(...*)} */
|
|
918
921
|
error: function error() {
|
|
919
922
|
if (Config$1.DEBUG && !_.isUndefined(window.console) && window.console) {
|
|
920
|
-
var args = ['PostHog error:'].concat(Array.prototype.slice.call(arguments));
|
|
923
|
+
var args = ['PostHog error:'].concat(Array.prototype.slice.call(arguments)); // Don't log PostHog debug messages in rrweb
|
|
924
|
+
|
|
925
|
+
var error = window.console.error['__rrweb_original__'] ? window.console.error['__rrweb_original__'] : window.console.error;
|
|
921
926
|
|
|
922
927
|
try {
|
|
923
|
-
|
|
928
|
+
error.apply(window.console, args);
|
|
924
929
|
} catch (err) {
|
|
925
930
|
_.each(args, function (arg) {
|
|
926
|
-
|
|
931
|
+
error(arg);
|
|
927
932
|
});
|
|
928
933
|
}
|
|
929
934
|
}
|
|
@@ -932,13 +937,15 @@ var console$1 = {
|
|
|
932
937
|
/** @type {function(...*)} */
|
|
933
938
|
critical: function critical() {
|
|
934
939
|
if (!_.isUndefined(window.console) && window.console) {
|
|
935
|
-
var args = ['PostHog error:'].concat(Array.prototype.slice.call(arguments));
|
|
940
|
+
var args = ['PostHog error:'].concat(Array.prototype.slice.call(arguments)); // Don't log PostHog debug messages in rrweb
|
|
941
|
+
|
|
942
|
+
var error = window.console.error['__rrweb_original__'] ? window.console.error['__rrweb_original__'] : window.console.error;
|
|
936
943
|
|
|
937
944
|
try {
|
|
938
|
-
|
|
945
|
+
error.apply(window.console, args);
|
|
939
946
|
} catch (err) {
|
|
940
947
|
_.each(args, function (arg) {
|
|
941
|
-
|
|
948
|
+
error(arg);
|
|
942
949
|
});
|
|
943
950
|
}
|
|
944
951
|
}
|
|
@@ -1138,10 +1145,10 @@ _.safewrap = function (f) {
|
|
|
1138
1145
|
try {
|
|
1139
1146
|
return f.apply(this, arguments);
|
|
1140
1147
|
} catch (e) {
|
|
1141
|
-
|
|
1148
|
+
logger.critical('Implementation error. Please turn on debug and contact support@posthog.com.');
|
|
1142
1149
|
|
|
1143
1150
|
if (Config$1.DEBUG) {
|
|
1144
|
-
|
|
1151
|
+
logger.critical(e);
|
|
1145
1152
|
}
|
|
1146
1153
|
}
|
|
1147
1154
|
};
|
|
@@ -1432,7 +1439,7 @@ _.getQueryParam = function (url, param) {
|
|
|
1432
1439
|
try {
|
|
1433
1440
|
result = decodeURIComponent(result);
|
|
1434
1441
|
} catch (err) {
|
|
1435
|
-
|
|
1442
|
+
logger.error('Skipping decoding for malformed query param: ' + result);
|
|
1436
1443
|
}
|
|
1437
1444
|
|
|
1438
1445
|
return result.replace(/\+/g, ' ');
|
|
@@ -1461,7 +1468,7 @@ _.register_event = function () {
|
|
|
1461
1468
|
*/
|
|
1462
1469
|
var register_event = function register_event(element, type, handler, oldSchool, useCapture) {
|
|
1463
1470
|
if (!element) {
|
|
1464
|
-
|
|
1471
|
+
logger.error('No valid element provided to register_event');
|
|
1465
1472
|
return;
|
|
1466
1473
|
}
|
|
1467
1474
|
|
|
@@ -2302,7 +2309,7 @@ var autocapture = {
|
|
|
2302
2309
|
var token = instance.get_config('token');
|
|
2303
2310
|
|
|
2304
2311
|
if (this._initializedTokens.indexOf(token) > -1) {
|
|
2305
|
-
|
|
2312
|
+
logger.log('autocapture already initialized for token "' + token + '"');
|
|
2306
2313
|
return;
|
|
2307
2314
|
}
|
|
2308
2315
|
|
|
@@ -2441,14 +2448,14 @@ var localStore = {
|
|
|
2441
2448
|
}
|
|
2442
2449
|
|
|
2443
2450
|
if (!supported) {
|
|
2444
|
-
|
|
2451
|
+
logger.error('localStorage unsupported; falling back to cookie store');
|
|
2445
2452
|
}
|
|
2446
2453
|
|
|
2447
2454
|
_localStorage_supported = supported;
|
|
2448
2455
|
return supported;
|
|
2449
2456
|
},
|
|
2450
2457
|
error: function error(msg) {
|
|
2451
|
-
|
|
2458
|
+
logger.error('localStorage error: ' + msg);
|
|
2452
2459
|
},
|
|
2453
2460
|
get: function get(name) {
|
|
2454
2461
|
try {
|
|
@@ -2539,7 +2546,7 @@ var memoryStore = {
|
|
|
2539
2546
|
return true;
|
|
2540
2547
|
},
|
|
2541
2548
|
error: function error(msg) {
|
|
2542
|
-
|
|
2549
|
+
logger.error('memoryStorage error: ' + msg);
|
|
2543
2550
|
},
|
|
2544
2551
|
parse: function parse(name) {
|
|
2545
2552
|
return memoryStorage[name] || null;
|
|
@@ -2583,7 +2590,7 @@ var sessionStore = {
|
|
|
2583
2590
|
},
|
|
2584
2591
|
error: function error(msg) {
|
|
2585
2592
|
if (Config.DEBUG) {
|
|
2586
|
-
|
|
2593
|
+
logger.error('sessionStorage error: ', msg);
|
|
2587
2594
|
}
|
|
2588
2595
|
},
|
|
2589
2596
|
get: function get(name) {
|
|
@@ -3407,7 +3414,7 @@ var CAMPAIGN_IDS_KEY = '__cmpns';
|
|
|
3407
3414
|
var EVENT_TIMERS_KEY = '__timers';
|
|
3408
3415
|
/** @const */
|
|
3409
3416
|
|
|
3410
|
-
var
|
|
3417
|
+
var SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side';
|
|
3411
3418
|
/** @const */
|
|
3412
3419
|
|
|
3413
3420
|
var SESSION_ID = '$sesid';
|
|
@@ -3416,7 +3423,7 @@ var SESSION_ID = '$sesid';
|
|
|
3416
3423
|
var ENABLED_FEATURE_FLAGS = '$enabled_feature_flags';
|
|
3417
3424
|
/** @const */
|
|
3418
3425
|
|
|
3419
|
-
var RESERVED_PROPERTIES = [SET_QUEUE_KEY, SET_ONCE_QUEUE_KEY, UNSET_QUEUE_KEY, ADD_QUEUE_KEY, APPEND_QUEUE_KEY, REMOVE_QUEUE_KEY, UNION_QUEUE_KEY, PEOPLE_DISTINCT_ID_KEY, ALIAS_ID_KEY, CAMPAIGN_IDS_KEY, EVENT_TIMERS_KEY,
|
|
3426
|
+
var RESERVED_PROPERTIES = [SET_QUEUE_KEY, SET_ONCE_QUEUE_KEY, UNSET_QUEUE_KEY, ADD_QUEUE_KEY, APPEND_QUEUE_KEY, REMOVE_QUEUE_KEY, UNION_QUEUE_KEY, PEOPLE_DISTINCT_ID_KEY, ALIAS_ID_KEY, CAMPAIGN_IDS_KEY, EVENT_TIMERS_KEY, SESSION_RECORDING_ENABLED_SERVER_SIDE, SESSION_ID, ENABLED_FEATURE_FLAGS];
|
|
3420
3427
|
/**
|
|
3421
3428
|
* PostHog Persistence Object
|
|
3422
3429
|
* @constructor
|
|
@@ -3443,7 +3450,7 @@ var PostHogPersistence = function PostHogPersistence(config) {
|
|
|
3443
3450
|
var storage_type = config['persistence'];
|
|
3444
3451
|
|
|
3445
3452
|
if (storage_type !== 'cookie' && storage_type.indexOf('localStorage') === -1 && storage_type !== 'memory') {
|
|
3446
|
-
|
|
3453
|
+
logger.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
|
|
3447
3454
|
storage_type = config['persistence'] = 'cookie';
|
|
3448
3455
|
}
|
|
3449
3456
|
|
|
@@ -3729,18 +3736,22 @@ var SessionRecording = /*#__PURE__*/function () {
|
|
|
3729
3736
|
this.instance = instance;
|
|
3730
3737
|
this.captureStarted = false;
|
|
3731
3738
|
this.snapshots = [];
|
|
3732
|
-
this.emit = false;
|
|
3739
|
+
this.emit = false; // Controls whether data is sent to the server or not
|
|
3740
|
+
|
|
3733
3741
|
this.endpoint = BASE_ENDPOINT;
|
|
3734
3742
|
this.stopRrweb = null;
|
|
3735
3743
|
this.windowId = null;
|
|
3736
3744
|
this.sessionId = null;
|
|
3745
|
+
this.receivedDecide = false;
|
|
3737
3746
|
}
|
|
3738
3747
|
|
|
3739
3748
|
_createClass(SessionRecording, [{
|
|
3740
3749
|
key: "startRecordingIfEnabled",
|
|
3741
3750
|
value: function startRecordingIfEnabled() {
|
|
3742
|
-
if (this.
|
|
3743
|
-
this.
|
|
3751
|
+
if (this.isRecordingEnabled()) {
|
|
3752
|
+
this.startCaptureAndTrySendingQueuedSnapshots();
|
|
3753
|
+
} else {
|
|
3754
|
+
this.stopRecording();
|
|
3744
3755
|
}
|
|
3745
3756
|
}
|
|
3746
3757
|
}, {
|
|
@@ -3757,35 +3768,47 @@ var SessionRecording = /*#__PURE__*/function () {
|
|
|
3757
3768
|
this.captureStarted = false;
|
|
3758
3769
|
}
|
|
3759
3770
|
}
|
|
3771
|
+
}, {
|
|
3772
|
+
key: "isRecordingEnabled",
|
|
3773
|
+
value: function isRecordingEnabled() {
|
|
3774
|
+
var enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE);
|
|
3775
|
+
var enabled_client_side = !this.instance.get_config('disable_session_recording');
|
|
3776
|
+
return enabled_server_side && enabled_client_side;
|
|
3777
|
+
}
|
|
3760
3778
|
}, {
|
|
3761
3779
|
key: "afterDecideResponse",
|
|
3762
3780
|
value: function afterDecideResponse(response) {
|
|
3763
|
-
var
|
|
3781
|
+
var _response$sessionReco;
|
|
3782
|
+
|
|
3783
|
+
this.receivedDecide = true;
|
|
3764
3784
|
|
|
3765
3785
|
if (this.instance.persistence) {
|
|
3766
|
-
this.instance.persistence.register(_defineProperty({},
|
|
3786
|
+
this.instance.persistence.register(_defineProperty({}, SESSION_RECORDING_ENABLED_SERVER_SIDE, !!response['sessionRecording']));
|
|
3767
3787
|
}
|
|
3768
3788
|
|
|
3769
|
-
if (
|
|
3770
|
-
|
|
3771
|
-
this.endpoint = response['sessionRecording'].endpoint;
|
|
3772
|
-
}
|
|
3789
|
+
if ((_response$sessionReco = response.sessionRecording) !== null && _response$sessionReco !== void 0 && _response$sessionReco.endpoint) {
|
|
3790
|
+
var _response$sessionReco2;
|
|
3773
3791
|
|
|
3774
|
-
this.
|
|
3792
|
+
this.endpoint = (_response$sessionReco2 = response.sessionRecording) === null || _response$sessionReco2 === void 0 ? void 0 : _response$sessionReco2.endpoint;
|
|
3775
3793
|
}
|
|
3794
|
+
|
|
3795
|
+
this.startRecordingIfEnabled();
|
|
3776
3796
|
}
|
|
3777
3797
|
}, {
|
|
3778
|
-
key: "
|
|
3779
|
-
value: function
|
|
3798
|
+
key: "startCaptureAndTrySendingQueuedSnapshots",
|
|
3799
|
+
value: function startCaptureAndTrySendingQueuedSnapshots() {
|
|
3780
3800
|
var _this = this;
|
|
3781
3801
|
|
|
3782
|
-
|
|
3802
|
+
// Only submit data after we've received a decide response to account for
|
|
3803
|
+
// changing endpoints and the feature being disabled on the server side.
|
|
3804
|
+
if (this.receivedDecide) {
|
|
3805
|
+
this.emit = true;
|
|
3806
|
+
this.snapshots.forEach(function (properties) {
|
|
3807
|
+
return _this._captureSnapshot(properties);
|
|
3808
|
+
});
|
|
3809
|
+
}
|
|
3783
3810
|
|
|
3784
3811
|
this._startCapture();
|
|
3785
|
-
|
|
3786
|
-
this.snapshots.forEach(function (properties) {
|
|
3787
|
-
return _this._captureSnapshot(properties);
|
|
3788
|
-
});
|
|
3789
3812
|
}
|
|
3790
3813
|
}, {
|
|
3791
3814
|
key: "_startCapture",
|
|
@@ -3815,7 +3838,7 @@ var SessionRecording = /*#__PURE__*/function () {
|
|
|
3815
3838
|
|
|
3816
3839
|
|
|
3817
3840
|
if ((this.windowId !== windowId || this.sessionId !== sessionId) && [FULL_SNAPSHOT_EVENT_TYPE, META_EVENT_TYPE].indexOf(event.type) === -1) {
|
|
3818
|
-
|
|
3841
|
+
this.rrwebRecord.takeFullSnapshot();
|
|
3819
3842
|
}
|
|
3820
3843
|
|
|
3821
3844
|
this.windowId = windowId;
|
|
@@ -3838,7 +3861,10 @@ var SessionRecording = /*#__PURE__*/function () {
|
|
|
3838
3861
|
maskInputFn: null,
|
|
3839
3862
|
slimDOMOptions: {},
|
|
3840
3863
|
collectFonts: false
|
|
3841
|
-
}; //
|
|
3864
|
+
}; // We switched from loading all of rrweb to just the record part, but
|
|
3865
|
+
// keep backwards compatibility if someone hasn't upgraded PostHog
|
|
3866
|
+
|
|
3867
|
+
this.rrwebRecord = window.rrweb ? window.rrweb.record : window.rrwebRecord; // only allows user to set our 'whitelisted' options
|
|
3842
3868
|
|
|
3843
3869
|
var userSessionRecordingOptions = this.instance.get_config('session_recording');
|
|
3844
3870
|
|
|
@@ -3852,7 +3878,7 @@ var SessionRecording = /*#__PURE__*/function () {
|
|
|
3852
3878
|
}
|
|
3853
3879
|
}
|
|
3854
3880
|
|
|
3855
|
-
this.stopRrweb =
|
|
3881
|
+
this.stopRrweb = this.rrwebRecord(_objectSpread2({
|
|
3856
3882
|
emit: function emit(event) {
|
|
3857
3883
|
event = filterDataURLsFromLargeDataObjects(event);
|
|
3858
3884
|
|
|
@@ -3873,13 +3899,14 @@ var SessionRecording = /*#__PURE__*/function () {
|
|
|
3873
3899
|
} else {
|
|
3874
3900
|
_this2.snapshots.push(properties);
|
|
3875
3901
|
}
|
|
3876
|
-
}
|
|
3902
|
+
},
|
|
3903
|
+
plugins: window.rrwebConsoleRecord && this.instance.get_config('enable_recording_console_log') ? [window.rrwebConsoleRecord.getRecordConsolePlugin()] : []
|
|
3877
3904
|
}, sessionRecordingOptions)); // :TRICKY: rrweb does not capture navigation within SPA-s, so hook into our $pageview events to get access to all events.
|
|
3878
3905
|
// Dropping the initial event is fine (it's always captured by rrweb).
|
|
3879
3906
|
|
|
3880
3907
|
this.instance._addCaptureHook(function (eventName) {
|
|
3881
3908
|
if (eventName === '$pageview') {
|
|
3882
|
-
|
|
3909
|
+
_this2.rrwebRecord.addCustomEvent('$pageview', {
|
|
3883
3910
|
href: window.location.href
|
|
3884
3911
|
});
|
|
3885
3912
|
}
|
|
@@ -5218,7 +5245,7 @@ var xhr = function xhr(_ref) {
|
|
|
5218
5245
|
try {
|
|
5219
5246
|
response = JSON.parse(req.responseText);
|
|
5220
5247
|
} catch (e) {
|
|
5221
|
-
|
|
5248
|
+
logger.error(e);
|
|
5222
5249
|
return;
|
|
5223
5250
|
}
|
|
5224
5251
|
|
|
@@ -5601,9 +5628,33 @@ function deduplicateKeys(performanceEntries) {
|
|
|
5601
5628
|
});
|
|
5602
5629
|
})];
|
|
5603
5630
|
}
|
|
5631
|
+
/*
|
|
5632
|
+
The duration property is on the PerformanceNavigationTiming object.
|
|
5633
|
+
|
|
5634
|
+
It is a timestamp that is the difference between the PerformanceNavigationTiming.loadEventEnd
|
|
5635
|
+
and PerformanceEntry.startTime properties.
|
|
5636
|
+
https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming
|
|
5637
|
+
|
|
5638
|
+
Even in browsers that implement it, it is not always available to us
|
|
5639
|
+
*/
|
|
5640
|
+
|
|
5604
5641
|
function pageLoadFrom(performanceData) {
|
|
5605
|
-
var
|
|
5606
|
-
|
|
5642
|
+
var keys = performanceData.navigation && performanceData.navigation[0];
|
|
5643
|
+
var values = performanceData.navigation && performanceData.navigation[1] && performanceData.navigation[1][0];
|
|
5644
|
+
var durationIndex = keys && keys.indexOf('duration');
|
|
5645
|
+
|
|
5646
|
+
if (durationIndex > -1) {
|
|
5647
|
+
return values[durationIndex];
|
|
5648
|
+
} else {
|
|
5649
|
+
var endKeyIndex = keys && keys.indexOf('loadEventEnd');
|
|
5650
|
+
var startKeyIndex = keys && keys.indexOf('startTime'); // start key is not present if start is 0
|
|
5651
|
+
|
|
5652
|
+
if (endKeyIndex > -1) {
|
|
5653
|
+
var end = values && values[endKeyIndex];
|
|
5654
|
+
var start = values && values[startKeyIndex] || 0;
|
|
5655
|
+
return end - start;
|
|
5656
|
+
}
|
|
5657
|
+
}
|
|
5607
5658
|
}
|
|
5608
5659
|
function getPerformanceData() {
|
|
5609
5660
|
var performanceEntries = {
|
|
@@ -5679,6 +5730,7 @@ var defaultConfig = function defaultConfig() {
|
|
|
5679
5730
|
disable_session_recording: false,
|
|
5680
5731
|
disable_persistence: false,
|
|
5681
5732
|
disable_cookie: false,
|
|
5733
|
+
enable_recording_console_log: false,
|
|
5682
5734
|
secure_cookie: win.location.protocol === 'https:',
|
|
5683
5735
|
ip: true,
|
|
5684
5736
|
opt_out_capturing_by_default: false,
|
|
@@ -5711,7 +5763,7 @@ var defaultConfig = function defaultConfig() {
|
|
|
5711
5763
|
advanced_disable_toolbar_metrics: false,
|
|
5712
5764
|
on_xhr_error: function on_xhr_error(req) {
|
|
5713
5765
|
var error = 'Bad HTTP status: ' + req.status + ' ' + req.statusText;
|
|
5714
|
-
console
|
|
5766
|
+
console.error(error);
|
|
5715
5767
|
},
|
|
5716
5768
|
// Used for internal testing
|
|
5717
5769
|
_onCapture: function _onCapture() {},
|
|
@@ -5743,7 +5795,7 @@ var create_mplib = function create_mplib(token, config, name) {
|
|
|
5743
5795
|
instance = target;
|
|
5744
5796
|
} else {
|
|
5745
5797
|
if (target && !_.isArray(target)) {
|
|
5746
|
-
console
|
|
5798
|
+
console.error('You have already initialized ' + name);
|
|
5747
5799
|
return;
|
|
5748
5800
|
}
|
|
5749
5801
|
|
|
@@ -5770,10 +5822,10 @@ var create_mplib = function create_mplib(token, config, name) {
|
|
|
5770
5822
|
|
|
5771
5823
|
if (!autocapture.enabledForProject(instance.get_config('token'), num_buckets, num_enabled_buckets)) {
|
|
5772
5824
|
instance['__autocapture_enabled'] = false;
|
|
5773
|
-
|
|
5825
|
+
logger.log('Not in active bucket: disabling Automatic Event Collection.');
|
|
5774
5826
|
} else if (!autocapture.isBrowserSupported()) {
|
|
5775
5827
|
instance['__autocapture_enabled'] = false;
|
|
5776
|
-
|
|
5828
|
+
logger.log('Disabling Automatic Event Collection because this browser is not supported');
|
|
5777
5829
|
} else {
|
|
5778
5830
|
autocapture.init(instance);
|
|
5779
5831
|
}
|
|
@@ -5815,12 +5867,12 @@ var create_mplib = function create_mplib(token, config, name) {
|
|
|
5815
5867
|
|
|
5816
5868
|
PostHogLib.prototype.init = function (token, config, name) {
|
|
5817
5869
|
if (_.isUndefined(name)) {
|
|
5818
|
-
console
|
|
5870
|
+
console.error('You must name your new library: init(token, config, name)');
|
|
5819
5871
|
return;
|
|
5820
5872
|
}
|
|
5821
5873
|
|
|
5822
5874
|
if (name === PRIMARY_INSTANCE_NAME) {
|
|
5823
|
-
console
|
|
5875
|
+
console.error('You must initialize the main posthog object right after you include the PostHog js snippet');
|
|
5824
5876
|
return;
|
|
5825
5877
|
}
|
|
5826
5878
|
|
|
@@ -5887,7 +5939,7 @@ PostHogLib.prototype._loaded = function () {
|
|
|
5887
5939
|
try {
|
|
5888
5940
|
this.get_config('loaded')(this);
|
|
5889
5941
|
} catch (err) {
|
|
5890
|
-
console
|
|
5942
|
+
console.error('`loaded` function failed', err);
|
|
5891
5943
|
}
|
|
5892
5944
|
|
|
5893
5945
|
this._start_queue_if_opted_in(); // this happens after so a user can call identify in
|
|
@@ -6050,7 +6102,7 @@ PostHogLib.prototype._send_request = function (url, data, options, callback) {
|
|
|
6050
6102
|
})));
|
|
6051
6103
|
} catch (e) {
|
|
6052
6104
|
if (this.get_config('debug')) {
|
|
6053
|
-
console
|
|
6105
|
+
console.error(e);
|
|
6054
6106
|
}
|
|
6055
6107
|
}
|
|
6056
6108
|
} else if (USE_XHR) {
|
|
@@ -6067,7 +6119,7 @@ PostHogLib.prototype._send_request = function (url, data, options, callback) {
|
|
|
6067
6119
|
onXHRError: this.get_config('on_xhr_error')
|
|
6068
6120
|
});
|
|
6069
6121
|
} catch (e) {
|
|
6070
|
-
console
|
|
6122
|
+
console.error(e);
|
|
6071
6123
|
}
|
|
6072
6124
|
} else {
|
|
6073
6125
|
var script = document$1.createElement('script');
|
|
@@ -6193,7 +6245,7 @@ PostHogLib.prototype.capture = addOptOutCheckPostHogLib(function (event_name, pr
|
|
|
6193
6245
|
}
|
|
6194
6246
|
|
|
6195
6247
|
if (_.isUndefined(event_name) || typeof event_name !== 'string') {
|
|
6196
|
-
console
|
|
6248
|
+
console.error('No event name provided to posthog.capture');
|
|
6197
6249
|
return;
|
|
6198
6250
|
}
|
|
6199
6251
|
|
|
@@ -6225,7 +6277,7 @@ PostHogLib.prototype.capture = addOptOutCheckPostHogLib(function (event_name, pr
|
|
|
6225
6277
|
data = _.copyAndTruncateStrings(data, options._noTruncate ? null : this.get_config('properties_string_max_length'));
|
|
6226
6278
|
|
|
6227
6279
|
if (this.get_config('debug')) {
|
|
6228
|
-
|
|
6280
|
+
logger.log('PostHog.js send', data);
|
|
6229
6281
|
}
|
|
6230
6282
|
|
|
6231
6283
|
var jsonData = JSON.stringify(data);
|
|
@@ -6259,7 +6311,8 @@ PostHogLib.prototype._invokeCaptureHooks = function (eventName, eventData) {
|
|
|
6259
6311
|
|
|
6260
6312
|
PostHogLib.prototype._calculate_event_properties = function (event_name, event_properties, start_timestamp) {
|
|
6261
6313
|
// set defaults
|
|
6262
|
-
var properties =
|
|
6314
|
+
var properties = _objectSpread2({}, event_properties);
|
|
6315
|
+
|
|
6263
6316
|
properties['token'] = this.get_config('token');
|
|
6264
6317
|
|
|
6265
6318
|
if (event_name === '$snapshot') {
|
|
@@ -6300,7 +6353,7 @@ PostHogLib.prototype._calculate_event_properties = function (event_name, event_p
|
|
|
6300
6353
|
delete properties[blacklisted_prop];
|
|
6301
6354
|
});
|
|
6302
6355
|
} else {
|
|
6303
|
-
console
|
|
6356
|
+
console.error('Invalid value for property_blacklist config: ' + property_blacklist);
|
|
6304
6357
|
}
|
|
6305
6358
|
|
|
6306
6359
|
var sanitize_properties = this.get_config('sanitize_properties');
|
|
@@ -6469,7 +6522,7 @@ PostHogLib.prototype.onFeatureFlags = function (callback) {
|
|
|
6469
6522
|
PostHogLib.prototype.identify = function (new_distinct_id, userPropertiesToSet, userPropertiesToSetOnce) {
|
|
6470
6523
|
//if the new_distinct_id has not been set ignore the identify event
|
|
6471
6524
|
if (!new_distinct_id) {
|
|
6472
|
-
console
|
|
6525
|
+
console.error('Unique user id has not been set in posthog.identify');
|
|
6473
6526
|
return;
|
|
6474
6527
|
}
|
|
6475
6528
|
|
|
@@ -6539,7 +6592,7 @@ PostHogLib.prototype.identify = function (new_distinct_id, userPropertiesToSet,
|
|
|
6539
6592
|
|
|
6540
6593
|
PostHogLib.prototype.group = function (groupType, groupKey, groupPropertiesToSet) {
|
|
6541
6594
|
if (!groupType || !groupKey) {
|
|
6542
|
-
console
|
|
6595
|
+
console.error('posthog.group requires a group type and group key');
|
|
6543
6596
|
return;
|
|
6544
6597
|
}
|
|
6545
6598
|
|
|
@@ -6633,7 +6686,7 @@ PostHogLib.prototype.alias = function (alias, original) {
|
|
|
6633
6686
|
// posthog.people.identify() call made for this user. It is VERY BAD to make an alias with
|
|
6634
6687
|
// this ID, as it will duplicate users.
|
|
6635
6688
|
if (alias === this.get_property(PEOPLE_DISTINCT_ID_KEY)) {
|
|
6636
|
-
console
|
|
6689
|
+
console.critical('Attempting to create alias for existing People user - aborting.');
|
|
6637
6690
|
return -2;
|
|
6638
6691
|
}
|
|
6639
6692
|
|
|
@@ -6654,7 +6707,7 @@ PostHogLib.prototype.alias = function (alias, original) {
|
|
|
6654
6707
|
_this.identify(alias);
|
|
6655
6708
|
});
|
|
6656
6709
|
} else {
|
|
6657
|
-
console
|
|
6710
|
+
console.error('alias matches current distinct_id - skipping api call.');
|
|
6658
6711
|
this.identify(alias);
|
|
6659
6712
|
return -1;
|
|
6660
6713
|
}
|