@servicetitan/datadog-rum 36.2.0 → 36.3.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"before-send.d.ts","sourceRoot":"","sources":["../src/before-send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"before-send.d.ts","sourceRoot":"","sources":["../src/before-send.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGR,oBAAoB,EAGvB,MAAM,sBAAsB,CAAC;AAiE9B,wBAAgB,UAAU,CACtB,OAAO,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,GAC7C,WAAW,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC,CAcjD"}
|
package/dist/before-send.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/before-send.ts"],"sourcesContent":["import type {\n RumEvent,\n RumEventDomainContext,\n
|
|
1
|
+
{"version":3,"sources":["../src/before-send.ts"],"sourcesContent":["import type {\n RumEvent,\n RumEventDomainContext,\n RumInitConfiguration,\n RumResourceEvent,\n RumResourceEventDomainContext,\n} from '@datadog/browser-rum';\n\nconst SERVICE_REGEX =\n /unpkg\\.servicetitan\\.com\\/@servicetitan\\/(?<service>[\\w-]+)(?:@(?<version>\\d+\\.\\d+\\.\\d+(?:-[\\w.]+)?))?/;\n\nfunction isSameDomainRequest(url: string) {\n return new URL(url).hostname === window.location.hostname;\n}\n\nfunction parseService(event: RumEvent, input: string | undefined) {\n const match = input?.match(SERVICE_REGEX);\n\n const service = match?.groups?.service;\n const version = match?.groups?.version;\n\n if (service) {\n event.service = service;\n event.version = version ?? 'unknown';\n return true;\n }\n\n return false;\n}\n\n/**\n * See https://docs.datadoghq.com/real_user_monitoring/browser/advanced_configuration/?tab=npm#micro-frontend\n */\nfunction enrichEvent(event: RumEvent, context: RumEventDomainContext): void {\n const stack =\n (context && 'handlingStack' in context ? context.handlingStack : undefined) ??\n (event.type === 'error' ? event.error?.stack : undefined);\n\n const message = event.type === 'error' ? event.error?.message : undefined;\n\n const url = event.type === 'resource' ? event.resource?.url : undefined;\n\n for (const source of [stack, message, url]) {\n if (parseService(event, source)) {\n break;\n }\n }\n}\n\nfunction handleResource(event: RumResourceEvent, context: RumResourceEventDomainContext): void {\n if (!isSameDomainRequest(event.resource.url)) {\n return;\n }\n\n let cfRay: string | undefined | null = undefined;\n\n switch (event.resource.type) {\n case 'fetch':\n cfRay = context.response?.headers.get('cf-ray');\n break;\n\n case 'xhr':\n cfRay = context.xhr?.getResponseHeader('cf-ray');\n break;\n }\n\n if (cfRay) {\n event.context = { ...event.context, cfRay };\n }\n}\n\nexport function beforeSend(\n handler?: RumInitConfiguration['beforeSend']\n): NonNullable<RumInitConfiguration['beforeSend']> {\n return function (event: RumEvent, context: RumEventDomainContext) {\n try {\n if (event.type === 'resource') {\n handleResource(event, context as RumResourceEventDomainContext);\n }\n\n enrichEvent(event, context);\n\n return handler?.(event, context) ?? true;\n } catch {} // eslint-disable-line no-empty\n\n return true;\n };\n}\n"],"names":["SERVICE_REGEX","isSameDomainRequest","url","URL","hostname","window","location","parseService","event","input","match","service","groups","version","enrichEvent","context","stack","handlingStack","undefined","type","error","message","resource","source","handleResource","cfRay","response","headers","get","xhr","getResponseHeader","beforeSend","handler"],"mappings":"AAQA,MAAMA,gBACF;AAEJ,SAASC,oBAAoBC,GAAW;IACpC,OAAO,IAAIC,IAAID,KAAKE,QAAQ,KAAKC,OAAOC,QAAQ,CAACF,QAAQ;AAC7D;AAEA,SAASG,aAAaC,KAAe,EAAEC,KAAyB;QAG5CC,eACAA;IAHhB,MAAMA,QAAQD,kBAAAA,4BAAAA,MAAOC,KAAK,CAACV;IAE3B,MAAMW,UAAUD,kBAAAA,6BAAAA,gBAAAA,MAAOE,MAAM,cAAbF,oCAAAA,cAAeC,OAAO;IACtC,MAAME,UAAUH,kBAAAA,6BAAAA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GP,MAAMO,OAAO;YAAEU;QAAM;IAC9C;AACJ;AAEA,OAAO,SAASM,WACZC,OAA4C;IAE5C,OAAO,SAAUxB,KAAe,EAAEO,OAA8B;QAC5D,IAAI;;YACA,IAAIP,MAAMW,IAAI,KAAK,YAAY;gBAC3BK,eAAehB,OAAOO;YAC1B;YAEAD,YAAYN,OAAOO;YAEnB,eAAOiB,oBAAAA,8BAAAA,QAAUxB,OAAOO,+CAAY;QACxC,EAAE,eAAM,CAAC,EAAE,+BAA+B;QAE1C,OAAO;IACX;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@servicetitan/datadog-rum",
|
|
3
|
-
"version": "36.
|
|
3
|
+
"version": "36.3.1",
|
|
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": "^
|
|
25
|
+
"@datadog/browser-rum": "^7.1.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": "93a049ba1e5cb737afb7bc95c06020736bc61a38"
|
|
44
44
|
}
|
package/src/before-send.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
RumEvent,
|
|
3
3
|
RumEventDomainContext,
|
|
4
|
-
RumFetchResourceEventDomainContext,
|
|
5
4
|
RumInitConfiguration,
|
|
6
5
|
RumResourceEvent,
|
|
7
|
-
|
|
6
|
+
RumResourceEventDomainContext,
|
|
8
7
|
} from '@datadog/browser-rum';
|
|
9
8
|
|
|
10
9
|
const SERVICE_REGEX =
|
|
@@ -48,7 +47,7 @@ function enrichEvent(event: RumEvent, context: RumEventDomainContext): void {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
function handleResource(event: RumResourceEvent, context:
|
|
50
|
+
function handleResource(event: RumResourceEvent, context: RumResourceEventDomainContext): void {
|
|
52
51
|
if (!isSameDomainRequest(event.resource.url)) {
|
|
53
52
|
return;
|
|
54
53
|
}
|
|
@@ -57,11 +56,11 @@ function handleResource(event: RumResourceEvent, context: RumEventDomainContext)
|
|
|
57
56
|
|
|
58
57
|
switch (event.resource.type) {
|
|
59
58
|
case 'fetch':
|
|
60
|
-
cfRay =
|
|
59
|
+
cfRay = context.response?.headers.get('cf-ray');
|
|
61
60
|
break;
|
|
62
61
|
|
|
63
62
|
case 'xhr':
|
|
64
|
-
cfRay =
|
|
63
|
+
cfRay = context.xhr?.getResponseHeader('cf-ray');
|
|
65
64
|
break;
|
|
66
65
|
}
|
|
67
66
|
|
|
@@ -76,7 +75,7 @@ export function beforeSend(
|
|
|
76
75
|
return function (event: RumEvent, context: RumEventDomainContext) {
|
|
77
76
|
try {
|
|
78
77
|
if (event.type === 'resource') {
|
|
79
|
-
handleResource(event, context);
|
|
78
|
+
handleResource(event, context as RumResourceEventDomainContext);
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
enrichEvent(event, context);
|