@sentry/solidstart 11.12.0 → 11.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/cjs/_virtual/_rolldown/runtime.js +34 -0
- package/build/cjs/client/index.js +11 -18
- package/build/cjs/client/sdk.js +19 -20
- package/build/cjs/client/sdk.js.map +1 -1
- package/build/cjs/client/solidrouter.js +8 -16
- package/build/cjs/common/tunnel.js +11 -8
- package/build/cjs/common/tunnel.js.map +1 -1
- package/build/cjs/config/addInstrumentation.js +110 -111
- package/build/cjs/config/addInstrumentation.js.map +1 -1
- package/build/cjs/config/index.js +2 -0
- package/build/cjs/config/withSentry.js +86 -87
- package/build/cjs/config/withSentry.js.map +1 -1
- package/build/cjs/config/wrapServerEntryWithDynamicImport.js +139 -135
- package/build/cjs/config/wrapServerEntryWithDynamicImport.js.map +1 -1
- package/build/cjs/index.client.js +12 -18
- package/build/cjs/index.server.js +162 -159
- package/build/cjs/index.server.js.map +1 -1
- package/build/cjs/nitro/tunnelPlugin.js +12 -10
- package/build/cjs/nitro/tunnelPlugin.js.map +1 -1
- package/build/cjs/server/index.js +151 -158
- package/build/cjs/server/middleware.js +26 -37
- package/build/cjs/server/middleware.js.map +1 -1
- package/build/cjs/server/sdk.js +13 -14
- package/build/cjs/server/sdk.js.map +1 -1
- package/build/cjs/server/solidrouter.js +26 -18
- package/build/cjs/server/solidrouter.js.map +1 -1
- package/build/cjs/server/utils.js +32 -27
- package/build/cjs/server/utils.js.map +1 -1
- package/build/cjs/server/withServerActionInstrumentation.js +46 -49
- package/build/cjs/server/withServerActionInstrumentation.js.map +1 -1
- package/build/cjs/solidrouter.client.js +9 -16
- package/build/cjs/solidrouter.js +12 -18
- package/build/cjs/solidrouter.server.js +3 -8
- package/build/cjs/vite/buildInstrumentationFile.js +46 -46
- package/build/cjs/vite/buildInstrumentationFile.js.map +1 -1
- package/build/cjs/vite/index.js +5 -10
- package/build/cjs/vite/sentrySolidStart.js +86 -39
- package/build/cjs/vite/sentrySolidStart.js.map +1 -1
- package/build/cjs/vite/sentrySolidStartVite.js +32 -35
- package/build/cjs/vite/sentrySolidStartVite.js.map +1 -1
- package/build/cjs/vite/sourceMaps.js +117 -152
- package/build/cjs/vite/sourceMaps.js.map +1 -1
- package/build/esm/client/index.js +2 -3
- package/build/esm/client/sdk.js +19 -18
- package/build/esm/client/sdk.js.map +1 -1
- package/build/esm/client/solidrouter.js +1 -2
- package/build/esm/common/tunnel.js +11 -6
- package/build/esm/common/tunnel.js.map +1 -1
- package/build/esm/config/addInstrumentation.js +107 -109
- package/build/esm/config/addInstrumentation.js.map +1 -1
- package/build/esm/config/index.js +1 -0
- package/build/esm/config/withSentry.js +86 -84
- package/build/esm/config/withSentry.js.map +1 -1
- package/build/esm/config/wrapServerEntryWithDynamicImport.js +139 -133
- package/build/esm/config/wrapServerEntryWithDynamicImport.js.map +1 -1
- package/build/esm/index.client.js +3 -3
- package/build/esm/index.server.js +14 -10
- package/build/esm/index.server.js.map +1 -1
- package/build/esm/nitro/tunnelPlugin.js +12 -10
- package/build/esm/nitro/tunnelPlugin.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/server/index.js +7 -7
- package/build/esm/server/middleware.js +26 -35
- package/build/esm/server/middleware.js.map +1 -1
- package/build/esm/server/sdk.js +13 -12
- package/build/esm/server/sdk.js.map +1 -1
- package/build/esm/server/solidrouter.js +25 -16
- package/build/esm/server/solidrouter.js.map +1 -1
- package/build/esm/server/utils.js +32 -25
- package/build/esm/server/utils.js.map +1 -1
- package/build/esm/server/withServerActionInstrumentation.js +46 -47
- package/build/esm/server/withServerActionInstrumentation.js.map +1 -1
- package/build/esm/solidrouter.client.js +2 -2
- package/build/esm/solidrouter.js +3 -3
- package/build/esm/solidrouter.server.js +1 -2
- package/build/esm/vite/buildInstrumentationFile.js +43 -44
- package/build/esm/vite/buildInstrumentationFile.js.map +1 -1
- package/build/esm/vite/index.js +3 -3
- package/build/esm/vite/sentrySolidStart.js +86 -37
- package/build/esm/vite/sentrySolidStart.js.map +1 -1
- package/build/esm/vite/sentrySolidStartVite.js +32 -33
- package/build/esm/vite/sentrySolidStartVite.js.map +1 -1
- package/build/esm/vite/sourceMaps.js +117 -150
- package/build/esm/vite/sourceMaps.js.map +1 -1
- package/package.json +20 -20
- package/build/cjs/client/index.js.map +0 -1
- package/build/cjs/client/solidrouter.js.map +0 -1
- package/build/cjs/index.client.js.map +0 -1
- package/build/cjs/server/index.js.map +0 -1
- package/build/cjs/solidrouter.client.js.map +0 -1
- package/build/cjs/solidrouter.js.map +0 -1
- package/build/cjs/solidrouter.server.js.map +0 -1
- package/build/cjs/vite/index.js.map +0 -1
- package/build/esm/client/index.js.map +0 -1
- package/build/esm/client/solidrouter.js.map +0 -1
- package/build/esm/index.client.js.map +0 -1
- package/build/esm/server/index.js.map +0 -1
- package/build/esm/solidrouter.client.js.map +0 -1
- package/build/esm/solidrouter.js.map +0 -1
- package/build/esm/solidrouter.server.js.map +0 -1
- package/build/esm/vite/index.js.map +0 -1
|
@@ -1,152 +1,158 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { consoleSandbox } from "@sentry/core";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
+
import { basename } from "node:path";
|
|
4
|
+
// src/config/wrapServerEntryWithDynamicImport.ts
|
|
5
|
+
/** THIS FILE IS AN UTILITY FOR NITRO-BASED PACKAGES AND SHOULD BE KEPT IN SYNC IN NUXT, SOLIDSTART, ETC. */
|
|
5
6
|
const SENTRY_WRAPPED_ENTRY = "?sentry-query-wrapped-entry";
|
|
6
7
|
const SENTRY_WRAPPED_FUNCTIONS = "?sentry-query-wrapped-functions=";
|
|
7
8
|
const SENTRY_REEXPORTED_FUNCTIONS = "?sentry-query-reexported-functions=";
|
|
8
9
|
const QUERY_END_INDICATOR = "SENTRY-QUERY-END";
|
|
10
|
+
/**
|
|
11
|
+
* `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows
|
|
12
|
+
* paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands
|
|
13
|
+
* filesystem paths. Returns `undefined` for a malformed `file://` URL.
|
|
14
|
+
*
|
|
15
|
+
* **Only exported for testing**
|
|
16
|
+
*/
|
|
9
17
|
function toResolvablePath(source) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
if (!source.startsWith("file://")) return {
|
|
19
|
+
path: source,
|
|
20
|
+
wasFileUrl: false
|
|
21
|
+
};
|
|
22
|
+
if (source === "file://" || source === "file:///") return;
|
|
23
|
+
try {
|
|
24
|
+
const filePath = fileURLToPath(source);
|
|
25
|
+
if (!filePath || filePath === "/" || filePath === "\\") return;
|
|
26
|
+
return {
|
|
27
|
+
path: filePath,
|
|
28
|
+
wasFileUrl: true
|
|
29
|
+
};
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
|
-
const CONFIG_EXTENSIONS = [
|
|
34
|
+
const CONFIG_EXTENSIONS = [
|
|
35
|
+
".ts",
|
|
36
|
+
".js",
|
|
37
|
+
".mjs",
|
|
38
|
+
".cjs",
|
|
39
|
+
".mts",
|
|
40
|
+
".cts"
|
|
41
|
+
];
|
|
27
42
|
function isServerConfigFile(sourcePath, resolvedPath, configFileName) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const name = basename(sourcePath);
|
|
32
|
-
return name === configFileName || CONFIG_EXTENSIONS.some((ext) => name === `${configFileName}${ext}`);
|
|
43
|
+
if (sourcePath === resolvedPath) return true;
|
|
44
|
+
const name = basename(sourcePath);
|
|
45
|
+
return name === configFileName || CONFIG_EXTENSIONS.some((ext) => name === `${configFileName}${ext}`);
|
|
33
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first
|
|
49
|
+
* by using a regular `import` and load the server after that.
|
|
50
|
+
* This also works with serverless `handler` functions, as it re-exports the `handler`.
|
|
51
|
+
*
|
|
52
|
+
* @param config Configuration options for the Rollup Plugin
|
|
53
|
+
* @param config.serverConfigFileName Name of the Sentry server config (without file extension). E.g. 'sentry.server.config'
|
|
54
|
+
* @param config.serverEntrypointFileName The server entrypoint (with file extension). Usually, this is defined by the Nitro preset and is something like 'node-server.mjs'
|
|
55
|
+
* @param config.resolvedServerConfigPath Resolved path of the Sentry server config (based on `src` directory)
|
|
56
|
+
* @param config.entryPointWrappedFunctions Exported bindings of the server entry file, which are wrapped as async function. E.g. ['default', 'handler', 'server']
|
|
57
|
+
* @param config.debug Whether debug logs are enabled in the build time environment
|
|
58
|
+
*/
|
|
34
59
|
function wrapServerEntryWithDynamicImport(config) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const reExportedFunctions = id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS) ? constructFunctionReExport(id, entryIdUrl) : "";
|
|
76
|
-
return (
|
|
77
|
-
// Regular `import` of the Sentry config
|
|
78
|
-
`import ${JSON.stringify(configUrl)};
|
|
79
|
-
import(${JSON.stringify(entryIdUrl)});
|
|
80
|
-
${reExportedFunctions}
|
|
81
|
-
`
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
60
|
+
const { serverConfigFileName, serverEntrypointFileName, resolvedServerConfigPath, entrypointWrappedFunctions, debug } = config;
|
|
61
|
+
const resolutionIdPrefix = "\0raw";
|
|
62
|
+
return {
|
|
63
|
+
name: "sentry-wrap-server-entry-with-dynamic-import",
|
|
64
|
+
async resolveId(source, importer, options) {
|
|
65
|
+
const resolvable = toResolvablePath(source);
|
|
66
|
+
if (!resolvable) return null;
|
|
67
|
+
const { path: normalizedSource, wasFileUrl } = resolvable;
|
|
68
|
+
if (isServerConfigFile(normalizedSource, resolvedServerConfigPath, serverConfigFileName)) return {
|
|
69
|
+
id: normalizedSource,
|
|
70
|
+
moduleSideEffects: true
|
|
71
|
+
};
|
|
72
|
+
if (options.isEntry && normalizedSource.includes(serverEntrypointFileName) && normalizedSource.includes(".mjs") && !normalizedSource.includes(`.mjs?sentry-query-wrapped-entry`)) {
|
|
73
|
+
const resolution = await this.resolve(normalizedSource, importer, options);
|
|
74
|
+
if (!resolution || resolution?.external) return resolution;
|
|
75
|
+
const moduleInfo = await this.load(resolution);
|
|
76
|
+
moduleInfo.moduleSideEffects = true;
|
|
77
|
+
return resolution.id.includes(`.mjs?sentry-query-wrapped-entry`) ? resolution.id : `${resolutionIdPrefix}${resolution.id.concat(SENTRY_WRAPPED_ENTRY).concat(constructWrappedFunctionExportQuery(moduleInfo.exportedBindings, entrypointWrappedFunctions, debug)).concat(QUERY_END_INDICATOR)}`;
|
|
78
|
+
}
|
|
79
|
+
if (wasFileUrl) {
|
|
80
|
+
const resolved = await this.resolve(normalizedSource, importer, {
|
|
81
|
+
...options,
|
|
82
|
+
isEntry: false
|
|
83
|
+
});
|
|
84
|
+
if (resolved) return resolved;
|
|
85
|
+
return { id: normalizedSource };
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
},
|
|
89
|
+
load(id) {
|
|
90
|
+
if (id.includes(`.mjs?sentry-query-wrapped-entry`)) {
|
|
91
|
+
const entryId = removeSentryQueryFromPath(id).slice(4);
|
|
92
|
+
const entryIdUrl = pathToFileURL(entryId).href;
|
|
93
|
+
const configUrl = pathToFileURL(resolvedServerConfigPath).href;
|
|
94
|
+
const reExportedFunctions = id.includes("?sentry-query-wrapped-functions=") || id.includes("?sentry-query-reexported-functions=") ? constructFunctionReExport(id, entryIdUrl) : "";
|
|
95
|
+
return `import ${JSON.stringify(configUrl)};\nimport(${JSON.stringify(entryIdUrl)});\n${reExportedFunctions}\n`;
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
87
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Strips the Sentry query part from a path.
|
|
103
|
+
* Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path
|
|
104
|
+
*
|
|
105
|
+
* **Only exported for testing**
|
|
106
|
+
*/
|
|
88
107
|
function removeSentryQueryFromPath(url) {
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
const regex = new RegExp(`\\${SENTRY_WRAPPED_ENTRY}.*?\\${QUERY_END_INDICATOR}`);
|
|
109
|
+
return url.replace(regex, "");
|
|
91
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Extracts and sanitizes function re-export and function wrap query parameters from a query string.
|
|
113
|
+
* If it is a default export, it is not considered for re-exporting.
|
|
114
|
+
*
|
|
115
|
+
* **Only exported for testing**
|
|
116
|
+
*/
|
|
92
117
|
function extractFunctionReexportQueryParameters(query) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return { wrap, reexport };
|
|
118
|
+
const wrapRegex = new RegExp(`\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\${QUERY_END_INDICATOR}|\\${SENTRY_REEXPORTED_FUNCTIONS})`);
|
|
119
|
+
const reexportRegex = new RegExp(`\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\${QUERY_END_INDICATOR})`);
|
|
120
|
+
const wrapMatch = query.match(wrapRegex);
|
|
121
|
+
const reexportMatch = query.match(reexportRegex);
|
|
122
|
+
return {
|
|
123
|
+
wrap: wrapMatch?.[1] ? wrapMatch[1].split(",").filter((param) => param !== "").map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) : [],
|
|
124
|
+
reexport: reexportMatch?.[1] ? reexportMatch[1].split(",").filter((param) => param !== "" && param !== "default").map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) : []
|
|
125
|
+
};
|
|
102
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.
|
|
129
|
+
* It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped
|
|
130
|
+
* (e.g. serverless handlers) are wrapped by Sentry.
|
|
131
|
+
*
|
|
132
|
+
* **Only exported for testing**
|
|
133
|
+
*/
|
|
103
134
|
function constructWrappedFunctionExportQuery(exportedBindings, entrypointWrappedFunctions, debug) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
);
|
|
117
|
-
if (debug && functionsToExport.wrap.length === 0) {
|
|
118
|
-
consoleSandbox(
|
|
119
|
-
() => (
|
|
120
|
-
// eslint-disable-next-line no-console
|
|
121
|
-
console.warn(
|
|
122
|
-
"[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to `entrypointWrappedFunctions`."
|
|
123
|
-
)
|
|
124
|
-
)
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
const wrapQuery = functionsToExport.wrap.length ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(",")}` : "";
|
|
128
|
-
const reexportQuery = functionsToExport.reexport.length ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(",")}` : "";
|
|
129
|
-
return [wrapQuery, reexportQuery].join("");
|
|
135
|
+
const functionsToExport = {
|
|
136
|
+
wrap: [],
|
|
137
|
+
reexport: []
|
|
138
|
+
};
|
|
139
|
+
Object.values(exportedBindings || {}).forEach((functions) => functions.forEach((fn) => {
|
|
140
|
+
if (entrypointWrappedFunctions.includes(fn)) functionsToExport.wrap.push(fn);
|
|
141
|
+
else functionsToExport.reexport.push(fn);
|
|
142
|
+
}));
|
|
143
|
+
if (debug && functionsToExport.wrap.length === 0) consoleSandbox(() => console.warn("[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to `entrypointWrappedFunctions`."));
|
|
144
|
+
return [functionsToExport.wrap.length ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(",")}` : "", functionsToExport.reexport.length ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(",")}` : ""].join("");
|
|
130
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)
|
|
148
|
+
*
|
|
149
|
+
* **Only exported for testing**
|
|
150
|
+
*/
|
|
131
151
|
function constructFunctionReExport(pathWithQuery, entryId) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
`async function ${currFunctionName}_sentryWrapped(...args) {
|
|
136
|
-
const res = await import(${JSON.stringify(entryId)});
|
|
137
|
-
return res.${currFunctionName}.call(this, ...args);
|
|
138
|
-
}
|
|
139
|
-
export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };
|
|
140
|
-
`
|
|
141
|
-
),
|
|
142
|
-
""
|
|
143
|
-
).concat(
|
|
144
|
-
reexportFunctions.reduce(
|
|
145
|
-
(functionsCode, currFunctionName) => functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),
|
|
146
|
-
""
|
|
147
|
-
)
|
|
148
|
-
);
|
|
152
|
+
const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);
|
|
153
|
+
return wrapFunctions.reduce((functionsCode, currFunctionName) => functionsCode.concat(`async function ${currFunctionName}_sentryWrapped(...args) {\n const res = await import(${JSON.stringify(entryId)});\n return res.${currFunctionName}.call(this, ...args);\n}
|
|
154
|
+
export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\n`), "").concat(reexportFunctions.reduce((functionsCode, currFunctionName) => functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`), ""));
|
|
149
155
|
}
|
|
150
|
-
|
|
151
156
|
export { QUERY_END_INDICATOR, SENTRY_REEXPORTED_FUNCTIONS, SENTRY_WRAPPED_ENTRY, SENTRY_WRAPPED_FUNCTIONS, constructFunctionReExport, constructWrappedFunctionExportQuery, extractFunctionReexportQueryParameters, removeSentryQueryFromPath, toResolvablePath, wrapServerEntryWithDynamicImport };
|
|
152
|
-
|
|
157
|
+
|
|
158
|
+
//# sourceMappingURL=wrapServerEntryWithDynamicImport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapServerEntryWithDynamicImport.js","sources":["../../../src/config/wrapServerEntryWithDynamicImport.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { consoleSandbox } from '@sentry/core';\nimport type { InputPluginOption } from 'rollup';\n\n/** THIS FILE IS AN UTILITY FOR NITRO-BASED PACKAGES AND SHOULD BE KEPT IN SYNC IN NUXT, SOLIDSTART, ETC. */\n\nexport const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';\nexport const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';\nexport const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';\nexport const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';\n\n/**\n * `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows\n * paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands\n * filesystem paths. Returns `undefined` for a malformed `file://` URL.\n *\n * **Only exported for testing**\n */\nexport function toResolvablePath(source: string): { path: string; wasFileUrl: boolean } | undefined {\n if (!source.startsWith('file://')) {\n return { path: source, wasFileUrl: false };\n }\n if (source === 'file://' || source === 'file:///') {\n return undefined;\n }\n try {\n const filePath = fileURLToPath(source);\n if (!filePath || filePath === '/' || filePath === '\\\\') {\n return undefined;\n }\n return { path: filePath, wasFileUrl: true };\n } catch {\n return undefined;\n }\n}\n\nconst CONFIG_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs', '.mts', '.cts'];\n\nfunction isServerConfigFile(sourcePath: string, resolvedPath: string, configFileName: string): boolean {\n if (sourcePath === resolvedPath) {\n return true;\n }\n const name = basename(sourcePath);\n return name === configFileName || CONFIG_EXTENSIONS.some(ext => name === `${configFileName}${ext}`);\n}\n\nexport type WrapServerEntryPluginOptions = {\n serverEntrypointFileName: string;\n serverConfigFileName: string;\n resolvedServerConfigPath: string;\n entrypointWrappedFunctions: string[];\n debug?: boolean;\n};\n\n/**\n * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first\n * by using a regular `import` and load the server after that.\n * This also works with serverless `handler` functions, as it re-exports the `handler`.\n *\n * @param config Configuration options for the Rollup Plugin\n * @param config.serverConfigFileName Name of the Sentry server config (without file extension). E.g. 'sentry.server.config'\n * @param config.serverEntrypointFileName The server entrypoint (with file extension). Usually, this is defined by the Nitro preset and is something like 'node-server.mjs'\n * @param config.resolvedServerConfigPath Resolved path of the Sentry server config (based on `src` directory)\n * @param config.entryPointWrappedFunctions Exported bindings of the server entry file, which are wrapped as async function. E.g. ['default', 'handler', 'server']\n * @param config.debug Whether debug logs are enabled in the build time environment\n */\nexport function wrapServerEntryWithDynamicImport(config: WrapServerEntryPluginOptions): InputPluginOption {\n const {\n serverConfigFileName,\n serverEntrypointFileName,\n resolvedServerConfigPath,\n entrypointWrappedFunctions,\n debug,\n } = config;\n\n // In order to correctly import the server config file\n // and dynamically import the nitro runtime, we need to\n // mark the resolutionId with '\\0raw' to fall into the\n // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142\n const resolutionIdPrefix = '\\0raw';\n\n return {\n name: 'sentry-wrap-server-entry-with-dynamic-import',\n async resolveId(source, importer, options) {\n // `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows paths,\n // but Rollup's resolver only understands filesystem paths.\n const resolvable = toResolvablePath(source);\n if (!resolvable) {\n return null;\n }\n const { path: normalizedSource, wasFileUrl } = resolvable;\n\n if (isServerConfigFile(normalizedSource, resolvedServerConfigPath, serverConfigFileName)) {\n return { id: normalizedSource, moduleSideEffects: true };\n }\n\n if (\n options.isEntry &&\n normalizedSource.includes(serverEntrypointFileName) &&\n normalizedSource.includes('.mjs') &&\n !normalizedSource.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ) {\n const resolution = await this.resolve(normalizedSource, importer, options);\n\n // If it cannot be resolved or is external, just return it so that Rollup can display an error\n if (!resolution || resolution?.external) return resolution;\n\n const moduleInfo = await this.load(resolution);\n\n moduleInfo.moduleSideEffects = true;\n\n // The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix\n return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ? resolution.id\n : `${resolutionIdPrefix}${resolution.id\n // Concatenates the query params to mark the file (also attaches names of re-exports - this is needed for serverless functions to re-export the handler)\n .concat(SENTRY_WRAPPED_ENTRY)\n .concat(\n constructWrappedFunctionExportQuery(moduleInfo.exportedBindings, entrypointWrappedFunctions, debug),\n )\n .concat(QUERY_END_INDICATOR)}`;\n }\n\n // Pass isEntry:false to avoid double-wrapping (normalizedSource lacks query suffix).\n if (wasFileUrl) {\n const resolved = await this.resolve(normalizedSource, importer, { ...options, isEntry: false });\n if (resolved) return resolved;\n return { id: normalizedSource };\n }\n\n return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n const entryIdUrl = pathToFileURL(entryId).href;\n const configUrl = pathToFileURL(resolvedServerConfigPath).href;\n\n // Use entryIdUrl so Node's runtime ESM loader receives file:// on Windows; Rollup normalizes it in resolveId.\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryIdUrl)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(configUrl)};\\n` +\n // Dynamic `import()` for the previous, actual entry point.\n // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)\n `import(${JSON.stringify(entryIdUrl)});\\n` +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n\n/**\n * Strips the Sentry query part from a path.\n * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path\n *\n * **Only exported for testing**\n */\nexport function removeSentryQueryFromPath(url: string): string {\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const regex = new RegExp(`\\\\${SENTRY_WRAPPED_ENTRY}.*?\\\\${QUERY_END_INDICATOR}`);\n return url.replace(regex, '');\n}\n\n/**\n * Extracts and sanitizes function re-export and function wrap query parameters from a query string.\n * If it is a default export, it is not considered for re-exporting.\n *\n * **Only exported for testing**\n */\nexport function extractFunctionReexportQueryParameters(query: string): { wrap: string[]; reexport: string[] } {\n // Regex matches the comma-separated params between the functions query\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const wrapRegex = new RegExp(\n `\\\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR}|\\\\${SENTRY_REEXPORTED_FUNCTIONS})`,\n );\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const reexportRegex = new RegExp(`\\\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR})`);\n\n const wrapMatch = query.match(wrapRegex);\n const reexportMatch = query.match(reexportRegex);\n\n const wrap = wrapMatch?.[1]\n ? wrapMatch[1]\n .split(',')\n .filter(param => param !== '')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n : [];\n\n const reexport = reexportMatch?.[1]\n ? reexportMatch[1]\n .split(',')\n .filter(param => param !== '' && param !== 'default')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n : [];\n\n return { wrap, reexport };\n}\n\n/**\n * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.\n * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped\n * (e.g. serverless handlers) are wrapped by Sentry.\n *\n * **Only exported for testing**\n */\nexport function constructWrappedFunctionExportQuery(\n exportedBindings: Record<string, string[]> | null,\n entrypointWrappedFunctions: string[],\n debug?: boolean,\n): string {\n const functionsToExport: { wrap: string[]; reexport: string[] } = {\n wrap: [],\n reexport: [],\n };\n\n // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`\n // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.\n Object.values(exportedBindings || {}).forEach(functions =>\n functions.forEach(fn => {\n if (entrypointWrappedFunctions.includes(fn)) {\n functionsToExport.wrap.push(fn);\n } else {\n functionsToExport.reexport.push(fn);\n }\n }),\n );\n\n if (debug && functionsToExport.wrap.length === 0) {\n consoleSandbox(() =>\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to `entrypointWrappedFunctions`.',\n ),\n );\n }\n\n const wrapQuery = functionsToExport.wrap.length\n ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`\n : '';\n const reexportQuery = functionsToExport.reexport.length\n ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`\n : '';\n\n return [wrapQuery, reexportQuery].join('');\n}\n\n/**\n * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)\n *\n * **Only exported for testing**\n */\nexport function constructFunctionReExport(pathWithQuery: string, entryId: string): string {\n const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);\n\n return wrapFunctions\n .reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(\n `async function ${currFunctionName}_sentryWrapped(...args) {\\n` +\n ` const res = await import(${JSON.stringify(entryId)});\\n` +\n ` return res.${currFunctionName}.call(this, ...args);\\n` +\n '}\\n' +\n `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\\n`,\n ),\n '',\n )\n .concat(\n reexportFunctions.reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),\n '',\n ),\n );\n}\n"],"names":[],"mappings":";;;;AAOO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,wBAAA,GAA2B;AACjC,MAAM,2BAAA,GAA8B;AACpC,MAAM,mBAAA,GAAsB;AAS5B,SAAS,iBAAiB,MAAA,EAAmE;AAClG,EAAA,IAAI,CAAC,MAAA,CAAO,UAAA,CAAW,SAAS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AAA,KACd,aAAA,CAAc,MAAA;AAAA,MACZ,kBAAkB,gBAAgB,CAAA;AAAA,2BAAA,EACF,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA;AAAA,aAAA,EACrC,gBAAgB,CAAA;AAAA;AAAA,SAAA,EAEpB,gBAAgB,qBAAqB,gBAAgB,CAAA;AAAA;AAAA,KACrE;AAAA,IACF;AAAA,GACF,CACC,MAAA;AAAA,IACC,iBAAA,CAAkB,MAAA;AAAA,MAChB,CAAC,aAAA,EAAe,gBAAA,KACd,aAAA,CAAc,MAAA,CAAO,CAAA,SAAA,EAAY,gBAAgB,CAAA,QAAA,EAAW,IAAA,CAAK,SAAA,CAAU,OAAO,CAAC,CAAA,CAAA,CAAG,CAAA;AAAA,MACxF;AAAA;AACF,GACF;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"wrapServerEntryWithDynamicImport.js","names":[],"sources":["../../../src/config/wrapServerEntryWithDynamicImport.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { consoleSandbox } from '@sentry/core';\nimport type { InputPluginOption } from 'rollup';\n\n/** THIS FILE IS AN UTILITY FOR NITRO-BASED PACKAGES AND SHOULD BE KEPT IN SYNC IN NUXT, SOLIDSTART, ETC. */\n\nexport const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';\nexport const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';\nexport const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';\nexport const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';\n\n/**\n * `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows\n * paths (`ERR_UNSUPPORTED_ESM_URL_SCHEME`), but Rollup's resolver only understands\n * filesystem paths. Returns `undefined` for a malformed `file://` URL.\n *\n * **Only exported for testing**\n */\nexport function toResolvablePath(source: string): { path: string; wasFileUrl: boolean } | undefined {\n if (!source.startsWith('file://')) {\n return { path: source, wasFileUrl: false };\n }\n if (source === 'file://' || source === 'file:///') {\n return undefined;\n }\n try {\n const filePath = fileURLToPath(source);\n if (!filePath || filePath === '/' || filePath === '\\\\') {\n return undefined;\n }\n return { path: filePath, wasFileUrl: true };\n } catch {\n return undefined;\n }\n}\n\nconst CONFIG_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs', '.mts', '.cts'];\n\nfunction isServerConfigFile(sourcePath: string, resolvedPath: string, configFileName: string): boolean {\n if (sourcePath === resolvedPath) {\n return true;\n }\n const name = basename(sourcePath);\n return name === configFileName || CONFIG_EXTENSIONS.some(ext => name === `${configFileName}${ext}`);\n}\n\nexport type WrapServerEntryPluginOptions = {\n serverEntrypointFileName: string;\n serverConfigFileName: string;\n resolvedServerConfigPath: string;\n entrypointWrappedFunctions: string[];\n debug?: boolean;\n};\n\n/**\n * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first\n * by using a regular `import` and load the server after that.\n * This also works with serverless `handler` functions, as it re-exports the `handler`.\n *\n * @param config Configuration options for the Rollup Plugin\n * @param config.serverConfigFileName Name of the Sentry server config (without file extension). E.g. 'sentry.server.config'\n * @param config.serverEntrypointFileName The server entrypoint (with file extension). Usually, this is defined by the Nitro preset and is something like 'node-server.mjs'\n * @param config.resolvedServerConfigPath Resolved path of the Sentry server config (based on `src` directory)\n * @param config.entryPointWrappedFunctions Exported bindings of the server entry file, which are wrapped as async function. E.g. ['default', 'handler', 'server']\n * @param config.debug Whether debug logs are enabled in the build time environment\n */\nexport function wrapServerEntryWithDynamicImport(config: WrapServerEntryPluginOptions): InputPluginOption {\n const {\n serverConfigFileName,\n serverEntrypointFileName,\n resolvedServerConfigPath,\n entrypointWrappedFunctions,\n debug,\n } = config;\n\n // In order to correctly import the server config file\n // and dynamically import the nitro runtime, we need to\n // mark the resolutionId with '\\0raw' to fall into the\n // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142\n const resolutionIdPrefix = '\\0raw';\n\n return {\n name: 'sentry-wrap-server-entry-with-dynamic-import',\n async resolveId(source, importer, options) {\n // `load()` emits `file://` specifiers because Node's ESM loader rejects bare Windows paths,\n // but Rollup's resolver only understands filesystem paths.\n const resolvable = toResolvablePath(source);\n if (!resolvable) {\n return null;\n }\n const { path: normalizedSource, wasFileUrl } = resolvable;\n\n if (isServerConfigFile(normalizedSource, resolvedServerConfigPath, serverConfigFileName)) {\n return { id: normalizedSource, moduleSideEffects: true };\n }\n\n if (\n options.isEntry &&\n normalizedSource.includes(serverEntrypointFileName) &&\n normalizedSource.includes('.mjs') &&\n !normalizedSource.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ) {\n const resolution = await this.resolve(normalizedSource, importer, options);\n\n // If it cannot be resolved or is external, just return it so that Rollup can display an error\n if (!resolution || resolution?.external) return resolution;\n\n const moduleInfo = await this.load(resolution);\n\n moduleInfo.moduleSideEffects = true;\n\n // The enclosing `if` already checks for the suffix in `source`, but a check in `resolution.id` is needed as well to prevent multiple attachment of the suffix\n return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ? resolution.id\n : `${resolutionIdPrefix}${resolution.id\n // Concatenates the query params to mark the file (also attaches names of re-exports - this is needed for serverless functions to re-export the handler)\n .concat(SENTRY_WRAPPED_ENTRY)\n .concat(\n constructWrappedFunctionExportQuery(moduleInfo.exportedBindings, entrypointWrappedFunctions, debug),\n )\n .concat(QUERY_END_INDICATOR)}`;\n }\n\n // Pass isEntry:false to avoid double-wrapping (normalizedSource lacks query suffix).\n if (wasFileUrl) {\n const resolved = await this.resolve(normalizedSource, importer, { ...options, isEntry: false });\n if (resolved) return resolved;\n return { id: normalizedSource };\n }\n\n return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n const entryIdUrl = pathToFileURL(entryId).href;\n const configUrl = pathToFileURL(resolvedServerConfigPath).href;\n\n // Use entryIdUrl so Node's runtime ESM loader receives file:// on Windows; Rollup normalizes it in resolveId.\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryIdUrl)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(configUrl)};\\n` +\n // Dynamic `import()` for the previous, actual entry point.\n // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)\n `import(${JSON.stringify(entryIdUrl)});\\n` +\n `${reExportedFunctions}\\n`\n );\n }\n\n return null;\n },\n };\n}\n\n/**\n * Strips the Sentry query part from a path.\n * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path\n *\n * **Only exported for testing**\n */\nexport function removeSentryQueryFromPath(url: string): string {\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const regex = new RegExp(`\\\\${SENTRY_WRAPPED_ENTRY}.*?\\\\${QUERY_END_INDICATOR}`);\n return url.replace(regex, '');\n}\n\n/**\n * Extracts and sanitizes function re-export and function wrap query parameters from a query string.\n * If it is a default export, it is not considered for re-exporting.\n *\n * **Only exported for testing**\n */\nexport function extractFunctionReexportQueryParameters(query: string): { wrap: string[]; reexport: string[] } {\n // Regex matches the comma-separated params between the functions query\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const wrapRegex = new RegExp(\n `\\\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR}|\\\\${SENTRY_REEXPORTED_FUNCTIONS})`,\n );\n // oxlint-disable-next-line sdk/no-regexp-constructor\n const reexportRegex = new RegExp(`\\\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\\\${QUERY_END_INDICATOR})`);\n\n const wrapMatch = query.match(wrapRegex);\n const reexportMatch = query.match(reexportRegex);\n\n const wrap = wrapMatch?.[1]\n ? wrapMatch[1]\n .split(',')\n .filter(param => param !== '')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n : [];\n\n const reexport = reexportMatch?.[1]\n ? reexportMatch[1]\n .split(',')\n .filter(param => param !== '' && param !== 'default')\n // Sanitize, as code could be injected with another rollup plugin\n .map((str: string) => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n : [];\n\n return { wrap, reexport };\n}\n\n/**\n * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.\n * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped\n * (e.g. serverless handlers) are wrapped by Sentry.\n *\n * **Only exported for testing**\n */\nexport function constructWrappedFunctionExportQuery(\n exportedBindings: Record<string, string[]> | null,\n entrypointWrappedFunctions: string[],\n debug?: boolean,\n): string {\n const functionsToExport: { wrap: string[]; reexport: string[] } = {\n wrap: [],\n reexport: [],\n };\n\n // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`\n // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.\n Object.values(exportedBindings || {}).forEach(functions =>\n functions.forEach(fn => {\n if (entrypointWrappedFunctions.includes(fn)) {\n functionsToExport.wrap.push(fn);\n } else {\n functionsToExport.reexport.push(fn);\n }\n }),\n );\n\n if (debug && functionsToExport.wrap.length === 0) {\n consoleSandbox(() =>\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] No functions found to wrap. In case the server needs to export async functions other than `handler` or `server`, consider adding the name(s) to `entrypointWrappedFunctions`.',\n ),\n );\n }\n\n const wrapQuery = functionsToExport.wrap.length\n ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`\n : '';\n const reexportQuery = functionsToExport.reexport.length\n ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`\n : '';\n\n return [wrapQuery, reexportQuery].join('');\n}\n\n/**\n * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)\n *\n * **Only exported for testing**\n */\nexport function constructFunctionReExport(pathWithQuery: string, entryId: string): string {\n const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);\n\n return wrapFunctions\n .reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(\n `async function ${currFunctionName}_sentryWrapped(...args) {\\n` +\n ` const res = await import(${JSON.stringify(entryId)});\\n` +\n ` return res.${currFunctionName}.call(this, ...args);\\n` +\n '}\\n' +\n `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\\n`,\n ),\n '',\n )\n .concat(\n reexportFunctions.reduce(\n (functionsCode, currFunctionName) =>\n functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),\n '',\n ),\n );\n}\n"],"mappings":";;;;;AAOA,MAAa,uBAAuB;AACpC,MAAa,2BAA2B;AACxC,MAAa,8BAA8B;AAC3C,MAAa,sBAAsB;;;;;;;;AASnC,SAAgB,iBAAiB,QAAmE;CAClG,IAAI,CAAC,OAAO,WAAW,SAAS,GAC9B,OAAO;EAAE,MAAM;EAAQ,YAAY;CAAM;CAE3C,IAAI,WAAW,aAAa,WAAW,YACrC;CAEF,IAAI;EACF,MAAM,WAAW,cAAc,MAAM;EACrC,IAAI,CAAC,YAAY,aAAa,OAAO,aAAa,MAChD;EAEF,OAAO;GAAE,MAAM;GAAU,YAAY;EAAK;CAC5C,QAAQ;EACN;CACF;AACF;AAEA,MAAM,oBAAoB;CAAC;CAAO;CAAO;CAAQ;CAAQ;CAAQ;AAAM;AAEvE,SAAS,mBAAmB,YAAoB,cAAsB,gBAAiC;CACrG,IAAI,eAAe,cACjB,OAAO;CAET,MAAM,OAAO,SAAS,UAAU;CAChC,OAAO,SAAS,kBAAkB,kBAAkB,MAAK,QAAO,S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E,GACxC,kBAAkB,KAAK,KAAK,EAAE;OAE9B,kBAAkB,SAAS,KAAK,EAAE;CAEtC,CAAC,CACH;CAEA,IAAI,SAAS,kBAAkB,KAAK,WAAW,GAC7C,qBAEE,QAAQ,KACN,wLACF,CACF;CAUF,OAAO,CAPW,kBAAkB,KAAK,SACrC,GAAG,2BAA2B,kBAAkB,KAAK,KAAK,GAAG,MAC7D,IACkB,kBAAkB,SAAS,SAC7C,GAAG,8BAA8B,kBAAkB,SAAS,KAAK,GAAG,MACpE,EAE4B,CAAC,CAAC,KAAK,EAAE;AAC3C;;;;;;AAOA,SAAgB,0BAA0B,eAAuB,SAAyB;CACxF,MAAM,EAAE,MAAM,eAAe,UAAU,sBAAsB,uCAAuC,aAAa;CAEjH,OAAO,cACJ,QACE,eAAe,qBACd,cAAc,OACZ,kBAAkB,iBAAiB,wDACH,KAAK,UAAU,OAAO,EAAE,mBACtC,iBAAiB;WAErB,iBAAiB,oBAAoB,iBAAiB,MACtE,GACF,EACF,CAAC,CACA,OACC,kBAAkB,QACf,eAAe,qBACd,cAAc,OAAO,YAAY,iBAAiB,UAAU,KAAK,UAAU,OAAO,EAAE,EAAE,GACxF,EACF,CACF;AACJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { init } from "./client/sdk.js";
|
|
2
|
+
import "./client/index.js";
|
|
3
|
+
export * from "@sentry/solid";
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { withSentry as withSentry$1 } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
1
|
+
import { withSentry as withSentry$1 } from "./config/withSentry.js";
|
|
2
|
+
import "./config/index.js";
|
|
3
|
+
import { init } from "./server/sdk.js";
|
|
4
|
+
import { withServerActionInstrumentation } from "./server/withServerActionInstrumentation.js";
|
|
5
|
+
import { sentryBeforeResponseMiddleware } from "./server/middleware.js";
|
|
6
|
+
import { NodeClient, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, Scope, addBreadcrumb, addEventProcessor, addIntegration, amqplibIntegration, anrIntegration, bindScopeToEmitter, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleIntegration, consoleLoggingIntegration, contextLinesIntegration, continueTrace, createConsolaReporter, createGetModuleFromFilename, createSentryWinstonTransport, createTransport, cron, cronJobIntegration, dedupeIntegration, defaultStackParser, disableAnrDetectionForCallback, endSession, eventFiltersIntegration, expressErrorHandler, expressIntegration, extraErrorDataIntegration, fastifyIntegration, flush, functionToStringIntegration, genericPoolIntegration, getActiveSpan, getAutoPerformanceIntegrations, getClient, getCurrentScope, getDefaultIntegrations, getGlobalScope, getIsolationScope, getRootSpan, getSentryRelease, getSpanDescendants, getSpanStatusFromHttpCode, getTunnelPath, graphqlIntegration, handleTunnelRequest, handleTunnelRequestIfMatched, hapiIntegration, honoIntegration, honoMiddleware, httpIntegration, httpServerIntegration, httpServerSpansIntegration, initOpenTelemetry, instrumentSupabaseClient, isEnabled, isInitialized, isTunnelRequest, kafkaIntegration, knexIntegration, koaIntegration, lastEventId, linkedErrorsIntegration, localVariablesIntegration, logger, makeNodeTransport, modulesIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, neonIntegration, nitroIntegration, nodeContextIntegration, nodeCronIntegration, nodeScheduleIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, parameterize, postgresIntegration, postgresJsIntegration, prismaIntegration, redisIntegration, requestDataIntegration, rewriteFramesIntegration, serveTunnelIntegration, setAttribute, setAttributes, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, spotlightIntegration, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, supabaseIntegration, suppressTracing, tediousIntegration, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, withSentryErrorBoundary, withStaticSpan, withStreamedSpan, zodErrorsIntegration } from "./server/index.js";
|
|
7
|
+
export * from "@sentry/node";
|
|
8
|
+
// src/index.server.ts
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Import `withSentry` from `@sentry/solidstart/vite` instead.
|
|
11
|
+
* This export will be removed in the next major version.
|
|
12
|
+
*/
|
|
9
13
|
const withSentry = withSentry$1;
|
|
14
|
+
export { NodeClient, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, Scope, addBreadcrumb, addEventProcessor, addIntegration, amqplibIntegration, anrIntegration, bindScopeToEmitter, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleIntegration, consoleLoggingIntegration, contextLinesIntegration, continueTrace, createConsolaReporter, createGetModuleFromFilename, createSentryWinstonTransport, createTransport, cron, cronJobIntegration, dedupeIntegration, defaultStackParser, disableAnrDetectionForCallback, endSession, eventFiltersIntegration, expressErrorHandler, expressIntegration, extraErrorDataIntegration, fastifyIntegration, flush, functionToStringIntegration, genericPoolIntegration, getActiveSpan, getAutoPerformanceIntegrations, getClient, getCurrentScope, getDefaultIntegrations, getGlobalScope, getIsolationScope, getRootSpan, getSentryRelease, getSpanDescendants, getSpanStatusFromHttpCode, getTunnelPath, graphqlIntegration, handleTunnelRequest, handleTunnelRequestIfMatched, hapiIntegration, honoIntegration, honoMiddleware, httpIntegration, httpServerIntegration, httpServerSpansIntegration, init, initOpenTelemetry, instrumentSupabaseClient, isEnabled, isInitialized, isTunnelRequest, kafkaIntegration, knexIntegration, koaIntegration, lastEventId, linkedErrorsIntegration, localVariablesIntegration, logger, makeNodeTransport, modulesIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, neonIntegration, nitroIntegration, nodeContextIntegration, nodeCronIntegration, nodeScheduleIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, parameterize, postgresIntegration, postgresJsIntegration, prismaIntegration, redisIntegration, requestDataIntegration, rewriteFramesIntegration, sentryBeforeResponseMiddleware, serveTunnelIntegration, setAttribute, setAttributes, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, spotlightIntegration, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, supabaseIntegration, suppressTracing, tediousIntegration, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, withSentry, withSentryErrorBoundary, withServerActionInstrumentation, withStaticSpan, withStreamedSpan, zodErrorsIntegration };
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=index.server.js.map
|
|
16
|
+
//# sourceMappingURL=index.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.js","sources":["../../src/index.server.ts"],"sourcesContent":["import { withSentry as _withSentry } from './config';\n\nexport * from './server';\n\n/**\n * @deprecated Import `withSentry` from `@sentry/solidstart/vite` instead.\n * This export will be removed in the next major version.\n */\nexport const withSentry = _withSentry;\n"],"
|
|
1
|
+
{"version":3,"file":"index.server.js","names":["_withSentry"],"sources":["../../src/index.server.ts"],"sourcesContent":["import { withSentry as _withSentry } from './config';\n\nexport * from './server';\n\n/**\n * @deprecated Import `withSentry` from `@sentry/solidstart/vite` instead.\n * This export will be removed in the next major version.\n */\nexport const withSentry = _withSentry;\n"],"mappings":";;;;;;;;;;;;AAQA,MAAa,aAAaA"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { TUNNEL_BASE_PATH_GLOBAL } from "../common/tunnel.js";
|
|
2
|
+
import { GLOBAL_OBJ } from "@sentry/core";
|
|
3
|
+
import { _INTERNAL_setTunnelDefaults } from "@sentry/core/server";
|
|
4
|
+
// src/nitro/tunnelPlugin.ts
|
|
5
|
+
/**
|
|
6
|
+
* Serves the managed tunnel under the app's base path on SolidStart v1 (Nitro v2). The runtime answers the requests.
|
|
7
|
+
* `withSentry` registers it.
|
|
8
|
+
*/
|
|
9
|
+
var tunnelPlugin_default = (() => {
|
|
10
|
+
_INTERNAL_setTunnelDefaults({ basePath: GLOBAL_OBJ[TUNNEL_BASE_PATH_GLOBAL] });
|
|
9
11
|
});
|
|
12
|
+
export { tunnelPlugin_default as default };
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=tunnelPlugin.js.map
|
|
14
|
+
//# sourceMappingURL=tunnelPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnelPlugin.js","sources":["../../../src/nitro/tunnelPlugin.ts"],"sourcesContent":["import { GLOBAL_OBJ } from '@sentry/core';\nimport { _INTERNAL_setTunnelDefaults as setTunnelDefaults } from '@sentry/core/server';\nimport type { NitroAppPlugin } from 'nitropack';\nimport { TUNNEL_BASE_PATH_GLOBAL } from '../common/tunnel';\n\n/**\n * Serves the managed tunnel under the app's base path on SolidStart v1 (Nitro v2). The runtime answers the requests.\n * `withSentry` registers it.\n */\nexport default (() => {\n // The server bundle's banner sets the global before this plugin runs.\n setTunnelDefaults({\n basePath: (GLOBAL_OBJ as { [TUNNEL_BASE_PATH_GLOBAL]?: string })[TUNNEL_BASE_PATH_GLOBAL],\n });\n}) satisfies NitroAppPlugin;\n"],"
|
|
1
|
+
{"version":3,"file":"tunnelPlugin.js","names":["setTunnelDefaults"],"sources":["../../../src/nitro/tunnelPlugin.ts"],"sourcesContent":["import { GLOBAL_OBJ } from '@sentry/core';\nimport { _INTERNAL_setTunnelDefaults as setTunnelDefaults } from '@sentry/core/server';\nimport type { NitroAppPlugin } from 'nitropack';\nimport { TUNNEL_BASE_PATH_GLOBAL } from '../common/tunnel';\n\n/**\n * Serves the managed tunnel under the app's base path on SolidStart v1 (Nitro v2). The runtime answers the requests.\n * `withSentry` registers it.\n */\nexport default (() => {\n // The server bundle's banner sets the global before this plugin runs.\n setTunnelDefaults({\n basePath: (GLOBAL_OBJ as { [TUNNEL_BASE_PATH_GLOBAL]?: string })[TUNNEL_BASE_PATH_GLOBAL],\n });\n}) satisfies NitroAppPlugin;\n"],"mappings":";;;;;;;;AASA,IAAA,8BAAsB;CAEpBA,4BAAkB,EAChB,UAAW,WAAsD,yBACnE,CAAC;AACH"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.
|
|
1
|
+
{"type":"module","version":"11.13.0"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
1
|
+
import { init } from "./sdk.js";
|
|
2
|
+
import { withServerActionInstrumentation } from "./withServerActionInstrumentation.js";
|
|
3
|
+
import { sentryBeforeResponseMiddleware } from "./middleware.js";
|
|
4
|
+
import { withSentryErrorBoundary } from "@sentry/solid";
|
|
5
|
+
import { NodeClient, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, Scope, addBreadcrumb, addEventProcessor, addIntegration, amqplibIntegration, anrIntegration, bindScopeToEmitter, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleIntegration, consoleLoggingIntegration, contextLinesIntegration, continueTrace, createConsolaReporter, createGetModuleFromFilename, createSentryWinstonTransport, createTransport, cron, cronJobIntegration, dedupeIntegration, defaultStackParser, disableAnrDetectionForCallback, endSession, eventFiltersIntegration, expressErrorHandler, expressIntegration, extraErrorDataIntegration, fastifyIntegration, flush, functionToStringIntegration, genericPoolIntegration, getActiveSpan, getAutoPerformanceIntegrations, getClient, getCurrentScope, getDefaultIntegrations, getGlobalScope, getIsolationScope, getRootSpan, getSentryRelease, getSpanDescendants, getSpanStatusFromHttpCode, getTunnelPath, graphqlIntegration, handleTunnelRequest, handleTunnelRequestIfMatched, hapiIntegration, honoIntegration, honoMiddleware, httpIntegration, httpServerIntegration, httpServerSpansIntegration, initOpenTelemetry, instrumentSupabaseClient, isEnabled, isInitialized, isTunnelRequest, kafkaIntegration, knexIntegration, koaIntegration, lastEventId, linkedErrorsIntegration, localVariablesIntegration, logger, makeNodeTransport, modulesIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, neonIntegration, nitroIntegration, nodeContextIntegration, nodeCronIntegration, nodeScheduleIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, parameterize, postgresIntegration, postgresJsIntegration, prismaIntegration, redisIntegration, requestDataIntegration, rewriteFramesIntegration, serveTunnelIntegration, setAttribute, setAttributes, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, spotlightIntegration, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, supabaseIntegration, suppressTracing, tediousIntegration, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, withStaticSpan, withStreamedSpan, zodErrorsIntegration } from "@sentry/node";
|
|
6
|
+
export * from "@sentry/node";
|
|
7
|
+
export { NodeClient, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, Scope, addBreadcrumb, addEventProcessor, addIntegration, amqplibIntegration, anrIntegration, bindScopeToEmitter, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, captureSession, close, consoleIntegration, consoleLoggingIntegration, contextLinesIntegration, continueTrace, createConsolaReporter, createGetModuleFromFilename, createSentryWinstonTransport, createTransport, cron, cronJobIntegration, dedupeIntegration, defaultStackParser, disableAnrDetectionForCallback, endSession, eventFiltersIntegration, expressErrorHandler, expressIntegration, extraErrorDataIntegration, fastifyIntegration, flush, functionToStringIntegration, genericPoolIntegration, getActiveSpan, getAutoPerformanceIntegrations, getClient, getCurrentScope, getDefaultIntegrations, getGlobalScope, getIsolationScope, getRootSpan, getSentryRelease, getSpanDescendants, getSpanStatusFromHttpCode, getTunnelPath, graphqlIntegration, handleTunnelRequest, handleTunnelRequestIfMatched, hapiIntegration, honoIntegration, honoMiddleware, httpIntegration, httpServerIntegration, httpServerSpansIntegration, init, initOpenTelemetry, instrumentSupabaseClient, isEnabled, isInitialized, isTunnelRequest, kafkaIntegration, knexIntegration, koaIntegration, lastEventId, linkedErrorsIntegration, localVariablesIntegration, logger, makeNodeTransport, modulesIntegration, mongoIntegration, mongooseIntegration, mysql2Integration, mysqlIntegration, nativeNodeFetchIntegration, neonIntegration, nitroIntegration, nodeContextIntegration, nodeCronIntegration, nodeScheduleIntegration, onUncaughtExceptionIntegration, onUnhandledRejectionIntegration, parameterize, postgresIntegration, postgresJsIntegration, prismaIntegration, redisIntegration, requestDataIntegration, rewriteFramesIntegration, sentryBeforeResponseMiddleware, serveTunnelIntegration, setAttribute, setAttributes, setContext, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, setupExpressErrorHandler, setupHapiErrorHandler, setupKoaErrorHandler, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, spotlightIntegration, startInactiveSpan, startNewTrace, startSession, startSpan, startSpanManual, supabaseIntegration, suppressTracing, tediousIntegration, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, withSentryErrorBoundary, withServerActionInstrumentation, withStaticSpan, withStreamedSpan, zodErrorsIntegration };
|
|
@@ -1,40 +1,31 @@
|
|
|
1
|
-
import { addNonEnumerableProperty, getTraceMetaTags } from
|
|
2
|
-
|
|
1
|
+
import { addNonEnumerableProperty, getTraceMetaTags } from "@sentry/core";
|
|
2
|
+
// src/server/middleware.ts
|
|
3
3
|
function addMetaTagToHead(html) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const content = `<head>
|
|
9
|
-
${metaTags}
|
|
10
|
-
`;
|
|
11
|
-
return html.replace("<head>", content);
|
|
4
|
+
const metaTags = getTraceMetaTags();
|
|
5
|
+
if (!metaTags) return html;
|
|
6
|
+
const content = `<head>\n${metaTags}\n`;
|
|
7
|
+
return html.replace("<head>", content);
|
|
12
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Returns an `onBeforeResponse` solid start middleware handler that adds tracing data as
|
|
11
|
+
* <meta> tags to a page on pageload to enable distributed tracing.
|
|
12
|
+
*/
|
|
13
13
|
function sentryBeforeResponseMiddleware() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
for await (const chunk of body) {
|
|
29
|
-
const html = typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true });
|
|
30
|
-
const modifiedHtml = addMetaTagToHead(html);
|
|
31
|
-
controller.enqueue(new TextEncoder().encode(modifiedHtml));
|
|
32
|
-
}
|
|
33
|
-
controller.close();
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
|
14
|
+
return async function onBeforeResponse(event, response) {
|
|
15
|
+
if (!response.body || response.__sentry_wrapped__) return;
|
|
16
|
+
addNonEnumerableProperty(response, "__sentry_wrapped__", true);
|
|
17
|
+
if (!event.response.headers.get("content-type")?.startsWith("text/html")) return;
|
|
18
|
+
const body = response.body;
|
|
19
|
+
const decoder = new TextDecoder();
|
|
20
|
+
response.body = new ReadableStream({ start: async (controller) => {
|
|
21
|
+
for await (const chunk of body) {
|
|
22
|
+
const modifiedHtml = addMetaTagToHead(typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true }));
|
|
23
|
+
controller.enqueue(new TextEncoder().encode(modifiedHtml));
|
|
24
|
+
}
|
|
25
|
+
controller.close();
|
|
26
|
+
} });
|
|
27
|
+
};
|
|
37
28
|
}
|
|
38
|
-
|
|
39
29
|
export { sentryBeforeResponseMiddleware };
|
|
40
|
-
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sources":["../../../src/server/middleware.ts"],"sourcesContent":["import { addNonEnumerableProperty, getTraceMetaTags } from '@sentry/core';\nimport type { ResponseMiddleware } from '@solidjs/start/middleware';\nimport type { FetchEvent } from '@solidjs/start/server';\n\nexport type ResponseMiddlewareResponse = Parameters<ResponseMiddleware>[1] & {\n __sentry_wrapped__?: boolean;\n};\n\nfunction addMetaTagToHead(html: string): string {\n const metaTags = getTraceMetaTags();\n\n if (!metaTags) {\n return html;\n }\n\n const content = `<head>\\n${metaTags}\\n`;\n return html.replace('<head>', content);\n}\n\n/**\n * Returns an `onBeforeResponse` solid start middleware handler that adds tracing data as\n * <meta> tags to a page on pageload to enable distributed tracing.\n */\nexport function sentryBeforeResponseMiddleware() {\n return async function onBeforeResponse(event: FetchEvent, response: ResponseMiddlewareResponse) {\n if (!response.body || response.__sentry_wrapped__) {\n return;\n }\n\n // Ensure we don't double-wrap, in case a user has added the middleware twice\n // e.g. once manually, once via the wizard\n addNonEnumerableProperty(response, '__sentry_wrapped__', true);\n\n const contentType = event.response.headers.get('content-type');\n const isPageloadRequest = contentType?.startsWith('text/html');\n\n if (!isPageloadRequest) {\n return;\n }\n\n const body = response.body as NodeJS.ReadableStream;\n const decoder = new TextDecoder();\n response.body = new ReadableStream({\n start: async controller => {\n for await (const chunk of body) {\n const html = typeof chunk === 'string' ? chunk : decoder.decode(chunk, { stream: true });\n const modifiedHtml = addMetaTagToHead(html);\n controller.enqueue(new TextEncoder().encode(modifiedHtml));\n }\n controller.close();\n },\n });\n };\n}\n"],"
|
|
1
|
+
{"version":3,"file":"middleware.js","names":[],"sources":["../../../src/server/middleware.ts"],"sourcesContent":["import { addNonEnumerableProperty, getTraceMetaTags } from '@sentry/core';\nimport type { ResponseMiddleware } from '@solidjs/start/middleware';\nimport type { FetchEvent } from '@solidjs/start/server';\n\nexport type ResponseMiddlewareResponse = Parameters<ResponseMiddleware>[1] & {\n __sentry_wrapped__?: boolean;\n};\n\nfunction addMetaTagToHead(html: string): string {\n const metaTags = getTraceMetaTags();\n\n if (!metaTags) {\n return html;\n }\n\n const content = `<head>\\n${metaTags}\\n`;\n return html.replace('<head>', content);\n}\n\n/**\n * Returns an `onBeforeResponse` solid start middleware handler that adds tracing data as\n * <meta> tags to a page on pageload to enable distributed tracing.\n */\nexport function sentryBeforeResponseMiddleware() {\n return async function onBeforeResponse(event: FetchEvent, response: ResponseMiddlewareResponse) {\n if (!response.body || response.__sentry_wrapped__) {\n return;\n }\n\n // Ensure we don't double-wrap, in case a user has added the middleware twice\n // e.g. once manually, once via the wizard\n addNonEnumerableProperty(response, '__sentry_wrapped__', true);\n\n const contentType = event.response.headers.get('content-type');\n const isPageloadRequest = contentType?.startsWith('text/html');\n\n if (!isPageloadRequest) {\n return;\n }\n\n const body = response.body as NodeJS.ReadableStream;\n const decoder = new TextDecoder();\n response.body = new ReadableStream({\n start: async controller => {\n for await (const chunk of body) {\n const html = typeof chunk === 'string' ? chunk : decoder.decode(chunk, { stream: true });\n const modifiedHtml = addMetaTagToHead(html);\n controller.enqueue(new TextEncoder().encode(modifiedHtml));\n }\n controller.close();\n },\n });\n };\n}\n"],"mappings":";;AAQA,SAAS,iBAAiB,MAAsB;CAC9C,MAAM,WAAW,iBAAiB;CAElC,IAAI,CAAC,UACH,OAAO;CAGT,MAAM,UAAU,WAAW,SAAS;CACpC,OAAO,KAAK,QAAQ,UAAU,OAAO;AACvC;;;;;AAMA,SAAgB,iCAAiC;CAC/C,OAAO,eAAe,iBAAiB,OAAmB,UAAsC;EAC9F,IAAI,CAAC,SAAS,QAAQ,SAAS,oBAC7B;EAKF,yBAAyB,UAAU,sBAAsB,IAAI;EAK7D,IAAI,CAHgB,MAAM,SAAS,QAAQ,IAAI,cACX,CAAC,EAAE,WAAW,WAAW,GAG3D;EAGF,MAAM,OAAO,SAAS;EACtB,MAAM,UAAU,IAAI,YAAY;EAChC,SAAS,OAAO,IAAI,eAAe,EACjC,OAAO,OAAM,eAAc;GACzB,WAAW,MAAM,SAAS,MAAM;IAE9B,MAAM,eAAe,iBADR,OAAO,UAAU,WAAW,QAAQ,QAAQ,OAAO,OAAO,EAAE,QAAQ,KAAK,CAAC,CAC7C;IAC1C,WAAW,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,YAAY,CAAC;GAC3D;GACA,WAAW,MAAM;EACnB,EACF,CAAC;CACH;AACF"}
|