@grafana/faro-core 1.14.1 → 1.14.2
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/bundle/faro-core.iife.js +1 -1
- package/dist/bundle/types/api/ItemBuffer.d.ts +7 -0
- package/dist/bundle/types/api/apiTestHelpers.d.ts +11 -0
- package/dist/bundle/types/api/const.d.ts +3 -0
- package/dist/bundle/types/api/events/initialize.d.ts +13 -2
- package/dist/bundle/types/api/events/types.d.ts +11 -0
- package/dist/bundle/types/api/exceptions/initialize.d.ts +13 -2
- package/dist/bundle/types/api/exceptions/types.d.ts +2 -0
- package/dist/bundle/types/api/index.d.ts +3 -1
- package/dist/bundle/types/api/initialize.d.ts +3 -1
- package/dist/bundle/types/api/logs/initialize.d.ts +13 -2
- package/dist/bundle/types/api/logs/types.d.ts +3 -1
- package/dist/bundle/types/api/measurements/initialize.d.ts +13 -1
- package/dist/bundle/types/api/measurements/types.d.ts +2 -0
- package/dist/bundle/types/api/meta/initialize.d.ts +14 -2
- package/dist/bundle/types/api/types.d.ts +37 -0
- package/dist/bundle/types/api/userActionLifecycleHandler.d.ts +13 -0
- package/dist/bundle/types/config/types.d.ts +21 -12
- package/dist/bundle/types/index.d.ts +4 -4
- package/dist/bundle/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/bundle/types/utils/index.d.ts +2 -0
- package/dist/bundle/types/utils/reactive.d.ts +46 -0
- package/dist/bundle/types/version.d.ts +1 -1
- package/dist/cjs/api/ItemBuffer.js +27 -0
- package/dist/cjs/api/ItemBuffer.js.map +1 -0
- package/dist/cjs/api/apiTestHelpers.js +36 -0
- package/dist/cjs/api/apiTestHelpers.js.map +1 -0
- package/dist/cjs/api/const.js +7 -0
- package/dist/cjs/api/const.js.map +1 -0
- package/dist/cjs/api/events/initialize.js +15 -6
- package/dist/cjs/api/events/initialize.js.map +1 -1
- package/dist/cjs/api/events/types.js.map +1 -1
- package/dist/cjs/api/exceptions/initialize.js +51 -37
- package/dist/cjs/api/exceptions/initialize.js.map +1 -1
- package/dist/cjs/api/exceptions/types.js.map +1 -1
- package/dist/cjs/api/index.js +7 -1
- package/dist/cjs/api/index.js.map +1 -1
- package/dist/cjs/api/initialize.js +16 -2
- package/dist/cjs/api/initialize.js.map +1 -1
- package/dist/cjs/api/logs/initialize.js +15 -6
- package/dist/cjs/api/logs/initialize.js.map +1 -1
- package/dist/cjs/api/logs/types.js.map +1 -1
- package/dist/cjs/api/measurements/initialize.js +12 -3
- package/dist/cjs/api/measurements/initialize.js.map +1 -1
- package/dist/cjs/api/measurements/types.js.map +1 -1
- package/dist/cjs/api/meta/initialize.js +2 -1
- package/dist/cjs/api/meta/initialize.js.map +1 -1
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/api/userActionLifecycleHandler.js +59 -0
- package/dist/cjs/api/userActionLifecycleHandler.js.map +1 -0
- package/dist/cjs/config/types.js.map +1 -1
- package/dist/cjs/index.js +8 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/index.js +4 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/reactive.js +104 -0
- package/dist/cjs/utils/reactive.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/api/ItemBuffer.js +21 -0
- package/dist/esm/api/ItemBuffer.js.map +1 -0
- package/dist/esm/api/apiTestHelpers.js +33 -0
- package/dist/esm/api/apiTestHelpers.js.map +1 -0
- package/dist/esm/api/const.js +4 -0
- package/dist/esm/api/const.js.map +1 -0
- package/dist/esm/api/events/initialize.js +15 -7
- package/dist/esm/api/events/initialize.js.map +1 -1
- package/dist/esm/api/events/types.js.map +1 -1
- package/dist/esm/api/exceptions/initialize.js +47 -34
- package/dist/esm/api/exceptions/initialize.js.map +1 -1
- package/dist/esm/api/exceptions/types.js.map +1 -1
- package/dist/esm/api/index.js +2 -0
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/initialize.js +15 -1
- package/dist/esm/api/initialize.js.map +1 -1
- package/dist/esm/api/logs/initialize.js +12 -4
- package/dist/esm/api/logs/initialize.js.map +1 -1
- package/dist/esm/api/logs/types.js.map +1 -1
- package/dist/esm/api/measurements/initialize.js +12 -4
- package/dist/esm/api/measurements/initialize.js.map +1 -1
- package/dist/esm/api/measurements/types.js.map +1 -1
- package/dist/esm/api/meta/initialize.js +1 -1
- package/dist/esm/api/meta/initialize.js.map +1 -1
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/api/userActionLifecycleHandler.js +43 -0
- package/dist/esm/api/userActionLifecycleHandler.js.map +1 -0
- package/dist/esm/config/types.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/reactive.js +93 -0
- package/dist/esm/utils/reactive.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/spec/core/src/api/ItemBuffer.js +27 -0
- package/dist/spec/core/src/api/ItemBuffer.js.map +1 -0
- package/dist/spec/core/src/api/apiTestHelpers.js +36 -0
- package/dist/spec/core/src/api/apiTestHelpers.js.map +1 -0
- package/dist/spec/core/src/api/const.js +7 -0
- package/dist/spec/core/src/api/const.js.map +1 -0
- package/dist/spec/core/src/api/events/initialize.js +15 -6
- package/dist/spec/core/src/api/events/initialize.js.map +1 -1
- package/dist/spec/core/src/api/events/initialize.test.js +57 -0
- package/dist/spec/core/src/api/events/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/events/types.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.js +51 -37
- package/dist/spec/core/src/api/exceptions/initialize.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/initialize.test.js +62 -3
- package/dist/spec/core/src/api/exceptions/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/exceptions/types.js.map +1 -1
- package/dist/spec/core/src/api/index.js +7 -1
- package/dist/spec/core/src/api/index.js.map +1 -1
- package/dist/spec/core/src/api/initialize.js +16 -2
- package/dist/spec/core/src/api/initialize.js.map +1 -1
- package/dist/spec/core/src/api/initialize.test.js +73 -0
- package/dist/spec/core/src/api/initialize.test.js.map +1 -0
- package/dist/spec/core/src/api/itemBuffer.test.js +36 -0
- package/dist/spec/core/src/api/itemBuffer.test.js.map +1 -0
- package/dist/spec/core/src/api/logs/initialize.js +15 -6
- package/dist/spec/core/src/api/logs/initialize.js.map +1 -1
- package/dist/spec/core/src/api/logs/initialize.test.js +98 -0
- package/dist/spec/core/src/api/logs/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/logs/types.js.map +1 -1
- package/dist/spec/core/src/api/measurements/initialize.js +12 -3
- package/dist/spec/core/src/api/measurements/initialize.js.map +1 -1
- package/dist/spec/core/src/api/measurements/initialize.test.js +105 -0
- package/dist/spec/core/src/api/measurements/initialize.test.js.map +1 -1
- package/dist/spec/core/src/api/measurements/types.js.map +1 -1
- package/dist/spec/core/src/api/meta/initialize.js +2 -1
- package/dist/spec/core/src/api/meta/initialize.js.map +1 -1
- package/dist/spec/core/src/api/meta/initilialize.test.js +1 -3
- package/dist/spec/core/src/api/meta/initilialize.test.js.map +1 -1
- package/dist/spec/core/src/api/types.js.map +1 -1
- package/dist/spec/core/src/api/userActionLifecycleHandler.js +59 -0
- package/dist/spec/core/src/api/userActionLifecycleHandler.js.map +1 -0
- package/dist/spec/core/src/api/userActionLifecycleHandler.test.js +152 -0
- package/dist/spec/core/src/api/userActionLifecycleHandler.test.js.map +1 -0
- package/dist/spec/core/src/config/types.js.map +1 -1
- package/dist/spec/core/src/index.js +8 -2
- package/dist/spec/core/src/index.js.map +1 -1
- package/dist/spec/core/src/utils/index.js +4 -1
- package/dist/spec/core/src/utils/index.js.map +1 -1
- package/dist/spec/core/src/utils/reactive.js +104 -0
- package/dist/spec/core/src/utils/reactive.js.map +1 -0
- package/dist/spec/core/src/utils/reactive.test.js +104 -0
- package/dist/spec/core/src/utils/reactive.test.js.map +1 -0
- package/dist/spec/core/src/version.js +1 -1
- package/dist/spec/core/src/version.js.map +1 -1
- package/dist/types/api/ItemBuffer.d.ts +7 -0
- package/dist/types/api/apiTestHelpers.d.ts +11 -0
- package/dist/types/api/const.d.ts +3 -0
- package/dist/types/api/events/initialize.d.ts +13 -2
- package/dist/types/api/events/types.d.ts +11 -0
- package/dist/types/api/exceptions/initialize.d.ts +13 -2
- package/dist/types/api/exceptions/types.d.ts +2 -0
- package/dist/types/api/index.d.ts +3 -1
- package/dist/types/api/initialize.d.ts +3 -1
- package/dist/types/api/logs/initialize.d.ts +13 -2
- package/dist/types/api/logs/types.d.ts +3 -1
- package/dist/types/api/measurements/initialize.d.ts +13 -1
- package/dist/types/api/measurements/types.d.ts +2 -0
- package/dist/types/api/meta/initialize.d.ts +14 -2
- package/dist/types/api/types.d.ts +37 -0
- package/dist/types/api/userActionLifecycleHandler.d.ts +13 -0
- package/dist/types/config/types.d.ts +21 -12
- package/dist/types/core/src/api/ItemBuffer.d.ts +7 -0
- package/dist/types/core/src/api/apiTestHelpers.d.ts +11 -0
- package/dist/types/core/src/api/const.d.ts +3 -0
- package/dist/types/core/src/api/events/initialize.d.ts +13 -2
- package/dist/types/core/src/api/events/types.d.ts +11 -0
- package/dist/types/core/src/api/exceptions/initialize.d.ts +13 -2
- package/dist/types/core/src/api/exceptions/types.d.ts +2 -0
- package/dist/types/core/src/api/index.d.ts +3 -1
- package/dist/types/core/src/api/initialize.d.ts +3 -1
- package/dist/types/core/src/api/initialize.test.d.ts +1 -0
- package/dist/types/core/src/api/itemBuffer.test.d.ts +1 -0
- package/dist/types/core/src/api/logs/initialize.d.ts +13 -2
- package/dist/types/core/src/api/logs/types.d.ts +3 -1
- package/dist/types/core/src/api/measurements/initialize.d.ts +13 -1
- package/dist/types/core/src/api/measurements/types.d.ts +2 -0
- package/dist/types/core/src/api/meta/initialize.d.ts +14 -2
- package/dist/types/core/src/api/types.d.ts +37 -0
- package/dist/types/core/src/api/userActionLifecycleHandler.d.ts +13 -0
- package/dist/types/core/src/api/userActionLifecycleHandler.test.d.ts +1 -0
- package/dist/types/core/src/config/types.d.ts +21 -12
- package/dist/types/core/src/index.d.ts +4 -4
- package/dist/types/core/src/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/core/src/utils/index.d.ts +2 -0
- package/dist/types/core/src/utils/reactive.d.ts +46 -0
- package/dist/types/core/src/utils/reactive.test.d.ts +1 -0
- package/dist/types/core/src/version.d.ts +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/testUtils/mockTransport.d.ts +1 -1
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/reactive.d.ts +46 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.USER_ACTION_CANCEL_MESSAGE_TYPE = exports.USER_ACTION_END_MESSAGE_TYPE = exports.USER_ACTION_START_MESSAGE_TYPE = void 0;
|
|
4
|
+
exports.USER_ACTION_START_MESSAGE_TYPE = 'user-action-start';
|
|
5
|
+
exports.USER_ACTION_END_MESSAGE_TYPE = 'user-action-end';
|
|
6
|
+
exports.USER_ACTION_CANCEL_MESSAGE_TYPE = 'user-action-cancel';
|
|
7
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../src/api/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,8BAA8B,GAAG,mBAAmB,CAAC;AACrD,QAAA,4BAA4B,GAAG,iBAAiB,CAAC;AACjD,QAAA,+BAA+B,GAAG,oBAAoB,CAAC","sourcesContent":["export const USER_ACTION_START_MESSAGE_TYPE = 'user-action-start';\nexport const USER_ACTION_END_MESSAGE_TYPE = 'user-action-end';\nexport const USER_ACTION_CANCEL_MESSAGE_TYPE = 'user-action-cancel';\n"]}
|
|
@@ -4,17 +4,20 @@ exports.initializeEventsAPI = void 0;
|
|
|
4
4
|
var transports_1 = require("../../transports");
|
|
5
5
|
var utils_1 = require("../../utils");
|
|
6
6
|
var date_1 = require("../../utils/date");
|
|
7
|
-
|
|
7
|
+
var const_1 = require("../const");
|
|
8
|
+
function initializeEventsAPI(_a) {
|
|
9
|
+
var internalLogger = _a.internalLogger, config = _a.config, metas = _a.metas, transports = _a.transports, tracesApi = _a.tracesApi, actionBuffer = _a.actionBuffer, getMessage = _a.getMessage;
|
|
8
10
|
var lastPayload = null;
|
|
9
11
|
var pushEvent = function (name, attributes, domain, _a) {
|
|
10
|
-
var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs;
|
|
12
|
+
var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs, _c = _b.customPayloadTransformer, customPayloadTransformer = _c === void 0 ? function (payload) { return payload; } : _c;
|
|
11
13
|
try {
|
|
14
|
+
var attrs = (0, utils_1.stringifyObjectValues)(attributes);
|
|
12
15
|
var item = {
|
|
13
16
|
meta: metas.value,
|
|
14
|
-
payload: {
|
|
17
|
+
payload: customPayloadTransformer({
|
|
15
18
|
name: name,
|
|
16
19
|
domain: domain !== null && domain !== void 0 ? domain : config.eventDomain,
|
|
17
|
-
attributes: (0, utils_1.
|
|
20
|
+
attributes: (0, utils_1.isEmpty)(attrs) ? undefined : attrs,
|
|
18
21
|
timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(),
|
|
19
22
|
trace: spanContext
|
|
20
23
|
? {
|
|
@@ -22,7 +25,7 @@ function initializeEventsAPI(_unpatchedConsole, internalLogger, config, metas, t
|
|
|
22
25
|
span_id: spanContext.spanId,
|
|
23
26
|
}
|
|
24
27
|
: tracesApi.getTraceContext(),
|
|
25
|
-
},
|
|
28
|
+
}),
|
|
26
29
|
type: transports_1.TransportItemType.EVENT,
|
|
27
30
|
};
|
|
28
31
|
var testingPayload = {
|
|
@@ -36,7 +39,13 @@ function initializeEventsAPI(_unpatchedConsole, internalLogger, config, metas, t
|
|
|
36
39
|
}
|
|
37
40
|
lastPayload = testingPayload;
|
|
38
41
|
internalLogger.debug('Pushing event\n', item);
|
|
39
|
-
|
|
42
|
+
var msg = getMessage();
|
|
43
|
+
if (msg && msg.type === const_1.USER_ACTION_START_MESSAGE_TYPE) {
|
|
44
|
+
actionBuffer.addItem(item);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
transports.execute(item);
|
|
48
|
+
}
|
|
40
49
|
}
|
|
41
50
|
catch (err) {
|
|
42
51
|
internalLogger.error('Error pushing event', err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/events/initialize.ts"],"names":[],"mappings":";;;AAGA,+
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/events/initialize.ts"],"names":[],"mappings":";;;AAGA,+CAAqD;AAGrD,qCAAqG;AACrG,yCAAwD;AACxD,kCAA0D;AAO1D,SAAgB,mBAAmB,CAAC,EAiBnC;QAhBC,cAAc,oBAAA,EACd,MAAM,YAAA,EACN,KAAK,WAAA,EACL,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,YAAY,kBAAA,EACZ,UAAU,gBAAA;IAWV,IAAI,WAAW,GAA8D,IAAI,CAAC;IAElF,IAAM,SAAS,GAA2B,UACxC,IAAI,EACJ,UAAU,EACV,MAAM,EACN,EAAmH;YAAnH,qBAAiH,EAAE,KAAA,EAAjH,UAAU,gBAAA,EAAE,WAAW,iBAAA,EAAE,oBAAoB,0BAAA,EAAE,gCAA2D,EAA3D,wBAAwB,mBAAG,UAAC,OAAmB,IAAK,OAAA,OAAO,EAAP,CAAO,KAAA;QAE5G,IAAI;YACF,IA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AG,GAAG,UAAU,EAAE,CAAC;YACzB,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,sCAA8B,EAAE;gBACtD,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC5B;iBAAM;gBACL,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC1B;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;SAClD;IACH,CAAC,CAAC;IAEF,OAAO;QACL,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AA5ED,kDA4EC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport { USER_ACTION_START_MESSAGE_TYPE } from '../const';\nimport type { ItemBuffer } from '../ItemBuffer';\nimport type { TracesAPI } from '../traces';\nimport type { ApiMessageBusMessages } from '../types';\n\nimport type { EventEvent, EventsAPI } from './types';\n\nexport function initializeEventsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n actionBuffer,\n getMessage,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n actionBuffer: ItemBuffer<TransportItem>;\n getMessage: () => ApiMessageBusMessages | undefined;\n}): EventsAPI {\n let lastPayload: Pick<EventEvent, 'name' | 'domain' | 'attributes'> | null = null;\n\n const pushEvent: EventsAPI['pushEvent'] = (\n name,\n attributes,\n domain,\n { skipDedupe, spanContext, timestampOverwriteMs, customPayloadTransformer = (payload: EventEvent) => payload } = {}\n ) => {\n try {\n const attrs = stringifyObjectValues(attributes);\n\n const item: TransportItem<EventEvent> = {\n meta: metas.value,\n payload: customPayloadTransformer({\n name,\n domain: domain ?? config.eventDomain,\n attributes: isEmpty(attrs) ? undefined : attrs,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n }),\n type: TransportItemType.EVENT,\n };\n\n const testingPayload = {\n name: item.payload.name,\n attributes: item.payload.attributes,\n domain: item.payload.domain,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping event push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing event\\n', item);\n\n const msg = getMessage();\n if (msg && msg.type === USER_ACTION_START_MESSAGE_TYPE) {\n actionBuffer.addItem(item);\n } else {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing event', err);\n }\n };\n\n return {\n pushEvent,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/events/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type EventAttributes = Record<string, string>;\n\nexport interface EventEvent {\n name: string;\n timestamp: string;\n\n domain?: string;\n attributes?: EventAttributes;\n trace?: TraceContext;\n}\n\nexport interface PushEventOptions {\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface EventsAPI {\n pushEvent: (name: string, attributes?: EventAttributes, domain?: string, options?: PushEventOptions) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/events/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\nimport type { UserAction } from '../types';\n\nexport type EventAttributes = Record<string, string>;\n\nexport interface EventEvent {\n name: string;\n timestamp: string;\n\n domain?: string;\n attributes?: EventAttributes;\n trace?: TraceContext;\n\n action?: UserAction;\n}\n\nexport interface PushEventOptions {\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n\n /**\n * Allows manual transformation of the payload before adding it to the internal buffer.\n *\n * @param payload - The event payload to be transformed.\n * @returns The transformed event payload.\n *\n * @remarks This should be used sparingly and only in special cases where custom payload processing cannot be deferred to the before-send hook.\n */\n customPayloadTransformer?: (payload: EventEvent) => EventEvent;\n}\n\nexport interface EventsAPI {\n pushEvent: (name: string, attributes?: EventAttributes, domain?: string, options?: PushEventOptions) => void;\n}\n"]}
|
|
@@ -15,60 +15,74 @@ exports.initializeExceptionsAPI = void 0;
|
|
|
15
15
|
var transports_1 = require("../../transports");
|
|
16
16
|
var utils_1 = require("../../utils");
|
|
17
17
|
var date_1 = require("../../utils/date");
|
|
18
|
+
var const_1 = require("../const");
|
|
18
19
|
var utils_2 = require("../utils");
|
|
19
|
-
var
|
|
20
|
+
var const_2 = require("./const");
|
|
20
21
|
var stacktraceParser;
|
|
21
|
-
function initializeExceptionsAPI(
|
|
22
|
-
var
|
|
22
|
+
function initializeExceptionsAPI(_a) {
|
|
23
|
+
var _b;
|
|
24
|
+
var internalLogger = _a.internalLogger, config = _a.config, metas = _a.metas, transports = _a.transports, tracesApi = _a.tracesApi, actionBuffer = _a.actionBuffer, getMessage = _a.getMessage;
|
|
23
25
|
internalLogger.debug('Initializing exceptions API');
|
|
24
26
|
var lastPayload = null;
|
|
25
|
-
stacktraceParser = (
|
|
27
|
+
stacktraceParser = (_b = config.parseStacktrace) !== null && _b !== void 0 ? _b : stacktraceParser;
|
|
26
28
|
var changeStacktraceParser = function (newStacktraceParser) {
|
|
27
29
|
internalLogger.debug('Changing stacktrace parser');
|
|
28
30
|
stacktraceParser = newStacktraceParser !== null && newStacktraceParser !== void 0 ? newStacktraceParser : stacktraceParser;
|
|
29
31
|
};
|
|
30
32
|
var getStacktraceParser = function () { return stacktraceParser; };
|
|
31
|
-
var
|
|
33
|
+
var _c = config.ignoreErrors, ignoreErrors = _c === void 0 ? [] : _c;
|
|
32
34
|
var pushError = function (error, _a) {
|
|
33
35
|
var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, stackFrames = _b.stackFrames, type = _b.type, context = _b.context, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs;
|
|
34
36
|
if (isErrorIgnored(ignoreErrors, error)) {
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
?
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (stackFrames === null || stackFrames === void 0 ? void 0 : stackFrames.length) {
|
|
55
|
-
item.payload.stacktrace = {
|
|
56
|
-
frames: stackFrames,
|
|
39
|
+
try {
|
|
40
|
+
var ctx = (0, utils_1.stringifyObjectValues)(__assign(__assign({}, parseCause(error)), (context !== null && context !== void 0 ? context : {})));
|
|
41
|
+
var item = {
|
|
42
|
+
meta: metas.value,
|
|
43
|
+
payload: {
|
|
44
|
+
type: type || error.name || const_2.defaultExceptionType,
|
|
45
|
+
value: error.message,
|
|
46
|
+
timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(),
|
|
47
|
+
trace: spanContext
|
|
48
|
+
? {
|
|
49
|
+
trace_id: spanContext.traceId,
|
|
50
|
+
span_id: spanContext.spanId,
|
|
51
|
+
}
|
|
52
|
+
: tracesApi.getTraceContext(),
|
|
53
|
+
context: (0, utils_1.isEmpty)(ctx) ? undefined : ctx,
|
|
54
|
+
},
|
|
55
|
+
type: transports_1.TransportItemType.EXCEPTION,
|
|
57
56
|
};
|
|
57
|
+
stackFrames = stackFrames !== null && stackFrames !== void 0 ? stackFrames : (error.stack ? stacktraceParser === null || stacktraceParser === void 0 ? void 0 : stacktraceParser(error).frames : undefined);
|
|
58
|
+
if (stackFrames === null || stackFrames === void 0 ? void 0 : stackFrames.length) {
|
|
59
|
+
item.payload.stacktrace = {
|
|
60
|
+
frames: stackFrames,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
var testingPayload = {
|
|
64
|
+
type: item.payload.type,
|
|
65
|
+
value: item.payload.value,
|
|
66
|
+
stackTrace: item.payload.stacktrace,
|
|
67
|
+
context: item.payload.context,
|
|
68
|
+
};
|
|
69
|
+
if (!skipDedupe && config.dedupe && !(0, utils_1.isNull)(lastPayload) && (0, utils_1.deepEqual)(testingPayload, lastPayload)) {
|
|
70
|
+
internalLogger.debug('Skipping error push because it is the same as the last one\n', item.payload);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
lastPayload = testingPayload;
|
|
74
|
+
internalLogger.debug('Pushing exception\n', item);
|
|
75
|
+
var msg = getMessage();
|
|
76
|
+
if (msg && msg.type === const_1.USER_ACTION_START_MESSAGE_TYPE) {
|
|
77
|
+
actionBuffer.addItem(item);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
transports.execute(item);
|
|
81
|
+
}
|
|
58
82
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
value: item.payload.value,
|
|
62
|
-
stackTrace: item.payload.stacktrace,
|
|
63
|
-
context: item.payload.context,
|
|
64
|
-
};
|
|
65
|
-
if (!skipDedupe && config.dedupe && !(0, utils_1.isNull)(lastPayload) && (0, utils_1.deepEqual)(testingPayload, lastPayload)) {
|
|
66
|
-
internalLogger.debug('Skipping error push because it is the same as the last one\n', item.payload);
|
|
67
|
-
return;
|
|
83
|
+
catch (err) {
|
|
84
|
+
internalLogger.error('Error pushing event', err);
|
|
68
85
|
}
|
|
69
|
-
lastPayload = testingPayload;
|
|
70
|
-
internalLogger.debug('Pushing exception\n', item);
|
|
71
|
-
transports.execute(item);
|
|
72
86
|
};
|
|
73
87
|
changeStacktraceParser(config.parseStacktrace);
|
|
74
88
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAqD;AAGrD,
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/exceptions/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAqD;AAGrD,qCAUqB;AACrB,yCAAwD;AACxD,kCAA0D;AAI1D,kCAA6C;AAE7C,iCAA+C;AAG/C,IAAI,gBAA8C,CAAC;AAEnD,SAAgB,uBAAuB,CAAC,EAiBvC;;QAhBC,cAAc,oBAAA,EACd,MAAM,YAAA,EACN,KAAK,WAAA,EACL,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,YAAY,kBAAA,EACZ,UAAU,gBAAA;IAWV,cAAc,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAEpD,IAAI,WAAW,GAA6E,IAAI,CAAC;IAEjG,gBAAgB,GAAG,MAAA,MAAM,CAAC,eAAe,mCAAI,gBAAgB,CAAC;IAE9D,IAAM,sBAAsB,GAA4C,UAAC,mBAAmB;QAC1F,cAAc,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAEnD,gBAAgB,GAAG,mBAAmB,aAAnB,mBAAmB,cAAnB,mBAAmB,GAAI,gBAAgB,CAAC;IAC7D,CAAC,CAAC;IAEF,IAAM,mBAAmB,GAAyC,cAAM,OAAA,gBAAgB,EAAhB,CAAgB,CAAC;IAEjF,IAAA,KAAsB,MAAM,aAAX,EAAjB,YAAY,mBAAG,EAAE,KAAA,C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GC;AAED,SAAS,UAAU,CAAC,KAA+B;IACjD,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAExB,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,EAAE;QAClB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC/B,wKAAwK;QACxK,sGAAsG;KACvG;SAAM,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAA,eAAO,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;QAC5E,KAAK,GAAG,IAAA,6BAAqB,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KAC5C;SAAM,IAAI,KAAK,IAAI,IAAI,EAAE;QACxB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;KAChC;IAED,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,cAAc,CAAC,YAAsB,EAAE,KAA+B;IACrE,IAAA,OAAO,GAAkB,KAAK,QAAvB,EAAE,IAAI,GAAY,KAAK,KAAjB,EAAE,KAAK,GAAK,KAAK,MAAV,CAAW;IACvC,OAAO,IAAA,yBAAiB,EAAC,YAAY,EAAE,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import type { Config, Patterns } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItemType } from '../../transports';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport {\n deepEqual,\n getCurrentTimestamp,\n isArray,\n isEmpty,\n isError,\n isNull,\n isObject,\n stringifyExternalJson,\n stringifyObjectValues,\n} from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport { USER_ACTION_START_MESSAGE_TYPE } from '../const';\nimport type { ItemBuffer } from '../ItemBuffer';\nimport type { TracesAPI } from '../traces';\nimport type { ApiMessageBusMessages } from '../types';\nimport { shouldIgnoreEvent } from '../utils';\n\nimport { defaultExceptionType } from './const';\nimport type { ErrorWithIndexProperties, ExceptionEvent, ExceptionsAPI, StacktraceParser } from './types';\n\nlet stacktraceParser: StacktraceParser | undefined;\n\nexport function initializeExceptionsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n actionBuffer,\n getMessage,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n actionBuffer: ItemBuffer<TransportItem>;\n getMessage: () => ApiMessageBusMessages | undefined;\n}): ExceptionsAPI {\n internalLogger.debug('Initializing exceptions API');\n\n let lastPayload: Pick<ExceptionEvent, 'type' | 'value' | 'stacktrace' | 'context'> | null = null;\n\n stacktraceParser = config.parseStacktrace ?? stacktraceParser;\n\n const changeStacktraceParser: ExceptionsAPI['changeStacktraceParser'] = (newStacktraceParser) => {\n internalLogger.debug('Changing stacktrace parser');\n\n stacktraceParser = newStacktraceParser ?? stacktraceParser;\n };\n\n const getStacktraceParser: ExceptionsAPI['getStacktraceParser'] = () => stacktraceParser;\n\n const { ignoreErrors = [] } = config;\n\n const pushError: ExceptionsAPI['pushError'] = (\n error,\n { skipDedupe, stackFrames, type, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n if (isErrorIgnored(ignoreErrors, error)) {\n return;\n }\n try {\n const ctx = stringifyObjectValues({\n ...parseCause(error),\n ...(context ?? {}),\n });\n\n const item: TransportItem<ExceptionEvent> = {\n meta: metas.value,\n payload: {\n type: type || error.name || defaultExceptionType,\n value: error.message,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n context: isEmpty(ctx) ? undefined : ctx,\n },\n type: TransportItemType.EXCEPTION,\n };\n\n stackFrames = stackFrames ?? (error.stack ? stacktraceParser?.(error).frames : undefined);\n\n if (stackFrames?.length) {\n item.payload.stacktrace = {\n frames: stackFrames,\n };\n }\n\n const testingPayload = {\n type: item.payload.type,\n value: item.payload.value,\n stackTrace: item.payload.stacktrace,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping error push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing exception\\n', item);\n\n const msg = getMessage();\n if (msg && msg.type === USER_ACTION_START_MESSAGE_TYPE) {\n actionBuffer.addItem(item);\n } else {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing event', err);\n }\n };\n\n changeStacktraceParser(config.parseStacktrace);\n\n return {\n changeStacktraceParser,\n getStacktraceParser,\n pushError,\n };\n}\n\nfunction parseCause(error: ErrorWithIndexProperties): {} | { cause: string } {\n let cause = error.cause;\n\n if (isError(cause)) {\n cause = error.cause.toString();\n // typeof operator on null returns \"object\". This is a well-known quirk in JavaScript and is considered a bug that cannot be fixed due to backward compatibility issues.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#typeof_null\n } else if (cause !== null && (isObject(error.cause) || isArray(error.cause))) {\n cause = stringifyExternalJson(error.cause);\n } else if (cause != null) {\n cause = error.cause.toString();\n }\n\n return cause == null ? {} : { cause };\n}\n\nfunction isErrorIgnored(ignoreErrors: Patterns, error: ErrorWithIndexProperties): boolean {\n const { message, name, stack } = error;\n return shouldIgnoreEvent(ignoreErrors, message + ' ' + name + ' ' + stack);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\n// ts type is missing the cause property\nexport type ErrorWithIndexProperties = Error & {\n cause?: any;\n};\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/exceptions/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\nimport type { UserAction } from '../types';\n\nexport type StacktraceParser = (err: ExtendedError) => Stacktrace;\n\nexport interface ExceptionStackFrame {\n filename: string;\n function: string;\n\n colno?: number;\n lineno?: number;\n\n bundleid?: string;\n}\n\nexport interface ExtendedError extends Error {\n columnNumber?: number;\n stacktrace?: Error['stack'];\n}\n\nexport interface Stacktrace {\n frames: ExceptionStackFrame[];\n}\n\nexport type ExceptionContext = Record<string, string>;\n\nexport interface ExceptionEvent {\n timestamp: string;\n type: string;\n value: string;\n\n stacktrace?: Stacktrace;\n trace?: TraceContext;\n context?: ExceptionContext;\n\n action?: UserAction;\n}\n\nexport interface PushErrorOptions {\n skipDedupe?: boolean;\n stackFrames?: ExceptionStackFrame[];\n type?: string;\n context?: ExceptionContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\n// ts type is missing the cause property\nexport type ErrorWithIndexProperties = Error & {\n cause?: any;\n};\n\nexport interface ExceptionsAPI {\n changeStacktraceParser: (stacktraceParser: StacktraceParser) => void;\n getStacktraceParser: () => StacktraceParser | undefined;\n pushError: (value: ErrorWithIndexProperties, options?: PushErrorOptions) => void;\n}\n"]}
|
package/dist/cjs/api/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultLogArgsSerializer = exports.defaultErrorArgsSerializer = exports.defaultExceptionType = exports.initializeAPI = void 0;
|
|
3
|
+
exports.USER_ACTION_START_MESSAGE_TYPE = exports.USER_ACTION_END_MESSAGE_TYPE = exports.USER_ACTION_CANCEL_MESSAGE_TYPE = exports.apiMessageBus = exports.defaultLogArgsSerializer = exports.defaultErrorArgsSerializer = exports.defaultExceptionType = exports.initializeAPI = void 0;
|
|
4
4
|
var initialize_1 = require("./initialize");
|
|
5
5
|
Object.defineProperty(exports, "initializeAPI", { enumerable: true, get: function () { return initialize_1.initializeAPI; } });
|
|
6
6
|
var exceptions_1 = require("./exceptions");
|
|
@@ -8,4 +8,10 @@ Object.defineProperty(exports, "defaultExceptionType", { enumerable: true, get:
|
|
|
8
8
|
Object.defineProperty(exports, "defaultErrorArgsSerializer", { enumerable: true, get: function () { return exceptions_1.defaultErrorArgsSerializer; } });
|
|
9
9
|
var logs_1 = require("./logs");
|
|
10
10
|
Object.defineProperty(exports, "defaultLogArgsSerializer", { enumerable: true, get: function () { return logs_1.defaultLogArgsSerializer; } });
|
|
11
|
+
var initialize_2 = require("./initialize");
|
|
12
|
+
Object.defineProperty(exports, "apiMessageBus", { enumerable: true, get: function () { return initialize_2.apiMessageBus; } });
|
|
13
|
+
var const_1 = require("./const");
|
|
14
|
+
Object.defineProperty(exports, "USER_ACTION_CANCEL_MESSAGE_TYPE", { enumerable: true, get: function () { return const_1.USER_ACTION_CANCEL_MESSAGE_TYPE; } });
|
|
15
|
+
Object.defineProperty(exports, "USER_ACTION_END_MESSAGE_TYPE", { enumerable: true, get: function () { return const_1.USER_ACTION_END_MESSAGE_TYPE; } });
|
|
16
|
+
Object.defineProperty(exports, "USER_ACTION_START_MESSAGE_TYPE", { enumerable: true, get: function () { return const_1.USER_ACTION_START_MESSAGE_TYPE; } });
|
|
11
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAApC,2GAAA,aAAa,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAatB,2CAAgF;AAAvE,kHAAA,oBAAoB,OAAA;AAAE,wHAAA,0BAA0B,OAAA;AAWzD,+BAAkD;AAAzC,gHAAA,wBAAwB,OAAA;AASjC,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AAEtB,iCAAwH;AAA/G,wHAAA,+BAA+B,OAAA;AAAE,qHAAA,4BAA4B,OAAA;AAAE,uHAAA,8BAA8B,OAAA","sourcesContent":["export { initializeAPI } from './initialize';\nexport type {\n API,\n APIEvent,\n ApiMessageBusMessages,\n UserActionCancelMessage,\n UserActionEndMessage,\n UserActionStartMessage,\n UserAction,\n} from './types';\n\nexport type { EventAttributes, EventEvent, EventsAPI, PushEventOptions } from './events';\n\nexport { defaultExceptionType, defaultErrorArgsSerializer } from './exceptions';\nexport type {\n ExceptionEvent,\n ExceptionStackFrame,\n ExceptionsAPI,\n ExtendedError,\n PushErrorOptions,\n Stacktrace,\n StacktraceParser,\n} from './exceptions';\n\nexport { defaultLogArgsSerializer } from './logs';\nexport type { LogContext, LogEvent, LogArgsSerializer, LogsAPI, PushLogOptions } from './logs';\n\nexport type { MeasurementEvent, MeasurementsAPI, PushMeasurementOptions } from './measurements';\n\nexport type { MetaAPI } from './meta';\n\nexport type { OTELApi, TraceContext, TraceEvent, TracesAPI } from './traces';\n\nexport { apiMessageBus } from './initialize';\n\nexport { USER_ACTION_CANCEL_MESSAGE_TYPE, USER_ACTION_END_MESSAGE_TYPE, USER_ACTION_START_MESSAGE_TYPE } from './const';\n"]}
|
|
@@ -11,17 +11,31 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.initializeAPI = void 0;
|
|
14
|
+
exports.initializeAPI = exports.apiMessageBus = void 0;
|
|
15
|
+
var utils_1 = require("../utils");
|
|
15
16
|
var events_1 = require("./events");
|
|
16
17
|
var exceptions_1 = require("./exceptions");
|
|
17
18
|
var logs_1 = require("./logs");
|
|
18
19
|
var measurements_1 = require("./measurements");
|
|
19
20
|
var meta_1 = require("./meta");
|
|
20
21
|
var traces_1 = require("./traces");
|
|
22
|
+
var userActionLifecycleHandler_1 = require("./userActionLifecycleHandler");
|
|
23
|
+
exports.apiMessageBus = new utils_1.Observable();
|
|
21
24
|
function initializeAPI(unpatchedConsole, internalLogger, config, metas, transports) {
|
|
22
25
|
internalLogger.debug('Initializing API');
|
|
26
|
+
var _a = (0, userActionLifecycleHandler_1.createUserActionLifecycleHandler)({ apiMessageBus: exports.apiMessageBus, transports: transports, config: config }), actionBuffer = _a.actionBuffer, getMessage = _a.getMessage;
|
|
23
27
|
var tracesApi = (0, traces_1.initializeTracesAPI)(unpatchedConsole, internalLogger, config, metas, transports);
|
|
24
|
-
|
|
28
|
+
var props = {
|
|
29
|
+
unpatchedConsole: unpatchedConsole,
|
|
30
|
+
internalLogger: internalLogger,
|
|
31
|
+
config: config,
|
|
32
|
+
metas: metas,
|
|
33
|
+
transports: transports,
|
|
34
|
+
tracesApi: tracesApi,
|
|
35
|
+
actionBuffer: actionBuffer,
|
|
36
|
+
getMessage: getMessage,
|
|
37
|
+
};
|
|
38
|
+
return __assign(__assign(__assign(__assign(__assign(__assign({}, tracesApi), (0, exceptions_1.initializeExceptionsAPI)(props)), (0, meta_1.initializeMetaAPI)(props)), (0, logs_1.initializeLogsAPI)(props)), (0, measurements_1.initializeMeasurementsAPI)(props)), (0, events_1.initializeEventsAPI)(props));
|
|
25
39
|
}
|
|
26
40
|
exports.initializeAPI = initializeAPI;
|
|
27
41
|
//# sourceMappingURL=initialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/api/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/api/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,kCAAsC;AAEtC,mCAA+C;AAC/C,2CAAuD;AACvD,+BAA2C;AAC3C,+CAA2D;AAC3D,+BAA2C;AAC3C,mCAA+C;AAE/C,2EAAgF;AAEnE,QAAA,aAAa,GAAG,IAAI,kBAAU,EAAyB,CAAC;AAErE,SAAgB,aAAa,CAC3B,gBAAkC,EAClC,cAA8B,EAC9B,MAAc,EACd,KAAY,EACZ,UAAsB;IAEtB,cAAc,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAEnC,IAAA,KAA+B,IAAA,6DAAgC,EAAC,EAAE,aAAa,uBAAA,EAAE,UAAU,YAAA,EAAE,MAAM,QAAA,EAAE,CAAC,EAApG,YAAY,kBAAA,EAAE,UAAU,gBAA4E,CAAC;IAE7G,IAAM,SAAS,GAAG,IAAA,4BAAmB,EAAC,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;IAEnG,IAAM,KAAK,GAAG;QACZ,gBAAgB,kBAAA;QAChB,cAAc,gBAAA;QACd,MAAM,QAAA;QACN,KAAK,OAAA;QACL,UAAU,YAAA;QACV,SAAS,WAAA;QACT,YAAY,cAAA;QACZ,UAAU,YAAA;KACX,CAAC;IAEF,iEACK,SAAS,GACT,IAAA,oCAAuB,EAAC,KAAK,CAAC,GAC9B,IAAA,wBAAiB,EAAC,KAAK,CAAC,GACxB,IAAA,wBAAiB,EAAC,KAAK,CAAC,GACxB,IAAA,wCAAyB,EAAC,KAAK,CAAC,GAChC,IAAA,4BAAmB,EAAC,KAAK,CAAC,EAC7B;AACJ,CAAC;AAhCD,sCAgCC","sourcesContent":["import type { Config } from '../config';\nimport type { InternalLogger } from '../internalLogger';\nimport type { Metas } from '../metas';\nimport type { Transports } from '../transports';\nimport type { UnpatchedConsole } from '../unpatchedConsole';\nimport { Observable } from '../utils';\n\nimport { initializeEventsAPI } from './events';\nimport { initializeExceptionsAPI } from './exceptions';\nimport { initializeLogsAPI } from './logs';\nimport { initializeMeasurementsAPI } from './measurements';\nimport { initializeMetaAPI } from './meta';\nimport { initializeTracesAPI } from './traces';\nimport type { API, ApiMessageBusMessages } from './types';\nimport { createUserActionLifecycleHandler } from './userActionLifecycleHandler';\n\nexport const apiMessageBus = new Observable<ApiMessageBusMessages>();\n\nexport function initializeAPI(\n unpatchedConsole: UnpatchedConsole,\n internalLogger: InternalLogger,\n config: Config,\n metas: Metas,\n transports: Transports\n): API {\n internalLogger.debug('Initializing API');\n\n const { actionBuffer, getMessage } = createUserActionLifecycleHandler({ apiMessageBus, transports, config });\n\n const tracesApi = initializeTracesAPI(unpatchedConsole, internalLogger, config, metas, transports);\n\n const props = {\n unpatchedConsole,\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n actionBuffer,\n getMessage,\n };\n\n return {\n ...tracesApi,\n ...initializeExceptionsAPI(props),\n ...initializeMetaAPI(props),\n ...initializeLogsAPI(props),\n ...initializeMeasurementsAPI(props),\n ...initializeEventsAPI(props),\n };\n}\n"]}
|
|
@@ -4,21 +4,24 @@ exports.initializeLogsAPI = void 0;
|
|
|
4
4
|
var transports_1 = require("../../transports");
|
|
5
5
|
var utils_1 = require("../../utils");
|
|
6
6
|
var date_1 = require("../../utils/date");
|
|
7
|
-
var const_1 = require("
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
var const_1 = require("../const");
|
|
8
|
+
var const_2 = require("./const");
|
|
9
|
+
function initializeLogsAPI(_a) {
|
|
10
|
+
var _b;
|
|
11
|
+
var internalLogger = _a.internalLogger, config = _a.config, metas = _a.metas, transports = _a.transports, tracesApi = _a.tracesApi, actionBuffer = _a.actionBuffer, getMessage = _a.getMessage;
|
|
10
12
|
internalLogger.debug('Initializing logs API');
|
|
11
13
|
var lastPayload = null;
|
|
12
|
-
var logArgsSerializer = (
|
|
14
|
+
var logArgsSerializer = (_b = config.logArgsSerializer) !== null && _b !== void 0 ? _b : const_2.defaultLogArgsSerializer;
|
|
13
15
|
var pushLog = function (args, _a) {
|
|
14
16
|
var _b = _a === void 0 ? {} : _a, context = _b.context, level = _b.level, skipDedupe = _b.skipDedupe, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs;
|
|
15
17
|
try {
|
|
18
|
+
var ctx = (0, utils_1.stringifyObjectValues)(context);
|
|
16
19
|
var item = {
|
|
17
20
|
type: transports_1.TransportItemType.LOG,
|
|
18
21
|
payload: {
|
|
19
22
|
message: logArgsSerializer(args),
|
|
20
23
|
level: level !== null && level !== void 0 ? level : utils_1.defaultLogLevel,
|
|
21
|
-
context: (0, utils_1.
|
|
24
|
+
context: (0, utils_1.isEmpty)(ctx) ? undefined : ctx,
|
|
22
25
|
timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(),
|
|
23
26
|
trace: spanContext
|
|
24
27
|
? {
|
|
@@ -40,7 +43,13 @@ function initializeLogsAPI(_unpatchedConsole, internalLogger, config, metas, tra
|
|
|
40
43
|
}
|
|
41
44
|
lastPayload = testingPayload;
|
|
42
45
|
internalLogger.debug('Pushing log\n', item);
|
|
43
|
-
|
|
46
|
+
var msg = getMessage();
|
|
47
|
+
if (msg && msg.type === const_1.USER_ACTION_START_MESSAGE_TYPE) {
|
|
48
|
+
actionBuffer.addItem(item);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
transports.execute(item);
|
|
52
|
+
}
|
|
44
53
|
}
|
|
45
54
|
catch (err) {
|
|
46
55
|
internalLogger.error('Error pushing log\n', err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/logs/initialize.ts"],"names":[],"mappings":";;;AAGA,+
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/logs/initialize.ts"],"names":[],"mappings":";;;AAGA,+CAAgF;AAEhF,qCAAsH;AACtH,yCAAwD;AACxD,kCAA0D;AAK1D,iCAAmD;AAGnD,SAAgB,iBAAiB,CAAC,EAiBjC;;QAhBC,cAAc,oBAAA,EACd,MAAM,YAAA,EACN,KAAK,WAAA,EACL,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,YAAY,kBAAA,EACZ,UAAU,gBAAA;IAWV,cAAc,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAE9C,IAAI,WAAW,GAA2D,IAAI,CAAC;IAE/E,IAAM,iBAAiB,GAAG,MAAA,MAAM,CAAC,iBAAiB,mCAAI,gCAAwB,CAAC;IAE/E,IAAM,OAAO,GAAuB,UAClC,IAAI,EACJ,EAAsE;YAAtE,qBAAoE,EAAE,KAAA,EAApE,OAAO,aAAA,EAAE,KAAK,WAAA,EAAE,UAAU,gBAAA,EAAE,WAAW,iBAAA,EAAE,oBAAoB,0BAAA;QAE/D,IAAI;YACF,IAAM,GAAG,GAA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,CAAC;YACzB,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,sCAA8B,EAAE;gBACtD,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC5B;iBAAM;gBACL,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC1B;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;SAClD;IACH,CAAC,CAAC;IAEF,OAAO;QACL,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AA9ED,8CA8EC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, defaultLogLevel, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport { USER_ACTION_START_MESSAGE_TYPE } from '../const';\nimport type { ItemBuffer } from '../ItemBuffer';\nimport type { TracesAPI } from '../traces';\nimport type { ApiMessageBusMessages } from '../types';\n\nimport { defaultLogArgsSerializer } from './const';\nimport type { LogEvent, LogsAPI } from './types';\n\nexport function initializeLogsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n actionBuffer,\n getMessage,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n actionBuffer: ItemBuffer<TransportItem>;\n getMessage: () => ApiMessageBusMessages | undefined;\n}): LogsAPI {\n internalLogger.debug('Initializing logs API');\n\n let lastPayload: Pick<LogEvent, 'message' | 'level' | 'context'> | null = null;\n\n const logArgsSerializer = config.logArgsSerializer ?? defaultLogArgsSerializer;\n\n const pushLog: LogsAPI['pushLog'] = (\n args,\n { context, level, skipDedupe, spanContext, timestampOverwriteMs } = {}\n ) => {\n try {\n const ctx = stringifyObjectValues(context);\n\n const item: TransportItem<LogEvent> = {\n type: TransportItemType.LOG,\n payload: {\n message: logArgsSerializer(args),\n level: level ?? defaultLogLevel,\n context: isEmpty(ctx) ? undefined : ctx,\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n message: item.payload.message,\n level: item.payload.level,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping log push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing log\\n', item);\n\n const msg = getMessage();\n if (msg && msg.type === USER_ACTION_START_MESSAGE_TYPE) {\n actionBuffer.addItem(item);\n } else {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing log\\n', err);\n }\n };\n\n return {\n pushLog,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n\nexport type LogArgsSerializer = (args: unknown[]) => string;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/logs/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { LogLevel } from '../../utils';\nimport type { TraceContext } from '../traces';\nimport type { UserAction } from '../types';\n\nexport type LogContext = Record<string, string>;\n\nexport interface LogEvent {\n context: LogContext | undefined;\n level: LogLevel;\n message: string;\n timestamp: string;\n\n trace?: TraceContext;\n action?: UserAction;\n}\n\nexport interface PushLogOptions {\n context?: LogContext;\n level?: LogLevel;\n skipDedupe?: boolean;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface LogsAPI {\n pushLog: (args: unknown[], options?: PushLogOptions) => void;\n}\n\nexport type LogArgsSerializer = (args: unknown[]) => string;\n"]}
|
|
@@ -15,12 +15,15 @@ exports.initializeMeasurementsAPI = void 0;
|
|
|
15
15
|
var transports_1 = require("../../transports");
|
|
16
16
|
var utils_1 = require("../../utils");
|
|
17
17
|
var date_1 = require("../../utils/date");
|
|
18
|
-
|
|
18
|
+
var const_1 = require("../const");
|
|
19
|
+
function initializeMeasurementsAPI(_a) {
|
|
20
|
+
var internalLogger = _a.internalLogger, config = _a.config, metas = _a.metas, transports = _a.transports, tracesApi = _a.tracesApi, actionBuffer = _a.actionBuffer, getMessage = _a.getMessage;
|
|
19
21
|
internalLogger.debug('Initializing measurements API');
|
|
20
22
|
var lastPayload = null;
|
|
21
23
|
var pushMeasurement = function (payload, _a) {
|
|
22
24
|
var _b = _a === void 0 ? {} : _a, skipDedupe = _b.skipDedupe, context = _b.context, spanContext = _b.spanContext, timestampOverwriteMs = _b.timestampOverwriteMs;
|
|
23
25
|
try {
|
|
26
|
+
var ctx = (0, utils_1.stringifyObjectValues)(context);
|
|
24
27
|
var item = {
|
|
25
28
|
type: transports_1.TransportItemType.MEASUREMENT,
|
|
26
29
|
payload: __assign(__assign({}, payload), { trace: spanContext
|
|
@@ -28,7 +31,7 @@ function initializeMeasurementsAPI(_unpatchedConsole, internalLogger, config, me
|
|
|
28
31
|
trace_id: spanContext.traceId,
|
|
29
32
|
span_id: spanContext.spanId,
|
|
30
33
|
}
|
|
31
|
-
: tracesApi.getTraceContext(), timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(), context: (0, utils_1.
|
|
34
|
+
: tracesApi.getTraceContext(), timestamp: timestampOverwriteMs ? (0, date_1.timestampToIsoString)(timestampOverwriteMs) : (0, utils_1.getCurrentTimestamp)(), context: (0, utils_1.isEmpty)(ctx) ? undefined : ctx }),
|
|
32
35
|
meta: metas.value,
|
|
33
36
|
};
|
|
34
37
|
var testingPayload = {
|
|
@@ -42,7 +45,13 @@ function initializeMeasurementsAPI(_unpatchedConsole, internalLogger, config, me
|
|
|
42
45
|
}
|
|
43
46
|
lastPayload = testingPayload;
|
|
44
47
|
internalLogger.debug('Pushing measurement\n', item);
|
|
45
|
-
|
|
48
|
+
var msg = getMessage();
|
|
49
|
+
if (msg && msg.type === const_1.USER_ACTION_START_MESSAGE_TYPE) {
|
|
50
|
+
actionBuffer.addItem(item);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
transports.execute(item);
|
|
54
|
+
}
|
|
46
55
|
}
|
|
47
56
|
catch (err) {
|
|
48
57
|
internalLogger.error('Error pushing measurement\n', err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAoE;AAGpE,
|
|
1
|
+
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/measurements/initialize.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,+CAAoE;AAGpE,qCAAqG;AACrG,yCAAwD;AACxD,kCAA0D;AAO1D,SAAgB,yBAAyB,CAAC,EAiBzC;QAhBC,cAAc,oBAAA,EACd,MAAM,YAAA,E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S,EAAC,cAAc,EAAE,WAAW,CAAC,EAAE;gBAClG,cAAc,CAAC,KAAK,CAAC,oEAAoE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEzG,OAAO;aACR;YAED,WAAW,GAAG,cAAc,CAAC;YAE7B,cAAc,CAAC,KAAK,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;YAEpD,IAAM,GAAG,GAAG,UAAU,EAAE,CAAC;YACzB,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,sCAA8B,EAAE;gBACtD,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC5B;iBAAM;gBACL,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC1B;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,cAAc,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;SAC1D;IACH,CAAC,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;KAChB,CAAC;AACJ,CAAC;AA3ED,8DA2EC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Metas } from '../../metas';\nimport { TransportItem, TransportItemType } from '../../transports';\nimport type { Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { deepEqual, getCurrentTimestamp, isEmpty, isNull, stringifyObjectValues } from '../../utils';\nimport { timestampToIsoString } from '../../utils/date';\nimport { USER_ACTION_START_MESSAGE_TYPE } from '../const';\nimport type { ItemBuffer } from '../ItemBuffer';\nimport type { TracesAPI } from '../traces';\nimport type { ApiMessageBusMessages } from '../types';\n\nimport type { MeasurementEvent, MeasurementsAPI } from './types';\n\nexport function initializeMeasurementsAPI({\n internalLogger,\n config,\n metas,\n transports,\n tracesApi,\n actionBuffer,\n getMessage,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n actionBuffer: ItemBuffer<TransportItem>;\n getMessage: () => ApiMessageBusMessages | undefined;\n}): MeasurementsAPI {\n internalLogger.debug('Initializing measurements API');\n\n let lastPayload: Pick<MeasurementEvent, 'type' | 'values' | 'context'> | null = null;\n\n const pushMeasurement: MeasurementsAPI['pushMeasurement'] = (\n payload,\n { skipDedupe, context, spanContext, timestampOverwriteMs } = {}\n ) => {\n try {\n const ctx = stringifyObjectValues(context);\n\n const item: TransportItem<MeasurementEvent> = {\n type: TransportItemType.MEASUREMENT,\n payload: {\n ...payload,\n trace: spanContext\n ? {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n }\n : tracesApi.getTraceContext(),\n timestamp: timestampOverwriteMs ? timestampToIsoString(timestampOverwriteMs) : getCurrentTimestamp(),\n context: isEmpty(ctx) ? undefined : ctx,\n },\n meta: metas.value,\n };\n\n const testingPayload = {\n type: item.payload.type,\n values: item.payload.values,\n context: item.payload.context,\n };\n\n if (!skipDedupe && config.dedupe && !isNull(lastPayload) && deepEqual(testingPayload, lastPayload)) {\n internalLogger.debug('Skipping measurement push because it is the same as the last one\\n', item.payload);\n\n return;\n }\n\n lastPayload = testingPayload;\n\n internalLogger.debug('Pushing measurement\\n', item);\n\n const msg = getMessage();\n if (msg && msg.type === USER_ACTION_START_MESSAGE_TYPE) {\n actionBuffer.addItem(item);\n } else {\n transports.execute(item);\n }\n } catch (err) {\n internalLogger.error('Error pushing measurement\\n', err);\n }\n };\n\n return {\n pushMeasurement,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/measurements/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\n\nexport type MeasurementContext = Record<string, string>;\n\nexport interface MeasurementEvent<V extends { [label: string]: number } = { [label: string]: number }> {\n type: string;\n values: V;\n\n timestamp: string;\n trace?: TraceContext;\n context?: MeasurementContext;\n}\n\nexport interface PushMeasurementOptions {\n skipDedupe?: boolean;\n context?: MeasurementContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface MeasurementsAPI {\n pushMeasurement: (\n payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>,\n options?: PushMeasurementOptions\n ) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/measurements/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SpanContext } from '@opentelemetry/api';\n\nimport type { TraceContext } from '../traces';\nimport type { UserAction } from '../types';\n\nexport type MeasurementContext = Record<string, string>;\n\nexport interface MeasurementEvent<V extends { [label: string]: number } = { [label: string]: number }> {\n type: string;\n values: V;\n\n timestamp: string;\n trace?: TraceContext;\n context?: MeasurementContext;\n\n action?: UserAction;\n}\n\nexport interface PushMeasurementOptions {\n skipDedupe?: boolean;\n context?: MeasurementContext;\n spanContext?: Pick<SpanContext, 'traceId' | 'spanId'>;\n timestampOverwriteMs?: number;\n}\n\nexport interface MeasurementsAPI {\n pushMeasurement: (\n payload: Omit<MeasurementEvent, 'timestamp'> & Partial<Pick<MeasurementEvent, 'timestamp'>>,\n options?: PushMeasurementOptions\n ) => void;\n}\n"]}
|
|
@@ -13,7 +13,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.initializeMetaAPI = void 0;
|
|
15
15
|
var is_1 = require("../../utils/is");
|
|
16
|
-
function initializeMetaAPI(
|
|
16
|
+
function initializeMetaAPI(_a) {
|
|
17
|
+
var internalLogger = _a.internalLogger, metas = _a.metas;
|
|
17
18
|
internalLogger.debug('Initializing meta API');
|
|
18
19
|
var metaSession = undefined;
|
|
19
20
|
var metaUser = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../../src/api/meta/initialize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C,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,IAAM,OAAO,GAAuB,cAAM,OAAA,KAAK,CAAC,KAAK,CAAC,IAAI,EAAhB,CAAgB,CAAC;IAE3D,OAAO;QACL,OAAO,SAAA;QACP,SAAS,EAAE,OAA+B;QAC1C,UAAU,YAAA;QACV,YAAY,EAAE,UAAqC;QACnD,UAAU,YAAA;QACV,OAAO,SAAA;QACP,OAAO,SAAA;QACP,OAAO,SAAA;QACP,OAAO,SAAA;KACR,CAAC;AACJ,CAAC;AAvHD,8CAuHC","sourcesContent":["import type { Config } from '../../config';\nimport type { InternalLogger } from '../../internalLogger';\nimport type { Meta, Metas } from '../../metas';\nimport type { TransportItem, Transports } from '../../transports';\nimport type { UnpatchedConsole } from '../../unpatchedConsole';\nimport { isEmpty, isString } from '../../utils/is';\nimport type { ItemBuffer } from '../ItemBuffer';\nimport type { TracesAPI } from '../traces';\nimport type { ApiMessageBusMessages } from '../types';\n\nimport type { MetaAPI } from './types';\n\nexport function initializeMetaAPI({\n internalLogger,\n metas,\n}: {\n unpatchedConsole: UnpatchedConsole;\n internalLogger: InternalLogger;\n config: Config;\n metas: Metas;\n transports: Transports;\n tracesApi: TracesAPI;\n actionBuffer: ItemBuffer<TransportItem>;\n getMessage: () => ApiMessageBusMessages | undefined;\n}): MetaAPI {\n internalLogger.debug('Initializing meta API');\n\n let metaSession: Partial<Meta> | undefined = undefined;\n let metaUser: Partial<Meta> | undefined = undefined;\n let metaView: Partial<Meta> | undefined = undefined;\n let metaPage: Partial<Meta> | undefined = undefined;\n\n const setUser: MetaAPI['setUser'] = (user) => {\n if (metaUser) {\n metas.remove(metaUser);\n }\n\n metaUser = {\n user,\n };\n\n metas.add(metaUser);\n };\n\n const setSession: MetaAPI['setSession'] = (session, options) => {\n const newOverrides = options?.overrides;\n const overrides = newOverrides\n ? {\n overrides: {\n ...metaSession?.session?.overrides,\n ...newOverrides,\n },\n }\n : {};\n\n if (metaSession) {\n metas.remove(metaSession);\n }\n\n metaSession = {\n session: {\n // if session is undefined, session manager force creates a new session\n ...(isEmpty(session) ? undefined : session),\n ...overrides,\n },\n };\n\n metas.add(metaSession);\n };\n\n const getSession: MetaAPI['getSession'] = () => metas.value.session;\n\n const setView: MetaAPI['setView'] = (view, options) => {\n if (options?.overrides) {\n setSession(getSession(), { overrides: options.overrides });\n }\n\n if (metaView?.view?.name === view?.name) {\n return;\n }\n\n const previousView = metaView;\n\n metaView = {\n view,\n };\n\n metas.add(metaView);\n\n if (previousView) {\n metas.remove(previousView);\n }\n };\n\n const getView: MetaAPI['getView'] = () => metas.value.view;\n\n const setPage: MetaAPI['setPage'] = (page) => {\n const pageMeta = isString(page)\n ? {\n // metaPage is available once setPage() has been called.\n // This is because page self updating metas like page need to be added as a function\n // Thus we call getPage in case metaPage is empty\n ...(metaPage?.page ?? getPage()),\n id: page,\n }\n : page;\n\n if (metaPage) {\n metas.remove(metaPage);\n }\n\n metaPage = {\n page: pageMeta,\n };\n\n metas.add(metaPage);\n };\n\n const getPage: MetaAPI['getPage'] = () => metas.value.page;\n\n return {\n setUser,\n resetUser: setUser as MetaAPI['resetUser'],\n setSession,\n resetSession: setSession as MetaAPI['resetSession'],\n getSession,\n setView,\n getView,\n setPage,\n getPage,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { EventEvent, EventsAPI } from './events';\nimport type { ExceptionEvent, ExceptionsAPI } from './exceptions';\nimport type { LogEvent, LogsAPI } from './logs';\nimport type { MeasurementEvent, MeasurementsAPI } from './measurements';\nimport type { MetaAPI } from './meta';\nimport type { TraceEvent, TracesAPI } from './traces';\n\nexport type APIEvent = LogEvent | ExceptionEvent | MeasurementEvent | TraceEvent | EventEvent;\n\nexport type API = LogsAPI & ExceptionsAPI & MeasurementsAPI & TracesAPI & MetaAPI & EventsAPI;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n USER_ACTION_CANCEL_MESSAGE_TYPE,\n USER_ACTION_END_MESSAGE_TYPE,\n USER_ACTION_START_MESSAGE_TYPE,\n} from './const';\nimport type { EventEvent, EventsAPI } from './events';\nimport type { ExceptionEvent, ExceptionsAPI } from './exceptions';\nimport type { LogEvent, LogsAPI } from './logs';\nimport type { MeasurementEvent, MeasurementsAPI } from './measurements';\nimport type { MetaAPI } from './meta';\nimport type { TraceEvent, TracesAPI } from './traces';\n\nexport type APIEvent = LogEvent | ExceptionEvent | MeasurementEvent | TraceEvent | EventEvent;\n\nexport type API = LogsAPI & ExceptionsAPI & MeasurementsAPI & TracesAPI & MetaAPI & EventsAPI;\n\nexport type ApiMessageBusMessages = UserActionStartMessage | UserActionEndMessage | UserActionCancelMessage;\n\nexport type UserActionMessageType =\n | typeof USER_ACTION_START_MESSAGE_TYPE\n | typeof USER_ACTION_END_MESSAGE_TYPE\n | typeof USER_ACTION_CANCEL_MESSAGE_TYPE;\n\nexport type UserActionStartMessage = {\n type: typeof USER_ACTION_START_MESSAGE_TYPE;\n name: string;\n startTime: number;\n\n /**\n * Unique identifier of the parent user action to which this action belongs.\n */\n parentId: string;\n};\n\nexport type UserActionEndMessage = {\n type: typeof USER_ACTION_END_MESSAGE_TYPE;\n name: string;\n startTime: number;\n endTime: number;\n duration: number;\n eventType: string;\n\n /**\n * Unique identifier for the user action. Will be undefined for messages related to child actions.\n */\n id: string;\n};\n\nexport type UserActionCancelMessage = {\n type: typeof USER_ACTION_CANCEL_MESSAGE_TYPE;\n name: string;\n\n /**\n * Unique identifier of the parent user action to which this action belongs.\n */\n parentId?: string;\n};\n\nexport type UserAction = {\n name: string;\n id?: string;\n parentId?: string;\n};\n"]}
|