@sentry/nuxt 10.11.0 → 10.13.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/build/esm/package.json +1 -1
- package/build/module/module.json +1 -1
- package/build/module/runtime/hooks/captureErrorHook.js +1 -1
- package/build/module/runtime/plugins/sentry-cloudflare.server.js +10 -14
- package/build/module/runtime/utils/event-type-check.d.ts +44 -0
- package/build/module/runtime/utils/event-type-check.js +32 -0
- package/build/module/runtime/utils.js +1 -1
- package/build/types/runtime/plugins/index.d.ts.map +1 -1
- package/build/types/runtime/plugins/sentry-cloudflare.server.d.ts.map +1 -1
- package/build/types/runtime/utils/event-type-check.d.ts +45 -0
- package/build/types/runtime/utils/event-type-check.d.ts.map +1 -0
- package/package.json +8 -8
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"10.
|
|
1
|
+
{"type":"module","version":"10.13.0"}
|
package/build/module/module.json
CHANGED
|
@@ -22,7 +22,7 @@ export async function sentryCaptureErrorHook(error, errorContext) {
|
|
|
22
22
|
const structuredContext = extractErrorContext(errorContext);
|
|
23
23
|
captureException(error, {
|
|
24
24
|
captureContext: { contexts: { nuxt: structuredContext } },
|
|
25
|
-
mechanism: { handled: false }
|
|
25
|
+
mechanism: { handled: false, type: "auto.function.nuxt.nitro" }
|
|
26
26
|
});
|
|
27
27
|
await flushIfServerless();
|
|
28
28
|
}
|
|
@@ -3,16 +3,7 @@ import { debug, getDefaultIsolationScope, getIsolationScope, getTraceData } from
|
|
|
3
3
|
import { sentryCaptureErrorHook } from "../hooks/captureErrorHook.js";
|
|
4
4
|
import { updateRouteBeforeResponse } from "../hooks/updateRouteBeforeResponse.js";
|
|
5
5
|
import { addSentryTracingMetaTags } from "../utils.js";
|
|
6
|
-
|
|
7
|
-
if (event === null || typeof event !== "object") return false;
|
|
8
|
-
return (
|
|
9
|
-
// basic properties
|
|
10
|
-
"protocol" in event && "host" in event && typeof event.protocol === "string" && typeof event.host === "string" && // context property
|
|
11
|
-
"context" in event && typeof event.context === "object" && event.context !== null && // context.cf properties
|
|
12
|
-
"cf" in event.context && typeof event.context.cf === "object" && event.context.cf !== null && // context.cloudflare properties
|
|
13
|
-
"cloudflare" in event.context && typeof event.context.cloudflare === "object" && event.context.cloudflare !== null && "context" in event.context.cloudflare
|
|
14
|
-
);
|
|
15
|
-
}
|
|
6
|
+
import { getCfProperties, getCloudflareProperties, hasCfProperty, isEventType } from "../utils/event-type-check.js";
|
|
16
7
|
export const sentryCloudflareNitroPlugin = (optionsOrFn) => (nitroApp) => {
|
|
17
8
|
const traceDataMap = /* @__PURE__ */ new WeakMap();
|
|
18
9
|
nitroApp.localFetch = new Proxy(nitroApp.localFetch, {
|
|
@@ -29,19 +20,19 @@ export const sentryCloudflareNitroPlugin = (optionsOrFn) => (nitroApp) => {
|
|
|
29
20
|
const request = new Request(url, {
|
|
30
21
|
method: event.method,
|
|
31
22
|
headers: event.headers,
|
|
32
|
-
cf: event
|
|
23
|
+
cf: getCfProperties(event)
|
|
33
24
|
});
|
|
34
25
|
const requestHandlerOptions = {
|
|
35
26
|
options: cloudflareOptions,
|
|
36
27
|
request,
|
|
37
|
-
context: event.context
|
|
28
|
+
context: getCloudflareProperties(event).context
|
|
38
29
|
};
|
|
39
30
|
return wrapRequestHandler(requestHandlerOptions, () => {
|
|
40
31
|
const isolationScope = getIsolationScope();
|
|
41
32
|
const newIsolationScope = isolationScope === getDefaultIsolationScope() ? isolationScope.clone() : isolationScope;
|
|
42
33
|
const traceData = getTraceData();
|
|
43
34
|
if (traceData && Object.keys(traceData).length > 0) {
|
|
44
|
-
traceDataMap.set(event
|
|
35
|
+
traceDataMap.set(getCfProperties(event), traceData);
|
|
45
36
|
debug.log("Stored trace data for later use in HTML meta-tags: ", traceData);
|
|
46
37
|
}
|
|
47
38
|
debug.log(
|
|
@@ -54,7 +45,12 @@ export const sentryCloudflareNitroPlugin = (optionsOrFn) => (nitroApp) => {
|
|
|
54
45
|
});
|
|
55
46
|
nitroApp.hooks.hook("beforeResponse", updateRouteBeforeResponse);
|
|
56
47
|
nitroApp.hooks.hook("render:html", (html, { event }) => {
|
|
57
|
-
|
|
48
|
+
let storedTraceData = void 0;
|
|
49
|
+
if (event?.context && "_platform" in event.context && event.context._platform && hasCfProperty(event.context._platform)) {
|
|
50
|
+
storedTraceData = traceDataMap.get(event.context._platform.cf);
|
|
51
|
+
} else if (event?.context && hasCfProperty(event.context)) {
|
|
52
|
+
storedTraceData = traceDataMap.get(event.context.cf);
|
|
53
|
+
}
|
|
58
54
|
if (storedTraceData && Object.keys(storedTraceData).length > 0) {
|
|
59
55
|
debug.log("Using stored trace data for HTML meta-tags: ", storedTraceData);
|
|
60
56
|
addSentryTracingMetaTags(html.head, storedTraceData);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CfProperties, ExecutionContext } from '@cloudflare/workers-types';
|
|
2
|
+
interface EventBase {
|
|
3
|
+
protocol: string;
|
|
4
|
+
host: string;
|
|
5
|
+
method: string;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
interface MinimalCloudflareProps {
|
|
9
|
+
context: ExecutionContext;
|
|
10
|
+
request?: Record<string, unknown>;
|
|
11
|
+
env?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface CloudflareContext {
|
|
14
|
+
cf: CfProperties;
|
|
15
|
+
cloudflare: MinimalCloudflareProps;
|
|
16
|
+
}
|
|
17
|
+
interface CfEventDirect extends EventBase {
|
|
18
|
+
context: CloudflareContext;
|
|
19
|
+
}
|
|
20
|
+
interface CfEventPlatform extends EventBase {
|
|
21
|
+
context: {
|
|
22
|
+
_platform: CloudflareContext;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export type CfEventType = CfEventDirect | CfEventPlatform;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if an event context object has cf properties
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasCfProperty(context: unknown): context is {
|
|
30
|
+
cf: CfProperties;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Type guard to check if an event is a Cloudflare event (nested in _platform or direct)
|
|
34
|
+
*/
|
|
35
|
+
export declare function isEventType(event: unknown): event is CfEventType;
|
|
36
|
+
/**
|
|
37
|
+
* Extracts cf properties from a Cloudflare event
|
|
38
|
+
*/
|
|
39
|
+
export declare function getCfProperties(event: CfEventType): CfProperties;
|
|
40
|
+
/**
|
|
41
|
+
* Extracts cloudflare properties from a Cloudflare event
|
|
42
|
+
*/
|
|
43
|
+
export declare function getCloudflareProperties(event: CfEventType): MinimalCloudflareProps;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function hasCloudflareProperty(context) {
|
|
2
|
+
return context !== null && typeof context === "object" && // context.cloudflare properties
|
|
3
|
+
"cloudflare" in context && typeof context.cloudflare === "object" && context.cloudflare !== null && "context" in context.cloudflare;
|
|
4
|
+
}
|
|
5
|
+
export function hasCfProperty(context) {
|
|
6
|
+
return context !== null && typeof context === "object" && // context.cf properties
|
|
7
|
+
"cf" in context && typeof context.cf === "object" && context.cf !== null;
|
|
8
|
+
}
|
|
9
|
+
function hasCfAndCloudflare(context) {
|
|
10
|
+
return hasCfProperty(context) && hasCloudflareProperty(context);
|
|
11
|
+
}
|
|
12
|
+
export function isEventType(event) {
|
|
13
|
+
if (event === null || typeof event !== "object") return false;
|
|
14
|
+
return (
|
|
15
|
+
// basic properties
|
|
16
|
+
"protocol" in event && "host" in event && typeof event.protocol === "string" && typeof event.host === "string" && // context property
|
|
17
|
+
"context" in event && typeof event.context === "object" && event.context !== null && // context.cf properties
|
|
18
|
+
(hasCfAndCloudflare(event.context) || "_platform" in event.context && hasCfAndCloudflare(event.context._platform))
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
export function getCfProperties(event) {
|
|
22
|
+
if ("cf" in event.context) {
|
|
23
|
+
return event.context.cf;
|
|
24
|
+
}
|
|
25
|
+
return event.context._platform.cf;
|
|
26
|
+
}
|
|
27
|
+
export function getCloudflareProperties(event) {
|
|
28
|
+
if ("cloudflare" in event.context) {
|
|
29
|
+
return event.context.cloudflare;
|
|
30
|
+
}
|
|
31
|
+
return event.context._platform.cloudflare;
|
|
32
|
+
}
|
|
@@ -42,7 +42,7 @@ export function reportNuxtError(options) {
|
|
|
42
42
|
setTimeout(() => {
|
|
43
43
|
captureException(error, {
|
|
44
44
|
captureContext: { contexts: { nuxt: metadata } },
|
|
45
|
-
mechanism: { handled: false }
|
|
45
|
+
mechanism: { handled: false, type: `auto.function.nuxt.${instance ? "vue" : "app"}-error` }
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry-cloudflare.server.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry-cloudflare.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"sentry-cloudflare.server.d.ts","sourceRoot":"","sources":["../../../../src/runtime/plugins/sentry-cloudflare.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI5D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAO1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,2BAA2B,gDACQ,QAAQ,KAAK,iBAAiB,MAAI,cAiF/E,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CfProperties, ExecutionContext } from '@cloudflare/workers-types';
|
|
2
|
+
interface EventBase {
|
|
3
|
+
protocol: string;
|
|
4
|
+
host: string;
|
|
5
|
+
method: string;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
interface MinimalCloudflareProps {
|
|
9
|
+
context: ExecutionContext;
|
|
10
|
+
request?: Record<string, unknown>;
|
|
11
|
+
env?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
interface CloudflareContext {
|
|
14
|
+
cf: CfProperties;
|
|
15
|
+
cloudflare: MinimalCloudflareProps;
|
|
16
|
+
}
|
|
17
|
+
interface CfEventDirect extends EventBase {
|
|
18
|
+
context: CloudflareContext;
|
|
19
|
+
}
|
|
20
|
+
interface CfEventPlatform extends EventBase {
|
|
21
|
+
context: {
|
|
22
|
+
_platform: CloudflareContext;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export type CfEventType = CfEventDirect | CfEventPlatform;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if an event context object has cf properties
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasCfProperty(context: unknown): context is {
|
|
30
|
+
cf: CfProperties;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Type guard to check if an event is a Cloudflare event (nested in _platform or direct)
|
|
34
|
+
*/
|
|
35
|
+
export declare function isEventType(event: unknown): event is CfEventType;
|
|
36
|
+
/**
|
|
37
|
+
* Extracts cf properties from a Cloudflare event
|
|
38
|
+
*/
|
|
39
|
+
export declare function getCfProperties(event: CfEventType): CfProperties;
|
|
40
|
+
/**
|
|
41
|
+
* Extracts cloudflare properties from a Cloudflare event
|
|
42
|
+
*/
|
|
43
|
+
export declare function getCloudflareProperties(event: CfEventType): MinimalCloudflareProps;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=event-type-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-type-check.d.ts","sourceRoot":"","sources":["../../../../src/runtime/utils/event-type-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEhF,UAAU,SAAS;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,UAAU,sBAAsB;IAC9B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,UAAU,iBAAiB;IACzB,EAAE,EAAE,YAAY,CAAC;IACjB,UAAU,EAAE,sBAAsB,CAAC;CACpC;AAGD,UAAU,aAAc,SAAQ,SAAS;IACvC,OAAO,EAAE,iBAAiB,CAAC;CAC5B;AAID,UAAU,eAAgB,SAAQ,SAAS;IACzC,OAAO,EAAE;QACP,SAAS,EAAE,iBAAiB,CAAC;KAC9B,CAAC;CACH;AAED,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,eAAe,CAAC;AAc1D;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI;IAAE,EAAE,EAAE,YAAY,CAAA;CAAE,CAS/E;AAMD;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAgBhE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAKhE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,WAAW,GAAG,sBAAsB,CAKlF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/nuxt",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.13.0",
|
|
4
4
|
"description": "Official Sentry SDK for Nuxt",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/nuxt",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@nuxt/kit": "^3.13.2",
|
|
50
|
-
"@sentry/browser": "10.
|
|
51
|
-
"@sentry/cloudflare": "10.
|
|
52
|
-
"@sentry/core": "10.
|
|
53
|
-
"@sentry/node": "10.
|
|
54
|
-
"@sentry/rollup-plugin": "^4.
|
|
55
|
-
"@sentry/vite-plugin": "^4.
|
|
56
|
-
"@sentry/vue": "10.
|
|
50
|
+
"@sentry/browser": "10.13.0",
|
|
51
|
+
"@sentry/cloudflare": "10.13.0",
|
|
52
|
+
"@sentry/core": "10.13.0",
|
|
53
|
+
"@sentry/node": "10.13.0",
|
|
54
|
+
"@sentry/rollup-plugin": "^4.3.0",
|
|
55
|
+
"@sentry/vite-plugin": "^4.3.0",
|
|
56
|
+
"@sentry/vue": "10.13.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@nuxt/module-builder": "^0.8.4",
|