@grafana/faro-web-sdk 1.0.0-beta3 → 1.0.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/README.md +16 -6
- package/dist/bundle/faro-web-sdk.iife.js +1 -0
- package/dist/cjs/config/getWebInstrumentations.js +1 -0
- package/dist/cjs/config/getWebInstrumentations.js.map +1 -1
- package/dist/cjs/config/makeCoreConfig.js +4 -4
- package/dist/cjs/config/makeCoreConfig.js.map +1 -1
- package/dist/cjs/index.js +6 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/instrumentations/console/instrumentation.js +2 -2
- package/dist/cjs/instrumentations/console/instrumentation.js.map +1 -1
- package/dist/cjs/instrumentations/errors/instrumentation.js +2 -2
- package/dist/cjs/instrumentations/errors/instrumentation.js.map +1 -1
- package/dist/cjs/instrumentations/errors/registerOnerror.js +2 -2
- package/dist/cjs/instrumentations/errors/registerOnerror.js.map +1 -1
- package/dist/cjs/instrumentations/errors/registerOnunhandledrejection.js +2 -2
- package/dist/cjs/instrumentations/errors/registerOnunhandledrejection.js.map +1 -1
- package/dist/cjs/instrumentations/index.js +3 -1
- package/dist/cjs/instrumentations/index.js.map +1 -1
- package/dist/cjs/instrumentations/session/instrumentation.js +3 -3
- package/dist/cjs/instrumentations/session/instrumentation.js.map +1 -1
- package/dist/cjs/instrumentations/view/index.js +6 -0
- package/dist/cjs/instrumentations/view/index.js.map +1 -0
- package/dist/cjs/instrumentations/view/instrumentation.js +44 -0
- package/dist/cjs/instrumentations/view/instrumentation.js.map +1 -0
- package/dist/cjs/instrumentations/webVitals/instrumentation.js +1 -1
- package/dist/cjs/instrumentations/webVitals/instrumentation.js.map +1 -1
- package/dist/cjs/metas/index.js +5 -1
- package/dist/cjs/metas/index.js.map +1 -1
- package/dist/cjs/{session.js → metas/session/createSession.js} +1 -1
- package/dist/cjs/metas/session/createSession.js.map +1 -0
- package/dist/cjs/metas/session/index.js +6 -0
- package/dist/cjs/metas/session/index.js.map +1 -0
- package/dist/cjs/metas/view/const.js +7 -0
- package/dist/cjs/metas/view/const.js.map +1 -0
- package/dist/cjs/metas/view/index.js +6 -0
- package/dist/cjs/metas/view/index.js.map +1 -0
- package/dist/cjs/transports/console/transport.js +1 -1
- package/dist/cjs/transports/console/transport.js.map +1 -1
- package/dist/cjs/transports/fetch/transport.js.map +1 -1
- package/dist/esm/config/getWebInstrumentations.js +2 -1
- package/dist/esm/config/getWebInstrumentations.js.map +1 -1
- package/dist/esm/config/makeCoreConfig.js +5 -5
- package/dist/esm/config/makeCoreConfig.js.map +1 -1
- package/dist/esm/index.js +3 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instrumentations/console/instrumentation.js +2 -2
- package/dist/esm/instrumentations/console/instrumentation.js.map +1 -1
- package/dist/esm/instrumentations/errors/instrumentation.js +2 -2
- package/dist/esm/instrumentations/errors/instrumentation.js.map +1 -1
- package/dist/esm/instrumentations/errors/registerOnerror.js +2 -2
- package/dist/esm/instrumentations/errors/registerOnerror.js.map +1 -1
- package/dist/esm/instrumentations/errors/registerOnunhandledrejection.js +2 -2
- package/dist/esm/instrumentations/errors/registerOnunhandledrejection.js.map +1 -1
- package/dist/esm/instrumentations/index.js +1 -0
- package/dist/esm/instrumentations/index.js.map +1 -1
- package/dist/esm/instrumentations/session/instrumentation.js +3 -3
- package/dist/esm/instrumentations/session/instrumentation.js.map +1 -1
- package/dist/esm/instrumentations/view/index.js +2 -0
- package/dist/esm/instrumentations/view/index.js.map +1 -0
- package/dist/esm/instrumentations/view/instrumentation.js +22 -0
- package/dist/esm/instrumentations/view/instrumentation.js.map +1 -0
- package/dist/esm/instrumentations/webVitals/instrumentation.js +1 -1
- package/dist/esm/instrumentations/webVitals/instrumentation.js.map +1 -1
- package/dist/esm/metas/index.js +2 -0
- package/dist/esm/metas/index.js.map +1 -1
- package/dist/esm/{session.js → metas/session/createSession.js} +1 -1
- package/dist/esm/metas/session/createSession.js.map +1 -0
- package/dist/esm/metas/session/index.js +2 -0
- package/dist/esm/metas/session/index.js.map +1 -0
- package/dist/esm/metas/view/const.js +4 -0
- package/dist/esm/metas/view/const.js.map +1 -0
- package/dist/esm/metas/view/index.js +2 -0
- package/dist/esm/metas/view/index.js.map +1 -0
- package/dist/esm/transports/console/transport.js +1 -1
- package/dist/esm/transports/console/transport.js.map +1 -1
- package/dist/esm/transports/fetch/transport.js.map +1 -1
- package/dist/{cjs → types}/config/getWebInstrumentations.d.ts +0 -0
- package/dist/{cjs → types}/config/index.d.ts +0 -0
- package/dist/{cjs → types}/config/makeCoreConfig.d.ts +0 -0
- package/dist/{cjs → types}/config/types.d.ts +0 -0
- package/dist/{cjs → types}/consts.d.ts +0 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/{cjs → types}/initialize.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/console/index.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/console/instrumentation.d.ts +1 -1
- package/dist/{cjs → types}/instrumentations/console/types.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/const.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/getErrorDetails.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/getValueAndTypeFromMessage.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/index.d.ts +0 -0
- package/dist/{esm → types}/instrumentations/errors/instrumentation.d.ts +1 -1
- package/dist/types/instrumentations/errors/registerOnerror.d.ts +2 -0
- package/dist/types/instrumentations/errors/registerOnunhandledrejection.d.ts +2 -0
- package/dist/{cjs → types}/instrumentations/errors/stackFrames/buildStackFrame.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/stackFrames/const.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/stackFrames/getDataFromSafariExtensions.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/stackFrames/getStackFramesFromError.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/stackFrames/index.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/stackFrames/parseStacktrace.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/errors/types.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/index.d.ts +1 -0
- package/dist/{cjs → types}/instrumentations/session/index.d.ts +0 -0
- package/dist/{cjs → types}/instrumentations/session/instrumentation.d.ts +0 -0
- package/dist/types/instrumentations/view/index.d.ts +1 -0
- package/dist/types/instrumentations/view/instrumentation.d.ts +8 -0
- package/dist/{cjs → types}/instrumentations/webVitals/index.d.ts +0 -0
- package/dist/{esm → types}/instrumentations/webVitals/instrumentation.d.ts +1 -1
- package/dist/{cjs → types}/metas/browser/index.d.ts +0 -0
- package/dist/{cjs → types}/metas/browser/meta.d.ts +0 -0
- package/dist/{cjs → types}/metas/const.d.ts +0 -0
- package/dist/{cjs → types}/metas/index.d.ts +2 -0
- package/dist/{cjs → types}/metas/page/index.d.ts +0 -0
- package/dist/{cjs → types}/metas/page/meta.d.ts +0 -0
- package/dist/{cjs/session.d.ts → types/metas/session/createSession.d.ts} +0 -0
- package/dist/types/metas/session/index.d.ts +1 -0
- package/dist/types/metas/view/const.d.ts +3 -0
- package/dist/types/metas/view/index.d.ts +1 -0
- package/dist/{cjs → types}/transports/console/index.d.ts +0 -0
- package/dist/{esm → types}/transports/console/transport.d.ts +1 -1
- package/dist/{cjs → types}/transports/console/types.d.ts +0 -0
- package/dist/{cjs → types}/transports/fetch/index.d.ts +0 -0
- package/dist/{cjs → types}/transports/fetch/transport.d.ts +3 -3
- package/dist/{cjs → types}/transports/fetch/types.d.ts +0 -0
- package/dist/{cjs → types}/transports/index.d.ts +0 -0
- package/package.json +21 -13
- package/dist/cjs/index.d.ts +0 -12
- package/dist/cjs/instrumentations/errors/instrumentation.d.ts +0 -6
- package/dist/cjs/instrumentations/errors/registerOnerror.d.ts +0 -2
- package/dist/cjs/instrumentations/errors/registerOnerror.test.d.ts +0 -1
- package/dist/cjs/instrumentations/errors/registerOnerror.test.js +0 -23
- package/dist/cjs/instrumentations/errors/registerOnerror.test.js.map +0 -1
- package/dist/cjs/instrumentations/errors/registerOnunhandledrejection.d.ts +0 -2
- package/dist/cjs/instrumentations/session/instrumentation.test.d.ts +0 -1
- package/dist/cjs/instrumentations/session/instrumentation.test.js +0 -47
- package/dist/cjs/instrumentations/session/instrumentation.test.js.map +0 -1
- package/dist/cjs/instrumentations/webVitals/instrumentation.d.ts +0 -14
- package/dist/cjs/session.js.map +0 -1
- package/dist/cjs/transports/console/transport.d.ts +0 -10
- package/dist/cjs/transports/fetch/transport.test.d.ts +0 -1
- package/dist/cjs/transports/fetch/transport.test.js +0 -193
- package/dist/cjs/transports/fetch/transport.test.js.map +0 -1
- package/dist/esm/config/getWebInstrumentations.d.ts +0 -3
- package/dist/esm/config/index.d.ts +0 -3
- package/dist/esm/config/makeCoreConfig.d.ts +0 -3
- package/dist/esm/config/types.d.ts +0 -9
- package/dist/esm/consts.d.ts +0 -1
- package/dist/esm/index.d.ts +0 -12
- package/dist/esm/initialize.d.ts +0 -3
- package/dist/esm/instrumentations/console/index.d.ts +0 -2
- package/dist/esm/instrumentations/console/instrumentation.d.ts +0 -10
- package/dist/esm/instrumentations/console/types.d.ts +0 -4
- package/dist/esm/instrumentations/errors/const.d.ts +0 -7
- package/dist/esm/instrumentations/errors/getErrorDetails.d.ts +0 -3
- package/dist/esm/instrumentations/errors/getValueAndTypeFromMessage.d.ts +0 -1
- package/dist/esm/instrumentations/errors/index.d.ts +0 -3
- package/dist/esm/instrumentations/errors/registerOnerror.d.ts +0 -2
- package/dist/esm/instrumentations/errors/registerOnerror.test.d.ts +0 -1
- package/dist/esm/instrumentations/errors/registerOnerror.test.js +0 -21
- package/dist/esm/instrumentations/errors/registerOnerror.test.js.map +0 -1
- package/dist/esm/instrumentations/errors/registerOnunhandledrejection.d.ts +0 -2
- package/dist/esm/instrumentations/errors/stackFrames/buildStackFrame.d.ts +0 -2
- package/dist/esm/instrumentations/errors/stackFrames/const.d.ts +0 -15
- package/dist/esm/instrumentations/errors/stackFrames/getDataFromSafariExtensions.d.ts +0 -1
- package/dist/esm/instrumentations/errors/stackFrames/getStackFramesFromError.d.ts +0 -2
- package/dist/esm/instrumentations/errors/stackFrames/index.d.ts +0 -4
- package/dist/esm/instrumentations/errors/stackFrames/parseStacktrace.d.ts +0 -2
- package/dist/esm/instrumentations/errors/types.d.ts +0 -8
- package/dist/esm/instrumentations/index.d.ts +0 -6
- package/dist/esm/instrumentations/session/index.d.ts +0 -1
- package/dist/esm/instrumentations/session/instrumentation.d.ts +0 -8
- package/dist/esm/instrumentations/session/instrumentation.test.d.ts +0 -1
- package/dist/esm/instrumentations/session/instrumentation.test.js +0 -45
- package/dist/esm/instrumentations/session/instrumentation.test.js.map +0 -1
- package/dist/esm/instrumentations/webVitals/index.d.ts +0 -1
- package/dist/esm/metas/browser/index.d.ts +0 -1
- package/dist/esm/metas/browser/meta.d.ts +0 -2
- package/dist/esm/metas/const.d.ts +0 -2
- package/dist/esm/metas/index.d.ts +0 -3
- package/dist/esm/metas/page/index.d.ts +0 -1
- package/dist/esm/metas/page/meta.d.ts +0 -2
- package/dist/esm/session.d.ts +0 -2
- package/dist/esm/session.js.map +0 -1
- package/dist/esm/transports/console/index.d.ts +0 -2
- package/dist/esm/transports/console/types.d.ts +0 -4
- package/dist/esm/transports/fetch/index.d.ts +0 -2
- package/dist/esm/transports/fetch/transport.d.ts +0 -16
- package/dist/esm/transports/fetch/transport.test.d.ts +0 -1
- package/dist/esm/transports/fetch/transport.test.js +0 -119
- package/dist/esm/transports/fetch/transport.test.js.map +0 -1
- package/dist/esm/transports/fetch/types.d.ts +0 -13
- package/dist/esm/transports/index.d.ts +0 -4
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { getWebInstrumentations, makeCoreConfig } from './config';
|
|
2
|
+
export type { BrowserConfig } from './config';
|
|
3
|
+
export { defaultEventDomain } from './consts';
|
|
4
|
+
export { initializeFaro } from './initialize';
|
|
5
|
+
export { buildStackFrame, ConsoleInstrumentation, ErrorsInstrumentation, getDataFromSafariExtensions, getStackFramesFromError, parseStacktrace, ViewInstrumentation, WebVitalsInstrumentation, } from './instrumentations';
|
|
6
|
+
export type { ConsoleInstrumentationOptions, ErrorEvent, ExtendedPromiseRejectionEvent } from './instrumentations';
|
|
7
|
+
export { browserMeta, createSession, defaultMetas, defaultViewMeta, pageMeta } from './metas';
|
|
8
|
+
export { ConsoleTransport, FetchTransport } from './transports';
|
|
9
|
+
export type { ClockFn, ConsoleTransportOptions, FetchTransportOptions, FetchTransportRequestOptions, } from './transports';
|
|
10
|
+
export { faro, allLogLevels, BaseExtension, BaseInstrumentation, BaseTransport, Conventions, createInternalLogger, createPromiseBuffer, deepEqual, defaultExceptionType, defaultGlobalObjectKey, defaultInternalLoggerLevel, defaultLogLevel, genShortID, getCurrentTimestamp, getInternalFaroFromGlobalObject, getTransportBody, globalObject, internalGlobalObjectKey, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isInternalFaroOnGlobalObject, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, InternalLoggerLevel, LogLevel, noop, setInternalFaroOnGlobalObject, TransportItemType, transportItemTypeToBodyKey, VERSION, } from '@grafana/faro-core';
|
|
11
|
+
export type { Faro, API, APIEvent, BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BeforeSendHook, BufferItem, Config, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, Extension, GlobalObject, Instrumentation, Instrumentations, InternalLogger, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, Meta, MetaAPI, MetaApp, MetaAttributes, MetaBrowser, MetaGetter, MetaItem, MetaPage, Metas, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, MetaView, OTELApi, Patterns, PromiseBuffer, PromiseBufferOptions, PromiseProducer, PushErrorOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, Transport, TransportBody, TransportItem, TransportItemPayload, Transports, UnpatchedConsole, } from '@grafana/faro-core';
|
|
File without changes
|
|
File without changes
|
|
@@ -3,7 +3,7 @@ import type { ConsoleInstrumentationOptions } from './types';
|
|
|
3
3
|
export declare class ConsoleInstrumentation extends BaseInstrumentation {
|
|
4
4
|
private options;
|
|
5
5
|
readonly name = "@grafana/faro-web-sdk:instrumentation-console";
|
|
6
|
-
readonly version = "1.0.0
|
|
6
|
+
readonly version = "1.0.0";
|
|
7
7
|
static defaultDisabledLevels: LogLevel[];
|
|
8
8
|
constructor(options?: ConsoleInstrumentationOptions);
|
|
9
9
|
initialize(): void;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class ErrorsInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-errors";
|
|
4
|
-
readonly version = "1.0.0
|
|
4
|
+
readonly version = "1.0.0";
|
|
5
5
|
initialize(): void;
|
|
6
6
|
}
|
|
File without changes
|
|
File without changes
|
package/dist/{cjs → types}/instrumentations/errors/stackFrames/getDataFromSafariExtensions.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,4 +3,5 @@ export { ConsoleInstrumentation } from './console';
|
|
|
3
3
|
export type { ConsoleInstrumentationOptions } from './console';
|
|
4
4
|
export { buildStackFrame, ErrorsInstrumentation, getDataFromSafariExtensions, getStackFramesFromError, parseStacktrace, } from './errors';
|
|
5
5
|
export type { ErrorEvent, ExtendedPromiseRejectionEvent } from './errors';
|
|
6
|
+
export { ViewInstrumentation } from './view';
|
|
6
7
|
export { WebVitalsInstrumentation } from './webVitals';
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ViewInstrumentation } from './instrumentation';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
|
+
export declare class ViewInstrumentation extends BaseInstrumentation {
|
|
3
|
+
readonly name = "@grafana/faro-web-sdk:instrumentation-view";
|
|
4
|
+
readonly version: string;
|
|
5
|
+
private notifiedView;
|
|
6
|
+
private sendViewChangedEvent;
|
|
7
|
+
initialize(): void;
|
|
8
|
+
}
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
2
|
export declare class WebVitalsInstrumentation extends BaseInstrumentation {
|
|
3
3
|
readonly name = "@grafana/faro-web-sdk:instrumentation-web-vitals";
|
|
4
|
-
readonly version = "1.0.0
|
|
4
|
+
readonly version = "1.0.0";
|
|
5
5
|
static mapping: {
|
|
6
6
|
cls: (onReport: import("web-vitals").CLSReportCallback, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
7
7
|
fcp: (onReport: import("web-vitals").FCPReportCallback, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createSession } from './createSession';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defaultViewMeta } from './const';
|
|
File without changes
|
|
@@ -4,7 +4,7 @@ import type { ConsoleTransportOptions } from './types';
|
|
|
4
4
|
export declare class ConsoleTransport extends BaseTransport {
|
|
5
5
|
private options;
|
|
6
6
|
readonly name = "@grafana/faro-web-sdk:transport-console";
|
|
7
|
-
readonly version = "1.0.0
|
|
7
|
+
readonly version = "1.0.0";
|
|
8
8
|
constructor(options?: ConsoleTransportOptions);
|
|
9
9
|
send(item: TransportItem): void;
|
|
10
10
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -4,10 +4,10 @@ import type { FetchTransportOptions } from './types';
|
|
|
4
4
|
export declare class FetchTransport extends BaseTransport {
|
|
5
5
|
private options;
|
|
6
6
|
readonly name = "@grafana/faro-web-sdk:transport-fetch";
|
|
7
|
-
readonly version = "1.0.0
|
|
7
|
+
readonly version = "1.0.0";
|
|
8
8
|
promiseBuffer: PromiseBuffer<Response | void>;
|
|
9
|
-
private rateLimitBackoffMs;
|
|
10
|
-
private getNow;
|
|
9
|
+
private readonly rateLimitBackoffMs;
|
|
10
|
+
private readonly getNow;
|
|
11
11
|
private disabledUntil;
|
|
12
12
|
constructor(options: FetchTransportOptions);
|
|
13
13
|
send(item: TransportItem): Promise<void>;
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/faro-web-sdk",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Faro instrumentations, metas, transports for web.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"observability",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
20
|
"url": "https://github.com/grafana/faro-web-sdk.git",
|
|
21
|
-
"directory": "packages/web"
|
|
21
|
+
"directory": "packages/web-sdk"
|
|
22
22
|
},
|
|
23
|
-
"main": "dist/cjs/index.js",
|
|
24
|
-
"module": "dist/esm/index.js",
|
|
25
|
-
"types": "dist/
|
|
23
|
+
"main": "./dist/cjs/index.js",
|
|
24
|
+
"module": "./dist/esm/index.js",
|
|
25
|
+
"types": "./dist/types/index.d.ts",
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
28
|
"globals.ts",
|
|
@@ -30,22 +30,30 @@
|
|
|
30
30
|
"LICENSE"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"start": "yarn
|
|
34
|
-
"build": "
|
|
33
|
+
"start": "yarn watch",
|
|
34
|
+
"build": "run-s build:*",
|
|
35
|
+
"build:compile": "run-p build:compile:*",
|
|
36
|
+
"build:compile:cjs": "tsc --build tsconfig.cjs.json",
|
|
37
|
+
"build:compile:esm": "tsc --build tsconfig.esm.json",
|
|
38
|
+
"build:compile:bundle": "run-s build:compile:bundle:*",
|
|
39
|
+
"build:compile:bundle:create": "rollup -c ./rollup.config.js",
|
|
40
|
+
"build:compile:bundle:remove-extras": "rimraf dist/bundle/dist",
|
|
41
|
+
"watch": "run-s watch:compile",
|
|
42
|
+
"watch:compile": "yarn build:compile:cjs -w",
|
|
35
43
|
"clean": "rimraf dist/ yarn-error.log",
|
|
36
44
|
"quality": "run-s quality:*",
|
|
37
45
|
"quality:test": "jest",
|
|
38
|
-
"quality:format": "prettier --ignore-path ../../.prettierignore -w \"./**/*.{js,jsx,ts,tsx,css,scss,md,yaml,yml,json}\"",
|
|
46
|
+
"quality:format": "prettier --cache --cache-location=../../.cache/prettier/webSdk --ignore-path ../../.prettierignore -w \"./**/*.{js,jsx,ts,tsx,css,scss,md,yaml,yml,json}\"",
|
|
39
47
|
"quality:lint": "run-s quality:lint:*",
|
|
40
|
-
"quality:lint:eslint": "eslint --ignore-path ../../.eslintignore \"./**/*.{js,jsx,ts,tsx}\"",
|
|
41
|
-
"quality:lint:prettier": "prettier --ignore-path ../../.prettierignore -c \"./**/*.{js,jsx,ts,tsx,css,scss,md,yaml,yml,json}\"",
|
|
48
|
+
"quality:lint:eslint": "eslint --cache --cache-location ../../.cache/eslint/webSdk --ignore-path ../../.eslintignore \"./**/*.{js,jsx,ts,tsx}\"",
|
|
49
|
+
"quality:lint:prettier": "prettier --cache --cache-location=../../.cache/prettier/webSdk --ignore-path ../../.prettierignore -c \"./**/*.{js,jsx,ts,tsx,css,scss,md,yaml,yml,json}\"",
|
|
42
50
|
"quality:lint:md": "markdownlint README.md",
|
|
43
51
|
"quality:circular-deps": "madge --circular ."
|
|
44
52
|
},
|
|
45
53
|
"dependencies": {
|
|
46
|
-
"@grafana/faro-core": "^1.0.0
|
|
54
|
+
"@grafana/faro-core": "^1.0.0",
|
|
47
55
|
"ua-parser-js": "^1.0.32",
|
|
48
|
-
"web-vitals": "^3.1.
|
|
56
|
+
"web-vitals": "^3.1.1"
|
|
49
57
|
},
|
|
50
58
|
"devDependencies": {
|
|
51
59
|
"@types/ua-parser-js": "^0.7.36"
|
|
@@ -53,5 +61,5 @@
|
|
|
53
61
|
"publishConfig": {
|
|
54
62
|
"access": "public"
|
|
55
63
|
},
|
|
56
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "afd9cbdff2b0665006e081bb72360301916e5e56"
|
|
57
65
|
}
|
package/dist/cjs/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { getWebInstrumentations, makeCoreConfig } from './config';
|
|
2
|
-
export type { BrowserConfig } from './config';
|
|
3
|
-
export { defaultEventDomain } from './consts';
|
|
4
|
-
export { initializeFaro } from './initialize';
|
|
5
|
-
export { buildStackFrame, ConsoleInstrumentation, ErrorsInstrumentation, getDataFromSafariExtensions, getStackFramesFromError, parseStacktrace, WebVitalsInstrumentation, } from './instrumentations';
|
|
6
|
-
export type { ConsoleInstrumentationOptions, ErrorEvent, ExtendedPromiseRejectionEvent } from './instrumentations';
|
|
7
|
-
export { browserMeta, defaultMetas, pageMeta } from './metas';
|
|
8
|
-
export { createSession } from './session';
|
|
9
|
-
export { ConsoleTransport, FetchTransport } from './transports';
|
|
10
|
-
export type { ClockFn, ConsoleTransportOptions, FetchTransportOptions, FetchTransportRequestOptions, } from './transports';
|
|
11
|
-
export { faro, allLogLevels, BaseExtension, BaseInstrumentation, BaseTransport, Conventions, createInternalLogger, createPromiseBuffer, deepEqual, defaultExceptionType, defaultGlobalObjectKey, defaultInternalLoggerLevel, defaultLogLevel, getCurrentTimestamp, getInternalFaroFromGlobalObject, getTransportBody, globalObject, internalGlobalObjectKey, isArray, isBoolean, isDomError, isDomException, isElement, isElementDefined, isError, isErrorDefined, isErrorEvent, isEvent, isEventDefined, isFunction, isInstanceOf, isInt, isInternalFaroOnGlobalObject, isMap, isMapDefined, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isSyntheticEvent, isThenable, isToString, isTypeof, isUndefined, InternalLoggerLevel, LogLevel, noop, setInternalFaroOnGlobalObject, TransportItemType, transportItemTypeToBodyKey, VERSION, } from '@grafana/faro-core';
|
|
12
|
-
export type { Faro, API, APIEvent, BaseObject, BaseObjectKey, BaseObjectPrimitiveValue, BaseObjectValue, BeforeSendHook, BufferItem, Config, EventAttributes, EventEvent, EventsAPI, ExceptionEvent, ExceptionStackFrame, ExceptionsAPI, ExtendedError, GlobalObject, Instrumentation, Instrumentations, InternalLogger, LogContext, LogEvent, LogsAPI, MeasurementEvent, MeasurementsAPI, Meta, MetaAPI, MetaApp, MetaAttributes, MetaBrowser, MetaGetter, MetaItem, MetaPage, Metas, MetaSDK, MetaSDKIntegration, MetaSession, MetaUser, OTELApi, Patterns, PromiseBuffer, PromiseBufferOptions, PromiseProducer, PushErrorOptions, PushLogOptions, PushMeasurementOptions, Stacktrace, StacktraceParser, TraceContext, TraceEvent, TracesAPI, Transport, TransportBody, TransportItem, TransportItemPayload, Transports, UnpatchedConsole, } from '@grafana/faro-core';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var testUtils_1 = require("@grafana/faro-core/src/testUtils");
|
|
4
|
-
var initialize_1 = require("../../initialize");
|
|
5
|
-
var registerOnerror_1 = require("./registerOnerror");
|
|
6
|
-
describe('registerOnerror', function () {
|
|
7
|
-
it('will preserve the old callback', function () {
|
|
8
|
-
var called = false;
|
|
9
|
-
window.onerror = function () {
|
|
10
|
-
called = true;
|
|
11
|
-
};
|
|
12
|
-
var transport = new testUtils_1.MockTransport();
|
|
13
|
-
var config = (0, testUtils_1.mockConfig)({
|
|
14
|
-
transports: [transport],
|
|
15
|
-
});
|
|
16
|
-
var faro = (0, initialize_1.initializeFaro)(config);
|
|
17
|
-
(0, registerOnerror_1.registerOnerror)(faro);
|
|
18
|
-
window.onerror('boo', 'some file', 10, 10, new Error('boo'));
|
|
19
|
-
expect(called).toBe(true);
|
|
20
|
-
expect(transport.items).toHaveLength(1);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=registerOnerror.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registerOnerror.test.js","sourceRoot":"","sources":["../../../../src/instrumentations/errors/registerOnerror.test.ts"],"names":[],"mappings":";;AAAA,8DAA6E;AAE7E,+CAAkD;AAClD,qDAAoD;AAEpD,QAAQ,CAAC,iBAAiB,EAAE;IAC1B,EAAE,CAAC,gCAAgC,EAAE;QACnC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,MAAM,CAAC,OAAO,GAAG;YACf,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC,CAAC;QACF,IAAM,SAAS,GAAG,IAAI,yBAAa,EAAE,CAAC;QACtC,IAAM,MAAM,GAAG,IAAA,sBAAU,EAAC;YACxB,UAAU,EAAE,CAAC,SAAS,CAAC;SACxB,CAAC,CAAC;QACH,IAAM,IAAI,GAAG,IAAA,2BAAc,EAAC,MAAM,CAAC,CAAC;QACpC,IAAA,iCAAe,EAAC,IAAI,CAAC,CAAC;QAEtB,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { mockConfig, MockTransport } from '@grafana/faro-core/src/testUtils';\n\nimport { initializeFaro } from '../../initialize';\nimport { registerOnerror } from './registerOnerror';\n\ndescribe('registerOnerror', () => {\n it('will preserve the old callback', () => {\n let called = false;\n window.onerror = () => {\n called = true;\n };\n const transport = new MockTransport();\n const config = mockConfig({\n transports: [transport],\n });\n const faro = initializeFaro(config);\n registerOnerror(faro);\n\n window.onerror('boo', 'some file', 10, 10, new Error('boo'));\n expect(called).toBe(true);\n expect(transport.items).toHaveLength(1);\n });\n});\n\nexport {};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var faro_core_1 = require("@grafana/faro-core");
|
|
4
|
-
var testUtils_1 = require("@grafana/faro-core/src/testUtils");
|
|
5
|
-
var session_1 = require("../../session");
|
|
6
|
-
var instrumentation_1 = require("./instrumentation");
|
|
7
|
-
describe('SessionInstrumentation', function () {
|
|
8
|
-
it('will send session start event on initialize', function () {
|
|
9
|
-
var _a, _b;
|
|
10
|
-
var transport = new testUtils_1.MockTransport();
|
|
11
|
-
var session = (0, session_1.createSession)({ foo: 'bar' });
|
|
12
|
-
var config = (0, testUtils_1.mockConfig)({
|
|
13
|
-
transports: [transport],
|
|
14
|
-
instrumentations: [new instrumentation_1.SessionInstrumentation()],
|
|
15
|
-
session: session,
|
|
16
|
-
});
|
|
17
|
-
(0, faro_core_1.initializeFaro)(config);
|
|
18
|
-
expect(transport.items).toHaveLength(1);
|
|
19
|
-
var event = transport.items[0];
|
|
20
|
-
expect(event.payload.name).toEqual(faro_core_1.Conventions.EventNames.SESSION_START);
|
|
21
|
-
expect((_a = event.meta.session) === null || _a === void 0 ? void 0 : _a.attributes).toEqual({ foo: 'bar' });
|
|
22
|
-
expect((_b = event.meta.session) === null || _b === void 0 ? void 0 : _b.id).toEqual(session.id);
|
|
23
|
-
});
|
|
24
|
-
it('will send session new start event if setSession is called.', function () {
|
|
25
|
-
var _a, _b;
|
|
26
|
-
var transport = new testUtils_1.MockTransport();
|
|
27
|
-
var session = (0, session_1.createSession)({ foo: 'bar' });
|
|
28
|
-
var config = (0, testUtils_1.mockConfig)({
|
|
29
|
-
transports: [transport],
|
|
30
|
-
instrumentations: [new instrumentation_1.SessionInstrumentation()],
|
|
31
|
-
session: session,
|
|
32
|
-
});
|
|
33
|
-
var faro = (0, faro_core_1.initializeFaro)(config);
|
|
34
|
-
expect(transport.items).toHaveLength(1);
|
|
35
|
-
var event = transport.items[0];
|
|
36
|
-
expect(event.payload.name).toEqual(faro_core_1.Conventions.EventNames.SESSION_START);
|
|
37
|
-
expect((_a = event.meta.session) === null || _a === void 0 ? void 0 : _a.id).toEqual(session.id);
|
|
38
|
-
faro.metas.add({ user: { id: 'foo' } });
|
|
39
|
-
expect(transport.items).toHaveLength(1);
|
|
40
|
-
var newSession = (0, session_1.createSession)();
|
|
41
|
-
faro.api.setSession(newSession);
|
|
42
|
-
expect(transport.items).toHaveLength(2);
|
|
43
|
-
event = transport.items[0];
|
|
44
|
-
expect((_b = event.meta.session) === null || _b === void 0 ? void 0 : _b.id).toEqual(session.id);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=instrumentation.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.test.js","sourceRoot":"","sources":["../../../../src/instrumentations/session/instrumentation.test.ts"],"names":[],"mappings":"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","sourcesContent":["import { Conventions, EventEvent, initializeFaro, TransportItem } from '@grafana/faro-core';\nimport { mockConfig, MockTransport } from '@grafana/faro-core/src/testUtils';\n\nimport { createSession } from '../../session';\nimport { SessionInstrumentation } from './instrumentation';\n\ndescribe('SessionInstrumentation', () => {\n it('will send session start event on initialize', () => {\n const transport = new MockTransport();\n const session = createSession({ foo: 'bar' });\n const config = mockConfig({\n transports: [transport],\n instrumentations: [new SessionInstrumentation()],\n session,\n });\n\n initializeFaro(config);\n\n expect(transport.items).toHaveLength(1);\n\n const event = transport.items[0]! as TransportItem<EventEvent>;\n expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);\n expect(event.meta.session?.attributes).toEqual({ foo: 'bar' });\n expect(event.meta.session?.id).toEqual(session.id);\n });\n\n it('will send session new start event if setSession is called.', () => {\n const transport = new MockTransport();\n const session = createSession({ foo: 'bar' });\n const config = mockConfig({\n transports: [transport],\n instrumentations: [new SessionInstrumentation()],\n session,\n });\n\n const faro = initializeFaro(config);\n\n expect(transport.items).toHaveLength(1);\n\n let event = transport.items[0]! as TransportItem<EventEvent>;\n expect(event.payload.name).toEqual(Conventions.EventNames.SESSION_START);\n expect(event.meta.session?.id).toEqual(session.id);\n\n faro.metas.add({ user: { id: 'foo' } });\n expect(transport.items).toHaveLength(1);\n\n const newSession = createSession();\n faro.api.setSession(newSession);\n expect(transport.items).toHaveLength(2);\n\n event = transport.items[0]! as TransportItem<EventEvent>;\n expect(event.meta.session?.id).toEqual(session.id);\n });\n});\n\nexport {};\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseInstrumentation } from '@grafana/faro-core';
|
|
2
|
-
export declare class WebVitalsInstrumentation extends BaseInstrumentation {
|
|
3
|
-
readonly name = "@grafana/faro-web-sdk:instrumentation-web-vitals";
|
|
4
|
-
readonly version = "1.0.0-beta3";
|
|
5
|
-
static mapping: {
|
|
6
|
-
cls: (onReport: import("web-vitals").CLSReportCallback, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
7
|
-
fcp: (onReport: import("web-vitals").FCPReportCallback, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
8
|
-
fid: (onReport: import("web-vitals").ReportHandler, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
9
|
-
inp: (onReport: import("web-vitals").ReportHandler, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
10
|
-
lcp: (onReport: import("web-vitals").ReportHandler, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
11
|
-
ttfb: (onReport: import("web-vitals").ReportHandler, opts?: import("web-vitals").ReportOpts | undefined) => void;
|
|
12
|
-
};
|
|
13
|
-
initialize(): void;
|
|
14
|
-
}
|
package/dist/cjs/session.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":";;;AACA,gDAAgD;AAEhD,SAAgB,aAAa,CAAC,UAAsC;IAClE,OAAO;QACL,EAAE,EAAE,IAAA,sBAAU,GAAE;QAChB,UAAU,YAAA;KACX,CAAC;AACJ,CAAC;AALD,sCAKC","sourcesContent":["import type { MetaSession } from '@grafana/faro-core';\nimport { genShortID } from '@grafana/faro-core';\n\nexport function createSession(attributes?: MetaSession['attributes']): MetaSession {\n return {\n id: genShortID(),\n attributes,\n };\n}\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BaseTransport } from '@grafana/faro-core';
|
|
2
|
-
import type { TransportItem } from '@grafana/faro-core';
|
|
3
|
-
import type { ConsoleTransportOptions } from './types';
|
|
4
|
-
export declare class ConsoleTransport extends BaseTransport {
|
|
5
|
-
private options;
|
|
6
|
-
readonly name = "@grafana/faro-web-sdk:transport-console";
|
|
7
|
-
readonly version = "1.0.0-beta3";
|
|
8
|
-
constructor(options?: ConsoleTransportOptions);
|
|
9
|
-
send(item: TransportItem): void;
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var faro_core_1 = require("@grafana/faro-core");
|
|
40
|
-
var transport_1 = require("./transport");
|
|
41
|
-
var fetch = jest.fn(function () { return Promise.resolve({ status: 202 }); });
|
|
42
|
-
global.fetch = fetch;
|
|
43
|
-
var item = {
|
|
44
|
-
type: faro_core_1.TransportItemType.LOG,
|
|
45
|
-
payload: {
|
|
46
|
-
context: {},
|
|
47
|
-
level: faro_core_1.LogLevel.INFO,
|
|
48
|
-
message: 'hi',
|
|
49
|
-
timestamp: new Date().toISOString(),
|
|
50
|
-
},
|
|
51
|
-
meta: {},
|
|
52
|
-
};
|
|
53
|
-
describe('FetchTransport', function () {
|
|
54
|
-
beforeEach(function () {
|
|
55
|
-
fetch.mockClear();
|
|
56
|
-
});
|
|
57
|
-
it('will send event over fetch', function () {
|
|
58
|
-
var transport = new transport_1.FetchTransport({
|
|
59
|
-
url: 'http://example.com/collect',
|
|
60
|
-
});
|
|
61
|
-
transport.send(item);
|
|
62
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
63
|
-
expect(fetch).toHaveBeenCalledWith('http://example.com/collect', {
|
|
64
|
-
body: JSON.stringify((0, faro_core_1.getTransportBody)(item)),
|
|
65
|
-
headers: {
|
|
66
|
-
'Content-Type': 'application/json',
|
|
67
|
-
},
|
|
68
|
-
keepalive: true,
|
|
69
|
-
method: 'POST',
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
it('will not sending events if buffer size is exhausted', function () {
|
|
73
|
-
var transport = new transport_1.FetchTransport({
|
|
74
|
-
url: 'http://example.com/collect',
|
|
75
|
-
bufferSize: 3,
|
|
76
|
-
});
|
|
77
|
-
for (var idx = 0; idx < 6; idx++) {
|
|
78
|
-
transport.send(item);
|
|
79
|
-
}
|
|
80
|
-
expect(fetch).toHaveBeenCalledTimes(3);
|
|
81
|
-
});
|
|
82
|
-
it('will back off on 429 for default interval if no retry-after header present', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
-
var now, transport;
|
|
84
|
-
return __generator(this, function (_a) {
|
|
85
|
-
switch (_a.label) {
|
|
86
|
-
case 0:
|
|
87
|
-
now = Date.now();
|
|
88
|
-
transport = new transport_1.FetchTransport({
|
|
89
|
-
url: 'http://example.com/collect',
|
|
90
|
-
defaultRateLimitBackoffMs: 1000,
|
|
91
|
-
getNow: function () { return now; },
|
|
92
|
-
});
|
|
93
|
-
fetch.mockImplementationOnce(function () {
|
|
94
|
-
return Promise.resolve({
|
|
95
|
-
status: 429,
|
|
96
|
-
headers: {
|
|
97
|
-
get: function () { return ''; },
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
return [4 /*yield*/, transport.send(item)];
|
|
102
|
-
case 1:
|
|
103
|
-
_a.sent();
|
|
104
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
105
|
-
return [4 /*yield*/, transport.send(item)];
|
|
106
|
-
case 2:
|
|
107
|
-
_a.sent();
|
|
108
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
109
|
-
now += 1001;
|
|
110
|
-
return [4 /*yield*/, transport.send(item)];
|
|
111
|
-
case 3:
|
|
112
|
-
_a.sent();
|
|
113
|
-
expect(fetch).toHaveBeenCalledTimes(2);
|
|
114
|
-
return [2 /*return*/];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}); });
|
|
118
|
-
it('will back off on 429 for default interval if retry-after header present, with delay', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
-
var now, transport;
|
|
120
|
-
return __generator(this, function (_a) {
|
|
121
|
-
switch (_a.label) {
|
|
122
|
-
case 0:
|
|
123
|
-
now = Date.now();
|
|
124
|
-
transport = new transport_1.FetchTransport({
|
|
125
|
-
url: 'http://example.com/collect',
|
|
126
|
-
defaultRateLimitBackoffMs: 1000,
|
|
127
|
-
getNow: function () { return now; },
|
|
128
|
-
});
|
|
129
|
-
fetch.mockImplementationOnce(function () {
|
|
130
|
-
return Promise.resolve({
|
|
131
|
-
status: 429,
|
|
132
|
-
headers: {
|
|
133
|
-
get: function () { return '2'; },
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
return [4 /*yield*/, transport.send(item)];
|
|
138
|
-
case 1:
|
|
139
|
-
_a.sent();
|
|
140
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
141
|
-
now += 1001;
|
|
142
|
-
return [4 /*yield*/, transport.send(item)];
|
|
143
|
-
case 2:
|
|
144
|
-
_a.sent();
|
|
145
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
146
|
-
now += 1001;
|
|
147
|
-
return [4 /*yield*/, transport.send(item)];
|
|
148
|
-
case 3:
|
|
149
|
-
_a.sent();
|
|
150
|
-
expect(fetch).toHaveBeenCalledTimes(2);
|
|
151
|
-
return [2 /*return*/];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}); });
|
|
155
|
-
it('will back off on 429 for default interval if retry-after header present, with delay', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
156
|
-
var now, transport;
|
|
157
|
-
return __generator(this, function (_a) {
|
|
158
|
-
switch (_a.label) {
|
|
159
|
-
case 0:
|
|
160
|
-
now = Date.now();
|
|
161
|
-
transport = new transport_1.FetchTransport({
|
|
162
|
-
url: 'http://example.com/collect',
|
|
163
|
-
defaultRateLimitBackoffMs: 1000,
|
|
164
|
-
getNow: function () { return now; },
|
|
165
|
-
});
|
|
166
|
-
fetch.mockImplementationOnce(function () {
|
|
167
|
-
return Promise.resolve({
|
|
168
|
-
status: 429,
|
|
169
|
-
headers: {
|
|
170
|
-
get: function () { return new Date(now + 3000).toISOString(); },
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
return [4 /*yield*/, transport.send(item)];
|
|
175
|
-
case 1:
|
|
176
|
-
_a.sent();
|
|
177
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
178
|
-
now += 1001;
|
|
179
|
-
return [4 /*yield*/, transport.send(item)];
|
|
180
|
-
case 2:
|
|
181
|
-
_a.sent();
|
|
182
|
-
expect(fetch).toHaveBeenCalledTimes(1);
|
|
183
|
-
now += 2001;
|
|
184
|
-
return [4 /*yield*/, transport.send(item)];
|
|
185
|
-
case 3:
|
|
186
|
-
_a.sent();
|
|
187
|
-
expect(fetch).toHaveBeenCalledTimes(2);
|
|
188
|
-
return [2 /*return*/];
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}); });
|
|
192
|
-
});
|
|
193
|
-
//# sourceMappingURL=transport.test.js.map
|