@posthog/core 1.51.2 → 1.52.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/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +36 -20
- package/dist/utils/index.mjs +5 -1
- package/package.json +2 -2
- package/src/utils/index.ts +6 -0
package/dist/utils/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export declare function getEventUuid(uuid: unknown, generateUuid: () => string):
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function createNamedError(name: string, message?: string): Error;
|
|
29
29
|
export declare function assert(truthyValue: any, message: string): void;
|
|
30
|
+
/** Detects HTTP(S) URLs and explicit relative paths by prefix; does not validate URL syntax. */
|
|
31
|
+
export declare function isUrl(value: unknown): value is string;
|
|
30
32
|
export declare function removeTrailingSlash(url: string): string;
|
|
31
33
|
export declare function stripUrlHash<T extends string | undefined>(url: T): T extends string ? string : undefined;
|
|
32
34
|
export interface RetriableOptions {
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA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CAAC,EACrC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,IAAI,GACrB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAoBnB;AAGD,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAEtD,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
|
@@ -81,9 +81,10 @@ function __webpack_require__(moduleId) {
|
|
|
81
81
|
var __webpack_exports__ = {};
|
|
82
82
|
(()=>{
|
|
83
83
|
__webpack_require__.r(__webpack_exports__);
|
|
84
|
-
var
|
|
84
|
+
var _type_utils__rspack_import_0 = __webpack_require__("./type-utils");
|
|
85
|
+
var _bot_detection__rspack_import_1 = __webpack_require__("./bot-detection");
|
|
85
86
|
var __rspack_reexport = {};
|
|
86
|
-
for(const __rspack_import_key in
|
|
87
|
+
for(const __rspack_import_key in _bot_detection__rspack_import_1)if ([
|
|
87
88
|
"UUID_REGEX",
|
|
88
89
|
"currentTimestamp",
|
|
89
90
|
"getEventUuid",
|
|
@@ -101,12 +102,13 @@ var __webpack_exports__ = {};
|
|
|
101
102
|
"retriable",
|
|
102
103
|
"isPromise",
|
|
103
104
|
"getFetch",
|
|
105
|
+
"isUrl",
|
|
104
106
|
"toJsonSafeValue"
|
|
105
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
107
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_bot_detection__rspack_import_1[__rspack_import_key];
|
|
106
108
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
107
|
-
var
|
|
109
|
+
var _browser_utils__rspack_import_2 = __webpack_require__("./browser-utils");
|
|
108
110
|
var __rspack_reexport = {};
|
|
109
|
-
for(const __rspack_import_key in
|
|
111
|
+
for(const __rspack_import_key in _browser_utils__rspack_import_2)if ([
|
|
110
112
|
"UUID_REGEX",
|
|
111
113
|
"currentTimestamp",
|
|
112
114
|
"getEventUuid",
|
|
@@ -124,12 +126,13 @@ var __webpack_exports__ = {};
|
|
|
124
126
|
"retriable",
|
|
125
127
|
"isPromise",
|
|
126
128
|
"getFetch",
|
|
129
|
+
"isUrl",
|
|
127
130
|
"toJsonSafeValue"
|
|
128
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
131
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_browser_utils__rspack_import_2[__rspack_import_key];
|
|
129
132
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
130
|
-
var
|
|
133
|
+
var _bucketed_rate_limiter__rspack_import_3 = __webpack_require__("./bucketed-rate-limiter");
|
|
131
134
|
var __rspack_reexport = {};
|
|
132
|
-
for(const __rspack_import_key in
|
|
135
|
+
for(const __rspack_import_key in _bucketed_rate_limiter__rspack_import_3)if ([
|
|
133
136
|
"UUID_REGEX",
|
|
134
137
|
"currentTimestamp",
|
|
135
138
|
"getEventUuid",
|
|
@@ -147,13 +150,14 @@ var __webpack_exports__ = {};
|
|
|
147
150
|
"retriable",
|
|
148
151
|
"isPromise",
|
|
149
152
|
"getFetch",
|
|
153
|
+
"isUrl",
|
|
150
154
|
"toJsonSafeValue"
|
|
151
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
155
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_bucketed_rate_limiter__rspack_import_3[__rspack_import_key];
|
|
152
156
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
153
|
-
var
|
|
154
|
-
var
|
|
157
|
+
var _json_utils__rspack_import_4 = __webpack_require__("./json-utils");
|
|
158
|
+
var _number_utils__rspack_import_5 = __webpack_require__("./number-utils");
|
|
155
159
|
var __rspack_reexport = {};
|
|
156
|
-
for(const __rspack_import_key in
|
|
160
|
+
for(const __rspack_import_key in _number_utils__rspack_import_5)if ([
|
|
157
161
|
"UUID_REGEX",
|
|
158
162
|
"currentTimestamp",
|
|
159
163
|
"getEventUuid",
|
|
@@ -171,12 +175,13 @@ var __webpack_exports__ = {};
|
|
|
171
175
|
"retriable",
|
|
172
176
|
"isPromise",
|
|
173
177
|
"getFetch",
|
|
178
|
+
"isUrl",
|
|
174
179
|
"toJsonSafeValue"
|
|
175
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
180
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_number_utils__rspack_import_5[__rspack_import_key];
|
|
176
181
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
177
|
-
var
|
|
182
|
+
var _string_utils__rspack_import_6 = __webpack_require__("./string-utils");
|
|
178
183
|
var __rspack_reexport = {};
|
|
179
|
-
for(const __rspack_import_key in
|
|
184
|
+
for(const __rspack_import_key in _string_utils__rspack_import_6)if ([
|
|
180
185
|
"UUID_REGEX",
|
|
181
186
|
"currentTimestamp",
|
|
182
187
|
"getEventUuid",
|
|
@@ -194,12 +199,12 @@ var __webpack_exports__ = {};
|
|
|
194
199
|
"retriable",
|
|
195
200
|
"isPromise",
|
|
196
201
|
"getFetch",
|
|
202
|
+
"isUrl",
|
|
197
203
|
"toJsonSafeValue"
|
|
198
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
204
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_string_utils__rspack_import_6[__rspack_import_key];
|
|
199
205
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
200
|
-
var _type_utils__rspack_import_6 = __webpack_require__("./type-utils");
|
|
201
206
|
var __rspack_reexport = {};
|
|
202
|
-
for(const __rspack_import_key in
|
|
207
|
+
for(const __rspack_import_key in _type_utils__rspack_import_0)if ([
|
|
203
208
|
"UUID_REGEX",
|
|
204
209
|
"currentTimestamp",
|
|
205
210
|
"getEventUuid",
|
|
@@ -217,8 +222,9 @@ var __webpack_exports__ = {};
|
|
|
217
222
|
"retriable",
|
|
218
223
|
"isPromise",
|
|
219
224
|
"getFetch",
|
|
225
|
+
"isUrl",
|
|
220
226
|
"toJsonSafeValue"
|
|
221
|
-
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>
|
|
227
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_type_utils__rspack_import_0[__rspack_import_key];
|
|
222
228
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
223
229
|
var _promise_queue__rspack_import_7 = __webpack_require__("./promise-queue");
|
|
224
230
|
var __rspack_reexport = {};
|
|
@@ -240,6 +246,7 @@ var __webpack_exports__ = {};
|
|
|
240
246
|
"retriable",
|
|
241
247
|
"isPromise",
|
|
242
248
|
"getFetch",
|
|
249
|
+
"isUrl",
|
|
243
250
|
"toJsonSafeValue"
|
|
244
251
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_promise_queue__rspack_import_7[__rspack_import_key];
|
|
245
252
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
@@ -263,6 +270,7 @@ var __webpack_exports__ = {};
|
|
|
263
270
|
"retriable",
|
|
264
271
|
"isPromise",
|
|
265
272
|
"getFetch",
|
|
273
|
+
"isUrl",
|
|
266
274
|
"toJsonSafeValue"
|
|
267
275
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_logger__rspack_import_8[__rspack_import_key];
|
|
268
276
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
@@ -286,6 +294,7 @@ var __webpack_exports__ = {};
|
|
|
286
294
|
"retriable",
|
|
287
295
|
"isPromise",
|
|
288
296
|
"getFetch",
|
|
297
|
+
"isUrl",
|
|
289
298
|
"toJsonSafeValue"
|
|
290
299
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_user_agent_utils__rspack_import_9[__rspack_import_key];
|
|
291
300
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
@@ -309,6 +318,7 @@ var __webpack_exports__ = {};
|
|
|
309
318
|
"retriable",
|
|
310
319
|
"isPromise",
|
|
311
320
|
"getFetch",
|
|
321
|
+
"isUrl",
|
|
312
322
|
"toJsonSafeValue"
|
|
313
323
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_webview_app_utils__rspack_import_10[__rspack_import_key];
|
|
314
324
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
@@ -339,6 +349,9 @@ var __webpack_exports__ = {};
|
|
|
339
349
|
if (0 === truthyValue.trim().length) return true;
|
|
340
350
|
return false;
|
|
341
351
|
}
|
|
352
|
+
function isUrl(value) {
|
|
353
|
+
return (0, _type_utils__rspack_import_0.isString)(value) && /^(https?:\/\/|\/|\.\.?\/)/i.test(value.trim());
|
|
354
|
+
}
|
|
342
355
|
function removeTrailingSlash(url) {
|
|
343
356
|
return url?.replace(/\/+$/, '');
|
|
344
357
|
}
|
|
@@ -412,13 +425,14 @@ var __webpack_exports__ = {};
|
|
|
412
425
|
currentTimestamp: ()=>currentTimestamp,
|
|
413
426
|
getEventUuid: ()=>getEventUuid,
|
|
414
427
|
getFetch: ()=>getFetch,
|
|
428
|
+
isUrl: ()=>isUrl,
|
|
415
429
|
isValidUUID: ()=>isValidUUID,
|
|
416
430
|
raceWithTimeout: ()=>raceWithTimeout,
|
|
417
431
|
removeTrailingSlash: ()=>removeTrailingSlash,
|
|
418
432
|
retriable: ()=>retriable,
|
|
419
433
|
safeSetTimeout: ()=>safeSetTimeout,
|
|
420
434
|
stripUrlHash: ()=>stripUrlHash,
|
|
421
|
-
toJsonSafeValue: ()=>
|
|
435
|
+
toJsonSafeValue: ()=>_json_utils__rspack_import_4.toJsonSafeValue
|
|
422
436
|
}, {
|
|
423
437
|
STRING_FORMAT: STRING_FORMAT,
|
|
424
438
|
UUID_REGEX: UUID_REGEX,
|
|
@@ -435,6 +449,7 @@ exports.currentTimestamp = __webpack_exports__.currentTimestamp;
|
|
|
435
449
|
exports.getEventUuid = __webpack_exports__.getEventUuid;
|
|
436
450
|
exports.getFetch = __webpack_exports__.getFetch;
|
|
437
451
|
exports.isPromise = __webpack_exports__.isPromise;
|
|
452
|
+
exports.isUrl = __webpack_exports__.isUrl;
|
|
438
453
|
exports.isValidUUID = __webpack_exports__.isValidUUID;
|
|
439
454
|
exports.raceWithTimeout = __webpack_exports__.raceWithTimeout;
|
|
440
455
|
exports.removeTrailingSlash = __webpack_exports__.removeTrailingSlash;
|
|
@@ -453,6 +468,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
453
468
|
"getEventUuid",
|
|
454
469
|
"getFetch",
|
|
455
470
|
"isPromise",
|
|
471
|
+
"isUrl",
|
|
456
472
|
"isValidUUID",
|
|
457
473
|
"raceWithTimeout",
|
|
458
474
|
"removeTrailingSlash",
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isString } from "./type-utils.mjs";
|
|
1
2
|
export * from "./bot-detection.mjs";
|
|
2
3
|
export * from "./browser-utils.mjs";
|
|
3
4
|
export * from "./bucketed-rate-limiter.mjs";
|
|
@@ -35,6 +36,9 @@ function isEmpty(truthyValue) {
|
|
|
35
36
|
if (0 === truthyValue.trim().length) return true;
|
|
36
37
|
return false;
|
|
37
38
|
}
|
|
39
|
+
function isUrl(value) {
|
|
40
|
+
return isString(value) && /^(https?:\/\/|\/|\.\.?\/)/i.test(value.trim());
|
|
41
|
+
}
|
|
38
42
|
function removeTrailingSlash(url) {
|
|
39
43
|
return url?.replace(/\/+$/, '');
|
|
40
44
|
}
|
|
@@ -101,4 +105,4 @@ function allSettled(promises) {
|
|
|
101
105
|
}))));
|
|
102
106
|
}
|
|
103
107
|
export { toJsonSafeValue } from "./json-utils.mjs";
|
|
104
|
-
export { STRING_FORMAT, UUID_REGEX, allSettled, assert, createNamedError, currentISOTime, currentTimestamp, getEventUuid, getFetch, isPromise, isValidUUID, raceWithTimeout, removeTrailingSlash, retriable, safeSetTimeout, stripUrlHash };
|
|
108
|
+
export { STRING_FORMAT, UUID_REGEX, allSettled, assert, createNamedError, currentISOTime, currentTimestamp, getEventUuid, getFetch, isPromise, isUrl, isValidUUID, raceWithTimeout, removeTrailingSlash, retriable, safeSetTimeout, stripUrlHash };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.52.0",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@posthog/types": "^1.409.
|
|
73
|
+
"@posthog/types": "^1.409.4"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@rslib/core": "0.23.2",
|
package/src/utils/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FetchLike } from '../types'
|
|
2
|
+
import { isString } from './type-utils'
|
|
2
3
|
|
|
3
4
|
export * from './bot-detection'
|
|
4
5
|
export * from './browser-utils'
|
|
@@ -60,6 +61,11 @@ function isEmpty(truthyValue: string): boolean {
|
|
|
60
61
|
return false
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
/** Detects HTTP(S) URLs and explicit relative paths by prefix; does not validate URL syntax. */
|
|
65
|
+
export function isUrl(value: unknown): value is string {
|
|
66
|
+
return isString(value) && /^(https?:\/\/|\/|\.\.?\/)/i.test(value.trim())
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
export function removeTrailingSlash(url: string): string {
|
|
64
70
|
return url?.replace(/\/+$/, '')
|
|
65
71
|
}
|