posthog-js 1.36.1 → 1.37.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 +9 -0
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/es.js +77 -14
- package/dist/es.js.map +1 -1
- package/dist/module.d.ts +32 -5
- package/dist/module.js +77 -14
- package/dist/module.js.map +1 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
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.37.0";
|
|
921
921
|
|
|
922
922
|
// e.g. Config.DEBUG = Config.DEBUG || instance.get_config('debug')
|
|
923
923
|
|
|
@@ -1864,20 +1864,64 @@ function isTextNode(el) {
|
|
|
1864
1864
|
function isDocumentFragment(el) {
|
|
1865
1865
|
return !!el && el.nodeType === 11; // Node.DOCUMENT_FRAGMENT_NODE - use integer constant for browser portability
|
|
1866
1866
|
}
|
|
1867
|
-
var
|
|
1867
|
+
var autocaptureCompatibleElements = ['a', 'button', 'form', 'input', 'select', 'textarea', 'label'];
|
|
1868
1868
|
/*
|
|
1869
1869
|
* Check whether a DOM event should be "captured" or if it may contain sentitive data
|
|
1870
1870
|
* using a variety of heuristics.
|
|
1871
1871
|
* @param {Element} el - element to check
|
|
1872
1872
|
* @param {Event} event - event to check
|
|
1873
|
+
* @param {Object} autocaptureConfig - autocapture config
|
|
1873
1874
|
* @returns {boolean} whether the event should be captured
|
|
1874
1875
|
*/
|
|
1875
1876
|
|
|
1876
1877
|
function shouldCaptureDomEvent(el, event) {
|
|
1878
|
+
var autocaptureConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
1879
|
+
|
|
1877
1880
|
if (!el || isTag(el, 'html') || !isElementNode(el)) {
|
|
1878
1881
|
return false;
|
|
1879
1882
|
}
|
|
1880
1883
|
|
|
1884
|
+
if (autocaptureConfig !== null && autocaptureConfig !== void 0 && autocaptureConfig.url_allowlist) {
|
|
1885
|
+
var url = window.location.href;
|
|
1886
|
+
var allowlist = autocaptureConfig.url_allowlist;
|
|
1887
|
+
|
|
1888
|
+
if (allowlist && !allowlist.some(function (regex) {
|
|
1889
|
+
return url.match(regex);
|
|
1890
|
+
})) {
|
|
1891
|
+
return false;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
if (autocaptureConfig !== null && autocaptureConfig !== void 0 && autocaptureConfig.dom_event_allowlist) {
|
|
1896
|
+
var _allowlist = autocaptureConfig.dom_event_allowlist;
|
|
1897
|
+
|
|
1898
|
+
if (_allowlist && !_allowlist.some(function (eventType) {
|
|
1899
|
+
return event.type === eventType;
|
|
1900
|
+
})) {
|
|
1901
|
+
return false;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
if (autocaptureConfig !== null && autocaptureConfig !== void 0 && autocaptureConfig.element_allowlist) {
|
|
1906
|
+
var _allowlist2 = autocaptureConfig.element_allowlist;
|
|
1907
|
+
|
|
1908
|
+
if (_allowlist2 && !_allowlist2.some(function (elementType) {
|
|
1909
|
+
return el.tagName.toLowerCase() === elementType;
|
|
1910
|
+
})) {
|
|
1911
|
+
return false;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
if (autocaptureConfig !== null && autocaptureConfig !== void 0 && autocaptureConfig.css_selector_allowlist) {
|
|
1916
|
+
var _allowlist3 = autocaptureConfig.css_selector_allowlist;
|
|
1917
|
+
|
|
1918
|
+
if (_allowlist3 && !_allowlist3.some(function (selector) {
|
|
1919
|
+
return el.matches(selector);
|
|
1920
|
+
})) {
|
|
1921
|
+
return false;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1881
1925
|
var parentIsUsefulElement = false;
|
|
1882
1926
|
var targetElementList = [el]; // TODO: remove this var, it's never queried
|
|
1883
1927
|
|
|
@@ -1895,7 +1939,7 @@ function shouldCaptureDomEvent(el, event) {
|
|
|
1895
1939
|
parentNode = curEl.parentNode || false;
|
|
1896
1940
|
if (!parentNode) break;
|
|
1897
1941
|
|
|
1898
|
-
if (
|
|
1942
|
+
if (autocaptureCompatibleElements.indexOf(parentNode.tagName.toLowerCase()) > -1) {
|
|
1899
1943
|
parentIsUsefulElement = true;
|
|
1900
1944
|
} else {
|
|
1901
1945
|
var _compStyles = window.getComputedStyle(parentNode);
|
|
@@ -1933,7 +1977,7 @@ function shouldCaptureDomEvent(el, event) {
|
|
|
1933
1977
|
|
|
1934
1978
|
default:
|
|
1935
1979
|
if (parentIsUsefulElement) return event.type === 'click';
|
|
1936
|
-
return event.type === 'click' && (
|
|
1980
|
+
return event.type === 'click' && (autocaptureCompatibleElements.indexOf(tag) > -1 || el.getAttribute('contenteditable') === 'true');
|
|
1937
1981
|
}
|
|
1938
1982
|
}
|
|
1939
1983
|
/*
|
|
@@ -2137,7 +2181,7 @@ var autocapture = {
|
|
|
2137
2181
|
tag_name: tag_name
|
|
2138
2182
|
};
|
|
2139
2183
|
|
|
2140
|
-
if (
|
|
2184
|
+
if (autocaptureCompatibleElements.indexOf(tag_name) > -1 && !maskText) {
|
|
2141
2185
|
props['$el_text'] = getSafeText(elem);
|
|
2142
2186
|
}
|
|
2143
2187
|
|
|
@@ -2248,7 +2292,7 @@ var autocapture = {
|
|
|
2248
2292
|
(_this$rageclicks = this.rageclicks) === null || _this$rageclicks === void 0 ? void 0 : _this$rageclicks.click(e.clientX, e.clientY, new Date().getTime());
|
|
2249
2293
|
}
|
|
2250
2294
|
|
|
2251
|
-
if (target && shouldCaptureDomEvent(target, e)) {
|
|
2295
|
+
if (target && shouldCaptureDomEvent(target, e, this.config)) {
|
|
2252
2296
|
var targetElementList = [target];
|
|
2253
2297
|
var curEl = target;
|
|
2254
2298
|
|
|
@@ -2328,7 +2372,21 @@ var autocapture = {
|
|
|
2328
2372
|
},
|
|
2329
2373
|
_customProperties: [],
|
|
2330
2374
|
rageclicks: null,
|
|
2375
|
+
config: undefined,
|
|
2331
2376
|
init: function init(instance) {
|
|
2377
|
+
var _this$config;
|
|
2378
|
+
|
|
2379
|
+
if (typeof instance.__autocapture !== 'boolean') {
|
|
2380
|
+
this.config = instance.__autocapture;
|
|
2381
|
+
} // precompile the regex
|
|
2382
|
+
|
|
2383
|
+
|
|
2384
|
+
if ((_this$config = this.config) !== null && _this$config !== void 0 && _this$config.url_allowlist) {
|
|
2385
|
+
this.config.url_allowlist = this.config.url_allowlist.map(function (url) {
|
|
2386
|
+
return new RegExp(url);
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2332
2390
|
this.rageclicks = new RageClick(instance);
|
|
2333
2391
|
},
|
|
2334
2392
|
afterDecideResponse: function afterDecideResponse(response, instance) {
|
|
@@ -2349,7 +2407,7 @@ var autocapture = {
|
|
|
2349
2407
|
|
|
2350
2408
|
this._addDomEventHandlers(instance);
|
|
2351
2409
|
} else {
|
|
2352
|
-
instance['
|
|
2410
|
+
instance['__autocapture'] = false;
|
|
2353
2411
|
}
|
|
2354
2412
|
},
|
|
2355
2413
|
// this is a mechanism to ramp up CE with no server-side interaction.
|
|
@@ -5297,6 +5355,10 @@ function strToU8(str, latin1) {
|
|
|
5297
5355
|
return slc(ar, 0, ai);
|
|
5298
5356
|
}
|
|
5299
5357
|
|
|
5358
|
+
/**
|
|
5359
|
+
* If an array is passed for an allowlist, autocapture events will only be sent for elements matching
|
|
5360
|
+
* at least one of the elements in the array. Multiple allowlists can be used
|
|
5361
|
+
*/
|
|
5300
5362
|
var Compression;
|
|
5301
5363
|
|
|
5302
5364
|
(function (Compression) {
|
|
@@ -6120,7 +6182,7 @@ var defaultConfig = function defaultConfig() {
|
|
|
6120
6182
|
ui_host: null,
|
|
6121
6183
|
token: '',
|
|
6122
6184
|
autocapture: true,
|
|
6123
|
-
rageclick:
|
|
6185
|
+
rageclick: true,
|
|
6124
6186
|
cross_subdomain_cookie: (document$1 === null || document$1 === void 0 ? void 0 : (_document$location = document$1.location) === null || _document$location === void 0 ? void 0 : (_document$location$ho = _document$location.hostname) === null || _document$location$ho === void 0 ? void 0 : _document$location$ho.indexOf('herokuapp.com')) === -1,
|
|
6125
6187
|
persistence: 'cookie',
|
|
6126
6188
|
persistence_name: '',
|
|
@@ -6223,17 +6285,18 @@ var create_mplib = function create_mplib(token, config, name) {
|
|
|
6223
6285
|
instance.toolbar.maybeLoadToolbar();
|
|
6224
6286
|
instance.sessionRecording = new SessionRecording(instance);
|
|
6225
6287
|
instance.sessionRecording.startRecordingIfEnabled();
|
|
6226
|
-
instance.
|
|
6288
|
+
instance.__autocapture = instance.get_config('autocapture');
|
|
6227
6289
|
|
|
6228
6290
|
if (instance.get_config('autocapture')) {
|
|
6291
|
+
instance.__autocapture = instance.get_config('autocapture');
|
|
6229
6292
|
var num_buckets = 100;
|
|
6230
6293
|
var num_enabled_buckets = 100;
|
|
6231
6294
|
|
|
6232
6295
|
if (!autocapture.enabledForProject(instance.get_config('token'), num_buckets, num_enabled_buckets)) {
|
|
6233
|
-
instance.
|
|
6296
|
+
instance.__autocapture = false;
|
|
6234
6297
|
logger.log('Not in active bucket: disabling Automatic Event Collection.');
|
|
6235
6298
|
} else if (!autocapture.isBrowserSupported()) {
|
|
6236
|
-
instance.
|
|
6299
|
+
instance.__autocapture = false;
|
|
6237
6300
|
logger.log('Disabling Automatic Event Collection because this browser is not supported');
|
|
6238
6301
|
} else {
|
|
6239
6302
|
autocapture.init(instance);
|
|
@@ -6279,7 +6342,7 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
6279
6342
|
this.__captureHooks = [];
|
|
6280
6343
|
this.__request_queue = [];
|
|
6281
6344
|
this.__loaded = false;
|
|
6282
|
-
this.
|
|
6345
|
+
this.__autocapture = undefined;
|
|
6283
6346
|
|
|
6284
6347
|
this._jsc = function () {};
|
|
6285
6348
|
|
|
@@ -7285,8 +7348,8 @@ var PostHog = /*#__PURE__*/function () {
|
|
|
7285
7348
|
* // Automatically capture clicks, form submissions and change events
|
|
7286
7349
|
* autocapture: true
|
|
7287
7350
|
*
|
|
7288
|
-
* // Capture rage clicks
|
|
7289
|
-
* rageclick:
|
|
7351
|
+
* // Capture rage clicks
|
|
7352
|
+
* rageclick: true
|
|
7290
7353
|
*
|
|
7291
7354
|
* // transport for sending requests ('XHR' or 'sendBeacon')
|
|
7292
7355
|
* // NB: sendBeacon should only be used for scenarios such as
|