posthog-js 1.30.0 → 1.31.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 +5 -0
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/es.js +48 -7
- package/dist/es.js.map +1 -1
- package/dist/module.d.ts +2 -0
- package/dist/module.js +48 -7
- package/dist/module.js.map +1 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
package/dist/es.js
CHANGED
|
@@ -881,7 +881,7 @@ var LZString = {
|
|
|
881
881
|
}
|
|
882
882
|
};
|
|
883
883
|
|
|
884
|
-
var version = "1.
|
|
884
|
+
var version = "1.31.0";
|
|
885
885
|
|
|
886
886
|
// e.g. Config.DEBUG = Config.DEBUG || instance.get_config('debug')
|
|
887
887
|
|
|
@@ -5545,12 +5545,28 @@ var SessionIdManager = /*#__PURE__*/function () {
|
|
|
5545
5545
|
this._sessionId = undefined;
|
|
5546
5546
|
this._sessionStartTimestamp = null;
|
|
5547
5547
|
this._sessionActivityTimestamp = null;
|
|
5548
|
+
var persistenceName = config['persistence_name'] || config['token'];
|
|
5549
|
+
this.window_id_storage_key = 'ph_' + persistenceName + '_window_id';
|
|
5550
|
+
this.primary_window_exists_storage_key = 'ph_' + persistenceName + '_primary_window_exists'; // primary_window_exists is set when the DOM has been loaded and is cleared on unload
|
|
5551
|
+
// if it exists here it means there was no unload which suggests this window is opened as a tab duplication, window.open, etc.
|
|
5552
|
+
|
|
5553
|
+
if (!this.persistence.disabled && sessionStore.is_supported()) {
|
|
5554
|
+
var lastWindowId = sessionStore.parse(this.window_id_storage_key);
|
|
5555
|
+
var primaryWindowExists = sessionStore.parse(this.primary_window_exists_storage_key);
|
|
5556
|
+
|
|
5557
|
+
if (lastWindowId && !primaryWindowExists) {
|
|
5558
|
+
// Persist window from previous storage state
|
|
5559
|
+
this._windowId = lastWindowId;
|
|
5560
|
+
} else {
|
|
5561
|
+
// Wipe any reference to previous window id
|
|
5562
|
+
sessionStore.remove(this.window_id_storage_key);
|
|
5563
|
+
} // Flag this session as having a primary window
|
|
5548
5564
|
|
|
5549
|
-
|
|
5550
|
-
this.
|
|
5551
|
-
} else {
|
|
5552
|
-
this.window_id_storage_key = 'ph_' + config['token'] + '_window_id';
|
|
5565
|
+
|
|
5566
|
+
sessionStore.set(this.primary_window_exists_storage_key, true);
|
|
5553
5567
|
}
|
|
5568
|
+
|
|
5569
|
+
this._listenToReloadWindow();
|
|
5554
5570
|
} // Note: this tries to store the windowId in sessionStorage. SessionStorage is unique to the current window/tab,
|
|
5555
5571
|
// and persists page loads/reloads. So it's uniquely suited for storing the windowId. This function also respects
|
|
5556
5572
|
// when persistence is disabled (by user config) and when sessionStorage is not supported (it *should* be supported on all browsers),
|
|
@@ -5577,7 +5593,8 @@ var SessionIdManager = /*#__PURE__*/function () {
|
|
|
5577
5593
|
|
|
5578
5594
|
if (!this.persistence.disabled && sessionStore.is_supported()) {
|
|
5579
5595
|
return sessionStore.parse(this.window_id_storage_key);
|
|
5580
|
-
}
|
|
5596
|
+
} // New window id will be generated
|
|
5597
|
+
|
|
5581
5598
|
|
|
5582
5599
|
return null;
|
|
5583
5600
|
} // Note: 'this.persistence.register' can be disabled in the config.
|
|
@@ -5616,6 +5633,24 @@ var SessionIdManager = /*#__PURE__*/function () {
|
|
|
5616
5633
|
value: function resetSessionId() {
|
|
5617
5634
|
this._setSessionId(null, null, null);
|
|
5618
5635
|
}
|
|
5636
|
+
/*
|
|
5637
|
+
* Listens to window unloads and removes the primaryWindowExists key from sessionStorage.
|
|
5638
|
+
* Reloaded or fresh tabs created after a DOM unloads (reloading the same tab) WILL NOT have this primaryWindowExists flag in session storage.
|
|
5639
|
+
* Cloned sessions (new tab, tab duplication, window.open(), ...) WILL have this primaryWindowExists flag in their copied session storage.
|
|
5640
|
+
* We conditionally check the primaryWindowExists value in the constructor to decide if the window id in the last session storage should be carried over.
|
|
5641
|
+
*/
|
|
5642
|
+
|
|
5643
|
+
}, {
|
|
5644
|
+
key: "_listenToReloadWindow",
|
|
5645
|
+
value: function _listenToReloadWindow() {
|
|
5646
|
+
var _this = this;
|
|
5647
|
+
|
|
5648
|
+
window.addEventListener('beforeunload', function () {
|
|
5649
|
+
if (!_this.persistence.disabled && sessionStore.is_supported()) {
|
|
5650
|
+
sessionStore.remove(_this.primary_window_exists_storage_key);
|
|
5651
|
+
}
|
|
5652
|
+
});
|
|
5653
|
+
}
|
|
5619
5654
|
/*
|
|
5620
5655
|
* This function returns the current sessionId and windowId. It should be used to
|
|
5621
5656
|
* access these values over directly calling `._sessionId` or `._windowId`. In addition
|
|
@@ -5826,6 +5861,8 @@ var SentryIntegration = /*#__PURE__*/_createClass(function SentryIntegration(_po
|
|
|
5826
5861
|
|
|
5827
5862
|
this.setupOnce = function (addGlobalEventProcessor) {
|
|
5828
5863
|
addGlobalEventProcessor(function (event) {
|
|
5864
|
+
var _event$exception, _exceptions$, _exceptions$2;
|
|
5865
|
+
|
|
5829
5866
|
if (event.level !== 'error' || !_posthog.__loaded) return event;
|
|
5830
5867
|
if (!event.tags) event.tags = {};
|
|
5831
5868
|
event.tags['PostHog Person URL'] = _posthog.config.api_host + '/person/' + _posthog.get_distinct_id();
|
|
@@ -5834,9 +5871,13 @@ var SentryIntegration = /*#__PURE__*/_createClass(function SentryIntegration(_po
|
|
|
5834
5871
|
event.tags['PostHog Recording URL'] = _posthog.config.api_host + '/recordings/#sessionRecordingId=' + _posthog.sessionManager.checkAndGetSessionAndWindowId(true).sessionId;
|
|
5835
5872
|
}
|
|
5836
5873
|
|
|
5874
|
+
var exceptions = ((_event$exception = event.exception) === null || _event$exception === void 0 ? void 0 : _event$exception.values) || [];
|
|
5837
5875
|
var data = {
|
|
5838
5876
|
$sentry_event_id: event.event_id,
|
|
5839
|
-
$sentry_exception: event.exception
|
|
5877
|
+
$sentry_exception: event.exception,
|
|
5878
|
+
$sentry_exception_message: (_exceptions$ = exceptions[0]) === null || _exceptions$ === void 0 ? void 0 : _exceptions$.value,
|
|
5879
|
+
$sentry_exception_type: (_exceptions$2 = exceptions[0]) === null || _exceptions$2 === void 0 ? void 0 : _exceptions$2.type,
|
|
5880
|
+
$sentry_tags: event.tags
|
|
5840
5881
|
};
|
|
5841
5882
|
if (organization && projectId) data['$sentry_url'] = (prefix || 'https://sentry.io/organizations/') + organization + '/issues/?project=' + projectId + '&query=' + event.event_id;
|
|
5842
5883
|
|