@servicetitan/datadog-rum 40.1.0 → 40.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/create-impl.d.ts.map +1 -1
- package/dist/create-impl.js +2 -0
- package/dist/create-impl.js.map +1 -1
- package/dist/element-service-recorder.d.ts +17 -0
- package/dist/element-service-recorder.d.ts.map +1 -0
- package/dist/element-service-recorder.js +39 -0
- package/dist/element-service-recorder.js.map +1 -0
- package/dist/enrich-event.d.ts.map +1 -1
- package/dist/enrich-event.js +81 -20
- package/dist/enrich-event.js.map +1 -1
- package/dist/resolve-path-service.d.ts +11 -0
- package/dist/resolve-path-service.d.ts.map +1 -0
- package/dist/resolve-path-service.js +71 -0
- package/dist/resolve-path-service.js.map +1 -0
- package/package.json +2 -2
- package/src/__mocks__/before-send-data.ts +272 -0
- package/src/__mocks__/index.ts +1 -0
- package/src/__mocks__/mfe-host.ts +7 -0
- package/src/__tests__/create-impl.test.ts +8 -0
- package/src/__tests__/element-service-recorder.test.ts +127 -0
- package/src/__tests__/enrich-event.test.ts +109 -4
- package/src/__tests__/resolve-path-service.test.ts +130 -0
- package/src/create-impl.ts +2 -0
- package/src/element-service-recorder.ts +45 -0
- package/src/enrich-event.ts +67 -19
- package/src/resolve-path-service.ts +83 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-impl.d.ts","sourceRoot":"","sources":["../src/create-impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-impl.d.ts","sourceRoot":"","sources":["../src/create-impl.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAShD;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,UAAU,CAiHvC"}
|
package/dist/create-impl.js
CHANGED
|
@@ -2,6 +2,7 @@ import { datadogRum } from '@datadog/browser-rum';
|
|
|
2
2
|
import { buildAllowedTracingUrls } from './build-allowed-tracing-urls';
|
|
3
3
|
import { buildBeforeSend } from './build-before-send';
|
|
4
4
|
import { installDdRumGuard } from './dd-rum-guard';
|
|
5
|
+
import { elementServiceRecorder } from './element-service-recorder';
|
|
5
6
|
import { DATADOG_RUM_FOR_DEV, installDevConsole, isForceEnabled } from './runtime-override';
|
|
6
7
|
const DEFAULTS = {
|
|
7
8
|
sessionSampleRate: 100,
|
|
@@ -39,6 +40,7 @@ const DEFAULTS = {
|
|
|
39
40
|
datadogRum.setGlobalContextProperty(DATADOG_RUM_FOR_DEV, true);
|
|
40
41
|
}
|
|
41
42
|
installDdRumGuard(datadogRum);
|
|
43
|
+
elementServiceRecorder.install();
|
|
42
44
|
if (initializedBy) {
|
|
43
45
|
datadogRum.setGlobalContextProperty('initializedBy', {
|
|
44
46
|
service: initializedBy
|
package/dist/create-impl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-impl.ts"],"sourcesContent":["import { datadogRum } from '@datadog/browser-rum';\nimport { buildAllowedTracingUrls } from './build-allowed-tracing-urls';\nimport { buildBeforeSend } from './build-before-send';\nimport { installDdRumGuard } from './dd-rum-guard';\nimport { DATADOG_RUM_FOR_DEV, installDevConsole, isForceEnabled } from './runtime-override';\nimport type { SharedImpl } from './shared-impl';\nimport type { ApplicationConfig, PendingApplication, ServiceConfig, State } from './types';\n\nconst DEFAULTS = {\n sessionSampleRate: 100,\n sessionReplaySampleRate: 0,\n defaultPrivacyLevel: 'mask-user-input',\n} as const;\n\n/**\n * Interop surface: stored on globalThis, shared across independently\n * deployed bundles. First bundle to load wins. Append-only — never\n * remove or change method signatures.\n */\nexport function createImpl(): SharedImpl {\n let initialized = false;\n let offer: PendingApplication | undefined;\n const state: State = {\n services: new Map(),\n };\n\n function initializeSdk({\n service,\n application,\n enabled,\n initializedBy,\n }: {\n service: ServiceConfig;\n application: ApplicationConfig;\n enabled: boolean;\n initializedBy?: string;\n }): boolean {\n if (datadogRum.getInitConfiguration()) {\n // eslint-disable-next-line no-console\n console.warn(\n '[datadog-rum] init: SDK was initialized outside the facade; service handlers will not fire.'\n );\n return false;\n }\n\n const { beforeSend: appBeforeSend, ...sdkConfigPart } = application;\n if (appBeforeSend) {\n state.applicationBeforeSend = appBeforeSend;\n }\n datadogRum.init({\n ...DEFAULTS,\n ...sdkConfigPart,\n service: service.name,\n beforeSend: buildBeforeSend(state),\n allowedTracingUrls: buildAllowedTracingUrls(state),\n });\n if (!enabled) {\n datadogRum.setGlobalContextProperty(DATADOG_RUM_FOR_DEV, true);\n }\n installDdRumGuard(datadogRum);\n if (initializedBy) {\n datadogRum.setGlobalContextProperty('initializedBy', { service: initializedBy });\n }\n initialized = true;\n return true;\n }\n\n function registerService({ name, ...reg }: ServiceConfig): void {\n const existing = state.services.get(name);\n state.services.set(name, { ...reg, context: existing?.context });\n }\n\n function startSdk(\n service: ServiceConfig,\n application: ApplicationConfig | undefined,\n enabled: boolean\n ): boolean {\n if (application && !enabled) {\n installDevConsole();\n }\n\n if (initialized) {\n if (application) {\n // eslint-disable-next-line no-console\n console.info(\n `[datadog-rum] init: application config from '${service.name}' ignored; the SDK is already started.`\n );\n }\n return false;\n }\n\n if (application) {\n offer ??= { service, application };\n }\n\n if (!offer || (!enabled && !isForceEnabled())) {\n return false;\n }\n\n const startedByOfferer = offer.service.name === service.name;\n if (application && !startedByOfferer) {\n // eslint-disable-next-line no-console\n console.info(\n `[datadog-rum] init: application config from '${service.name}' ignored; started the application offered by '${offer.service.name}'.`\n );\n }\n\n return initializeSdk({\n service: offer.service,\n application: offer.application,\n enabled,\n initializedBy: startedByOfferer ? undefined : service.name,\n });\n }\n\n return {\n init({ service, application, enabled = true }) {\n const initializedSdk = startSdk(service, application, enabled);\n registerService(service);\n\n return {\n cleanup: () => state.services.delete(service.name),\n initializedSdk,\n };\n },\n\n setServiceContext(key, context) {\n const existing = state.services.get(key);\n state.services.set(key, { ...existing, context });\n },\n };\n}\n"],"names":["datadogRum","buildAllowedTracingUrls","buildBeforeSend","installDdRumGuard","DATADOG_RUM_FOR_DEV","installDevConsole","isForceEnabled","DEFAULTS","sessionSampleRate","sessionReplaySampleRate","defaultPrivacyLevel","createImpl","initialized","offer","state","services","Map","initializeSdk","service","application","enabled","initializedBy","getInitConfiguration","console","warn","beforeSend","appBeforeSend","sdkConfigPart","applicationBeforeSend","init","name","allowedTracingUrls","setGlobalContextProperty","registerService","reg","existing","get","set","context","startSdk","info","startedByOfferer","undefined","initializedSdk","cleanup","delete","setServiceContext","key"],"mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,SAASC,uBAAuB,QAAQ,+BAA+B;AACvE,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,mBAAmB,EAAEC,iBAAiB,EAAEC,cAAc,QAAQ,qBAAqB;AAI5F,MAAMC,WAAW;IACbC,mBAAmB;IACnBC,yBAAyB;IACzBC,qBAAqB;AACzB;AAEA;;;;CAIC,GACD,OAAO,SAASC;IACZ,IAAIC,cAAc;IAClB,IAAIC;IACJ,MAAMC,QAAe;QACjBC,UAAU,IAAIC;IAClB;IAEA,SAASC,cAAc,EACnBC,OAAO,EACPC,WAAW,EACXC,OAAO,EACPC,aAAa,EAMhB;QACG,
|
|
1
|
+
{"version":3,"sources":["../src/create-impl.ts"],"sourcesContent":["import { datadogRum } from '@datadog/browser-rum';\nimport { buildAllowedTracingUrls } from './build-allowed-tracing-urls';\nimport { buildBeforeSend } from './build-before-send';\nimport { installDdRumGuard } from './dd-rum-guard';\nimport { elementServiceRecorder } from './element-service-recorder';\nimport { DATADOG_RUM_FOR_DEV, installDevConsole, isForceEnabled } from './runtime-override';\nimport type { SharedImpl } from './shared-impl';\nimport type { ApplicationConfig, PendingApplication, ServiceConfig, State } from './types';\n\nconst DEFAULTS = {\n sessionSampleRate: 100,\n sessionReplaySampleRate: 0,\n defaultPrivacyLevel: 'mask-user-input',\n} as const;\n\n/**\n * Interop surface: stored on globalThis, shared across independently\n * deployed bundles. First bundle to load wins. Append-only — never\n * remove or change method signatures.\n */\nexport function createImpl(): SharedImpl {\n let initialized = false;\n let offer: PendingApplication | undefined;\n const state: State = {\n services: new Map(),\n };\n\n function initializeSdk({\n service,\n application,\n enabled,\n initializedBy,\n }: {\n service: ServiceConfig;\n application: ApplicationConfig;\n enabled: boolean;\n initializedBy?: string;\n }): boolean {\n if (datadogRum.getInitConfiguration()) {\n // eslint-disable-next-line no-console\n console.warn(\n '[datadog-rum] init: SDK was initialized outside the facade; service handlers will not fire.'\n );\n return false;\n }\n\n const { beforeSend: appBeforeSend, ...sdkConfigPart } = application;\n if (appBeforeSend) {\n state.applicationBeforeSend = appBeforeSend;\n }\n datadogRum.init({\n ...DEFAULTS,\n ...sdkConfigPart,\n service: service.name,\n beforeSend: buildBeforeSend(state),\n allowedTracingUrls: buildAllowedTracingUrls(state),\n });\n if (!enabled) {\n datadogRum.setGlobalContextProperty(DATADOG_RUM_FOR_DEV, true);\n }\n installDdRumGuard(datadogRum);\n elementServiceRecorder.install();\n if (initializedBy) {\n datadogRum.setGlobalContextProperty('initializedBy', { service: initializedBy });\n }\n initialized = true;\n return true;\n }\n\n function registerService({ name, ...reg }: ServiceConfig): void {\n const existing = state.services.get(name);\n state.services.set(name, { ...reg, context: existing?.context });\n }\n\n function startSdk(\n service: ServiceConfig,\n application: ApplicationConfig | undefined,\n enabled: boolean\n ): boolean {\n if (application && !enabled) {\n installDevConsole();\n }\n\n if (initialized) {\n if (application) {\n // eslint-disable-next-line no-console\n console.info(\n `[datadog-rum] init: application config from '${service.name}' ignored; the SDK is already started.`\n );\n }\n return false;\n }\n\n if (application) {\n offer ??= { service, application };\n }\n\n if (!offer || (!enabled && !isForceEnabled())) {\n return false;\n }\n\n const startedByOfferer = offer.service.name === service.name;\n if (application && !startedByOfferer) {\n // eslint-disable-next-line no-console\n console.info(\n `[datadog-rum] init: application config from '${service.name}' ignored; started the application offered by '${offer.service.name}'.`\n );\n }\n\n return initializeSdk({\n service: offer.service,\n application: offer.application,\n enabled,\n initializedBy: startedByOfferer ? undefined : service.name,\n });\n }\n\n return {\n init({ service, application, enabled = true }) {\n const initializedSdk = startSdk(service, application, enabled);\n registerService(service);\n\n return {\n cleanup: () => state.services.delete(service.name),\n initializedSdk,\n };\n },\n\n setServiceContext(key, context) {\n const existing = state.services.get(key);\n state.services.set(key, { ...existing, context });\n },\n };\n}\n"],"names":["datadogRum","buildAllowedTracingUrls","buildBeforeSend","installDdRumGuard","elementServiceRecorder","DATADOG_RUM_FOR_DEV","installDevConsole","isForceEnabled","DEFAULTS","sessionSampleRate","sessionReplaySampleRate","defaultPrivacyLevel","createImpl","initialized","offer","state","services","Map","initializeSdk","service","application","enabled","initializedBy","getInitConfiguration","console","warn","beforeSend","appBeforeSend","sdkConfigPart","applicationBeforeSend","init","name","allowedTracingUrls","setGlobalContextProperty","install","registerService","reg","existing","get","set","context","startSdk","info","startedByOfferer","undefined","initializedSdk","cleanup","delete","setServiceContext","key"],"mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,SAASC,uBAAuB,QAAQ,+BAA+B;AACvE,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,mBAAmB,EAAEC,iBAAiB,EAAEC,cAAc,QAAQ,qBAAqB;AAI5F,MAAMC,WAAW;IACbC,mBAAmB;IACnBC,yBAAyB;IACzBC,qBAAqB;AACzB;AAEA;;;;CAIC,GACD,OAAO,SAASC;IACZ,IAAIC,cAAc;IAClB,IAAIC;IACJ,MAAMC,QAAe;QACjBC,UAAU,IAAIC;IAClB;IAEA,SAASC,cAAc,EACnBC,OAAO,EACPC,WAAW,EACXC,OAAO,EACPC,aAAa,EAMhB;QACG,IAAItB,WAAWuB,oBAAoB,IAAI;YACnC,sCAAsC;YACtCC,QAAQC,IAAI,CACR;YAEJ,OAAO;QACX;QAEA,MAAM,EAAEC,YAAY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AClC,sCAAsC;YACtCnB,QAAQkB,IAAI,CACR,CAAC,6CAA6C,EAAEvB,QAAQY,IAAI,CAAC,+CAA+C,EAAEjB,MAAMK,OAAO,CAACY,IAAI,CAAC,EAAE,CAAC;QAE5I;QAEA,OAAOb,cAAc;YACjBC,SAASL,MAAMK,OAAO;YACtBC,aAAaN,MAAMM,WAAW;YAC9BC;YACAC,eAAeqB,mBAAmBC,YAAYzB,QAAQY,IAAI;QAC9D;IACJ;IAEA,OAAO;QACHD,MAAK,EAAEX,OAAO,EAAEC,WAAW,EAAEC,UAAU,IAAI,EAAE;YACzC,MAAMwB,iBAAiBJ,SAAStB,SAASC,aAAaC;YACtDc,gBAAgBhB;YAEhB,OAAO;gBACH2B,SAAS,IAAM/B,MAAMC,QAAQ,CAAC+B,MAAM,CAAC5B,QAAQY,IAAI;gBACjDc;YACJ;QACJ;QAEAG,mBAAkBC,GAAG,EAAET,OAAO;YAC1B,MAAMH,WAAWtB,MAAMC,QAAQ,CAACsB,GAAG,CAACW;YACpClC,MAAMC,QAAQ,CAACuB,GAAG,CAACU,KAAK;gBAAE,GAAGZ,QAAQ;gBAAEG;YAAQ;QACnD;IACJ;AACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ElementService } from './resolve-path-service';
|
|
2
|
+
export type { ElementService } from './resolve-path-service';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the MFE of each click at dispatch time. The browser empties `composedPath()`
|
|
5
|
+
* once dispatch ends, and the MFE can unmount before the RUM SDK runs `beforeSend`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createElementServiceRecorder(): {
|
|
8
|
+
install(): void;
|
|
9
|
+
/** Falls back to the retargeted target when the event was not recorded. */
|
|
10
|
+
serviceFor(event: Event): ElementService | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare const elementServiceRecorder: {
|
|
13
|
+
install(): void;
|
|
14
|
+
/** Falls back to the retargeted target when the event was not recorded. */
|
|
15
|
+
serviceFor(event: Event): ElementService | undefined;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=element-service-recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-service-recorder.d.ts","sourceRoot":"","sources":["../src/element-service-recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAsB,MAAM,wBAAwB,CAAC;AAEjF,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAa7D;;;GAGG;AACH,wBAAgB,4BAA4B;eAOzB,IAAI;IAQf,2EAA2E;sBACzD,KAAK,GAAG,cAAc,GAAG,SAAS;EAO3D;AAED,eAAO,MAAM,sBAAsB;eAlBhB,IAAI;IAQf,2EAA2E;sBACzD,KAAK,GAAG,cAAc,GAAG,SAAS;CASQ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { resolvePathService } from './resolve-path-service';
|
|
2
|
+
/** The SDK passes each click's `pointerup` as `context.events` (`@datadog/browser-rum` 6.19.0 to 7.15.0); re-check on an SDK upgrade. */ const RECORDED_EVENT = 'pointerup';
|
|
3
|
+
function ancestors(target) {
|
|
4
|
+
const path = [];
|
|
5
|
+
for(let node = target instanceof Element ? target : null; node; node = node.parentElement){
|
|
6
|
+
path.push(node);
|
|
7
|
+
}
|
|
8
|
+
return path;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves the MFE of each click at dispatch time. The browser empties `composedPath()`
|
|
12
|
+
* once dispatch ends, and the MFE can unmount before the RUM SDK runs `beforeSend`.
|
|
13
|
+
*/ export function createElementServiceRecorder() {
|
|
14
|
+
const recorded = new WeakMap();
|
|
15
|
+
let installed = false;
|
|
16
|
+
const record = (event)=>{
|
|
17
|
+
var _resolvePathService;
|
|
18
|
+
return recorded.set(event, (_resolvePathService = resolvePathService(event.composedPath())) !== null && _resolvePathService !== void 0 ? _resolvePathService : null);
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
install () {
|
|
22
|
+
if (installed) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
installed = true;
|
|
26
|
+
window.addEventListener(RECORDED_EVENT, record, {
|
|
27
|
+
capture: true,
|
|
28
|
+
passive: true
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
/** Falls back to the retargeted target when the event was not recorded. */ serviceFor (event) {
|
|
32
|
+
const hit = recorded.get(event);
|
|
33
|
+
return hit !== undefined ? hit !== null && hit !== void 0 ? hit : undefined : resolvePathService(ancestors(event.target));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export const elementServiceRecorder = createElementServiceRecorder();
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=element-service-recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/element-service-recorder.ts"],"sourcesContent":["import { type ElementService, resolvePathService } from './resolve-path-service';\n\nexport type { ElementService } from './resolve-path-service';\n\n/** The SDK passes each click's `pointerup` as `context.events` (`@datadog/browser-rum` 6.19.0 to 7.15.0); re-check on an SDK upgrade. */\nconst RECORDED_EVENT = 'pointerup';\n\nfunction ancestors(target: EventTarget | null): Element[] {\n const path: Element[] = [];\n for (let node = target instanceof Element ? target : null; node; node = node.parentElement) {\n path.push(node);\n }\n return path;\n}\n\n/**\n * Resolves the MFE of each click at dispatch time. The browser empties `composedPath()`\n * once dispatch ends, and the MFE can unmount before the RUM SDK runs `beforeSend`.\n */\nexport function createElementServiceRecorder() {\n const recorded = new WeakMap<Event, ElementService | null>();\n let installed = false;\n const record = (event: Event) =>\n recorded.set(event, resolvePathService(event.composedPath()) ?? null);\n\n return {\n install(): void {\n if (installed) {\n return;\n }\n installed = true;\n window.addEventListener(RECORDED_EVENT, record, { capture: true, passive: true });\n },\n\n /** Falls back to the retargeted target when the event was not recorded. */\n serviceFor(event: Event): ElementService | undefined {\n const hit = recorded.get(event);\n return hit !== undefined\n ? (hit ?? undefined)\n : resolvePathService(ancestors(event.target));\n },\n };\n}\n\nexport const elementServiceRecorder = createElementServiceRecorder();\n"],"names":["resolvePathService","RECORDED_EVENT","ancestors","target","path","node","Element","parentElement","push","createElementServiceRecorder","recorded","WeakMap","installed","record","event","set","composedPath","install","window","addEventListener","capture","passive","serviceFor","hit","get","undefined","elementServiceRecorder"],"mappings":"AAAA,SAA8BA,kBAAkB,QAAQ,yBAAyB;AAIjF,uIAAuI,GACvI,MAAMC,iBAAiB;AAEvB,SAASC,UAAUC,MAA0B;IACzC,MAAMC,OAAkB,EAAE;IAC1B,IAAK,IAAIC,OAAOF,kBAAkBG,UAAUH,SAAS,MAAME,MAAMA,OAAOA,KAAKE,aAAa,CAAE;QACxFH,KAAKI,IAAI,CAACH;IACd;IACA,OAAOD;AACX;AAEA;;;CAGC,GACD,OAAO,SAASK;IACZ,MAAMC,WAAW,IAAIC;IACrB,IAAIC,YAAY;IAChB,MAAMC,SAAS,CAACC;YACQd;eAApBU,SAASK,GAAG,CAACD,QAAOd,sBAAAA,mBAAmBc,MAAME,YAAY,iBAArChB,iCAAAA,sBAA4C;;IAEpE,OAAO;QACHiB;YACI,IAAIL,WAAW;gBACX;YACJ;YACAA,YAAY;YACZM,OAAOC,gBAAgB,CAAClB,gBAAgBY,QAAQ;gBAAEO,SAAS;gBAAMC,SAAS;YAAK;QACnF;QAEA,yEAAyE,GACzEC,YAAWR,KAAY;YACnB,MAAMS,MAAMb,SAASc,GAAG,CAACV;YACzB,OAAOS,QAAQE,YACRF,gBAAAA,iBAAAA,MAAOE,YACRzB,mBAAmBE,UAAUY,MAAMX,MAAM;QACnD;IACJ;AACJ;AAEA,OAAO,MAAMuB,yBAAyBjB,+BAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrich-event.d.ts","sourceRoot":"","sources":["../src/enrich-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"enrich-event.d.ts","sourceRoot":"","sources":["../src/enrich-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,qBAAqB,EAAoB,MAAM,sBAAsB,CAAC;AAuE9F;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAWjF"}
|
package/dist/enrich-event.js
CHANGED
|
@@ -1,33 +1,94 @@
|
|
|
1
|
+
import { elementServiceRecorder } from './element-service-recorder';
|
|
1
2
|
const SERVICE_REGEX = /unpkg\.servicetitan\.com\/@servicetitan\/(?<service>[\w-]+)(?:@(?<version>\d+\.\d+\.\d+(?:-[\w.-]+)?))?/;
|
|
3
|
+
function matchService(input) {
|
|
4
|
+
var _groups_version;
|
|
5
|
+
var _SERVICE_REGEX_exec;
|
|
6
|
+
const groups = input ? (_SERVICE_REGEX_exec = SERVICE_REGEX.exec(input)) === null || _SERVICE_REGEX_exec === void 0 ? void 0 : _SERVICE_REGEX_exec.groups : undefined;
|
|
7
|
+
return (groups === null || groups === void 0 ? void 0 : groups.service) ? {
|
|
8
|
+
service: groups.service,
|
|
9
|
+
version: (_groups_version = groups.version) !== null && _groups_version !== void 0 ? _groups_version : 'unknown'
|
|
10
|
+
} : undefined;
|
|
11
|
+
}
|
|
2
12
|
function parseService(event, input) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
const match = matchService(input);
|
|
14
|
+
if (match) {
|
|
15
|
+
event.service = match.service;
|
|
16
|
+
event.version = match.version;
|
|
17
|
+
}
|
|
18
|
+
return !!match;
|
|
19
|
+
}
|
|
20
|
+
function attributionSources(event, context) {
|
|
21
|
+
const handlingStack = context && 'handlingStack' in context ? context.handlingStack : undefined;
|
|
22
|
+
switch(event.type){
|
|
23
|
+
case 'error':
|
|
24
|
+
return event.error.stack ? [
|
|
25
|
+
event.error.stack,
|
|
26
|
+
event.error.message
|
|
27
|
+
] : [
|
|
28
|
+
handlingStack,
|
|
29
|
+
event.error.message
|
|
30
|
+
];
|
|
31
|
+
case 'resource':
|
|
32
|
+
return [
|
|
33
|
+
handlingStack,
|
|
34
|
+
event.resource.url
|
|
35
|
+
];
|
|
36
|
+
default:
|
|
37
|
+
return [
|
|
38
|
+
handlingStack
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Writes every MFE that ran a script to `context.loafServices`, and returns the source URL of the
|
|
44
|
+
* longest script, which names the frame's service. Legacy long tasks have no `scripts`.
|
|
45
|
+
*/ function tagLoafServices(event) {
|
|
46
|
+
var _event_long_task_scripts;
|
|
47
|
+
const services = new Set();
|
|
48
|
+
let longest;
|
|
49
|
+
for (const script of (_event_long_task_scripts = event.long_task.scripts) !== null && _event_long_task_scripts !== void 0 ? _event_long_task_scripts : []){
|
|
50
|
+
var _script_duration, _longest_duration;
|
|
51
|
+
const match = matchService(script.source_url);
|
|
52
|
+
if (match) {
|
|
53
|
+
services.add(match.service);
|
|
54
|
+
}
|
|
55
|
+
if (!longest || ((_script_duration = script.duration) !== null && _script_duration !== void 0 ? _script_duration : 0) > ((_longest_duration = longest.duration) !== null && _longest_duration !== void 0 ? _longest_duration : 0)) {
|
|
56
|
+
longest = script;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (services.size) {
|
|
60
|
+
event.context = {
|
|
61
|
+
...event.context,
|
|
62
|
+
loafServices: [
|
|
63
|
+
...services
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return longest === null || longest === void 0 ? void 0 : longest.source_url;
|
|
68
|
+
}
|
|
69
|
+
function applyElementService(event, context) {
|
|
70
|
+
var _context_events;
|
|
71
|
+
const domEvent = context && 'events' in context ? (_context_events = context.events) === null || _context_events === void 0 ? void 0 : _context_events[0] : undefined;
|
|
72
|
+
const result = domEvent && elementServiceRecorder.serviceFor(domEvent);
|
|
73
|
+
if (result) {
|
|
74
|
+
event.service = result.service;
|
|
75
|
+
event.version = result.version;
|
|
11
76
|
}
|
|
12
|
-
return false;
|
|
13
77
|
}
|
|
14
78
|
/**
|
|
15
79
|
* See https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#micro-frontend
|
|
16
80
|
*/ export function enrichEvent(event, context) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const url = event.type === 'resource' ? (_event_resource = event.resource) === null || _event_resource === void 0 ? void 0 : _event_resource.url : undefined;
|
|
22
|
-
for (const source of [
|
|
23
|
-
stack,
|
|
24
|
-
message,
|
|
25
|
-
url
|
|
26
|
-
]){
|
|
81
|
+
const sources = event.type === 'long_task' ? [
|
|
82
|
+
tagLoafServices(event)
|
|
83
|
+
] : attributionSources(event, context);
|
|
84
|
+
for (const source of sources){
|
|
27
85
|
if (parseService(event, source)) {
|
|
28
|
-
|
|
86
|
+
return;
|
|
29
87
|
}
|
|
30
88
|
}
|
|
89
|
+
if (event.type === 'action') {
|
|
90
|
+
applyElementService(event, context);
|
|
91
|
+
}
|
|
31
92
|
}
|
|
32
93
|
|
|
33
94
|
//# sourceMappingURL=enrich-event.js.map
|
package/dist/enrich-event.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/enrich-event.ts"],"sourcesContent":["import type { RumEvent, RumEventDomainContext } from '@datadog/browser-rum';\n\nconst SERVICE_REGEX =\n /unpkg\\.servicetitan\\.com\\/@servicetitan\\/(?<service>[\\w-]+)(?:@(?<version>\\d+\\.\\d+\\.\\d+(?:-[\\w.-]+)?))?/;\n\nfunction
|
|
1
|
+
{"version":3,"sources":["../src/enrich-event.ts"],"sourcesContent":["import type { RumEvent, RumEventDomainContext, RumLongTaskEvent } from '@datadog/browser-rum';\nimport { elementServiceRecorder } from './element-service-recorder';\n\nconst SERVICE_REGEX =\n /unpkg\\.servicetitan\\.com\\/@servicetitan\\/(?<service>[\\w-]+)(?:@(?<version>\\d+\\.\\d+\\.\\d+(?:-[\\w.-]+)?))?/;\n\nfunction matchService(input: string | undefined): { service: string; version: string } | undefined {\n const groups = input ? SERVICE_REGEX.exec(input)?.groups : undefined;\n return groups?.service\n ? { service: groups.service, version: groups.version ?? 'unknown' }\n : undefined;\n}\n\nfunction parseService(event: RumEvent, input: string | undefined) {\n const match = matchService(input);\n if (match) {\n event.service = match.service;\n event.version = match.version;\n }\n return !!match;\n}\n\nfunction attributionSources(\n event: RumEvent,\n context: RumEventDomainContext\n): (string | undefined)[] {\n const handlingStack = context && 'handlingStack' in context ? context.handlingStack : undefined;\n\n switch (event.type) {\n case 'error':\n return event.error.stack\n ? [event.error.stack, event.error.message]\n : [handlingStack, event.error.message];\n case 'resource':\n return [handlingStack, event.resource.url];\n default:\n return [handlingStack];\n }\n}\n\n/**\n * Writes every MFE that ran a script to `context.loafServices`, and returns the source URL of the\n * longest script, which names the frame's service. Legacy long tasks have no `scripts`.\n */\nfunction tagLoafServices(event: RumLongTaskEvent): string | undefined {\n const services = new Set<string>();\n let longest: NonNullable<RumLongTaskEvent['long_task']['scripts']>[number] | undefined;\n for (const script of event.long_task.scripts ?? []) {\n const match = matchService(script.source_url);\n if (match) {\n services.add(match.service);\n }\n if (!longest || (script.duration ?? 0) > (longest.duration ?? 0)) {\n longest = script;\n }\n }\n if (services.size) {\n event.context = { ...event.context, loafServices: [...services] };\n }\n return longest?.source_url;\n}\n\nfunction applyElementService(event: RumEvent, context: RumEventDomainContext): void {\n const domEvent = context && 'events' in context ? context.events?.[0] : undefined;\n const result = domEvent && elementServiceRecorder.serviceFor(domEvent);\n if (result) {\n event.service = result.service;\n event.version = result.version;\n }\n}\n\n/**\n * See https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#micro-frontend\n */\nexport function enrichEvent(event: RumEvent, context: RumEventDomainContext): void {\n const sources =\n event.type === 'long_task' ? [tagLoafServices(event)] : attributionSources(event, context);\n for (const source of sources) {\n if (parseService(event, source)) {\n return;\n }\n }\n if (event.type === 'action') {\n applyElementService(event, context);\n }\n}\n"],"names":["elementServiceRecorder","SERVICE_REGEX","matchService","input","groups","exec","undefined","service","version","parseService","event","match","attributionSources","context","handlingStack","type","error","stack","message","resource","url","tagLoafServices","services","Set","longest","script","long_task","scripts","source_url","add","duration","size","loafServices","applyElementService","domEvent","events","result","serviceFor","enrichEvent","sources","source"],"mappings":"AACA,SAASA,sBAAsB,QAAQ,6BAA6B;AAEpE,MAAMC,gBACF;AAEJ,SAASC,aAAaC,KAAyB;QAGDC;QAFnBH;IAAvB,MAAMG,SAASD,SAAQF,sBAAAA,cAAcI,IAAI,CAACF,oBAAnBF,0CAAAA,oBAA2BG,MAAM,GAAGE;IAC3D,OAAOF,CAAAA,mBAAAA,6BAAAA,OAAQG,OAAO,IAChB;QAAEA,SAASH,OAAOG,OAAO;QAAEC,OAAO,GAAEJ,kBAAAA,OAAOI,OAAO,cAAdJ,6BAAAA,kBAAkB;IAAU,IAChEE;AACV;AAEA,SAASG,aAAaC,KAAe,EAAEP,KAAyB;IAC5D,MAAMQ,QAAQT,aAAaC;IAC3B,IAAIQ,OAAO;QACPD,MAAMH,OAAO,GAAGI,MAAMJ,OAAO;QAC7BG,MAAMF,OAAO,GAAGG,MAAMH,OAAO;IACjC;IACA,OAAO,CAAC,CAACG;AACb;AAEA,SAASC,mBACLF,KAAe,EACfG,OAA8B;IAE9B,MAAMC,gBAAgBD,WAAW,mBAAmBA,UAAUA,QAAQC,aAAa,GAAGR;IAEtF,OAAQI,MAAMK,IAAI;QACd,KAAK;YACD,OAAOL,MAAMM,KAAK,CAACC,KAAK,GAClB;gBAACP,MAAMM,KAAK,CAACC,KAAK;gBAAEP,MAAMM,KAAK,CAACE,OAAO;aAAC,GACxC;gBAACJ;gBAAeJ,MAAMM,KAAK,CAACE,OAAO;aAAC;QAC9C,KAAK;YACD,OAAO;gBAACJ;gBAAeJ,MAAMS,QAAQ,C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UD,QAAS;QAC1B,IAAI9B,aAAaC,OAAO8B,SAAS;YAC7B;QACJ;IACJ;IACA,IAAI9B,MAAMK,IAAI,KAAK,UAAU;QACzBkB,oBAAoBvB,OAAOG;IAC/B;AACJ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ElementService {
|
|
2
|
+
service: string;
|
|
3
|
+
version: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Returns the service of the innermost MFE element on `path`.
|
|
7
|
+
* `data-mfe-name` holds the element name (`servicetitan-task-hub`); the service is the
|
|
8
|
+
* unscoped package name (`task-hub`), the same value parsed from unpkg URLs.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolvePathService(path: EventTarget[]): ElementService | undefined;
|
|
11
|
+
//# sourceMappingURL=resolve-path-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-path-service.d.ts","sourceRoot":"","sources":["../src/resolve-path-service.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACnB;AA0DD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,cAAc,GAAG,SAAS,CAUlF"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const NAME_ATTRIBUTE = 'data-mfe-name';
|
|
2
|
+
const PORTAL_NAME_ATTRIBUTE = 'data-mfe-portal-name';
|
|
3
|
+
const VERSION_ATTRIBUTE = 'data-mfe-version';
|
|
4
|
+
const ELEMENT_NAME_PREFIX = /^servicetitan-/;
|
|
5
|
+
const UNKNOWN_VERSION = 'unknown';
|
|
6
|
+
const portalServices = new WeakMap();
|
|
7
|
+
function toService(name, version) {
|
|
8
|
+
return {
|
|
9
|
+
service: name.replace(ELEMENT_NAME_PREFIX, ''),
|
|
10
|
+
version: version !== null && version !== void 0 ? version : UNKNOWN_VERSION
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Finds the host that owns `portal`. Builds of one MFE share a name, so the `portal` field
|
|
15
|
+
* identifies the owner; the name is a fallback for builds that do not keep that field.
|
|
16
|
+
*/ function findHost(portal, name) {
|
|
17
|
+
let byName;
|
|
18
|
+
const roots = [
|
|
19
|
+
document
|
|
20
|
+
];
|
|
21
|
+
for (const root of roots){
|
|
22
|
+
for (const element of root.querySelectorAll('*')){
|
|
23
|
+
if (portal.shadowRoot && element.portal === portal.shadowRoot) {
|
|
24
|
+
return element;
|
|
25
|
+
}
|
|
26
|
+
if (!byName && element.getAttribute(NAME_ATTRIBUTE) === name) {
|
|
27
|
+
byName = element;
|
|
28
|
+
}
|
|
29
|
+
if (element.shadowRoot) {
|
|
30
|
+
roots.push(element.shadowRoot);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return byName;
|
|
35
|
+
}
|
|
36
|
+
/** Caches a portal's service. */ function toPortalService(portal, name) {
|
|
37
|
+
const cached = portalServices.get(portal);
|
|
38
|
+
if (cached) {
|
|
39
|
+
return cached;
|
|
40
|
+
}
|
|
41
|
+
const ownVersion = portal.getAttribute(VERSION_ATTRIBUTE);
|
|
42
|
+
const host = ownVersion ? undefined : findHost(portal, name);
|
|
43
|
+
const result = toService(name, ownVersion !== null && ownVersion !== void 0 ? ownVersion : host === null || host === void 0 ? void 0 : host.getAttribute(VERSION_ATTRIBUTE));
|
|
44
|
+
portalServices.set(portal, result);
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
function toElementService(element) {
|
|
48
|
+
const hostName = element.getAttribute(NAME_ATTRIBUTE);
|
|
49
|
+
if (hostName) {
|
|
50
|
+
return toService(hostName, element.getAttribute(VERSION_ATTRIBUTE));
|
|
51
|
+
}
|
|
52
|
+
const portalName = element.getAttribute(PORTAL_NAME_ATTRIBUTE);
|
|
53
|
+
return portalName ? toPortalService(element, portalName) : undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the service of the innermost MFE element on `path`.
|
|
57
|
+
* `data-mfe-name` holds the element name (`servicetitan-task-hub`); the service is the
|
|
58
|
+
* unscoped package name (`task-hub`), the same value parsed from unpkg URLs.
|
|
59
|
+
*/ export function resolvePathService(path) {
|
|
60
|
+
for (const target of path){
|
|
61
|
+
if (target instanceof Element) {
|
|
62
|
+
const result = toElementService(target);
|
|
63
|
+
if (result) {
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=resolve-path-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resolve-path-service.ts"],"sourcesContent":["const NAME_ATTRIBUTE = 'data-mfe-name';\nconst PORTAL_NAME_ATTRIBUTE = 'data-mfe-portal-name';\nconst VERSION_ATTRIBUTE = 'data-mfe-version';\nconst ELEMENT_NAME_PREFIX = /^servicetitan-/;\nconst UNKNOWN_VERSION = 'unknown';\n\nexport interface ElementService {\n service: string;\n version: string;\n}\n\n/** The `portal` field that `@servicetitan/web-components` keeps on each MFE element. */\ninterface MfeHostElement extends Element {\n portal?: ShadowRoot;\n}\n\nconst portalServices = new WeakMap<Element, ElementService>();\n\nfunction toService(name: string, version: string | null | undefined): ElementService {\n return { service: name.replace(ELEMENT_NAME_PREFIX, ''), version: version ?? UNKNOWN_VERSION };\n}\n\n/**\n * Finds the host that owns `portal`. Builds of one MFE share a name, so the `portal` field\n * identifies the owner; the name is a fallback for builds that do not keep that field.\n */\nfunction findHost(portal: Element, name: string): Element | undefined {\n let byName: Element | undefined;\n const roots: (Document | ShadowRoot)[] = [document];\n for (const root of roots) {\n for (const element of root.querySelectorAll('*')) {\n if (portal.shadowRoot && (element as MfeHostElement).portal === portal.shadowRoot) {\n return element;\n }\n if (!byName && element.getAttribute(NAME_ATTRIBUTE) === name) {\n byName = element;\n }\n if (element.shadowRoot) {\n roots.push(element.shadowRoot);\n }\n }\n }\n return byName;\n}\n\n/** Caches a portal's service. */\nfunction toPortalService(portal: Element, name: string): ElementService {\n const cached = portalServices.get(portal);\n if (cached) {\n return cached;\n }\n const ownVersion = portal.getAttribute(VERSION_ATTRIBUTE);\n const host = ownVersion ? undefined : findHost(portal, name);\n const result = toService(name, ownVersion ?? host?.getAttribute(VERSION_ATTRIBUTE));\n portalServices.set(portal, result);\n return result;\n}\n\nfunction toElementService(element: Element): ElementService | undefined {\n const hostName = element.getAttribute(NAME_ATTRIBUTE);\n if (hostName) {\n return toService(hostName, element.getAttribute(VERSION_ATTRIBUTE));\n }\n const portalName = element.getAttribute(PORTAL_NAME_ATTRIBUTE);\n return portalName ? toPortalService(element, portalName) : undefined;\n}\n\n/**\n * Returns the service of the innermost MFE element on `path`.\n * `data-mfe-name` holds the element name (`servicetitan-task-hub`); the service is the\n * unscoped package name (`task-hub`), the same value parsed from unpkg URLs.\n */\nexport function resolvePathService(path: EventTarget[]): ElementService | undefined {\n for (const target of path) {\n if (target instanceof Element) {\n const result = toElementService(target);\n if (result) {\n return result;\n }\n }\n }\n return undefined;\n}\n"],"names":["NAME_ATTRIBUTE","PORTAL_NAME_ATTRIBUTE","VERSION_ATTRIBUTE","ELEMENT_NAME_PREFIX","UNKNOWN_VERSION","portalServices","WeakMap","toService","name","version","service","replace","findHost","portal","byName","roots","document","root","element","querySelectorAll","shadowRoot","getAttribute","push","toPortalService","cached","get","ownVersion","host","undefined","result","set","toElementService","hostName","portalName","resolvePathService","path","target","Element"],"mappings":"AAAA,MAAMA,iBAAiB;AACvB,MAAMC,wBAAwB;AAC9B,MAAMC,oBAAoB;AAC1B,MAAMC,sBAAsB;AAC5B,MAAMC,kBAAkB;AAYxB,MAAMC,iBAAiB,IAAIC;AAE3B,SAASC,UAAUC,IAAY,EAAEC,OAAkC;IAC/D,OAAO;QAAEC,SAASF,KAAKG,OAAO,CAACR,qBAAqB;Q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M;QACvB,IAAIC,kBAAkBC,SAAS;YAC3B,MAAMR,SAASE,iBAAiBK;YAChC,IAAIP,QAAQ;gBACR,OAAOA;YACX;QACJ;IACJ;IACA,OAAOD;AACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/datadog-rum",
|
|
3
|
-
"version": "40.
|
|
3
|
+
"version": "40.2.0",
|
|
4
4
|
"description": "DataDog RUM JS SDK configuration for standalone applications",
|
|
5
5
|
"homepage": "https://docs.st.dev/docs/frontend/uikit/datadog-rum",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"src"
|
|
23
23
|
],
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@datadog/browser-rum": "^7.
|
|
25
|
+
"@datadog/browser-rum": "^7.15.0",
|
|
26
26
|
"@testing-library/dom": "^10.4.2",
|
|
27
27
|
"@testing-library/jest-dom": "^7.0.1",
|
|
28
28
|
"@testing-library/react": "^16.3.3",
|