@naturalcycles/js-lib 14.138.0 → 14.139.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.
|
@@ -20,6 +20,12 @@ export interface ErrorData {
|
|
|
20
20
|
* Useful to be able to force-report e.g a 4xx error, which by default wouldn't be reported.
|
|
21
21
|
*/
|
|
22
22
|
report?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* If defined - used by SentrySharedService in backend-lib.
|
|
25
|
+
* Allows to report only X% of errors of this type.
|
|
26
|
+
* E.g 0.1 will report 10% of errors (and ignore the 90%)
|
|
27
|
+
*/
|
|
28
|
+
reportRate?: number;
|
|
23
29
|
/**
|
|
24
30
|
* Sometimes error.message gets "decorated" with extra information
|
|
25
31
|
* (e.g frontend-lib adds a method, url, etc for all the errors)
|
package/dist/http/fetcher.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ import type { FetcherAfterResponseHook, FetcherBeforeRequestHook, FetcherBeforeR
|
|
|
3
3
|
/**
|
|
4
4
|
* Experimental wrapper around Fetch.
|
|
5
5
|
* Works in both Browser and Node, using `globalThis.fetch`.
|
|
6
|
-
*
|
|
7
|
-
* @experimental
|
|
8
6
|
*/
|
|
9
7
|
export declare class Fetcher {
|
|
10
8
|
private constructor();
|
package/dist/http/fetcher.js
CHANGED
|
@@ -20,8 +20,6 @@ const defRetryOptions = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Experimental wrapper around Fetch.
|
|
22
22
|
* Works in both Browser and Node, using `globalThis.fetch`.
|
|
23
|
-
*
|
|
24
|
-
* @experimental
|
|
25
23
|
*/
|
|
26
24
|
class Fetcher {
|
|
27
25
|
constructor(cfg = {}) {
|
|
@@ -340,7 +338,8 @@ class Fetcher {
|
|
|
340
338
|
retryPost: false,
|
|
341
339
|
retry4xx: false,
|
|
342
340
|
retry5xx: true,
|
|
343
|
-
logger: console,
|
|
341
|
+
// logger: console, Danger! doing this mutates console!
|
|
342
|
+
logger: cfg.logger || console,
|
|
344
343
|
debug,
|
|
345
344
|
logRequest: debug,
|
|
346
345
|
logRequestBody: debug,
|
|
@@ -355,7 +354,7 @@ class Fetcher {
|
|
|
355
354
|
credentials: cfg.credentials,
|
|
356
355
|
},
|
|
357
356
|
hooks: {},
|
|
358
|
-
}, (0, object_util_1._omit)(cfg, ['method', 'credentials', 'headers']));
|
|
357
|
+
}, (0, object_util_1._omit)(cfg, ['method', 'credentials', 'headers', 'logger']));
|
|
359
358
|
norm.init.headers = (0, object_util_1._mapKeys)(norm.init.headers, k => k.toLowerCase());
|
|
360
359
|
return norm;
|
|
361
360
|
}
|
package/dist-esm/http/fetcher.js
CHANGED
|
@@ -18,8 +18,6 @@ const defRetryOptions = {
|
|
|
18
18
|
/**
|
|
19
19
|
* Experimental wrapper around Fetch.
|
|
20
20
|
* Works in both Browser and Node, using `globalThis.fetch`.
|
|
21
|
-
*
|
|
22
|
-
* @experimental
|
|
23
21
|
*/
|
|
24
22
|
export class Fetcher {
|
|
25
23
|
constructor(cfg = {}) {
|
|
@@ -382,7 +380,8 @@ export class Fetcher {
|
|
|
382
380
|
retryPost: false,
|
|
383
381
|
retry4xx: false,
|
|
384
382
|
retry5xx: true,
|
|
385
|
-
logger: console,
|
|
383
|
+
// logger: console, Danger! doing this mutates console!
|
|
384
|
+
logger: cfg.logger || console,
|
|
386
385
|
debug,
|
|
387
386
|
logRequest: debug,
|
|
388
387
|
logRequestBody: debug,
|
|
@@ -397,7 +396,7 @@ export class Fetcher {
|
|
|
397
396
|
credentials: cfg.credentials,
|
|
398
397
|
},
|
|
399
398
|
hooks: {},
|
|
400
|
-
}, _omit(cfg, ['method', 'credentials', 'headers']));
|
|
399
|
+
}, _omit(cfg, ['method', 'credentials', 'headers', 'logger']));
|
|
401
400
|
norm.init.headers = _mapKeys(norm.init.headers, k => k.toLowerCase());
|
|
402
401
|
return norm;
|
|
403
402
|
}
|
package/package.json
CHANGED
package/src/error/error.model.ts
CHANGED
|
@@ -24,6 +24,13 @@ export interface ErrorData {
|
|
|
24
24
|
*/
|
|
25
25
|
report?: boolean
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* If defined - used by SentrySharedService in backend-lib.
|
|
29
|
+
* Allows to report only X% of errors of this type.
|
|
30
|
+
* E.g 0.1 will report 10% of errors (and ignore the 90%)
|
|
31
|
+
*/
|
|
32
|
+
reportRate?: number
|
|
33
|
+
|
|
27
34
|
/**
|
|
28
35
|
* Sometimes error.message gets "decorated" with extra information
|
|
29
36
|
* (e.g frontend-lib adds a method, url, etc for all the errors)
|
package/src/http/fetcher.ts
CHANGED
|
@@ -39,8 +39,6 @@ const defRetryOptions: FetcherRetryOptions = {
|
|
|
39
39
|
/**
|
|
40
40
|
* Experimental wrapper around Fetch.
|
|
41
41
|
* Works in both Browser and Node, using `globalThis.fetch`.
|
|
42
|
-
*
|
|
43
|
-
* @experimental
|
|
44
42
|
*/
|
|
45
43
|
export class Fetcher {
|
|
46
44
|
private constructor(cfg: FetcherCfg & FetcherOptions = {}) {
|
|
@@ -435,7 +433,8 @@ export class Fetcher {
|
|
|
435
433
|
retryPost: false,
|
|
436
434
|
retry4xx: false,
|
|
437
435
|
retry5xx: true,
|
|
438
|
-
logger: console,
|
|
436
|
+
// logger: console, Danger! doing this mutates console!
|
|
437
|
+
logger: cfg.logger || console,
|
|
439
438
|
debug,
|
|
440
439
|
logRequest: debug,
|
|
441
440
|
logRequestBody: debug,
|
|
@@ -451,7 +450,7 @@ export class Fetcher {
|
|
|
451
450
|
},
|
|
452
451
|
hooks: {},
|
|
453
452
|
},
|
|
454
|
-
_omit(cfg, ['method', 'credentials', 'headers']),
|
|
453
|
+
_omit(cfg, ['method', 'credentials', 'headers', 'logger']),
|
|
455
454
|
)
|
|
456
455
|
|
|
457
456
|
norm.init.headers = _mapKeys(norm.init.headers, k => k.toLowerCase())
|