@posthog/core 1.4.0 → 1.5.1
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/dist/process/spawn-local.d.ts +1 -1
- package/dist/process/spawn-local.d.ts.map +1 -1
- package/dist/process/spawn-local.js +3 -4
- package/dist/process/spawn-local.mjs +2 -3
- package/dist/utils/bot-detection.d.ts +6 -0
- package/dist/utils/bot-detection.d.ts.map +1 -0
- package/dist/utils/bot-detection.js +125 -0
- package/dist/utils/bot-detection.mjs +88 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +37 -15
- package/dist/utils/index.mjs +1 -0
- package/package.json +5 -1
- package/src/process/spawn-local.ts +3 -4
- package/src/utils/bot-detection.ts +114 -0
- package/src/utils/index.ts +1 -0
|
@@ -3,6 +3,6 @@ export declare function spawnLocal(binaryName: string, args: string[], options:
|
|
|
3
3
|
stdio: 'inherit' | 'ignore';
|
|
4
4
|
resolveFrom: string;
|
|
5
5
|
cwd: string;
|
|
6
|
-
onBinaryFound
|
|
6
|
+
onBinaryFound?: (binaryLocation: string) => void;
|
|
7
7
|
}): Promise<void>;
|
|
8
8
|
//# sourceMappingURL=spawn-local.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn-local.d.ts","sourceRoot":"","sources":["../../src/process/spawn-local.ts"],"names":[],"mappings":"AAGA,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;IACtB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAA;IAE3B,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"spawn-local.d.ts","sourceRoot":"","sources":["../../src/process/spawn-local.ts"],"names":[],"mappings":"AAGA,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE;IACP,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;IACtB,KAAK,EAAE,SAAS,GAAG,QAAQ,CAAA;IAE3B,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,aAAa,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAA;CACjD,GACA,OAAO,CAAC,IAAI,CAAC,CA+Bf"}
|
|
@@ -26,21 +26,20 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
spawnLocal: ()=>spawnLocal
|
|
28
28
|
});
|
|
29
|
-
const
|
|
29
|
+
const external_cross_spawn_namespaceObject = require("cross-spawn");
|
|
30
30
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
31
31
|
async function spawnLocal(binaryName, args, options) {
|
|
32
32
|
let binaryLocation;
|
|
33
33
|
try {
|
|
34
34
|
binaryLocation = (0, external_utils_js_namespaceObject.resolveBinaryPath)(options.env.PATH ?? '', options.resolveFrom, binaryName);
|
|
35
|
-
options.onBinaryFound(binaryLocation);
|
|
35
|
+
options.onBinaryFound?.(binaryLocation);
|
|
36
36
|
} catch (e) {
|
|
37
37
|
console.error(e);
|
|
38
38
|
throw new Error(`Binary ${binaryName} not found. Make sure postinstall script was allowed if it installs the binary`);
|
|
39
39
|
}
|
|
40
|
-
const child = (0,
|
|
40
|
+
const child = (0, external_cross_spawn_namespaceObject.spawn)(binaryLocation, [
|
|
41
41
|
...args
|
|
42
42
|
], {
|
|
43
|
-
shell: true,
|
|
44
43
|
stdio: options?.stdio ?? 'inherit',
|
|
45
44
|
env: options.env,
|
|
46
45
|
cwd: options.cwd
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { spawn } from "
|
|
1
|
+
import { spawn } from "cross-spawn";
|
|
2
2
|
import { resolveBinaryPath } from "./utils.mjs";
|
|
3
3
|
async function spawnLocal(binaryName, args, options) {
|
|
4
4
|
let binaryLocation;
|
|
5
5
|
try {
|
|
6
6
|
binaryLocation = resolveBinaryPath(options.env.PATH ?? '', options.resolveFrom, binaryName);
|
|
7
|
-
options.onBinaryFound(binaryLocation);
|
|
7
|
+
options.onBinaryFound?.(binaryLocation);
|
|
8
8
|
} catch (e) {
|
|
9
9
|
console.error(e);
|
|
10
10
|
throw new Error(`Binary ${binaryName} not found. Make sure postinstall script was allowed if it installs the binary`);
|
|
@@ -12,7 +12,6 @@ async function spawnLocal(binaryName, args, options) {
|
|
|
12
12
|
const child = spawn(binaryLocation, [
|
|
13
13
|
...args
|
|
14
14
|
], {
|
|
15
|
-
shell: true,
|
|
16
15
|
stdio: options?.stdio ?? 'inherit',
|
|
17
16
|
env: options.env,
|
|
18
17
|
cwd: options.cwd
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const DEFAULT_BLOCKED_UA_STRS: string[];
|
|
2
|
+
/**
|
|
3
|
+
* Block various web spiders from executing our JS and sending false capturing data
|
|
4
|
+
*/
|
|
5
|
+
export declare const isBlockedUA: (ua: string | undefined, customBlockedUserAgents?: string[]) => boolean;
|
|
6
|
+
//# sourceMappingURL=bot-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bot-detection.d.ts","sourceRoot":"","sources":["../../src/utils/bot-detection.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,UA+FnC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,GAAa,IAAI,MAAM,GAAG,SAAS,EAAE,0BAAyB,MAAM,EAAO,KAAG,OAWrG,CAAA"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
DEFAULT_BLOCKED_UA_STRS: ()=>DEFAULT_BLOCKED_UA_STRS,
|
|
28
|
+
isBlockedUA: ()=>isBlockedUA
|
|
29
|
+
});
|
|
30
|
+
const DEFAULT_BLOCKED_UA_STRS = [
|
|
31
|
+
'amazonbot',
|
|
32
|
+
'amazonproductbot',
|
|
33
|
+
'app.hypefactors.com',
|
|
34
|
+
'applebot',
|
|
35
|
+
'archive.org_bot',
|
|
36
|
+
'awariobot',
|
|
37
|
+
'backlinksextendedbot',
|
|
38
|
+
'baiduspider',
|
|
39
|
+
'bingbot',
|
|
40
|
+
'bingpreview',
|
|
41
|
+
'chrome-lighthouse',
|
|
42
|
+
'dataforseobot',
|
|
43
|
+
'deepscan',
|
|
44
|
+
'duckduckbot',
|
|
45
|
+
'facebookexternal',
|
|
46
|
+
'facebookcatalog',
|
|
47
|
+
'http://yandex.com/bots',
|
|
48
|
+
'hubspot',
|
|
49
|
+
'ia_archiver',
|
|
50
|
+
'leikibot',
|
|
51
|
+
'linkedinbot',
|
|
52
|
+
'meta-externalagent',
|
|
53
|
+
'mj12bot',
|
|
54
|
+
'msnbot',
|
|
55
|
+
'nessus',
|
|
56
|
+
'petalbot',
|
|
57
|
+
'pinterest',
|
|
58
|
+
'prerender',
|
|
59
|
+
'rogerbot',
|
|
60
|
+
'screaming frog',
|
|
61
|
+
'sebot-wa',
|
|
62
|
+
'sitebulb',
|
|
63
|
+
'slackbot',
|
|
64
|
+
'slurp',
|
|
65
|
+
'trendictionbot',
|
|
66
|
+
'turnitin',
|
|
67
|
+
'twitterbot',
|
|
68
|
+
'vercel-screenshot',
|
|
69
|
+
'vercelbot',
|
|
70
|
+
'yahoo! slurp',
|
|
71
|
+
'yandexbot',
|
|
72
|
+
'zoombot',
|
|
73
|
+
'bot.htm',
|
|
74
|
+
'bot.php',
|
|
75
|
+
'(bot;',
|
|
76
|
+
'bot/',
|
|
77
|
+
'crawler',
|
|
78
|
+
'ahrefsbot',
|
|
79
|
+
'ahrefssiteaudit',
|
|
80
|
+
'semrushbot',
|
|
81
|
+
'siteauditbot',
|
|
82
|
+
'splitsignalbot',
|
|
83
|
+
'gptbot',
|
|
84
|
+
'oai-searchbot',
|
|
85
|
+
'chatgpt-user',
|
|
86
|
+
'perplexitybot',
|
|
87
|
+
'better uptime bot',
|
|
88
|
+
'sentryuptimebot',
|
|
89
|
+
'uptimerobot',
|
|
90
|
+
'headlesschrome',
|
|
91
|
+
'cypress',
|
|
92
|
+
'google-hoteladsverifier',
|
|
93
|
+
'adsbot-google',
|
|
94
|
+
'apis-google',
|
|
95
|
+
'duplexweb-google',
|
|
96
|
+
'feedfetcher-google',
|
|
97
|
+
'google favicon',
|
|
98
|
+
'google web preview',
|
|
99
|
+
'google-read-aloud',
|
|
100
|
+
'googlebot',
|
|
101
|
+
'googleother',
|
|
102
|
+
'google-cloudvertexbot',
|
|
103
|
+
'googleweblight',
|
|
104
|
+
'mediapartners-google',
|
|
105
|
+
'storebot-google',
|
|
106
|
+
'google-inspectiontool',
|
|
107
|
+
'bytespider'
|
|
108
|
+
];
|
|
109
|
+
const isBlockedUA = function(ua, customBlockedUserAgents = []) {
|
|
110
|
+
if (!ua) return false;
|
|
111
|
+
const uaLower = ua.toLowerCase();
|
|
112
|
+
return DEFAULT_BLOCKED_UA_STRS.concat(customBlockedUserAgents).some((blockedUA)=>{
|
|
113
|
+
const blockedUaLower = blockedUA.toLowerCase();
|
|
114
|
+
return -1 !== uaLower.indexOf(blockedUaLower);
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
exports.DEFAULT_BLOCKED_UA_STRS = __webpack_exports__.DEFAULT_BLOCKED_UA_STRS;
|
|
118
|
+
exports.isBlockedUA = __webpack_exports__.isBlockedUA;
|
|
119
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
120
|
+
"DEFAULT_BLOCKED_UA_STRS",
|
|
121
|
+
"isBlockedUA"
|
|
122
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
123
|
+
Object.defineProperty(exports, '__esModule', {
|
|
124
|
+
value: true
|
|
125
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const DEFAULT_BLOCKED_UA_STRS = [
|
|
2
|
+
'amazonbot',
|
|
3
|
+
'amazonproductbot',
|
|
4
|
+
'app.hypefactors.com',
|
|
5
|
+
'applebot',
|
|
6
|
+
'archive.org_bot',
|
|
7
|
+
'awariobot',
|
|
8
|
+
'backlinksextendedbot',
|
|
9
|
+
'baiduspider',
|
|
10
|
+
'bingbot',
|
|
11
|
+
'bingpreview',
|
|
12
|
+
'chrome-lighthouse',
|
|
13
|
+
'dataforseobot',
|
|
14
|
+
'deepscan',
|
|
15
|
+
'duckduckbot',
|
|
16
|
+
'facebookexternal',
|
|
17
|
+
'facebookcatalog',
|
|
18
|
+
'http://yandex.com/bots',
|
|
19
|
+
'hubspot',
|
|
20
|
+
'ia_archiver',
|
|
21
|
+
'leikibot',
|
|
22
|
+
'linkedinbot',
|
|
23
|
+
'meta-externalagent',
|
|
24
|
+
'mj12bot',
|
|
25
|
+
'msnbot',
|
|
26
|
+
'nessus',
|
|
27
|
+
'petalbot',
|
|
28
|
+
'pinterest',
|
|
29
|
+
'prerender',
|
|
30
|
+
'rogerbot',
|
|
31
|
+
'screaming frog',
|
|
32
|
+
'sebot-wa',
|
|
33
|
+
'sitebulb',
|
|
34
|
+
'slackbot',
|
|
35
|
+
'slurp',
|
|
36
|
+
'trendictionbot',
|
|
37
|
+
'turnitin',
|
|
38
|
+
'twitterbot',
|
|
39
|
+
'vercel-screenshot',
|
|
40
|
+
'vercelbot',
|
|
41
|
+
'yahoo! slurp',
|
|
42
|
+
'yandexbot',
|
|
43
|
+
'zoombot',
|
|
44
|
+
'bot.htm',
|
|
45
|
+
'bot.php',
|
|
46
|
+
'(bot;',
|
|
47
|
+
'bot/',
|
|
48
|
+
'crawler',
|
|
49
|
+
'ahrefsbot',
|
|
50
|
+
'ahrefssiteaudit',
|
|
51
|
+
'semrushbot',
|
|
52
|
+
'siteauditbot',
|
|
53
|
+
'splitsignalbot',
|
|
54
|
+
'gptbot',
|
|
55
|
+
'oai-searchbot',
|
|
56
|
+
'chatgpt-user',
|
|
57
|
+
'perplexitybot',
|
|
58
|
+
'better uptime bot',
|
|
59
|
+
'sentryuptimebot',
|
|
60
|
+
'uptimerobot',
|
|
61
|
+
'headlesschrome',
|
|
62
|
+
'cypress',
|
|
63
|
+
'google-hoteladsverifier',
|
|
64
|
+
'adsbot-google',
|
|
65
|
+
'apis-google',
|
|
66
|
+
'duplexweb-google',
|
|
67
|
+
'feedfetcher-google',
|
|
68
|
+
'google favicon',
|
|
69
|
+
'google web preview',
|
|
70
|
+
'google-read-aloud',
|
|
71
|
+
'googlebot',
|
|
72
|
+
'googleother',
|
|
73
|
+
'google-cloudvertexbot',
|
|
74
|
+
'googleweblight',
|
|
75
|
+
'mediapartners-google',
|
|
76
|
+
'storebot-google',
|
|
77
|
+
'google-inspectiontool',
|
|
78
|
+
'bytespider'
|
|
79
|
+
];
|
|
80
|
+
const isBlockedUA = function(ua, customBlockedUserAgents = []) {
|
|
81
|
+
if (!ua) return false;
|
|
82
|
+
const uaLower = ua.toLowerCase();
|
|
83
|
+
return DEFAULT_BLOCKED_UA_STRS.concat(customBlockedUserAgents).some((blockedUA)=>{
|
|
84
|
+
const blockedUaLower = blockedUA.toLowerCase();
|
|
85
|
+
return -1 !== uaLower.indexOf(blockedUaLower);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
export { DEFAULT_BLOCKED_UA_STRS, isBlockedUA };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAE/B,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,wBAAgB,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI9D;AASD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAA;CACtC;AAED,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAqB5F;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAOnE;AAGD,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAEtD,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,KAEzC,CAAA;AAED,wBAAgB,QAAQ,IAAI,SAAS,GAAG,SAAS,CAEhD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC1C,OAAO,CAAC,CAAC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,EAAE,CAAC,CAStF"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAE/B,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,wBAAgB,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI9D;AASD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAA;CACtC;AAED,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAqB5F;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAOnE;AAGD,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAEtD,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,KAEzC,CAAA;AAED,wBAAgB,QAAQ,IAAI,SAAS,GAAG,SAAS,CAEhD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC1C,OAAO,CAAC,CAAC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,EAAE,CAAC,CAStF"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
+
"./bot-detection": function(module) {
|
|
4
|
+
module.exports = require("./bot-detection.js");
|
|
5
|
+
},
|
|
3
6
|
"./bucketed-rate-limiter": function(module) {
|
|
4
7
|
module.exports = require("./bucketed-rate-limiter.js");
|
|
5
8
|
},
|
|
@@ -72,9 +75,28 @@ var __webpack_exports__ = {};
|
|
|
72
75
|
retriable: ()=>retriable,
|
|
73
76
|
safeSetTimeout: ()=>safeSetTimeout
|
|
74
77
|
});
|
|
75
|
-
var
|
|
78
|
+
var _bot_detection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./bot-detection");
|
|
79
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
80
|
+
for(var __WEBPACK_IMPORT_KEY__ in _bot_detection__WEBPACK_IMPORTED_MODULE_0__)if ([
|
|
81
|
+
"removeTrailingSlash",
|
|
82
|
+
"retriable",
|
|
83
|
+
"default",
|
|
84
|
+
"currentISOTime",
|
|
85
|
+
"currentTimestamp",
|
|
86
|
+
"STRING_FORMAT",
|
|
87
|
+
"isError",
|
|
88
|
+
"safeSetTimeout",
|
|
89
|
+
"getFetch",
|
|
90
|
+
"isPromise",
|
|
91
|
+
"assert",
|
|
92
|
+
"allSettled"
|
|
93
|
+
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
94
|
+
return _bot_detection__WEBPACK_IMPORTED_MODULE_0__[key];
|
|
95
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
96
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
97
|
+
var _bucketed_rate_limiter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./bucketed-rate-limiter");
|
|
76
98
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
77
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
99
|
+
for(var __WEBPACK_IMPORT_KEY__ in _bucketed_rate_limiter__WEBPACK_IMPORTED_MODULE_1__)if ([
|
|
78
100
|
"removeTrailingSlash",
|
|
79
101
|
"retriable",
|
|
80
102
|
"default",
|
|
@@ -88,12 +110,12 @@ var __webpack_exports__ = {};
|
|
|
88
110
|
"assert",
|
|
89
111
|
"allSettled"
|
|
90
112
|
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
91
|
-
return
|
|
113
|
+
return _bucketed_rate_limiter__WEBPACK_IMPORTED_MODULE_1__[key];
|
|
92
114
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
93
115
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
94
|
-
var
|
|
116
|
+
var _number_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./number-utils");
|
|
95
117
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
96
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
118
|
+
for(var __WEBPACK_IMPORT_KEY__ in _number_utils__WEBPACK_IMPORTED_MODULE_2__)if ([
|
|
97
119
|
"removeTrailingSlash",
|
|
98
120
|
"retriable",
|
|
99
121
|
"default",
|
|
@@ -107,12 +129,12 @@ var __webpack_exports__ = {};
|
|
|
107
129
|
"assert",
|
|
108
130
|
"allSettled"
|
|
109
131
|
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
110
|
-
return
|
|
132
|
+
return _number_utils__WEBPACK_IMPORTED_MODULE_2__[key];
|
|
111
133
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
112
134
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
113
|
-
var
|
|
135
|
+
var _string_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./string-utils");
|
|
114
136
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
115
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
137
|
+
for(var __WEBPACK_IMPORT_KEY__ in _string_utils__WEBPACK_IMPORTED_MODULE_3__)if ([
|
|
116
138
|
"removeTrailingSlash",
|
|
117
139
|
"retriable",
|
|
118
140
|
"default",
|
|
@@ -126,12 +148,12 @@ var __webpack_exports__ = {};
|
|
|
126
148
|
"assert",
|
|
127
149
|
"allSettled"
|
|
128
150
|
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
129
|
-
return
|
|
151
|
+
return _string_utils__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
130
152
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
131
153
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
132
|
-
var
|
|
154
|
+
var _type_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./type-utils");
|
|
133
155
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
134
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
156
|
+
for(var __WEBPACK_IMPORT_KEY__ in _type_utils__WEBPACK_IMPORTED_MODULE_4__)if ([
|
|
135
157
|
"removeTrailingSlash",
|
|
136
158
|
"retriable",
|
|
137
159
|
"default",
|
|
@@ -145,12 +167,12 @@ var __webpack_exports__ = {};
|
|
|
145
167
|
"assert",
|
|
146
168
|
"allSettled"
|
|
147
169
|
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
148
|
-
return
|
|
170
|
+
return _type_utils__WEBPACK_IMPORTED_MODULE_4__[key];
|
|
149
171
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
150
172
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
151
|
-
var
|
|
173
|
+
var _promise_queue__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./promise-queue");
|
|
152
174
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
153
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
175
|
+
for(var __WEBPACK_IMPORT_KEY__ in _promise_queue__WEBPACK_IMPORTED_MODULE_5__)if ([
|
|
154
176
|
"removeTrailingSlash",
|
|
155
177
|
"retriable",
|
|
156
178
|
"default",
|
|
@@ -164,7 +186,7 @@ var __webpack_exports__ = {};
|
|
|
164
186
|
"assert",
|
|
165
187
|
"allSettled"
|
|
166
188
|
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
167
|
-
return
|
|
189
|
+
return _promise_queue__WEBPACK_IMPORTED_MODULE_5__[key];
|
|
168
190
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
169
191
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
170
192
|
const STRING_FORMAT = 'utf8';
|
package/dist/utils/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -49,9 +49,13 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@rslib/core": "^0.10.5",
|
|
52
|
+
"@types/cross-spawn": "^6.0.6",
|
|
52
53
|
"jest": "^29.7.0",
|
|
53
54
|
"@posthog-tooling/tsconfig-base": "1.0.0"
|
|
54
55
|
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"cross-spawn": "^7.0.6"
|
|
58
|
+
},
|
|
55
59
|
"scripts": {
|
|
56
60
|
"clean": "rimraf dist",
|
|
57
61
|
"lint": "eslint src",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawn } from '
|
|
1
|
+
import { spawn } from 'cross-spawn'
|
|
2
2
|
import { resolveBinaryPath } from './utils'
|
|
3
3
|
|
|
4
4
|
export async function spawnLocal(
|
|
@@ -10,13 +10,13 @@ export async function spawnLocal(
|
|
|
10
10
|
// We start traversing the file system tree from this directory and we go up until we find the binary
|
|
11
11
|
resolveFrom: string
|
|
12
12
|
cwd: string
|
|
13
|
-
onBinaryFound
|
|
13
|
+
onBinaryFound?: (binaryLocation: string) => void
|
|
14
14
|
}
|
|
15
15
|
): Promise<void> {
|
|
16
16
|
let binaryLocation
|
|
17
17
|
try {
|
|
18
18
|
binaryLocation = resolveBinaryPath(options.env.PATH ?? '', options.resolveFrom, binaryName)
|
|
19
|
-
options.onBinaryFound(binaryLocation)
|
|
19
|
+
options.onBinaryFound?.(binaryLocation)
|
|
20
20
|
} catch (e) {
|
|
21
21
|
console.error(e)
|
|
22
22
|
throw new Error(
|
|
@@ -25,7 +25,6 @@ export async function spawnLocal(
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const child = spawn(binaryLocation, [...args], {
|
|
28
|
-
shell: true,
|
|
29
28
|
stdio: options?.stdio ?? 'inherit',
|
|
30
29
|
env: options.env,
|
|
31
30
|
cwd: options.cwd,
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// List of blocked user agent strings that identify bots
|
|
2
|
+
// This is shared between browser and node SDKs to ensure consistent bot detection
|
|
3
|
+
export const DEFAULT_BLOCKED_UA_STRS = [
|
|
4
|
+
// Random assortment of bots
|
|
5
|
+
'amazonbot',
|
|
6
|
+
'amazonproductbot',
|
|
7
|
+
'app.hypefactors.com', // Buck, but "buck" is too short to be safe to block (https://app.hypefactors.com/media-monitoring/about.htm)
|
|
8
|
+
'applebot',
|
|
9
|
+
'archive.org_bot',
|
|
10
|
+
'awariobot',
|
|
11
|
+
'backlinksextendedbot',
|
|
12
|
+
'baiduspider',
|
|
13
|
+
'bingbot',
|
|
14
|
+
'bingpreview',
|
|
15
|
+
'chrome-lighthouse',
|
|
16
|
+
'dataforseobot',
|
|
17
|
+
'deepscan',
|
|
18
|
+
'duckduckbot',
|
|
19
|
+
'facebookexternal',
|
|
20
|
+
'facebookcatalog',
|
|
21
|
+
'http://yandex.com/bots',
|
|
22
|
+
'hubspot',
|
|
23
|
+
'ia_archiver',
|
|
24
|
+
'leikibot',
|
|
25
|
+
'linkedinbot',
|
|
26
|
+
'meta-externalagent',
|
|
27
|
+
'mj12bot',
|
|
28
|
+
'msnbot',
|
|
29
|
+
'nessus',
|
|
30
|
+
'petalbot',
|
|
31
|
+
'pinterest',
|
|
32
|
+
'prerender',
|
|
33
|
+
'rogerbot',
|
|
34
|
+
'screaming frog',
|
|
35
|
+
'sebot-wa',
|
|
36
|
+
'sitebulb',
|
|
37
|
+
'slackbot',
|
|
38
|
+
'slurp',
|
|
39
|
+
'trendictionbot',
|
|
40
|
+
'turnitin',
|
|
41
|
+
'twitterbot',
|
|
42
|
+
'vercel-screenshot',
|
|
43
|
+
'vercelbot',
|
|
44
|
+
'yahoo! slurp',
|
|
45
|
+
'yandexbot',
|
|
46
|
+
'zoombot',
|
|
47
|
+
|
|
48
|
+
// Bot-like words, maybe we should block `bot` entirely?
|
|
49
|
+
'bot.htm',
|
|
50
|
+
'bot.php',
|
|
51
|
+
'(bot;',
|
|
52
|
+
'bot/',
|
|
53
|
+
'crawler',
|
|
54
|
+
|
|
55
|
+
// Ahrefs: https://ahrefs.com/seo/glossary/ahrefsbot
|
|
56
|
+
'ahrefsbot',
|
|
57
|
+
'ahrefssiteaudit',
|
|
58
|
+
|
|
59
|
+
// Semrush bots: https://www.semrush.com/bot/
|
|
60
|
+
'semrushbot',
|
|
61
|
+
'siteauditbot',
|
|
62
|
+
'splitsignalbot',
|
|
63
|
+
|
|
64
|
+
// AI Crawlers
|
|
65
|
+
'gptbot',
|
|
66
|
+
'oai-searchbot',
|
|
67
|
+
'chatgpt-user',
|
|
68
|
+
'perplexitybot',
|
|
69
|
+
|
|
70
|
+
// Uptime-like stuff
|
|
71
|
+
'better uptime bot',
|
|
72
|
+
'sentryuptimebot',
|
|
73
|
+
'uptimerobot',
|
|
74
|
+
|
|
75
|
+
// headless browsers
|
|
76
|
+
'headlesschrome',
|
|
77
|
+
'cypress',
|
|
78
|
+
// we don't block electron here, as many customers use posthog-js in electron apps
|
|
79
|
+
|
|
80
|
+
// a whole bunch of goog-specific crawlers
|
|
81
|
+
// https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers
|
|
82
|
+
'google-hoteladsverifier',
|
|
83
|
+
'adsbot-google',
|
|
84
|
+
'apis-google',
|
|
85
|
+
'duplexweb-google',
|
|
86
|
+
'feedfetcher-google',
|
|
87
|
+
'google favicon',
|
|
88
|
+
'google web preview',
|
|
89
|
+
'google-read-aloud',
|
|
90
|
+
'googlebot',
|
|
91
|
+
'googleother',
|
|
92
|
+
'google-cloudvertexbot',
|
|
93
|
+
'googleweblight',
|
|
94
|
+
'mediapartners-google',
|
|
95
|
+
'storebot-google',
|
|
96
|
+
'google-inspectiontool',
|
|
97
|
+
'bytespider',
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Block various web spiders from executing our JS and sending false capturing data
|
|
102
|
+
*/
|
|
103
|
+
export const isBlockedUA = function (ua: string | undefined, customBlockedUserAgents: string[] = []): boolean {
|
|
104
|
+
if (!ua) {
|
|
105
|
+
return false
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const uaLower = ua.toLowerCase()
|
|
109
|
+
return DEFAULT_BLOCKED_UA_STRS.concat(customBlockedUserAgents).some((blockedUA) => {
|
|
110
|
+
const blockedUaLower = blockedUA.toLowerCase()
|
|
111
|
+
// can't use includes because IE 11 :/
|
|
112
|
+
return uaLower.indexOf(blockedUaLower) !== -1
|
|
113
|
+
})
|
|
114
|
+
}
|