@servicetitan/datadog-rum 36.3.1 → 37.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/before-send.d.ts +11 -1
- package/dist/before-send.d.ts.map +1 -1
- package/dist/before-send.js +2 -56
- package/dist/before-send.js.map +1 -1
- package/dist/build-allowed-tracing-urls.d.ts +9 -0
- package/dist/build-allowed-tracing-urls.d.ts.map +1 -0
- package/dist/build-allowed-tracing-urls.js +54 -0
- package/dist/build-allowed-tracing-urls.js.map +1 -0
- package/dist/build-before-send.d.ts +4 -0
- package/dist/build-before-send.d.ts.map +1 -0
- package/dist/build-before-send.js +64 -0
- package/dist/build-before-send.js.map +1 -0
- package/dist/bundle-state.d.ts +10 -0
- package/dist/bundle-state.d.ts.map +1 -0
- package/dist/bundle-state.js +10 -0
- package/dist/bundle-state.js.map +1 -0
- package/dist/create-impl.d.ts +8 -0
- package/dist/create-impl.d.ts.map +1 -0
- package/dist/create-impl.js +81 -0
- package/dist/create-impl.js.map +1 -0
- package/dist/datadog-provider.d.ts +2 -5
- package/dist/datadog-provider.d.ts.map +1 -1
- package/dist/datadog-provider.js +2 -2
- package/dist/datadog-provider.js.map +1 -1
- package/dist/enrich-event.d.ts +6 -0
- package/dist/enrich-event.d.ts.map +1 -0
- package/dist/enrich-event.js +33 -0
- package/dist/enrich-event.js.map +1 -0
- package/dist/get-shared.d.ts +10 -0
- package/dist/get-shared.d.ts.map +1 -0
- package/dist/get-shared.js +16 -0
- package/dist/get-shared.js.map +1 -0
- package/dist/handle-resource.d.ts +3 -0
- package/dist/handle-resource.d.ts.map +1 -0
- package/dist/handle-resource.js +27 -0
- package/dist/handle-resource.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +17 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +28 -0
- package/dist/init.js.map +1 -0
- package/dist/runtime-override/constants.d.ts +2 -0
- package/dist/runtime-override/constants.d.ts.map +1 -0
- package/dist/runtime-override/constants.js +3 -0
- package/dist/runtime-override/constants.js.map +1 -0
- package/dist/runtime-override/dev-console.d.ts +12 -0
- package/dist/runtime-override/dev-console.d.ts.map +1 -0
- package/dist/runtime-override/dev-console.js +40 -0
- package/dist/runtime-override/dev-console.js.map +1 -0
- package/dist/runtime-override/index.d.ts +4 -0
- package/dist/runtime-override/index.d.ts.map +1 -0
- package/dist/runtime-override/index.js +5 -0
- package/dist/runtime-override/index.js.map +1 -0
- package/dist/runtime-override/override.d.ts +4 -0
- package/dist/runtime-override/override.d.ts.map +1 -0
- package/dist/runtime-override/override.js +35 -0
- package/dist/runtime-override/override.js.map +1 -0
- package/dist/set-user.d.ts +13 -0
- package/dist/set-user.d.ts.map +1 -0
- package/dist/set-user.js +22 -0
- package/dist/set-user.js.map +1 -0
- package/dist/shared-impl.d.ts +11 -0
- package/dist/shared-impl.d.ts.map +1 -0
- package/dist/shared-impl.js +3 -0
- package/dist/shared-impl.js.map +1 -0
- package/dist/types.d.ts +51 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/use-rum-service.d.ts +12 -0
- package/dist/use-rum-service.d.ts.map +1 -0
- package/dist/use-rum-service.js +25 -0
- package/dist/use-rum-service.js.map +1 -0
- package/package.json +3 -3
- package/src/__mocks__/index.ts +6 -0
- package/src/__mocks__/init-config.ts +6 -0
- package/src/__mocks__/process-event.ts +20 -0
- package/src/__mocks__/reset-shared-impl.ts +8 -0
- package/src/__mocks__/tracing-urls.ts +30 -0
- package/src/__mocks__/types.ts +1 -0
- package/src/__tests__/before-send.test.ts +39 -87
- package/src/__tests__/build-allowed-tracing-urls.test.ts +120 -0
- package/src/__tests__/build-before-send.test.ts +193 -0
- package/src/__tests__/create-impl.test.ts +293 -0
- package/src/__tests__/datadog-provider.test.tsx +55 -25
- package/src/__tests__/enrich-event.test.ts +34 -0
- package/src/__tests__/get-shared.test.ts +56 -0
- package/src/__tests__/handle-resource.test.ts +76 -0
- package/src/__tests__/init.test.ts +69 -0
- package/src/__tests__/integration.test.ts +147 -0
- package/src/__tests__/set-user.test.ts +61 -0
- package/src/__tests__/use-rum-service.test.tsx +82 -0
- package/src/before-send.ts +13 -60
- package/src/build-allowed-tracing-urls.ts +53 -0
- package/src/build-before-send.ts +81 -0
- package/src/bundle-state.ts +9 -0
- package/src/create-impl.ts +94 -0
- package/src/datadog-provider.tsx +4 -6
- package/src/enrich-event.ts +38 -0
- package/src/get-shared.ts +24 -0
- package/src/handle-resource.ts +30 -0
- package/src/index.ts +3 -0
- package/src/init.ts +39 -0
- package/src/runtime-override/__tests__/dev-console.test.ts +158 -0
- package/src/runtime-override/__tests__/override.test.ts +109 -0
- package/src/runtime-override/constants.ts +1 -0
- package/src/runtime-override/dev-console.ts +56 -0
- package/src/runtime-override/index.ts +3 -0
- package/src/runtime-override/override.ts +41 -0
- package/src/set-user.ts +25 -0
- package/src/shared-impl.ts +9 -0
- package/src/types.ts +62 -0
- package/src/use-rum-service.ts +28 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './before-send';\nexport * from './datadog-provider';\n"],"names":[],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './before-send';\nexport * from './datadog-provider';\nexport * from './init';\nexport * from './set-user';\nexport * from './use-rum-service';\n"],"names":[],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,oBAAoB"}
|
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { InitRumOptions, RumServiceRegistration } from './types';
|
|
2
|
+
export type { ApplicationConfig, Cleanup, InitRumOptions, RumService, RumServiceRegistration, ServiceConfig, ServiceTracingUrls, } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Registers a service and, optionally, initializes the Datadog RUM SDK.
|
|
5
|
+
*
|
|
6
|
+
* Any caller may pass `application`. The first call that includes it
|
|
7
|
+
* initializes the SDK; subsequent callers' `application` config is ignored
|
|
8
|
+
* with a warning. Callers that omit `application` register their service
|
|
9
|
+
* without attempting SDK init.
|
|
10
|
+
*
|
|
11
|
+
* Returns a `RumServiceRegistration` — `{ cleanup, setServiceContext }`.
|
|
12
|
+
* `cleanup` removes this service's `beforeSend`, `allowedTracingUrls`, and
|
|
13
|
+
* persistent context. `setServiceContext` attaches session-lifetime metadata
|
|
14
|
+
* to every event whose `event.service` matches this service's name.
|
|
15
|
+
*/
|
|
16
|
+
export declare function init(opts: InitRumOptions): RumServiceRegistration;
|
|
17
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtE,YAAY,EACR,iBAAiB,EACjB,OAAO,EACP,cAAc,EACd,UAAU,EACV,sBAAsB,EACtB,aAAa,EACb,kBAAkB,GACrB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,sBAAsB,CAWjE"}
|
package/dist/init.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { bundleState } from './bundle-state';
|
|
2
|
+
import { getOrCreateSharedImpl } from './get-shared';
|
|
3
|
+
/**
|
|
4
|
+
* Registers a service and, optionally, initializes the Datadog RUM SDK.
|
|
5
|
+
*
|
|
6
|
+
* Any caller may pass `application`. The first call that includes it
|
|
7
|
+
* initializes the SDK; subsequent callers' `application` config is ignored
|
|
8
|
+
* with a warning. Callers that omit `application` register their service
|
|
9
|
+
* without attempting SDK init.
|
|
10
|
+
*
|
|
11
|
+
* Returns a `RumServiceRegistration` — `{ cleanup, setServiceContext }`.
|
|
12
|
+
* `cleanup` removes this service's `beforeSend`, `allowedTracingUrls`, and
|
|
13
|
+
* persistent context. `setServiceContext` attaches session-lifetime metadata
|
|
14
|
+
* to every event whose `event.service` matches this service's name.
|
|
15
|
+
*/ export function init(opts) {
|
|
16
|
+
const impl = getOrCreateSharedImpl();
|
|
17
|
+
const result = impl.init(opts);
|
|
18
|
+
if (result.initializedSdk) {
|
|
19
|
+
bundleState.isSdkInitializer = true;
|
|
20
|
+
}
|
|
21
|
+
const { name } = opts.service;
|
|
22
|
+
return {
|
|
23
|
+
cleanup: result.cleanup,
|
|
24
|
+
setServiceContext: (context)=>impl.setServiceContext(name, context)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/init.ts"],"sourcesContent":["import { bundleState } from './bundle-state';\nimport { getOrCreateSharedImpl } from './get-shared';\nimport type { InitRumOptions, RumServiceRegistration } from './types';\n\nexport type {\n ApplicationConfig,\n Cleanup,\n InitRumOptions,\n RumService,\n RumServiceRegistration,\n ServiceConfig,\n ServiceTracingUrls,\n} from './types';\n\n/**\n * Registers a service and, optionally, initializes the Datadog RUM SDK.\n *\n * Any caller may pass `application`. The first call that includes it\n * initializes the SDK; subsequent callers' `application` config is ignored\n * with a warning. Callers that omit `application` register their service\n * without attempting SDK init.\n *\n * Returns a `RumServiceRegistration` — `{ cleanup, setServiceContext }`.\n * `cleanup` removes this service's `beforeSend`, `allowedTracingUrls`, and\n * persistent context. `setServiceContext` attaches session-lifetime metadata\n * to every event whose `event.service` matches this service's name.\n */\nexport function init(opts: InitRumOptions): RumServiceRegistration {\n const impl = getOrCreateSharedImpl();\n const result = impl.init(opts);\n if (result.initializedSdk) {\n bundleState.isSdkInitializer = true;\n }\n const { name } = opts.service;\n return {\n cleanup: result.cleanup,\n setServiceContext: context => impl.setServiceContext(name, context),\n };\n}\n"],"names":["bundleState","getOrCreateSharedImpl","init","opts","impl","result","initializedSdk","isSdkInitializer","name","service","cleanup","setServiceContext","context"],"mappings":"AAAA,SAASA,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,qBAAqB,QAAQ,eAAe;AAarD;;;;;;;;;;;;CAYC,GACD,OAAO,SAASC,KAAKC,IAAoB;IACrC,MAAMC,OAAOH;IACb,MAAMI,SAASD,KAAKF,IAAI,CAACC;IACzB,IAAIE,OAAOC,cAAc,EAAE;QACvBN,YAAYO,gBAAgB,GAAG;IACnC;IACA,MAAM,EAAEC,IAAI,EAAE,GAAGL,KAAKM,OAAO;IAC7B,OAAO;QACHC,SAASL,OAAOK,OAAO;QACvBC,mBAAmBC,CAAAA,UAAWR,KAAKO,iBAAiB,CAACH,MAAMI;IAC/D;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/runtime-override/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-override/constants.ts"],"sourcesContent":["export const DATADOG_RUM_FOR_DEV = 'datadogRumForDev';\n"],"names":["DATADOG_RUM_FOR_DEV"],"mappings":"AAAA,OAAO,MAAMA,sBAAsB,mBAAmB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface DevConsole {
|
|
2
|
+
start: () => void;
|
|
3
|
+
stop: () => void;
|
|
4
|
+
}
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
datadogRumForDev?: DevConsole;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare function installDevConsole(): void;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=dev-console.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-console.d.ts","sourceRoot":"","sources":["../../src/runtime-override/dev-console.ts"],"names":[],"mappings":"AAIA,UAAU,UAAU;IAChB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;CACpB;AAMD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,gBAAgB,CAAC,EAAE,UAAU,CAAC;KACjC;CACJ;AA0BD,wBAAgB,iBAAiB,IAAI,IAAI,CAYxC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { datadogRum } from '@datadog/browser-rum';
|
|
2
|
+
import { DATADOG_RUM_FOR_DEV } from './constants';
|
|
3
|
+
import { clearOverride, enableOverride } from './override';
|
|
4
|
+
/* istanbul ignore next: thin seam over location.reload, which jsdom does not implement */ function reloadPage() {
|
|
5
|
+
globalThis.location.reload();
|
|
6
|
+
}
|
|
7
|
+
function start() {
|
|
8
|
+
enableOverride();
|
|
9
|
+
// eslint-disable-next-line no-console
|
|
10
|
+
console.info(`[datadog-rum] ${DATADOG_RUM_FOR_DEV}.start(): RUM enabled for 12h; reloading.`);
|
|
11
|
+
reloadPage();
|
|
12
|
+
}
|
|
13
|
+
function stop() {
|
|
14
|
+
try {
|
|
15
|
+
datadogRum.stopSession();
|
|
16
|
+
} catch (unused) {
|
|
17
|
+
// ignore: SDK may not be initialized
|
|
18
|
+
}
|
|
19
|
+
clearOverride();
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.info(`[datadog-rum] ${DATADOG_RUM_FOR_DEV}.stop(): override cleared; reloading.`);
|
|
22
|
+
reloadPage();
|
|
23
|
+
}
|
|
24
|
+
export function installDevConsole() {
|
|
25
|
+
const slot = globalThis;
|
|
26
|
+
if (slot[DATADOG_RUM_FOR_DEV]) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
slot[DATADOG_RUM_FOR_DEV] = {
|
|
30
|
+
start,
|
|
31
|
+
stop
|
|
32
|
+
};
|
|
33
|
+
globalThis.addEventListener('storage', (event)=>{
|
|
34
|
+
if (event.key === DATADOG_RUM_FOR_DEV) {
|
|
35
|
+
reloadPage();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=dev-console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-override/dev-console.ts"],"sourcesContent":["import { datadogRum } from '@datadog/browser-rum';\nimport { DATADOG_RUM_FOR_DEV } from './constants';\nimport { clearOverride, enableOverride } from './override';\n\ninterface DevConsole {\n start: () => void;\n stop: () => void;\n}\n\ninterface DevGlobalSlot {\n [DATADOG_RUM_FOR_DEV]?: DevConsole;\n}\n\ndeclare global {\n interface Window {\n datadogRumForDev?: DevConsole;\n }\n}\n\n/* istanbul ignore next: thin seam over location.reload, which jsdom does not implement */\nfunction reloadPage(): void {\n globalThis.location.reload();\n}\n\nfunction start(): void {\n enableOverride();\n // eslint-disable-next-line no-console\n console.info(`[datadog-rum] ${DATADOG_RUM_FOR_DEV}.start(): RUM enabled for 12h; reloading.`);\n reloadPage();\n}\n\nfunction stop(): void {\n try {\n datadogRum.stopSession();\n } catch {\n // ignore: SDK may not be initialized\n }\n clearOverride();\n // eslint-disable-next-line no-console\n console.info(`[datadog-rum] ${DATADOG_RUM_FOR_DEV}.stop(): override cleared; reloading.`);\n reloadPage();\n}\n\nexport function installDevConsole(): void {\n const slot = globalThis as unknown as DevGlobalSlot;\n if (slot[DATADOG_RUM_FOR_DEV]) {\n return;\n }\n slot[DATADOG_RUM_FOR_DEV] = { start, stop };\n\n globalThis.addEventListener('storage', event => {\n if (event.key === DATADOG_RUM_FOR_DEV) {\n reloadPage();\n }\n });\n}\n"],"names":["datadogRum","DATADOG_RUM_FOR_DEV","clearOverride","enableOverride","reloadPage","globalThis","location","reload","start","console","info","stop","stopSession","installDevConsole","slot","addEventListener","event","key"],"mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,SAASC,mBAAmB,QAAQ,cAAc;AAClD,SAASC,aAAa,EAAEC,cAAc,QAAQ,aAAa;AAiB3D,wFAAwF,GACxF,SAASC;IACLC,WAAWC,QAAQ,CAACC,MAAM;AAC9B;AAEA,SAASC;IACLL;IACA,sCAAsC;IACtCM,QAAQC,IAAI,CAAC,CAAC,cAAc,EAAET,oBAAoB,yCAAyC,CAAC;IAC5FG;AACJ;AAEA,SAASO;IACL,IAAI;QACAX,WAAWY,WAAW;IAC1B,EAAE,eAAM;IACJ,qCAAqC;IACzC;IACAV;IACA,sCAAsC;IACtCO,QAAQC,IAAI,CAAC,CAAC,cAAc,EAAET,oBAAoB,qCAAqC,CAAC;IACxFG;AACJ;AAEA,OAAO,SAASS;IACZ,MAAMC,OAAOT;IACb,IAAIS,IAAI,CAACb,oBAAoB,EAAE;QAC3B;IACJ;IACAa,IAAI,CAACb,oBAAoB,GAAG;QAAEO;QAAOG;IAAK;IAE1CN,WAAWU,gBAAgB,CAAC,WAAWC,CAAAA;QACnC,IAAIA,MAAMC,GAAG,KAAKhB,qBAAqB;YACnCG;QACJ;IACJ;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime-override/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-override/index.ts"],"sourcesContent":["export { DATADOG_RUM_FOR_DEV } from './constants';\nexport { installDevConsole } from './dev-console';\nexport { isForceEnabled } from './override';\n"],"names":["DATADOG_RUM_FOR_DEV","installDevConsole","isForceEnabled"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAClD,SAASC,iBAAiB,QAAQ,gBAAgB;AAClD,SAASC,cAAc,QAAQ,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"override.d.ts","sourceRoot":"","sources":["../../src/runtime-override/override.ts"],"names":[],"mappings":"AA6BA,wBAAgB,cAAc,IAAI,OAAO,CAGxC;AAED,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DATADOG_RUM_FOR_DEV } from './constants';
|
|
2
|
+
const TTL_MS = 12 * 60 * 60 * 1000;
|
|
3
|
+
function readOverride() {
|
|
4
|
+
try {
|
|
5
|
+
const raw = localStorage.getItem(DATADOG_RUM_FOR_DEV);
|
|
6
|
+
return raw ? JSON.parse(raw) : null;
|
|
7
|
+
} catch (unused) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function writeOverride(record) {
|
|
12
|
+
try {
|
|
13
|
+
if (record === null) {
|
|
14
|
+
localStorage.removeItem(DATADOG_RUM_FOR_DEV);
|
|
15
|
+
} else {
|
|
16
|
+
localStorage.setItem(DATADOG_RUM_FOR_DEV, JSON.stringify(record));
|
|
17
|
+
}
|
|
18
|
+
} catch (unused) {
|
|
19
|
+
// storage unavailable
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function isForceEnabled() {
|
|
23
|
+
const record = readOverride();
|
|
24
|
+
return record !== null && typeof record.exp === 'number' && Date.now() < record.exp;
|
|
25
|
+
}
|
|
26
|
+
export function enableOverride() {
|
|
27
|
+
writeOverride({
|
|
28
|
+
exp: Date.now() + TTL_MS
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export function clearOverride() {
|
|
32
|
+
writeOverride(null);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=override.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-override/override.ts"],"sourcesContent":["import { DATADOG_RUM_FOR_DEV } from './constants';\n\nconst TTL_MS = 12 * 60 * 60 * 1000;\n\ninterface OverrideRecord {\n exp: number;\n}\n\nfunction readOverride(): OverrideRecord | null {\n try {\n const raw = localStorage.getItem(DATADOG_RUM_FOR_DEV);\n return raw ? (JSON.parse(raw) as OverrideRecord) : null;\n } catch {\n return null;\n }\n}\n\nfunction writeOverride(record: OverrideRecord | null): void {\n try {\n if (record === null) {\n localStorage.removeItem(DATADOG_RUM_FOR_DEV);\n } else {\n localStorage.setItem(DATADOG_RUM_FOR_DEV, JSON.stringify(record));\n }\n } catch {\n // storage unavailable\n }\n}\n\nexport function isForceEnabled(): boolean {\n const record = readOverride();\n return record !== null && typeof record.exp === 'number' && Date.now() < record.exp;\n}\n\nexport function enableOverride(): void {\n writeOverride({ exp: Date.now() + TTL_MS });\n}\n\nexport function clearOverride(): void {\n writeOverride(null);\n}\n"],"names":["DATADOG_RUM_FOR_DEV","TTL_MS","readOverride","raw","localStorage","getItem","JSON","parse","writeOverride","record","removeItem","setItem","stringify","isForceEnabled","exp","Date","now","enableOverride","clearOverride"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,cAAc;AAElD,MAAMC,SAAS,KAAK,KAAK,KAAK;AAM9B,SAASC;IACL,IAAI;QACA,MAAMC,MAAMC,aAAaC,OAAO,CAACL;QACjC,OAAOG,MAAOG,KAAKC,KAAK,CAACJ,OAA0B;IACvD,EAAE,eAAM;QACJ,OAAO;IACX;AACJ;AAEA,SAASK,cAAcC,MAA6B;IAChD,IAAI;QACA,IAAIA,WAAW,MAAM;YACjBL,aAAaM,UAAU,CAACV;QAC5B,OAAO;YACHI,aAAaO,OAAO,CAACX,qBAAqBM,KAAKM,SAAS,CAACH;QAC7D;IACJ,EAAE,eAAM;IACJ,sBAAsB;IAC1B;AACJ;AAEA,OAAO,SAASI;IACZ,MAAMJ,SAASP;IACf,OAAOO,WAAW,QAAQ,OAAOA,OAAOK,GAAG,KAAK,YAAYC,KAAKC,GAAG,KAAKP,OAAOK,GAAG;AACvF;AAEA,OAAO,SAASG;IACZT,cAAc;QAAEM,KAAKC,KAAKC,GAAG,KAAKf;IAAO;AAC7C;AAEA,OAAO,SAASiB;IACZV,cAAc;AAClB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RumUser } from './shared-impl';
|
|
2
|
+
export type { RumUser } from './shared-impl';
|
|
3
|
+
/**
|
|
4
|
+
* Sets the session user on the Datadog RUM SDK.
|
|
5
|
+
*
|
|
6
|
+
* - **SDK initialized via `init`**: only the bundle whose `init` call
|
|
7
|
+
* initialized the SDK may set the user; calls from any other bundle are
|
|
8
|
+
* silent no-ops.
|
|
9
|
+
* - **SDK initialized directly via `datadogRum.init`**: no gating is applied.
|
|
10
|
+
* - **Neither initialized**: no-op.
|
|
11
|
+
*/
|
|
12
|
+
export declare function setUser(user: RumUser): void;
|
|
13
|
+
//# sourceMappingURL=set-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-user.d.ts","sourceRoot":"","sources":["../src/set-user.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAQ3C"}
|
package/dist/set-user.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { datadogRum } from '@datadog/browser-rum';
|
|
2
|
+
import { bundleState } from './bundle-state';
|
|
3
|
+
import { getSharedImpl } from './get-shared';
|
|
4
|
+
/**
|
|
5
|
+
* Sets the session user on the Datadog RUM SDK.
|
|
6
|
+
*
|
|
7
|
+
* - **SDK initialized via `init`**: only the bundle whose `init` call
|
|
8
|
+
* initialized the SDK may set the user; calls from any other bundle are
|
|
9
|
+
* silent no-ops.
|
|
10
|
+
* - **SDK initialized directly via `datadogRum.init`**: no gating is applied.
|
|
11
|
+
* - **Neither initialized**: no-op.
|
|
12
|
+
*/ export function setUser(user) {
|
|
13
|
+
if (bundleState.isSdkInitializer) {
|
|
14
|
+
datadogRum.setUser(user);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (!getSharedImpl() && datadogRum.getInitConfiguration()) {
|
|
18
|
+
datadogRum.setUser(user);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=set-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/set-user.ts"],"sourcesContent":["import { datadogRum } from '@datadog/browser-rum';\nimport { bundleState } from './bundle-state';\nimport { getSharedImpl } from './get-shared';\nimport type { RumUser } from './shared-impl';\n\nexport type { RumUser } from './shared-impl';\n\n/**\n * Sets the session user on the Datadog RUM SDK.\n *\n * - **SDK initialized via `init`**: only the bundle whose `init` call\n * initialized the SDK may set the user; calls from any other bundle are\n * silent no-ops.\n * - **SDK initialized directly via `datadogRum.init`**: no gating is applied.\n * - **Neither initialized**: no-op.\n */\nexport function setUser(user: RumUser): void {\n if (bundleState.isSdkInitializer) {\n datadogRum.setUser(user);\n return;\n }\n if (!getSharedImpl() && datadogRum.getInitConfiguration()) {\n datadogRum.setUser(user);\n }\n}\n"],"names":["datadogRum","bundleState","getSharedImpl","setUser","user","isSdkInitializer","getInitConfiguration"],"mappings":"AAAA,SAASA,UAAU,QAAQ,uBAAuB;AAClD,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,aAAa,QAAQ,eAAe;AAK7C;;;;;;;;CAQC,GACD,OAAO,SAASC,QAAQC,IAAa;IACjC,IAAIH,YAAYI,gBAAgB,EAAE;QAC9BL,WAAWG,OAAO,CAACC;QACnB;IACJ;IACA,IAAI,CAACF,mBAAmBF,WAAWM,oBAAoB,IAAI;QACvDN,WAAWG,OAAO,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context, User } from '@datadog/browser-core';
|
|
2
|
+
import type { Cleanup, InitRumOptions } from './types';
|
|
3
|
+
export type RumUser = Omit<User, 'id'> & Required<Pick<User, 'id'>>;
|
|
4
|
+
export interface SharedImpl {
|
|
5
|
+
init(opts: InitRumOptions): {
|
|
6
|
+
cleanup: Cleanup;
|
|
7
|
+
initializedSdk: boolean;
|
|
8
|
+
};
|
|
9
|
+
setServiceContext(key: string, context: Context): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=shared-impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-impl.d.ts","sourceRoot":"","sources":["../src/shared-impl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEvD,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEpE,MAAM,WAAW,UAAU;IACvB,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,CAAC;IAC1E,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared-impl.ts"],"sourcesContent":["import type { Context, User } from '@datadog/browser-core';\nimport type { Cleanup, InitRumOptions } from './types';\n\nexport type RumUser = Omit<User, 'id'> & Required<Pick<User, 'id'>>;\n\nexport interface SharedImpl {\n init(opts: InitRumOptions): { cleanup: Cleanup; initializedSdk: boolean };\n setServiceContext(key: string, context: Context): void;\n}\n"],"names":[],"mappings":"AAKA,WAGC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Context } from '@datadog/browser-core';
|
|
2
|
+
import type { MatchOption, PropagatorType, RumInitConfiguration } from '@datadog/browser-rum';
|
|
3
|
+
import type { ApplicationBeforeSendHandler, ServiceBeforeSendHandler } from './before-send';
|
|
4
|
+
/**
|
|
5
|
+
* URL matchers grouped by the propagator type whose headers they should
|
|
6
|
+
* activate. A service registers its tracing URLs as e.g.
|
|
7
|
+
* `{ tracecontext: [/api\//, 'https://...'] }`.
|
|
8
|
+
*/
|
|
9
|
+
export type ServiceTracingUrls = Partial<Record<PropagatorType, MatchOption[]>>;
|
|
10
|
+
/** Tears down a service registration: handlers, tracing URLs, and persistent context. */
|
|
11
|
+
export type Cleanup = () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Service handle returned by `useRumService`. `setServiceContext` is bound to the
|
|
14
|
+
* service registered by the hook, so callers don't pass the service name again.
|
|
15
|
+
*/
|
|
16
|
+
export interface RumService {
|
|
17
|
+
setServiceContext: (context: Context) => void;
|
|
18
|
+
}
|
|
19
|
+
/** Imperative service registration returned by `init`. Adds the cleanup contract. */
|
|
20
|
+
export interface RumServiceRegistration extends RumService {
|
|
21
|
+
cleanup: Cleanup;
|
|
22
|
+
}
|
|
23
|
+
export type ApplicationConfig = Omit<RumInitConfiguration, 'beforeSend' | 'allowedTracingUrls' | 'service'> & {
|
|
24
|
+
beforeSend?: ApplicationBeforeSendHandler;
|
|
25
|
+
};
|
|
26
|
+
interface ServiceShape {
|
|
27
|
+
beforeSend?: ServiceBeforeSendHandler;
|
|
28
|
+
allowedTracingUrls?: ServiceTracingUrls;
|
|
29
|
+
}
|
|
30
|
+
export interface ServiceConfig extends ServiceShape {
|
|
31
|
+
name: string;
|
|
32
|
+
}
|
|
33
|
+
export interface InitRumOptions {
|
|
34
|
+
service: ServiceConfig;
|
|
35
|
+
application?: ApplicationConfig;
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Per-service entry — `beforeSend` and `allowedTracingUrls` come from
|
|
40
|
+
* `init`; `context` comes from `setServiceContext`. One service = one entry.
|
|
41
|
+
*/
|
|
42
|
+
export interface ServiceEntry extends ServiceShape {
|
|
43
|
+
context?: Context;
|
|
44
|
+
}
|
|
45
|
+
/** Registration state: application-level handler + per-service entries keyed by service name. */
|
|
46
|
+
export interface State {
|
|
47
|
+
applicationBeforeSend?: ApplicationBeforeSendHandler;
|
|
48
|
+
services: Map<string, ServiceEntry>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE5F;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;AAEhF,yFAAyF;AACzF,MAAM,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC;AAEjC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACvB,iBAAiB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD;AAED,qFAAqF;AACrF,MAAM,WAAW,sBAAuB,SAAQ,UAAU;IACtD,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAChC,oBAAoB,EACpB,YAAY,GAAG,oBAAoB,GAAG,SAAS,CAClD,GAAG;IACA,UAAU,CAAC,EAAE,4BAA4B,CAAC;CAC7C,CAAC;AAEF,UAAU,YAAY;IAClB,UAAU,CAAC,EAAE,wBAAwB,CAAC;IACtC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CAC3C;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IAC/C,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC3B,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,YAAY;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,iGAAiG;AACjG,MAAM,WAAW,KAAK;IAClB,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IACrD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACvC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Context } from '@datadog/browser-core';\nimport type { MatchOption, PropagatorType, RumInitConfiguration } from '@datadog/browser-rum';\nimport type { ApplicationBeforeSendHandler, ServiceBeforeSendHandler } from './before-send';\n\n/**\n * URL matchers grouped by the propagator type whose headers they should\n * activate. A service registers its tracing URLs as e.g.\n * `{ tracecontext: [/api\\//, 'https://...'] }`.\n */\nexport type ServiceTracingUrls = Partial<Record<PropagatorType, MatchOption[]>>;\n\n/** Tears down a service registration: handlers, tracing URLs, and persistent context. */\nexport type Cleanup = () => void;\n\n/**\n * Service handle returned by `useRumService`. `setServiceContext` is bound to the\n * service registered by the hook, so callers don't pass the service name again.\n */\nexport interface RumService {\n setServiceContext: (context: Context) => void;\n}\n\n/** Imperative service registration returned by `init`. Adds the cleanup contract. */\nexport interface RumServiceRegistration extends RumService {\n cleanup: Cleanup;\n}\n\nexport type ApplicationConfig = Omit<\n RumInitConfiguration,\n 'beforeSend' | 'allowedTracingUrls' | 'service'\n> & {\n beforeSend?: ApplicationBeforeSendHandler;\n};\n\ninterface ServiceShape {\n beforeSend?: ServiceBeforeSendHandler;\n allowedTracingUrls?: ServiceTracingUrls;\n}\n\nexport interface ServiceConfig extends ServiceShape {\n name: string;\n}\n\nexport interface InitRumOptions {\n service: ServiceConfig;\n application?: ApplicationConfig;\n enabled?: boolean;\n}\n\n/**\n * Per-service entry — `beforeSend` and `allowedTracingUrls` come from\n * `init`; `context` comes from `setServiceContext`. One service = one entry.\n */\nexport interface ServiceEntry extends ServiceShape {\n context?: Context;\n}\n\n/** Registration state: application-level handler + per-service entries keyed by service name. */\nexport interface State {\n applicationBeforeSend?: ApplicationBeforeSendHandler;\n services: Map<string, ServiceEntry>;\n}\n"],"names":[],"mappings":"AAyDA,+FAA+F,GAC/F,WAGC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type RumService, type ServiceConfig } from './init';
|
|
2
|
+
/**
|
|
3
|
+
* Registers a service on mount and disposes it on unmount. On unmount the
|
|
4
|
+
* service's `beforeSend`, `allowedTracingUrls`, and any context previously set
|
|
5
|
+
* via `setServiceContext` are removed atomically. The config is captured on
|
|
6
|
+
* first render — changing it across renders does not re-register.
|
|
7
|
+
*
|
|
8
|
+
* Returns a `RumService` — `{ setServiceContext }`, bound to this service.
|
|
9
|
+
* The handle is identity-stable across renders.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useRumService(config: ServiceConfig): RumService;
|
|
12
|
+
//# sourceMappingURL=use-rum-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rum-service.d.ts","sourceRoot":"","sources":["../src/use-rum-service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEnE;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAc/D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { getOrCreateSharedImpl } from './get-shared';
|
|
3
|
+
import { init } from './init';
|
|
4
|
+
/**
|
|
5
|
+
* Registers a service on mount and disposes it on unmount. On unmount the
|
|
6
|
+
* service's `beforeSend`, `allowedTracingUrls`, and any context previously set
|
|
7
|
+
* via `setServiceContext` are removed atomically. The config is captured on
|
|
8
|
+
* first render — changing it across renders does not re-register.
|
|
9
|
+
*
|
|
10
|
+
* Returns a `RumService` — `{ setServiceContext }`, bound to this service.
|
|
11
|
+
* The handle is identity-stable across renders.
|
|
12
|
+
*/ export function useRumService(config) {
|
|
13
|
+
useEffect(()=>{
|
|
14
|
+
return init({
|
|
15
|
+
service: config
|
|
16
|
+
}).cleanup;
|
|
17
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
+
}, []);
|
|
19
|
+
return useMemo(()=>({
|
|
20
|
+
setServiceContext: (context)=>getOrCreateSharedImpl().setServiceContext(config.name, context)
|
|
21
|
+
}), // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
|
+
[]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=use-rum-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-rum-service.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport { getOrCreateSharedImpl } from './get-shared';\nimport { init, type RumService, type ServiceConfig } from './init';\n\n/**\n * Registers a service on mount and disposes it on unmount. On unmount the\n * service's `beforeSend`, `allowedTracingUrls`, and any context previously set\n * via `setServiceContext` are removed atomically. The config is captured on\n * first render — changing it across renders does not re-register.\n *\n * Returns a `RumService` — `{ setServiceContext }`, bound to this service.\n * The handle is identity-stable across renders.\n */\nexport function useRumService(config: ServiceConfig): RumService {\n useEffect(() => {\n return init({ service: config }).cleanup;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return useMemo(\n () => ({\n setServiceContext: context =>\n getOrCreateSharedImpl().setServiceContext(config.name, context),\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n}\n"],"names":["useEffect","useMemo","getOrCreateSharedImpl","init","useRumService","config","service","cleanup","setServiceContext","context","name"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,QAAQ;AAC3C,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,IAAI,QAA6C,SAAS;AAEnE;;;;;;;;CAQC,GACD,OAAO,SAASC,cAAcC,MAAqB;IAC/CL,UAAU;QACN,OAAOG,KAAK;YAAEG,SAASD;QAAO,GAAGE,OAAO;IACxC,uDAAuD;IAC3D,GAAG,EAAE;IAEL,OAAON,QACH,IAAO,CAAA;YACHO,mBAAmBC,CAAAA,UACfP,wBAAwBM,iBAAiB,CAACH,OAAOK,IAAI,EAAED;QAC/D,CAAA,GACA,uDAAuD;IACvD,EAAE;AAEV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/datadog-rum",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.0.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.3.0",
|
|
26
26
|
"@testing-library/dom": "^10.4.1",
|
|
27
27
|
"@testing-library/jest-dom": "^6.9.1",
|
|
28
28
|
"@testing-library/react": "^16.3.2",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"cli": {
|
|
41
41
|
"webpack": false
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "f0acf332ece207c91acb18da23a614efbc8551ec"
|
|
44
44
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RumEvent, RumEventDomainContext } from '@datadog/browser-rum';
|
|
2
|
+
import { datadogRum } from '@datadog/browser-rum';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Invokes the `beforeSend` captured on the most recent `datadogRum.init` call
|
|
6
|
+
* with the given event partial. Returns whatever `beforeSend` returns (false
|
|
7
|
+
* drops, true/void proceeds). The helper mutates `event` in place, so callers
|
|
8
|
+
* that need to inspect mutations should hold a reference to the event they
|
|
9
|
+
* pass in.
|
|
10
|
+
*/
|
|
11
|
+
export const processEvent = (
|
|
12
|
+
event: Partial<RumEvent>,
|
|
13
|
+
context: RumEventDomainContext = {}
|
|
14
|
+
): boolean | void => {
|
|
15
|
+
const beforeSend = jest.mocked(datadogRum.init).mock.calls.at(-1)?.[0].beforeSend as (
|
|
16
|
+
e: RumEvent,
|
|
17
|
+
c: RumEventDomainContext
|
|
18
|
+
) => boolean | void;
|
|
19
|
+
return beforeSend(event as RumEvent, context);
|
|
20
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { bundleState } from '../bundle-state';
|
|
2
|
+
import { STATE_KEY, type GlobalSlot } from '../get-shared';
|
|
3
|
+
|
|
4
|
+
export function resetSharedImpl(): void {
|
|
5
|
+
const slot = globalThis as unknown as GlobalSlot;
|
|
6
|
+
delete slot[STATE_KEY];
|
|
7
|
+
bundleState.isSdkInitializer = false;
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PropagatorType, RumInitConfiguration } from '@datadog/browser-rum';
|
|
2
|
+
import { datadogRum } from '@datadog/browser-rum';
|
|
3
|
+
|
|
4
|
+
export type { PropagatorType };
|
|
5
|
+
|
|
6
|
+
interface Matcher {
|
|
7
|
+
match: (url: string) => boolean;
|
|
8
|
+
propagatorTypes?: PropagatorType[] | null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isAllowedTracingUrl(
|
|
12
|
+
matchers: NonNullable<RumInitConfiguration['allowedTracingUrls']>,
|
|
13
|
+
url: string,
|
|
14
|
+
propagator: PropagatorType = 'tracecontext'
|
|
15
|
+
): boolean {
|
|
16
|
+
const matcher = matchers.find(
|
|
17
|
+
(candidate): candidate is Matcher =>
|
|
18
|
+
typeof candidate === 'object' &&
|
|
19
|
+
'propagatorTypes' in candidate &&
|
|
20
|
+
!!candidate.propagatorTypes?.includes(propagator)
|
|
21
|
+
);
|
|
22
|
+
return matcher?.match(url) ?? false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getInitAllowedTracingUrls(): NonNullable<
|
|
26
|
+
RumInitConfiguration['allowedTracingUrls']
|
|
27
|
+
> {
|
|
28
|
+
const call = jest.mocked(datadogRum.init).mock.calls.at(-1)![0];
|
|
29
|
+
return call.allowedTracingUrls!;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Mutable<T> = { -readonly [P in keyof T]: T[P] };
|