@coralogix/browser 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 +3 -0
- package/browser-sdk-version.d.ts +1 -0
- package/browser-sdk-version.js +2 -0
- package/browser-sdk-version.js.map +1 -0
- package/package.json +21 -0
- package/src/CoralogixCustomLogInstrumentation.d.ts +12 -0
- package/src/CoralogixCustomLogInstrumentation.js +32 -0
- package/src/CoralogixCustomLogInstrumentation.js.map +1 -0
- package/src/CoralogixErrorInstrumentation.d.ts +30 -0
- package/src/CoralogixErrorInstrumentation.js +193 -0
- package/src/CoralogixErrorInstrumentation.js.map +1 -0
- package/src/CoralogixExporter.d.ts +14 -0
- package/src/CoralogixExporter.js +149 -0
- package/src/CoralogixExporter.js.map +1 -0
- package/src/CoralogixFetchInstrumentation.d.ts +8 -0
- package/src/CoralogixFetchInstrumentation.js +28 -0
- package/src/CoralogixFetchInstrumentation.js.map +1 -0
- package/src/CoralogixPropgator.d.ts +3 -0
- package/src/CoralogixPropgator.js +9 -0
- package/src/CoralogixPropgator.js.map +1 -0
- package/src/CoralogixSpanAttributesProcessor.d.ts +18 -0
- package/src/CoralogixSpanAttributesProcessor.js +57 -0
- package/src/CoralogixSpanAttributesProcessor.js.map +1 -0
- package/src/CoralogixWebTracerProvider.d.ts +3 -0
- package/src/CoralogixWebTracerProvider.js +4 -0
- package/src/CoralogixWebTracerProvider.js.map +1 -0
- package/src/CoralogixXhrInstrumentation.d.ts +7 -0
- package/src/CoralogixXhrInstrumentation.js +25 -0
- package/src/CoralogixXhrInstrumentation.js.map +1 -0
- package/src/constants.d.ts +54 -0
- package/src/constants.js +67 -0
- package/src/constants.js.map +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +170 -0
- package/src/index.js.map +1 -0
- package/src/types-external.d.ts +8 -0
- package/src/types-external.js +10 -0
- package/src/types-external.js.map +1 -0
- package/src/types.d.ts +202 -0
- package/src/types.js +17 -0
- package/src/types.js.map +1 -0
- package/src/utils..d.ts +11 -0
- package/src/utils..js +67 -0
- package/src/utils..js.map +1 -0
- package/tests/integration/utils.d.ts +7 -0
- package/tests/integration/utils.js +39 -0
- package/tests/integration/utils.js.map +1 -0
- package/tests/unit/test-utils.d.ts +2 -0
- package/tests/unit/test-utils.js +14 -0
- package/tests/unit/test-utils.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoralogixWebTracerProvider.js","sourceRoot":"","sources":["../../../../libs/browser/src/CoralogixWebTracerProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,MAAM,OAAO,0BAA2B,SAAQ,iBAAiB;CAAG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { XMLHttpRequestInstrumentation, XMLHttpRequestInstrumentationConfig } from '@opentelemetry/instrumentation-xml-http-request';
|
|
2
|
+
export declare enum XHRSource {
|
|
3
|
+
XHR = "xhr"
|
|
4
|
+
}
|
|
5
|
+
export declare class CoralogixXhrInstrumentation extends XMLHttpRequestInstrumentation {
|
|
6
|
+
constructor(config: XMLHttpRequestInstrumentationConfig);
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { XMLHttpRequestInstrumentation, } from '@opentelemetry/instrumentation-xml-http-request';
|
|
2
|
+
import { CoralogixAttributes } from './constants';
|
|
3
|
+
import { CoralogixEventType } from './types';
|
|
4
|
+
import { CoralogixLogSeverity } from './types-external';
|
|
5
|
+
import { isNetworkError } from './utils.';
|
|
6
|
+
import { propagateTraceHeaderCorsUrls } from './CoralogixPropgator';
|
|
7
|
+
export var XHRSource;
|
|
8
|
+
(function (XHRSource) {
|
|
9
|
+
XHRSource["XHR"] = "xhr";
|
|
10
|
+
})(XHRSource || (XHRSource = {}));
|
|
11
|
+
export class CoralogixXhrInstrumentation extends XMLHttpRequestInstrumentation {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
propagateTraceHeaderCorsUrls(config);
|
|
14
|
+
config.applyCustomAttributesOnSpan = (span, xhr) => {
|
|
15
|
+
const { status } = xhr;
|
|
16
|
+
span.setAttribute(CoralogixAttributes.SEVERITY, isNetworkError(status)
|
|
17
|
+
? CoralogixLogSeverity.Error
|
|
18
|
+
: CoralogixLogSeverity.Info);
|
|
19
|
+
span.setAttribute(CoralogixAttributes.EVENT_TYPE, CoralogixEventType.NETWORK_REQUEST);
|
|
20
|
+
span.setAttribute(CoralogixAttributes.SOURCE, XHRSource.XHR);
|
|
21
|
+
};
|
|
22
|
+
super(config);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=CoralogixXhrInstrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoralogixXhrInstrumentation.js","sourceRoot":"","sources":["../../../../libs/browser/src/CoralogixXhrInstrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,GAE9B,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAEpE,MAAM,CAAN,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,wBAAW,CAAA;AACb,CAAC,EAFW,SAAS,KAAT,SAAS,QAEpB;AAED,MAAM,OAAO,2BAA4B,SAAQ,6BAA6B;IAC5E,YAAY,MAA2C;QACrD,4BAA4B,CAAC,MAAM,CAAC,CAAC;QAErC,MAAM,CAAC,2BAA2B,GAAG,CAAC,IAAU,EAAE,GAAmB,EAAE,EAAE;YACvE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;YAEvB,IAAI,CAAC,YAAY,CACf,mBAAmB,CAAC,QAAQ,EAC5B,cAAc,CAAC,MAAM,CAAC;gBACpB,CAAC,CAAC,oBAAoB,CAAC,KAAK;gBAC5B,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAC9B,CAAC;YACF,IAAI,CAAC,YAAY,CACf,mBAAmB,CAAC,UAAU,EAC9B,kBAAkB,CAAC,eAAe,CACnC,CAAC;YACF,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;QAC/D,CAAC,CAAC;QAEF,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CoralogixOtelWebConfig } from './types';
|
|
2
|
+
import { CoralogixErrorInstrumentation } from './CoralogixErrorInstrumentation';
|
|
3
|
+
import { CoralogixFetchInstrumentation } from './CoralogixFetchInstrumentation';
|
|
4
|
+
import { CoralogixXhrInstrumentation } from './CoralogixXhrInstrumentation';
|
|
5
|
+
import { CoralogixCustomLogInstrumentation } from './CoralogixCustomLogInstrumentation';
|
|
6
|
+
export declare const miillisecondsInSecond = 1000;
|
|
7
|
+
export declare const CORALOGIX_LOGS_URL_SUFFIX = "/browser/v1beta/logs";
|
|
8
|
+
export declare const MAX_EXPORT_BATCH_SIZE = 50;
|
|
9
|
+
export declare const SCHEDULE_DELAY_MILLIS: number;
|
|
10
|
+
export declare const REQUIRED_CONFIG_KEYS: Array<keyof CoralogixOtelWebConfig>;
|
|
11
|
+
export declare const OPTIONS_DEFAULTS: Partial<CoralogixOtelWebConfig>;
|
|
12
|
+
export declare const INSTRUMENTATIONS: readonly [{
|
|
13
|
+
readonly Instrument: typeof CoralogixErrorInstrumentation;
|
|
14
|
+
readonly confKey: "errors";
|
|
15
|
+
readonly disable: false;
|
|
16
|
+
}, {
|
|
17
|
+
readonly Instrument: typeof CoralogixFetchInstrumentation;
|
|
18
|
+
readonly confKey: "fetch";
|
|
19
|
+
readonly disable: false;
|
|
20
|
+
}, {
|
|
21
|
+
readonly Instrument: typeof CoralogixXhrInstrumentation;
|
|
22
|
+
readonly confKey: "xhr";
|
|
23
|
+
readonly disable: false;
|
|
24
|
+
}, {
|
|
25
|
+
readonly Instrument: typeof CoralogixCustomLogInstrumentation;
|
|
26
|
+
readonly confKey: "custom";
|
|
27
|
+
readonly disable: false;
|
|
28
|
+
}];
|
|
29
|
+
export declare const CoralogixAttributes: {
|
|
30
|
+
USER_AGENT: string;
|
|
31
|
+
LOCATION_HREF: string;
|
|
32
|
+
EVENT_TYPE: string;
|
|
33
|
+
SEVERITY: string;
|
|
34
|
+
USER_CONTEXT: string;
|
|
35
|
+
COUNTRY: string;
|
|
36
|
+
APP_NAME: string;
|
|
37
|
+
APP_VERSION: string;
|
|
38
|
+
SOURCE: string;
|
|
39
|
+
ERROR: {
|
|
40
|
+
TYPE: string;
|
|
41
|
+
STACK: string;
|
|
42
|
+
MESSAGE: string;
|
|
43
|
+
};
|
|
44
|
+
LOG: string;
|
|
45
|
+
CUSTOM_LABELS: string;
|
|
46
|
+
ENVIRONMENT: string;
|
|
47
|
+
};
|
|
48
|
+
export declare const CoralogixDomainsApiUrlMap: {
|
|
49
|
+
EU1: string;
|
|
50
|
+
EU2: string;
|
|
51
|
+
US1: string;
|
|
52
|
+
AP1: string;
|
|
53
|
+
AP2: string;
|
|
54
|
+
};
|
package/src/constants.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { CoralogixErrorInstrumentation, ERROR_INSTRUMENTATION_NAME, ErrorAttributes, } from './CoralogixErrorInstrumentation';
|
|
2
|
+
import { CoralogixFetchInstrumentation } from './CoralogixFetchInstrumentation';
|
|
3
|
+
import { CoralogixXhrInstrumentation } from './CoralogixXhrInstrumentation';
|
|
4
|
+
import { CoralogixCustomLogInstrumentation } from './CoralogixCustomLogInstrumentation';
|
|
5
|
+
export const miillisecondsInSecond = 1000;
|
|
6
|
+
export const CORALOGIX_LOGS_URL_SUFFIX = '/browser/v1beta/logs';
|
|
7
|
+
export const MAX_EXPORT_BATCH_SIZE = 50;
|
|
8
|
+
export const SCHEDULE_DELAY_MILLIS = 2 * miillisecondsInSecond;
|
|
9
|
+
export const REQUIRED_CONFIG_KEYS = [
|
|
10
|
+
'application',
|
|
11
|
+
'public_key',
|
|
12
|
+
'coralogixdDomain',
|
|
13
|
+
'version',
|
|
14
|
+
];
|
|
15
|
+
export const OPTIONS_DEFAULTS = {
|
|
16
|
+
ignoreUrls: [new RegExp('.*' + CORALOGIX_LOGS_URL_SUFFIX + '.*')],
|
|
17
|
+
user_context: {
|
|
18
|
+
user_id: '',
|
|
19
|
+
user_name: '',
|
|
20
|
+
},
|
|
21
|
+
labels: {},
|
|
22
|
+
};
|
|
23
|
+
export const INSTRUMENTATIONS = [
|
|
24
|
+
{
|
|
25
|
+
Instrument: CoralogixErrorInstrumentation,
|
|
26
|
+
confKey: ERROR_INSTRUMENTATION_NAME,
|
|
27
|
+
disable: false,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
Instrument: CoralogixFetchInstrumentation,
|
|
31
|
+
confKey: 'fetch',
|
|
32
|
+
disable: false,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
Instrument: CoralogixXhrInstrumentation,
|
|
36
|
+
confKey: 'xhr',
|
|
37
|
+
disable: false,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
Instrument: CoralogixCustomLogInstrumentation,
|
|
41
|
+
confKey: 'custom',
|
|
42
|
+
disable: false,
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
export const CoralogixAttributes = {
|
|
46
|
+
USER_AGENT: 'user_agent',
|
|
47
|
+
LOCATION_HREF: 'location_href',
|
|
48
|
+
EVENT_TYPE: 'event_type',
|
|
49
|
+
SEVERITY: 'severity',
|
|
50
|
+
USER_CONTEXT: 'user_context',
|
|
51
|
+
COUNTRY: 'country',
|
|
52
|
+
APP_NAME: 'app_name',
|
|
53
|
+
APP_VERSION: 'app_version',
|
|
54
|
+
SOURCE: 'source',
|
|
55
|
+
ERROR: ErrorAttributes,
|
|
56
|
+
LOG: 'cx_log',
|
|
57
|
+
CUSTOM_LABELS: 'custom_labels',
|
|
58
|
+
ENVIRONMENT: 'environment',
|
|
59
|
+
};
|
|
60
|
+
export const CoralogixDomainsApiUrlMap = {
|
|
61
|
+
EU1: 'https://ingress.coralogix.com',
|
|
62
|
+
EU2: 'https://ingress.eu2.coralogix.com',
|
|
63
|
+
US1: 'https://ingress.coralogix.us',
|
|
64
|
+
AP1: 'https://ingress.coralogix.in',
|
|
65
|
+
AP2: 'https://ingress.coralogixsg.com', // ap-southeast-1 (Singapore)
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../libs/browser/src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,eAAe,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAE1C,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AAEhE,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAG,qBAAqB,CAAC;AAE/D,MAAM,CAAC,MAAM,oBAAoB,GAAwC;IACvE,aAAa;IACb,YAAY;IACZ,kBAAkB;IAClB,SAAS;CACV,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAoC;IAC/D,UAAU,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,yBAAyB,GAAG,IAAI,CAAC,CAAC;IACjE,YAAY,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,SAAS,EAAE,EAAE;KACd;IACD,MAAM,EAAE,EAAE;CACX,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B;QACE,UAAU,EAAE,6BAA6B;QACzC,OAAO,EAAE,0BAA0B;QACnC,OAAO,EAAE,KAAK;KACf;IACD;QACE,UAAU,EAAE,6BAA6B;QACzC,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,KAAK;KACf;IACD;QACE,UAAU,EAAE,2BAA2B;QACvC,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,KAAK;KACf;IACD;QACE,UAAU,EAAE,iCAAiC;QAC7C,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,KAAK;KACf;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,eAAe;IAC9B,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;IAC5B,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;IAC1B,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,eAAe;IACtB,GAAG,EAAE,QAAQ;IACb,aAAa,EAAE,eAAe;IAC9B,WAAW,EAAE,aAAa;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,GAAG,EAAE,+BAA+B;IACpC,GAAG,EAAE,mCAAmC;IACxC,GAAG,EAAE,8BAA8B;IACnC,GAAG,EAAE,8BAA8B;IACnC,GAAG,EAAE,iCAAiC,EAAE,6BAA6B;CACtE,CAAC"}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
import { getInstrumentationConfig, resolveCoralogixOtelWebConfig, } from './utils.';
|
|
3
|
+
import { CoralogixSpanAttributesProcessor } from './CoralogixSpanAttributesProcessor';
|
|
4
|
+
import { CoralogixAttributes, INSTRUMENTATIONS, MAX_EXPORT_BATCH_SIZE, OPTIONS_DEFAULTS, REQUIRED_CONFIG_KEYS, SCHEDULE_DELAY_MILLIS, } from './constants';
|
|
5
|
+
import { registerInstrumentations } from '@opentelemetry/instrumentation';
|
|
6
|
+
import { CoralogixExporter } from './CoralogixExporter';
|
|
7
|
+
import { CoralogixLogSeverity } from './types-external';
|
|
8
|
+
import { CoralogixCustomLogInstrumentation } from './CoralogixCustomLogInstrumentation';
|
|
9
|
+
import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator, } from '@opentelemetry/core';
|
|
10
|
+
import { CoralogixWebTracerProvider } from './CoralogixWebTracerProvider';
|
|
11
|
+
import { isNil } from 'lodash-es';
|
|
12
|
+
let isInited = false;
|
|
13
|
+
let _deregisterInstrumentations;
|
|
14
|
+
let _customInstrumentation;
|
|
15
|
+
let tracerProvider;
|
|
16
|
+
let attributesProcessor;
|
|
17
|
+
export const CoralogixRum = {
|
|
18
|
+
get isInited() {
|
|
19
|
+
return isInited;
|
|
20
|
+
},
|
|
21
|
+
init: function (options) {
|
|
22
|
+
// Check if CoralogixRum already inited.
|
|
23
|
+
if (isInited) {
|
|
24
|
+
console.warn('CoralogixRum already inited.');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Abort if running in a non-browser environment.
|
|
28
|
+
if (typeof window !== 'object') {
|
|
29
|
+
console.error('CoralogixRum: Non-browser environment detected, aborting');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Abort if running in a not supported browser.
|
|
33
|
+
if (typeof Symbol !== 'function') {
|
|
34
|
+
console.error('CoralogixRum: browser not supported, disabling instrumentation.');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// Abort if didn't provide all required init options.
|
|
38
|
+
for (const requiredProp of REQUIRED_CONFIG_KEYS) {
|
|
39
|
+
if (isNil(options[requiredProp])) {
|
|
40
|
+
console.error(`CoralogixRum: Initialization aborted. Please provide the required property "${requiredProp}".`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Merge options & default options.
|
|
45
|
+
const resolvedOptions = resolveCoralogixOtelWebConfig(options);
|
|
46
|
+
// Check if not in debug mode & no auth token.
|
|
47
|
+
if (!resolvedOptions.debug && !resolvedOptions.public_key) {
|
|
48
|
+
console.warn('rumAuth will be required in the future');
|
|
49
|
+
}
|
|
50
|
+
const { ignoreUrls, labels, user_context, application, version, traceParentInHeader, environment, } = resolvedOptions;
|
|
51
|
+
tracerProvider = new CoralogixWebTracerProvider();
|
|
52
|
+
const pluginDefaults = { ignoreUrls };
|
|
53
|
+
// Resolve instrumentations.
|
|
54
|
+
const instrumentations = INSTRUMENTATIONS.map(({ Instrument, confKey, disable }) => {
|
|
55
|
+
var _a;
|
|
56
|
+
const pluginConf = getInstrumentationConfig((_a = resolvedOptions === null || resolvedOptions === void 0 ? void 0 : resolvedOptions.instrumentations) === null || _a === void 0 ? void 0 : _a[confKey], pluginDefaults, disable, resolvedOptions);
|
|
57
|
+
if (pluginConf) {
|
|
58
|
+
let instrumentation;
|
|
59
|
+
switch (confKey) {
|
|
60
|
+
case 'errors': {
|
|
61
|
+
instrumentation = new Instrument(Object.assign(Object.assign({}, pluginConf), { ignoreErrors: options === null || options === void 0 ? void 0 : options.ignoreErrors }));
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
default:
|
|
65
|
+
instrumentation = new Instrument(pluginConf);
|
|
66
|
+
}
|
|
67
|
+
if (instrumentation instanceof CoralogixCustomLogInstrumentation) {
|
|
68
|
+
_customInstrumentation = instrumentation;
|
|
69
|
+
}
|
|
70
|
+
return instrumentation;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}).filter((a) => Boolean(a));
|
|
74
|
+
const mergedUserContext = Object.assign(Object.assign({}, OPTIONS_DEFAULTS.user_context), user_context);
|
|
75
|
+
// Init Span Attributes Processor.
|
|
76
|
+
attributesProcessor = new CoralogixSpanAttributesProcessor(Object.assign({ [CoralogixAttributes.APP_NAME]: application, [CoralogixAttributes.APP_VERSION]: version, [CoralogixAttributes.USER_CONTEXT]: JSON.stringify(mergedUserContext) }, (environment
|
|
77
|
+
? { [CoralogixAttributes.ENVIRONMENT]: environment }
|
|
78
|
+
: {})));
|
|
79
|
+
if (labels) {
|
|
80
|
+
attributesProcessor.setCustomLabels(labels);
|
|
81
|
+
}
|
|
82
|
+
// Add Span Attributes Processor.
|
|
83
|
+
tracerProvider.addSpanProcessor(attributesProcessor);
|
|
84
|
+
// Add Batch Span Processor and Exporter
|
|
85
|
+
tracerProvider.addSpanProcessor(new BatchSpanProcessor(new CoralogixExporter({
|
|
86
|
+
public_key: options === null || options === void 0 ? void 0 : options.public_key,
|
|
87
|
+
application,
|
|
88
|
+
coralogixdDomain: options === null || options === void 0 ? void 0 : options.coralogixdDomain,
|
|
89
|
+
}), {
|
|
90
|
+
maxExportBatchSize: MAX_EXPORT_BATCH_SIZE,
|
|
91
|
+
scheduledDelayMillis: SCHEDULE_DELAY_MILLIS,
|
|
92
|
+
}));
|
|
93
|
+
if (traceParentInHeader === null || traceParentInHeader === void 0 ? void 0 : traceParentInHeader.enabled) {
|
|
94
|
+
tracerProvider.register({
|
|
95
|
+
propagator: new CompositePropagator({
|
|
96
|
+
propagators: [
|
|
97
|
+
new W3CTraceContextPropagator(),
|
|
98
|
+
new W3CBaggagePropagator(),
|
|
99
|
+
],
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// Register Instrumentations
|
|
104
|
+
_deregisterInstrumentations = registerInstrumentations({
|
|
105
|
+
tracerProvider,
|
|
106
|
+
instrumentations,
|
|
107
|
+
});
|
|
108
|
+
isInited = true;
|
|
109
|
+
if (options === null || options === void 0 ? void 0 : options.debug) {
|
|
110
|
+
console.info('CoralogixRum.init() complete');
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
shutdown() {
|
|
114
|
+
if (!isInited) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
_deregisterInstrumentations === null || _deregisterInstrumentations === void 0 ? void 0 : _deregisterInstrumentations();
|
|
118
|
+
_deregisterInstrumentations = undefined;
|
|
119
|
+
tracerProvider === null || tracerProvider === void 0 ? void 0 : tracerProvider.shutdown();
|
|
120
|
+
tracerProvider = undefined;
|
|
121
|
+
isInited = false;
|
|
122
|
+
},
|
|
123
|
+
setUserContext(userContext) {
|
|
124
|
+
if (!isInited) {
|
|
125
|
+
console.debug('CoralogixRum must be initiated before setting user context');
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
attributesProcessor === null || attributesProcessor === void 0 ? void 0 : attributesProcessor.setInternalLabels(Object.assign(Object.assign({}, attributesProcessor.getInternalLabels()), { [CoralogixAttributes.USER_CONTEXT]: userContext }));
|
|
129
|
+
},
|
|
130
|
+
getUserContext() {
|
|
131
|
+
return attributesProcessor === null || attributesProcessor === void 0 ? void 0 : attributesProcessor.getUserContext();
|
|
132
|
+
},
|
|
133
|
+
setLabels(labels) {
|
|
134
|
+
attributesProcessor === null || attributesProcessor === void 0 ? void 0 : attributesProcessor.setCustomLabels(labels);
|
|
135
|
+
},
|
|
136
|
+
getLabels() {
|
|
137
|
+
return (attributesProcessor === null || attributesProcessor === void 0 ? void 0 : attributesProcessor.getCustomLabels()) || {};
|
|
138
|
+
},
|
|
139
|
+
log(severity, message, data) {
|
|
140
|
+
if (!isInited) {
|
|
141
|
+
console.debug('CoralogixRum must be initiated before using log');
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (!_customInstrumentation) {
|
|
145
|
+
console.error('Log was reported, but custom instrumentation is disabled.');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
_customInstrumentation === null || _customInstrumentation === void 0 ? void 0 : _customInstrumentation.log(severity, message, data);
|
|
149
|
+
},
|
|
150
|
+
debug(message, data) {
|
|
151
|
+
this.log(CoralogixLogSeverity.Debug, message, data);
|
|
152
|
+
},
|
|
153
|
+
verbose(message, data) {
|
|
154
|
+
this.log(CoralogixLogSeverity.Verbose, message, data);
|
|
155
|
+
},
|
|
156
|
+
info(message, data) {
|
|
157
|
+
this.log(CoralogixLogSeverity.Info, message, data);
|
|
158
|
+
},
|
|
159
|
+
warn(message, data) {
|
|
160
|
+
this.log(CoralogixLogSeverity.Warn, message, data);
|
|
161
|
+
},
|
|
162
|
+
error(message, data) {
|
|
163
|
+
this.log(CoralogixLogSeverity.Error, message, data);
|
|
164
|
+
},
|
|
165
|
+
critical(message, data) {
|
|
166
|
+
this.log(CoralogixLogSeverity.Critical, message, data);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
window.CoralogixRum = CoralogixRum;
|
|
170
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/browser/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EACL,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAQtF,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EACL,m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AO,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,OAAO,EAAE,IAAI;QACjB,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,CAAC,OAAO,EAAE,IAAI;QACnB,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,IAAI;QAChB,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,IAAI;QAChB,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,OAAO,EAAE,IAAI;QACjB,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,QAAQ,CAAC,OAAO,EAAE,IAAI;QACpB,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACzD,CAAC;CACF,CAAC;AAED,MAAc,CAAC,YAAY,GAAG,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var CoralogixLogSeverity;
|
|
2
|
+
(function (CoralogixLogSeverity) {
|
|
3
|
+
CoralogixLogSeverity[CoralogixLogSeverity["Debug"] = 1] = "Debug";
|
|
4
|
+
CoralogixLogSeverity[CoralogixLogSeverity["Verbose"] = 2] = "Verbose";
|
|
5
|
+
CoralogixLogSeverity[CoralogixLogSeverity["Info"] = 3] = "Info";
|
|
6
|
+
CoralogixLogSeverity[CoralogixLogSeverity["Warn"] = 4] = "Warn";
|
|
7
|
+
CoralogixLogSeverity[CoralogixLogSeverity["Error"] = 5] = "Error";
|
|
8
|
+
CoralogixLogSeverity[CoralogixLogSeverity["Critical"] = 6] = "Critical";
|
|
9
|
+
})(CoralogixLogSeverity || (CoralogixLogSeverity = {}));
|
|
10
|
+
//# sourceMappingURL=types-external.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-external.js","sourceRoot":"","sources":["../../../../libs/browser/src/types-external.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC9B,iEAAS,CAAA;IACT,qEAAW,CAAA;IACX,+DAAQ,CAAA;IACR,+DAAQ,CAAA;IACR,iEAAS,CAAA;IACT,uEAAY,CAAA;AACd,CAAC,EAPW,oBAAoB,KAApB,oBAAoB,QAO/B"}
|
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { Attributes } from '@opentelemetry/api';
|
|
3
|
+
import { CoralogixDomainsApiUrlMap } from './constants';
|
|
4
|
+
import { CoralogixLogSeverity } from './types-external';
|
|
5
|
+
import { ErrorSource } from './CoralogixErrorInstrumentation';
|
|
6
|
+
import { FetchSource } from './CoralogixFetchInstrumentation';
|
|
7
|
+
import { XHRSource } from './CoralogixXhrInstrumentation';
|
|
8
|
+
import { LogSource } from './CoralogixCustomLogInstrumentation';
|
|
9
|
+
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
10
|
+
import { StackFrame } from 'error-stack-parser';
|
|
11
|
+
export declare enum CoralogixEventType {
|
|
12
|
+
ERROR = "error",
|
|
13
|
+
NETWORK_REQUEST = "network-request",
|
|
14
|
+
LOG = "log"
|
|
15
|
+
}
|
|
16
|
+
export declare type CoralogixDomain = keyof typeof CoralogixDomainsApiUrlMap;
|
|
17
|
+
export declare type CoralogixRumLabels = Record<string, any>;
|
|
18
|
+
export interface UserContextConfig {
|
|
19
|
+
user_id: string;
|
|
20
|
+
user_name: string;
|
|
21
|
+
user_email?: string;
|
|
22
|
+
user_metadata?: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface TraceHeaderConfiguration {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
options?: {
|
|
29
|
+
/** urls outside of origin that should also add Traceparent to header */
|
|
30
|
+
propagateTraceHeaderCorsUrls?: Array<string | RegExp>;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface CoralogixOtelWebOptionsInstrumentations {
|
|
34
|
+
errors?: boolean;
|
|
35
|
+
fetch?: boolean;
|
|
36
|
+
xhr?: boolean;
|
|
37
|
+
custom?: boolean;
|
|
38
|
+
}
|
|
39
|
+
interface SendLog {
|
|
40
|
+
log: (severity: CoralogixLogSeverity, message: string, data?: any) => void;
|
|
41
|
+
debug: (message: string, data?: any) => void;
|
|
42
|
+
verbose: (message: string, data?: any) => void;
|
|
43
|
+
info: (message: string, data?: any) => void;
|
|
44
|
+
warn: (message: string, data?: any) => void;
|
|
45
|
+
error: (message: string, data?: any) => void;
|
|
46
|
+
critical: (message: string, data?: any) => void;
|
|
47
|
+
}
|
|
48
|
+
export interface CoralogixOtelWebConfig {
|
|
49
|
+
/** Publicly-visible `public_key` value */
|
|
50
|
+
public_key: string;
|
|
51
|
+
/** Sets a value for the `application` attribute */
|
|
52
|
+
application: string;
|
|
53
|
+
/** Coralogix account domain */
|
|
54
|
+
coralogixdDomain: CoralogixDomain;
|
|
55
|
+
/** Sets a value for the 'app.version' attribute */
|
|
56
|
+
version: string;
|
|
57
|
+
/** Configuration for user context. */
|
|
58
|
+
user_context?: UserContextConfig;
|
|
59
|
+
/** Turns on/off internal debug logging */
|
|
60
|
+
debug?: boolean;
|
|
61
|
+
/** Sets labels added to every Span. */
|
|
62
|
+
labels?: CoralogixRumLabels;
|
|
63
|
+
/**
|
|
64
|
+
* Applies for XHR and Fetch URLs. URLs that partially match any regex in ignoreUrls will not be traced.
|
|
65
|
+
* In addition, URLs that are _exact matches_ of strings in ignoreUrls will also not be traced.
|
|
66
|
+
* */
|
|
67
|
+
ignoreUrls?: Array<string | RegExp>;
|
|
68
|
+
/**
|
|
69
|
+
A pattern for error messages which should not be sent to Coralogix. By default, all errors will be sent.
|
|
70
|
+
* */
|
|
71
|
+
ignoreErrors?: Array<string | RegExp>;
|
|
72
|
+
/** Configuration for instrumentation modules. */
|
|
73
|
+
instrumentations?: CoralogixOtelWebOptionsInstrumentations;
|
|
74
|
+
/** Add Traceparent to headers in order to start a trace */
|
|
75
|
+
traceParentInHeader?: TraceHeaderConfiguration;
|
|
76
|
+
/** Sets a value for the `environment` attribute */
|
|
77
|
+
environment?: string;
|
|
78
|
+
}
|
|
79
|
+
export interface CoralogixOtelWebType extends SendLog {
|
|
80
|
+
/**
|
|
81
|
+
* Init CoralogixRum.
|
|
82
|
+
*/
|
|
83
|
+
init: (options: CoralogixOtelWebConfig) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Turn CoralogixRum off.
|
|
86
|
+
*/
|
|
87
|
+
shutdown: () => void;
|
|
88
|
+
/** Sets labels to be added to every log after CoralogixRum initialization. */
|
|
89
|
+
setLabels: (labels: CoralogixRumLabels) => void;
|
|
90
|
+
/**
|
|
91
|
+
* Provides access to computed, final value of global attributes, which are applied to all created logs.
|
|
92
|
+
*/
|
|
93
|
+
getLabels: () => Attributes;
|
|
94
|
+
/** Sets user context to be added to every log after CoralogixRum initialization. */
|
|
95
|
+
setUserContext: (userContext: UserContextConfig) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Provides access to computed, final value of user context, which applied to all created logs.
|
|
98
|
+
*/
|
|
99
|
+
getUserContext: () => UserContextConfig | undefined;
|
|
100
|
+
readonly isInited: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface PluginDefaultsConfig extends InstrumentationConfig {
|
|
103
|
+
ignoreUrls: (string | RegExp)[] | undefined;
|
|
104
|
+
}
|
|
105
|
+
export interface ErrorContext {
|
|
106
|
+
error_type?: string;
|
|
107
|
+
error_message?: string;
|
|
108
|
+
original_stacktrace?: Partial<StackFrame>[];
|
|
109
|
+
}
|
|
110
|
+
export interface LogContext {
|
|
111
|
+
message: string;
|
|
112
|
+
data?: any;
|
|
113
|
+
}
|
|
114
|
+
export interface NetworkRequestContext {
|
|
115
|
+
method: string;
|
|
116
|
+
status_code: number;
|
|
117
|
+
url: string;
|
|
118
|
+
host: string;
|
|
119
|
+
schema: string;
|
|
120
|
+
status_text: string;
|
|
121
|
+
response_content_length: string;
|
|
122
|
+
}
|
|
123
|
+
export interface EventTypeContext {
|
|
124
|
+
error_context?: ErrorContext;
|
|
125
|
+
log_context?: LogContext;
|
|
126
|
+
network_request_context?: NetworkRequestContext;
|
|
127
|
+
}
|
|
128
|
+
export interface SessionContext {
|
|
129
|
+
session_id: string;
|
|
130
|
+
user_agent: string;
|
|
131
|
+
user_id: string;
|
|
132
|
+
user_name?: string;
|
|
133
|
+
user_email?: string;
|
|
134
|
+
browser?: Browser;
|
|
135
|
+
browserVersion: string;
|
|
136
|
+
os: OS;
|
|
137
|
+
osVersion: string;
|
|
138
|
+
device: Device;
|
|
139
|
+
user_session_id?: string;
|
|
140
|
+
user_metadata?: {
|
|
141
|
+
[key: string]: any;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
export declare type EventSource = ErrorSource | FetchSource | XHRSource | LogSource;
|
|
145
|
+
export interface EventContext {
|
|
146
|
+
type: CoralogixEventType;
|
|
147
|
+
source: EventSource;
|
|
148
|
+
severity: CoralogixLogSeverity;
|
|
149
|
+
}
|
|
150
|
+
interface SpanContext {
|
|
151
|
+
readonly spanId: string;
|
|
152
|
+
readonly traceId: string;
|
|
153
|
+
}
|
|
154
|
+
interface OtelResource {
|
|
155
|
+
attributes: Attributes;
|
|
156
|
+
}
|
|
157
|
+
interface InstrumentationData {
|
|
158
|
+
otelSpan: Partial<ReadableSpan> & SpanContext;
|
|
159
|
+
otelResource: OtelResource;
|
|
160
|
+
}
|
|
161
|
+
export interface CxRum extends EventTypeContext {
|
|
162
|
+
browser_sdk: {
|
|
163
|
+
version: string;
|
|
164
|
+
};
|
|
165
|
+
version_metadata: {
|
|
166
|
+
app_name: string;
|
|
167
|
+
app_version: string;
|
|
168
|
+
};
|
|
169
|
+
session_context: SessionContext;
|
|
170
|
+
page_context: {
|
|
171
|
+
page_url: string;
|
|
172
|
+
};
|
|
173
|
+
event_context: EventContext;
|
|
174
|
+
labels: CoralogixRumLabels;
|
|
175
|
+
spanId: string;
|
|
176
|
+
traceId: string;
|
|
177
|
+
environment: string;
|
|
178
|
+
}
|
|
179
|
+
export interface CxSpan {
|
|
180
|
+
applicationName: string;
|
|
181
|
+
subsystemName: string;
|
|
182
|
+
timestamp: number;
|
|
183
|
+
severity: CoralogixLogSeverity;
|
|
184
|
+
isErrorWithStacktrace: boolean;
|
|
185
|
+
instrumentation_data: InstrumentationData;
|
|
186
|
+
text: {
|
|
187
|
+
cx_rum: CxRum;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export declare enum OtelNetworkAttrs {
|
|
191
|
+
METHOD = "http.method",
|
|
192
|
+
URL = "http.url",
|
|
193
|
+
STATUS_CODE = "http.status_code",
|
|
194
|
+
HOST = "http.host",
|
|
195
|
+
SCHEME = "http.scheme",
|
|
196
|
+
STATUS_TEXT = "http.status_text",
|
|
197
|
+
RESPONSE_CONTENT_LENGTH = "http.response_content_length"
|
|
198
|
+
}
|
|
199
|
+
export declare type Browser = 'Chrome' | 'Edge' | 'Firefox' | 'Safari' | 'Opera' | 'IE' | 'Unknown';
|
|
200
|
+
export declare type OS = 'Windows' | 'MacOS' | 'Linux' | 'iOS' | 'Android' | 'Unknown';
|
|
201
|
+
export declare type Device = 'Mobile' | 'Tablet' | 'Desktop' | 'Unknown';
|
|
202
|
+
export {};
|
package/src/types.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export var CoralogixEventType;
|
|
2
|
+
(function (CoralogixEventType) {
|
|
3
|
+
CoralogixEventType["ERROR"] = "error";
|
|
4
|
+
CoralogixEventType["NETWORK_REQUEST"] = "network-request";
|
|
5
|
+
CoralogixEventType["LOG"] = "log";
|
|
6
|
+
})(CoralogixEventType || (CoralogixEventType = {}));
|
|
7
|
+
export var OtelNetworkAttrs;
|
|
8
|
+
(function (OtelNetworkAttrs) {
|
|
9
|
+
OtelNetworkAttrs["METHOD"] = "http.method";
|
|
10
|
+
OtelNetworkAttrs["URL"] = "http.url";
|
|
11
|
+
OtelNetworkAttrs["STATUS_CODE"] = "http.status_code";
|
|
12
|
+
OtelNetworkAttrs["HOST"] = "http.host";
|
|
13
|
+
OtelNetworkAttrs["SCHEME"] = "http.scheme";
|
|
14
|
+
OtelNetworkAttrs["STATUS_TEXT"] = "http.status_text";
|
|
15
|
+
OtelNetworkAttrs["RESPONSE_CONTENT_LENGTH"] = "http.response_content_length";
|
|
16
|
+
})(OtelNetworkAttrs || (OtelNetworkAttrs = {}));
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
package/src/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../libs/browser/src/types.ts"],"names":[],"mappings":"AAWA,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,qCAAe,CAAA;IACf,yDAAmC,CAAA;IACnC,iCAAW,CAAA;AACb,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B;AAsND,MAAM,CAAN,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,0CAAsB,CAAA;IACtB,oCAAgB,CAAA;IAChB,oDAAgC,CAAA;IAChC,sCAAkB,CAAA;IAClB,0CAAsB,CAAA;IACtB,oDAAgC,CAAA;IAChC,4EAAwD,CAAA;AAC1D,CAAC,EARW,gBAAgB,KAAhB,gBAAgB,QAQ3B"}
|
package/src/utils..d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Browser, CoralogixOtelWebConfig, Device, OS, PluginDefaultsConfig } from './types';
|
|
2
|
+
export declare function getInstrumentationConfig(value: boolean | undefined, defaults: PluginDefaultsConfig, defaultDisable: boolean, resolvedOptions: CoralogixOtelWebConfig): CoralogixOtelWebConfig | undefined;
|
|
3
|
+
export declare function resolveCoralogixOtelWebConfig(config: CoralogixOtelWebConfig): CoralogixOtelWebConfig;
|
|
4
|
+
export declare const isNetworkError: (status?: number) => boolean;
|
|
5
|
+
export declare function parseUserAgent(userAgent: string): {
|
|
6
|
+
browser: Browser;
|
|
7
|
+
browserVersion: string;
|
|
8
|
+
os: OS;
|
|
9
|
+
osVersion: string;
|
|
10
|
+
device: Device;
|
|
11
|
+
};
|