@sentry/solidstart 10.53.0 → 10.54.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.
Files changed (51) hide show
  1. package/build/cjs/client/sdk.js +3 -20
  2. package/build/cjs/client/sdk.js.map +1 -1
  3. package/build/cjs/config/addInstrumentation.js +28 -91
  4. package/build/cjs/config/addInstrumentation.js.map +1 -1
  5. package/build/cjs/config/withSentry.js +28 -52
  6. package/build/cjs/config/withSentry.js.map +1 -1
  7. package/build/cjs/config/wrapServerEntryWithDynamicImport.js +52 -170
  8. package/build/cjs/config/wrapServerEntryWithDynamicImport.js.map +1 -1
  9. package/build/cjs/server/middleware.js +11 -22
  10. package/build/cjs/server/middleware.js.map +1 -1
  11. package/build/cjs/server/sdk.js +2 -7
  12. package/build/cjs/server/sdk.js.map +1 -1
  13. package/build/cjs/server/solidrouter.js +1 -20
  14. package/build/cjs/server/solidrouter.js.map +1 -1
  15. package/build/cjs/server/utils.js +6 -24
  16. package/build/cjs/server/utils.js.map +1 -1
  17. package/build/cjs/server/withServerActionInstrumentation.js +14 -31
  18. package/build/cjs/server/withServerActionInstrumentation.js.map +1 -1
  19. package/build/cjs/vite/buildInstrumentationFile.js +12 -22
  20. package/build/cjs/vite/buildInstrumentationFile.js.map +1 -1
  21. package/build/cjs/vite/sentrySolidStartVite.js +3 -15
  22. package/build/cjs/vite/sentrySolidStartVite.js.map +1 -1
  23. package/build/cjs/vite/sourceMaps.js +37 -89
  24. package/build/cjs/vite/sourceMaps.js.map +1 -1
  25. package/build/esm/client/sdk.js +3 -20
  26. package/build/esm/client/sdk.js.map +1 -1
  27. package/build/esm/config/addInstrumentation.js +28 -91
  28. package/build/esm/config/addInstrumentation.js.map +1 -1
  29. package/build/esm/config/withSentry.js +28 -52
  30. package/build/esm/config/withSentry.js.map +1 -1
  31. package/build/esm/config/wrapServerEntryWithDynamicImport.js +52 -170
  32. package/build/esm/config/wrapServerEntryWithDynamicImport.js.map +1 -1
  33. package/build/esm/package.json +1 -1
  34. package/build/esm/server/middleware.js +11 -22
  35. package/build/esm/server/middleware.js.map +1 -1
  36. package/build/esm/server/sdk.js +2 -7
  37. package/build/esm/server/sdk.js.map +1 -1
  38. package/build/esm/server/solidrouter.js +1 -20
  39. package/build/esm/server/solidrouter.js.map +1 -1
  40. package/build/esm/server/utils.js +6 -24
  41. package/build/esm/server/utils.js.map +1 -1
  42. package/build/esm/server/withServerActionInstrumentation.js +14 -31
  43. package/build/esm/server/withServerActionInstrumentation.js.map +1 -1
  44. package/build/esm/vite/buildInstrumentationFile.js +12 -22
  45. package/build/esm/vite/buildInstrumentationFile.js.map +1 -1
  46. package/build/esm/vite/sentrySolidStartVite.js +3 -15
  47. package/build/esm/vite/sentrySolidStartVite.js.map +1 -1
  48. package/build/esm/vite/sourceMaps.js +37 -89
  49. package/build/esm/vite/sourceMaps.js.map +1 -1
  50. package/build/types/config/withSentry.d.ts.map +1 -1
  51. package/package.json +4 -4
@@ -2,26 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const core = require('@sentry/core');
4
4
 
5
- /** THIS FILE IS AN UTILITY FOR NITRO-BASED PACKAGES AND SHOULD BE KEPT IN SYNC IN NUXT, SOLIDSTART, ETC. */
6
-
7
- const SENTRY_WRAPPED_ENTRY = '?sentry-query-wrapped-entry';
8
- const SENTRY_WRAPPED_FUNCTIONS = '?sentry-query-wrapped-functions=';
9
- const SENTRY_REEXPORTED_FUNCTIONS = '?sentry-query-reexported-functions=';
10
- const QUERY_END_INDICATOR = 'SENTRY-QUERY-END';
11
-
12
- /**
13
- * A Rollup plugin which wraps the server entry with a dynamic `import()`. This makes it possible to initialize Sentry first
14
- * by using a regular `import` and load the server after that.
15
- * This also works with serverless `handler` functions, as it re-exports the `handler`.
16
- *
17
- * @param config Configuration options for the Rollup Plugin
18
- * @param config.serverConfigFileName Name of the Sentry server config (without file extension). E.g. 'sentry.server.config'
19
- * @param config.serverEntrypointFileName The server entrypoint (with file extension). Usually, this is defined by the Nitro preset and is something like 'node-server.mjs'
20
- * @param config.resolvedServerConfigPath Resolved path of the Sentry server config (based on `src` directory)
21
- * @param config.entryPointWrappedFunctions Exported bindings of the server entry file, which are wrapped as async function. E.g. ['default', 'handler', 'server']
22
- * @param config.additionalImports Adds additional imports to the entry file. Can be e.g. 'import-in-the-middle/hook.mjs'
23
- * @param config.debug Whether debug logs are enabled in the build time environment
24
- */
5
+ const SENTRY_WRAPPED_ENTRY = "?sentry-query-wrapped-entry";
6
+ const SENTRY_WRAPPED_FUNCTIONS = "?sentry-query-wrapped-functions=";
7
+ const SENTRY_REEXPORTED_FUNCTIONS = "?sentry-query-reexported-functions=";
8
+ const QUERY_END_INDICATOR = "SENTRY-QUERY-END";
25
9
  function wrapServerEntryWithDynamicImport(config) {
26
10
  const {
27
11
  serverConfigFileName,
@@ -29,209 +13,107 @@ function wrapServerEntryWithDynamicImport(config) {
29
13
  resolvedServerConfigPath,
30
14
  entrypointWrappedFunctions,
31
15
  additionalImports,
32
- debug,
16
+ debug
33
17
  } = config;
34
-
35
- // In order to correctly import the server config file
36
- // and dynamically import the nitro runtime, we need to
37
- // mark the resolutionId with '\0raw' to fall into the
38
- // raw chunk group, c.f. https://github.com/nitrojs/nitro/commit/8b4a408231bdc222569a32ce109796a41eac4aa6#diff-e58102d2230f95ddeef2662957b48d847a6e891e354cfd0ae6e2e03ce848d1a2R142
39
- const resolutionIdPrefix = '\0raw';
40
-
18
+ const resolutionIdPrefix = "\0raw";
41
19
  return {
42
- name: 'sentry-wrap-server-entry-with-dynamic-import',
20
+ name: "sentry-wrap-server-entry-with-dynamic-import",
43
21
  async resolveId(source, importer, options) {
44
22
  if (source.includes(`/${serverConfigFileName}`)) {
45
23
  return { id: source, moduleSideEffects: true };
46
24
  }
47
-
48
25
  if (additionalImports?.includes(source)) {
49
- // When importing additional imports like "import-in-the-middle/hook.mjs" in the returned code of the `load()` function below:
50
- // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it
51
- // By importing "import-in-the-middle/hook.mjs", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.
52
- // Prevents the error "Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'"
53
26
  return { id: source, moduleSideEffects: true, external: true };
54
27
  }
55
-
56
- if (
57
- options.isEntry &&
58
- source.includes(serverEntrypointFileName) &&
59
- source.includes('.mjs') &&
60
- !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)
61
- ) {
28
+ if (options.isEntry && source.includes(serverEntrypointFileName) && source.includes(".mjs") && !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
62
29
  const resolution = await this.resolve(source, importer, options);
63
-
64
- // If it cannot be resolved or is external, just return it so that Rollup can display an error
65
30
  if (!resolution || resolution?.external) return resolution;
66
-
67
31
  const moduleInfo = await this.load(resolution);
68
-
69
32
  moduleInfo.moduleSideEffects = true;
70
-
71
- // 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
72
- return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)
73
- ? resolution.id
74
- : `${resolutionIdPrefix}${resolution.id
75
- // 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)
76
- .concat(SENTRY_WRAPPED_ENTRY)
77
- .concat(
78
- constructWrappedFunctionExportQuery(moduleInfo.exportedBindings, entrypointWrappedFunctions, debug),
79
- )
80
- .concat(QUERY_END_INDICATOR)}`;
33
+ return resolution.id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`) ? resolution.id : `${resolutionIdPrefix}${resolution.id.concat(SENTRY_WRAPPED_ENTRY).concat(
34
+ constructWrappedFunctionExportQuery(moduleInfo.exportedBindings, entrypointWrappedFunctions, debug)
35
+ ).concat(QUERY_END_INDICATOR)}`;
81
36
  }
82
37
  return null;
83
38
  },
84
39
  load(id) {
85
40
  if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {
86
41
  const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);
87
-
88
- // Mostly useful for serverless `handler` functions
89
- const reExportedFunctions =
90
- id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)
91
- ? constructFunctionReExport(id, entryId)
92
- : '';
93
-
42
+ const reExportedFunctions = id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS) ? constructFunctionReExport(id, entryId) : "";
94
43
  return (
95
44
  // Regular `import` of the Sentry config
96
- `import ${JSON.stringify(resolvedServerConfigPath)};\n` +
97
- // Dynamic `import()` for the previous, actual entry point.
98
- // `import()` can be used for any code that should be run after the hooks are registered (https://nodejs.org/api/module.html#enabling)
99
- `import(${JSON.stringify(entryId)});\n` +
100
- // By importing additional imports like "import-in-the-middle/hook.mjs", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.
101
- `${additionalImports ? additionalImports.map(importPath => `import "${importPath}";\n`) : ''}` +
102
- `${reExportedFunctions}\n`
45
+ `import ${JSON.stringify(resolvedServerConfigPath)};
46
+ import(${JSON.stringify(entryId)});
47
+ ${additionalImports ? additionalImports.map((importPath) => `import "${importPath}";
48
+ `) : ""}${reExportedFunctions}
49
+ `
103
50
  );
104
51
  }
105
-
106
52
  return null;
107
- },
53
+ }
108
54
  };
109
55
  }
110
-
111
- /**
112
- * Strips the Sentry query part from a path.
113
- * Example: example/path?sentry-query-wrapped-entry?sentry-query-functions-reexport=foo,SENTRY-QUERY-END -> /example/path
114
- *
115
- * **Only exported for testing**
116
- */
117
56
  function removeSentryQueryFromPath(url) {
118
- // oxlint-disable-next-line sdk/no-regexp-constructor
119
57
  const regex = new RegExp(`\\${SENTRY_WRAPPED_ENTRY}.*?\\${QUERY_END_INDICATOR}`);
120
- return url.replace(regex, '');
58
+ return url.replace(regex, "");
121
59
  }
122
-
123
- /**
124
- * Extracts and sanitizes function re-export and function wrap query parameters from a query string.
125
- * If it is a default export, it is not considered for re-exporting.
126
- *
127
- * **Only exported for testing**
128
- */
129
60
  function extractFunctionReexportQueryParameters(query) {
130
- // Regex matches the comma-separated params between the functions query
131
- // oxlint-disable-next-line sdk/no-regexp-constructor
132
61
  const wrapRegex = new RegExp(
133
- `\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\${QUERY_END_INDICATOR}|\\${SENTRY_REEXPORTED_FUNCTIONS})`,
62
+ `\\${SENTRY_WRAPPED_FUNCTIONS}(.*?)(\\${QUERY_END_INDICATOR}|\\${SENTRY_REEXPORTED_FUNCTIONS})`
134
63
  );
135
- // oxlint-disable-next-line sdk/no-regexp-constructor
136
64
  const reexportRegex = new RegExp(`\\${SENTRY_REEXPORTED_FUNCTIONS}(.*?)(\\${QUERY_END_INDICATOR})`);
137
-
138
65
  const wrapMatch = query.match(wrapRegex);
139
66
  const reexportMatch = query.match(reexportRegex);
140
-
141
- const wrap = wrapMatch?.[1]
142
- ? wrapMatch[1]
143
- .split(',')
144
- .filter(param => param !== '')
145
- // Sanitize, as code could be injected with another rollup plugin
146
- .map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
147
- : [];
148
-
149
- const reexport = reexportMatch?.[1]
150
- ? reexportMatch[1]
151
- .split(',')
152
- .filter(param => param !== '' && param !== 'default')
153
- // Sanitize, as code could be injected with another rollup plugin
154
- .map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
155
- : [];
156
-
67
+ const wrap = wrapMatch?.[1] ? wrapMatch[1].split(",").filter((param) => param !== "").map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) : [];
68
+ const reexport = reexportMatch?.[1] ? reexportMatch[1].split(",").filter((param) => param !== "" && param !== "default").map((str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")) : [];
157
69
  return { wrap, reexport };
158
70
  }
159
-
160
- /**
161
- * Constructs a comma-separated string with all functions that need to be re-exported later from the server entry.
162
- * It uses Rollup's `exportedBindings` to determine the functions to re-export. Functions which should be wrapped
163
- * (e.g. serverless handlers) are wrapped by Sentry.
164
- *
165
- * **Only exported for testing**
166
- */
167
- function constructWrappedFunctionExportQuery(
168
- exportedBindings,
169
- entrypointWrappedFunctions,
170
- debug,
171
- ) {
71
+ function constructWrappedFunctionExportQuery(exportedBindings, entrypointWrappedFunctions, debug) {
172
72
  const functionsToExport = {
173
73
  wrap: [],
174
- reexport: [],
74
+ reexport: []
175
75
  };
176
-
177
- // `exportedBindings` can look like this: `{ '.': [ 'handler' ] }` or `{ '.': [], './firebase-gen-1.mjs': [ 'server' ] }`
178
- // The key `.` refers to exports within the current file, while other keys show from where exports were imported first.
179
- Object.values(exportedBindings || {}).forEach(functions =>
180
- functions.forEach(fn => {
76
+ Object.values(exportedBindings || {}).forEach(
77
+ (functions) => functions.forEach((fn) => {
181
78
  if (entrypointWrappedFunctions.includes(fn)) {
182
79
  functionsToExport.wrap.push(fn);
183
80
  } else {
184
81
  functionsToExport.reexport.push(fn);
185
82
  }
186
- }),
83
+ })
187
84
  );
188
-
189
85
  if (debug && functionsToExport.wrap.length === 0) {
190
- core.consoleSandbox(() =>
191
- // eslint-disable-next-line no-console
192
- console.warn(
193
- '[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`.',
194
- ),
86
+ core.consoleSandbox(
87
+ () => (
88
+ // eslint-disable-next-line no-console
89
+ console.warn(
90
+ "[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`."
91
+ )
92
+ )
195
93
  );
196
94
  }
197
-
198
- const wrapQuery = functionsToExport.wrap.length
199
- ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(',')}`
200
- : '';
201
- const reexportQuery = functionsToExport.reexport.length
202
- ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(',')}`
203
- : '';
204
-
205
- return [wrapQuery, reexportQuery].join('');
95
+ const wrapQuery = functionsToExport.wrap.length ? `${SENTRY_WRAPPED_FUNCTIONS}${functionsToExport.wrap.join(",")}` : "";
96
+ const reexportQuery = functionsToExport.reexport.length ? `${SENTRY_REEXPORTED_FUNCTIONS}${functionsToExport.reexport.join(",")}` : "";
97
+ return [wrapQuery, reexportQuery].join("");
206
98
  }
207
-
208
- /**
209
- * Constructs a code snippet with function reexports (can be used in Rollup plugins as a return value for `load()`)
210
- *
211
- * **Only exported for testing**
212
- */
213
99
  function constructFunctionReExport(pathWithQuery, entryId) {
214
100
  const { wrap: wrapFunctions, reexport: reexportFunctions } = extractFunctionReexportQueryParameters(pathWithQuery);
215
-
216
- return wrapFunctions
217
- .reduce(
218
- (functionsCode, currFunctionName) =>
219
- functionsCode.concat(
220
- `async function ${currFunctionName}_sentryWrapped(...args) {\n` +
221
- ` const res = await import(${JSON.stringify(entryId)});\n` +
222
- ` return res.${currFunctionName}.call(this, ...args);\n` +
223
- '}\n' +
224
- `export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };\n`,
225
- ),
226
- '',
101
+ return wrapFunctions.reduce(
102
+ (functionsCode, currFunctionName) => functionsCode.concat(
103
+ `async function ${currFunctionName}_sentryWrapped(...args) {
104
+ const res = await import(${JSON.stringify(entryId)});
105
+ return res.${currFunctionName}.call(this, ...args);
106
+ }
107
+ export { ${currFunctionName}_sentryWrapped as ${currFunctionName} };
108
+ `
109
+ ),
110
+ ""
111
+ ).concat(
112
+ reexportFunctions.reduce(
113
+ (functionsCode, currFunctionName) => functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),
114
+ ""
227
115
  )
228
- .concat(
229
- reexportFunctions.reduce(
230
- (functionsCode, currFunctionName) =>
231
- functionsCode.concat(`export { ${currFunctionName} } from ${JSON.stringify(entryId)};`),
232
- '',
233
- ),
234
- );
116
+ );
235
117
  }
236
118
 
237
119
  exports.QUERY_END_INDICATOR = QUERY_END_INDICATOR;
@@ -1 +1 @@
1
- {"version":3,"file":"wrapServerEntryWithDynamicImport.js","sources":["../../../src/config/wrapServerEntryWithDynamicImport.ts"],"sourcesContent":["import { 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\nexport type WrapServerEntryPluginOptions = {\n serverEntrypointFileName: string;\n serverConfigFileName: string;\n resolvedServerConfigPath: string;\n entrypointWrappedFunctions: string[];\n additionalImports?: 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.additionalImports Adds additional imports to the entry file. Can be e.g. 'import-in-the-middle/hook.mjs'\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 additionalImports,\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 if (source.includes(`/${serverConfigFileName}`)) {\n return { id: source, moduleSideEffects: true };\n }\n\n if (additionalImports?.includes(source)) {\n // When importing additional imports like \"import-in-the-middle/hook.mjs\" in the returned code of the `load()` function below:\n // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.\n // Prevents the error \"Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'\"\n return { id: source, moduleSideEffects: true, external: true };\n }\n\n if (\n options.isEntry &&\n source.includes(serverEntrypointFileName) &&\n source.includes('.mjs') &&\n !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ) {\n const resolution = await this.resolve(source, 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 return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryId)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(resolvedServerConfigPath)};\\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(entryId)});\\n` +\n // By importing additional imports like \"import-in-the-middle/hook.mjs\", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.\n `${additionalImports ? additionalImports.map(importPath => `import \"${importPath}\";\\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":["consoleSandbox"],"mappings":";;;;AAGA;;AAEO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,wBAAA,GAA2B;AACjC,MAAM,2BAAA,GAA8B;AACpC,MAAM,mBAAA,GAAsB;;AAWnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gCAAgC,CAAC,MAAM,EAAmD;AAC1G,EAAE,MAAM;AACR,IAAI,oBAAoB;AACxB,IAAI,wBAAwB;AAC5B,IAAI,wBAAwB;AAC5B,IAAI,0BAA0B;AAC9B,IAAI,iBAAiB;AACrB,IAAI,KAAK;AACT,GAAE,GAAI,MAAM;;AAEZ;AACA;AACA;AACA;AACA,EAAE,MAAM,kBAAA,GAAqB,OAAO;;AAEpC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,8CAA8C;AACxD,IAAI,MAAM,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAA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,EAAA,OAAA;AACA,KAAA,MAAA;AACA,MAAA,CAAA,aAAA,EAAA,gBAAA;AACA,QAAA,aAAA,CAAA,MAAA;AACA,UAAA,CAAA,eAAA,EAAA,gBAAA,CAAA,2BAAA,CAAA;AACA,YAAA,CAAA,2BAAA,EAAA,IAAA,CAAA,SAAA,CAAA,OAAA,CAAA,CAAA,IAAA,CAAA;AACA,YAAA,CAAA,aAAA,EAAA,gBAAA,CAAA,uBAAA,CAAA;AACA,YAAA,KAAA;AACA,YAAA,CAAA,SAAA,EAAA,gBAAA,CAAA,kBAAA,EAAA,gBAAA,CAAA,KAAA,CAAA;AACA,SAAA;AACA,MAAA,EAAA;AACA;AACA,KAAA,MAAA;AACA,MAAA,iBAAA,CAAA,MAAA;AACA,QAAA,CAAA,aAAA,EAAA,gBAAA;AACA,UAAA,aAAA,CAAA,MAAA,CAAA,CAAA,SAAA,EAAA,gBAAA,CAAA,QAAA,EAAA,IAAA,CAAA,SAAA,CAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA,QAAA,EAAA;AACA,OAAA;AACA,KAAA;AACA;;;;;;;;;;;;"}
1
+ {"version":3,"file":"wrapServerEntryWithDynamicImport.js","sources":["../../../src/config/wrapServerEntryWithDynamicImport.ts"],"sourcesContent":["import { 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\nexport type WrapServerEntryPluginOptions = {\n serverEntrypointFileName: string;\n serverConfigFileName: string;\n resolvedServerConfigPath: string;\n entrypointWrappedFunctions: string[];\n additionalImports?: 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.additionalImports Adds additional imports to the entry file. Can be e.g. 'import-in-the-middle/hook.mjs'\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 additionalImports,\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 if (source.includes(`/${serverConfigFileName}`)) {\n return { id: source, moduleSideEffects: true };\n }\n\n if (additionalImports?.includes(source)) {\n // When importing additional imports like \"import-in-the-middle/hook.mjs\" in the returned code of the `load()` function below:\n // By setting `moduleSideEffects` to `true`, the import is added to the bundle, although nothing is imported from it\n // By importing \"import-in-the-middle/hook.mjs\", we can make sure this file is included, as not all node builders are including files imported with `module.register()`.\n // Prevents the error \"Failed to register ESM hook Error: Cannot find module 'import-in-the-middle/hook.mjs'\"\n return { id: source, moduleSideEffects: true, external: true };\n }\n\n if (\n options.isEntry &&\n source.includes(serverEntrypointFileName) &&\n source.includes('.mjs') &&\n !source.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)\n ) {\n const resolution = await this.resolve(source, 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 return null;\n },\n load(id: string) {\n if (id.includes(`.mjs${SENTRY_WRAPPED_ENTRY}`)) {\n const entryId = removeSentryQueryFromPath(id).slice(resolutionIdPrefix.length);\n\n // Mostly useful for serverless `handler` functions\n const reExportedFunctions =\n id.includes(SENTRY_WRAPPED_FUNCTIONS) || id.includes(SENTRY_REEXPORTED_FUNCTIONS)\n ? constructFunctionReExport(id, entryId)\n : '';\n\n return (\n // Regular `import` of the Sentry config\n `import ${JSON.stringify(resolvedServerConfigPath)};\\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(entryId)});\\n` +\n // By importing additional imports like \"import-in-the-middle/hook.mjs\", we can make sure this file wil be included, as not all node builders are including files imported with `module.register()`.\n `${additionalImports ? additionalImports.map(importPath => `import \"${importPath}\";\\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":["consoleSandbox"],"mappings":";;;;AAKO,MAAM,oBAAA,GAAuB;AAC7B,MAAM,wBAAA,GAA2B;AACjC,MAAM,2BAAA,GAA8B;AACpC,MAAM,mBAAA,GAAsB;AAwB5B,SAAS,iCAAiC,MAAA,EAAyD;AACxG,EAAA,MAAM;AAAA,IACJ,oBAAA;AAAA,IACA,wBAAA;AAAA,IACA,wBAAA;AAAA,IACA,0BAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,GACF,GAAI,MAAA;AAMJ,EAAA,MAAM,kBAAA,GAAqB,OAAA;AAE3B,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,8CAAA;AAAA,IACN,MAAM,SAAA,CAAU,MAAA,EAAQ,QAAA,EAAU,OAAA,EAAS;AACzC,MAAA,IAAI,MAAA,CAAO,QAAA,CAAS,CAAA,CAAA,EAAI,oBAAoB,EAAE,CAAA,EAAG;AAC/C,QAAA,OAAO,EAAE,EAAA,EAAI,MAAA,EAAQ,iBAAA,EAAmB,IAAA,EAAK;AAAA,MAC/C;AAEA,MAAA,IAAI,iBAAA,EAAmB,QAAA,CAAS,MAAM,CAAA,EAAG;AAKvC,QAAA,OAAO,EAAE,EAAA,EAAI,MAAA,EAAQ,iBAAA,EAAmB,IAAA,EAAM,UAAU,IAAA,EAAK;AAAA,MAC/D;AAEA,MAAA,IACE,QAAQ,OAAA,IACR,MAAA,CAAO,QAAA,CAAS,wBAAwB,KACxC,MAAA,CAAO,QAAA,CAAS,MAAM,CAAA,IACtB,CAAC,MAAA,CAAO,QAAA,CAAS,CAAA,IAAA,EAAO,oBAAoB,EAAE,CAAA,EAC9C;AACA,QAAA,MAAM,aAAa,MAAM,IAAA,CAAK,OAAA,CAAQ,MAAA,EAAQ,UAAU,OAAO,CAAA;AAG/D,QAAA,IAA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AAA,CAAE,KAAK,EAAE,CAAA;AAC3C;AAOO,SAAS,yBAAA,CAA0B,eAAuB,OAAA,EAAyB;AACxF,EAAA,MAAM,EAAE,IAAA,EAAM,aAAA,EAAe,UAAU,iBAAA,EAAkB,GAAI,uCAAuC,aAAa,CAAA;AAEjH,EAAA,OAAO,aAAA,CACJ,MAAA;AAAA,IACC,CAAC,aAAA,EAAe,gBAAA,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;;;;;;;;;;;;"}
@@ -4,47 +4,36 @@ const core = require('@sentry/core');
4
4
 
5
5
  function addMetaTagToHead(html) {
6
6
  const metaTags = core.getTraceMetaTags();
7
-
8
7
  if (!metaTags) {
9
8
  return html;
10
9
  }
11
-
12
- const content = `<head>\n${metaTags}\n`;
13
- return html.replace('<head>', content);
10
+ const content = `<head>
11
+ ${metaTags}
12
+ `;
13
+ return html.replace("<head>", content);
14
14
  }
15
-
16
- /**
17
- * Returns an `onBeforeResponse` solid start middleware handler that adds tracing data as
18
- * <meta> tags to a page on pageload to enable distributed tracing.
19
- */
20
15
  function sentryBeforeResponseMiddleware() {
21
16
  return async function onBeforeResponse(event, response) {
22
17
  if (!response.body || response.__sentry_wrapped__) {
23
18
  return;
24
19
  }
25
-
26
- // Ensure we don't double-wrap, in case a user has added the middleware twice
27
- // e.g. once manually, once via the wizard
28
- core.addNonEnumerableProperty(response, '__sentry_wrapped__', true);
29
-
30
- const contentType = event.response.headers.get('content-type');
31
- const isPageloadRequest = contentType?.startsWith('text/html');
32
-
20
+ core.addNonEnumerableProperty(response, "__sentry_wrapped__", true);
21
+ const contentType = event.response.headers.get("content-type");
22
+ const isPageloadRequest = contentType?.startsWith("text/html");
33
23
  if (!isPageloadRequest) {
34
24
  return;
35
25
  }
36
-
37
- const body = response.body ;
26
+ const body = response.body;
38
27
  const decoder = new TextDecoder();
39
28
  response.body = new ReadableStream({
40
- start: async controller => {
29
+ start: async (controller) => {
41
30
  for await (const chunk of body) {
42
- const html = typeof chunk === 'string' ? chunk : decoder.decode(chunk, { stream: true });
31
+ const html = typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true });
43
32
  const modifiedHtml = addMetaTagToHead(html);
44
33
  controller.enqueue(new TextEncoder().encode(modifiedHtml));
45
34
  }
46
35
  controller.close();
47
- },
36
+ }
48
37
  });
49
38
  };
50
39
  }
@@ -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"],"names":["getTraceMetaTags","addNonEnumerableProperty"],"mappings":";;;;AAQA,SAAS,gBAAgB,CAAC,IAAI,EAAkB;AAChD,EAAE,MAAM,QAAA,GAAWA,qBAAgB,EAAE;;AAErC,EAAE,IAAI,CAAC,QAAQ,EAAE;AACjB,IAAI,OAAO,IAAI;AACf,EAAE;;AAEF,EAAE,MAAM,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;AACzC,EAAE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACO,SAAS,8BAA8B,GAAG;AACjD,EAAE,OAAO,eAAe,gBAAgB,CAAC,KAAK,EAAc,QAAQ,EAA8B;AAClG,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,QAAQ,CAAC,kBAAkB,EAAE;AACvD,MAAM;AACN,IAAI;;AAEJ;AACA;AACA,IAAIC,6BAAwB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,CAAC;;AAElE,IAAI,MAAM,WAAA,GAAc,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;AAClE,IAAI,MAAM,oBAAoB,WAAW,EAAE,UAAU,CAAC,WAAW,CAAC;;AAElE,IAAI,IAAI,CAAC,iBAAiB,EAAE;AAC5B,MAAM;AACN,IAAI;;AAEJ,IAAI,MAAM,IAAA,GAAO,QAAQ,CAAC,IAAA;AAC1B,IAAI,MAAM,OAAA,GAAU,IAAI,WAAW,EAAE;AACrC,IAAI,QAAQ,CAAC,IAAA,GAAO,IAAI,cAAc,CAAC;AACvC,MAAM,KAAK,EAAE,MAAM,UAAA,IAAc;AACjC,QAAQ,WAAW,MAAM,KAAA,IAAS,IAAI,EAAE;AACxC,UAAU,MAAM,OAAO,OAAO,UAAU,QAAA,GAAW,KAAA,GAAQ,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAA,EAAM,CAAC;AAClG,UAAU,MAAM,YAAA,GAAe,gBAAgB,CAAC,IAAI,CAAC;AACrD,UAAU,UAAU,CAAC,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;AACpE,QAAQ;AACR,QAAQ,UAAU,CAAC,KAAK,EAAE;AAC1B,MAAM,CAAC;AACP,KAAK,CAAC;AACN,EAAE,CAAC;AACH;;;;"}
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"],"names":["getTraceMetaTags","addNonEnumerableProperty"],"mappings":";;;;AAQA,SAAS,iBAAiB,IAAA,EAAsB;AAC9C,EAAA,MAAM,WAAWA,qBAAA,EAAiB;AAElC,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,OAAA,GAAU,CAAA;AAAA,EAAW,QAAQ;AAAA,CAAA;AACnC,EAAA,OAAO,IAAA,CAAK,OAAA,CAAQ,QAAA,EAAU,OAAO,CAAA;AACvC;AAMO,SAAS,8BAAA,GAAiC;AAC/C,EAAA,OAAO,eAAe,gBAAA,CAAiB,KAAA,EAAmB,QAAA,EAAsC;AAC9F,IAAA,IAAI,CAAC,QAAA,CAAS,IAAA,IAAQ,QAAA,CAAS,kBAAA,EAAoB;AACjD,MAAA;AAAA,IACF;AAIA,IAAAC,6BAAA,CAAyB,QAAA,EAAU,sBAAsB,IAAI,CAAA;AAE7D,IAAA,MAAM,WAAA,GAAc,KAAA,CAAM,QAAA,CAAS,OAAA,CAAQ,IAAI,cAAc,CAAA;AAC7D,IAAA,MAAM,iBAAA,GAAoB,WAAA,EAAa,UAAA,CAAW,WAAW,CAAA;AAE7D,IAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,OAAO,QAAA,CAAS,IAAA;AACtB,IAAA,MAAM,OAAA,GAAU,IAAI,WAAA,EAAY;AAChC,IAAA,QAAA,CAAS,IAAA,GAAO,IAAI,cAAA,CAAe;AAAA,MACjC,KAAA,EAAO,OAAM,UAAA,KAAc;AACzB,QAAA,WAAA,MAAiB,SAAS,IAAA,EAAM;AAC9B,UAAA,MAAM,IAAA,GAAO,OAAO,KAAA,KAAU,QAAA,GAAW,KAAA,GAAQ,OAAA,CAAQ,MAAA,CAAO,KAAA,EAAO,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAA;AACvF,UAAA,MAAM,YAAA,GAAe,iBAAiB,IAAI,CAAA;AAC1C,UAAA,UAAA,CAAW,QAAQ,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,YAAY,CAAC,CAAA;AAAA,QAC3D;AACA,QAAA,UAAA,CAAW,KAAA,EAAM;AAAA,MACnB;AAAA,KACD,CAAA;AAAA,EACH,CAAA;AACF;;;;"}
@@ -4,17 +4,12 @@ const core = require('@sentry/core');
4
4
  const node = require('@sentry/node');
5
5
  const utils = require('./utils.js');
6
6
 
7
- /**
8
- * Initializes the server side of the Solid Start SDK
9
- */
10
7
  function init(options) {
11
8
  const opts = {
12
- ...options,
9
+ ...options
13
10
  };
14
-
15
- core.applySdkMetadata(opts, 'solidstart', ['solidstart', 'node']);
11
+ core.applySdkMetadata(opts, "solidstart", ["solidstart", "node"]);
16
12
  utils.filterLowQualityTransactions(opts);
17
-
18
13
  return node.init(opts);
19
14
  }
20
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import { applySdkMetadata } from '@sentry/core';\nimport type { NodeClient, NodeOptions } from '@sentry/node';\nimport { init as initNodeSdk } from '@sentry/node';\nimport { filterLowQualityTransactions } from './utils';\n\n/**\n * Initializes the server side of the Solid Start SDK\n */\nexport function init(options: NodeOptions): NodeClient | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'solidstart', ['solidstart', 'node']);\n filterLowQualityTransactions(opts);\n\n return initNodeSdk(opts);\n}\n"],"names":["applySdkMetadata","filterLowQualityTransactions","initNodeSdk"],"mappings":";;;;;;AAKA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAuC;AACnE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,qBAAgB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAC9D,EAAEC,kCAA4B,CAAC,IAAI,CAAC;;AAEpC,EAAE,OAAOC,SAAW,CAAC,IAAI,CAAC;AAC1B;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../../src/server/sdk.ts"],"sourcesContent":["import { applySdkMetadata } from '@sentry/core';\nimport type { NodeClient, NodeOptions } from '@sentry/node';\nimport { init as initNodeSdk } from '@sentry/node';\nimport { filterLowQualityTransactions } from './utils';\n\n/**\n * Initializes the server side of the Solid Start SDK\n */\nexport function init(options: NodeOptions): NodeClient | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'solidstart', ['solidstart', 'node']);\n filterLowQualityTransactions(opts);\n\n return initNodeSdk(opts);\n}\n"],"names":["applySdkMetadata","filterLowQualityTransactions","initNodeSdk"],"mappings":";;;;;;AAQO,SAAS,KAAK,OAAA,EAA8C;AACjE,EAAA,MAAM,IAAA,GAAO;AAAA,IACX,GAAG;AAAA,GACL;AAEA,EAAAA,qBAAA,CAAiB,IAAA,EAAM,YAAA,EAAc,CAAC,YAAA,EAAc,MAAM,CAAC,CAAA;AAC3D,EAAAC,kCAAA,CAA6B,IAAI,CAAA;AAEjC,EAAA,OAAOC,UAAY,IAAI,CAAA;AACzB;;;;"}
@@ -3,40 +3,21 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const solidJs = require('solid-js');
4
4
  const web = require('solid-js/web');
5
5
 
6
- // We use @sentry/solid/solidrouter on the client.
7
- // On the server, we have to create matching components
8
- // in structure to avoid hydration errors.
9
-
10
- /** Pass-through component in case user didn't specify a root **/
11
6
  function SentryDefaultRoot(props) {
12
7
  return props.children;
13
8
  }
14
-
15
- /**
16
- * On the client, router hooks are used in the router's root render prop.
17
- * This creates a matching structure that's purely pass-through to avoid hydration errors.
18
- */
19
9
  function withSentryRouterRoot(Root) {
20
10
  const SentryRouterRoot = (props) => {
21
11
  return web.createComponent(Root, props);
22
12
  };
23
-
24
13
  return SentryRouterRoot;
25
14
  }
26
-
27
- /**
28
- * On the client, router hooks are used to start navigation spans.
29
- * This creates a matching structure that's purely pass-through to avoid hydration errors.
30
- */
31
15
  function withSentryRouterRouting(Router) {
32
16
  const SentryRouter = (props) => {
33
- const [local, others] = solidJs.splitProps(props, ['root']);
34
- // We need to wrap root here in case the user passed in their own root
17
+ const [local, others] = solidJs.splitProps(props, ["root"]);
35
18
  const Root = withSentryRouterRoot(local.root ? local.root : SentryDefaultRoot);
36
-
37
19
  return web.createComponent(Router, solidJs.mergeProps({ root: Root }, others));
38
20
  };
39
-
40
21
  return SentryRouter;
41
22
  }
42
23
 
@@ -1 +1 @@
1
- {"version":3,"file":"solidrouter.js","sources":["../../../src/server/solidrouter.ts"],"sourcesContent":["import type { HashRouter, MemoryRouter, Router as BaseRouter, RouteSectionProps, StaticRouter } from '@solidjs/router';\nimport type { Component, JSX, ParentProps } from 'solid-js';\nimport { mergeProps, splitProps } from 'solid-js';\nimport { createComponent } from 'solid-js/web';\n\n// We use @sentry/solid/solidrouter on the client.\n// On the server, we have to create matching components\n// in structure to avoid hydration errors.\n\n/** Pass-through component in case user didn't specify a root **/\nfunction SentryDefaultRoot(props: ParentProps): JSX.Element {\n return props.children;\n}\n\n/**\n * On the client, router hooks are used in the router's root render prop.\n * This creates a matching structure that's purely pass-through to avoid hydration errors.\n */\nfunction withSentryRouterRoot(Root: Component<RouteSectionProps>): Component<RouteSectionProps> {\n const SentryRouterRoot = (props: RouteSectionProps): JSX.Element => {\n return createComponent(Root, props);\n };\n\n return SentryRouterRoot;\n}\n\nexport type RouterType = typeof BaseRouter | typeof HashRouter | typeof MemoryRouter | typeof StaticRouter;\n\n/**\n * On the client, router hooks are used to start navigation spans.\n * This creates a matching structure that's purely pass-through to avoid hydration errors.\n */\nexport function withSentryRouterRouting(Router: RouterType): RouterType {\n const SentryRouter = (props: Parameters<RouterType>[0]): JSX.Element => {\n const [local, others] = splitProps(props, ['root']);\n // We need to wrap root here in case the user passed in their own root\n const Root = withSentryRouterRoot(local.root ? local.root : SentryDefaultRoot);\n\n return createComponent(Router, mergeProps({ root: Root }, others));\n };\n\n return SentryRouter;\n}\n"],"names":["createComponent","splitProps","mergeProps"],"mappings":";;;;;AAKA;AACA;AACA;;AAEA;AACA,SAAS,iBAAiB,CAAC,KAAK,EAA4B;AAC5D,EAAE,OAAO,KAAK,CAAC,QAAQ;AACvB;;AAEA;AACA;AACA;AACA;AACA,SAAS,oBAAoB,CAAC,IAAI,EAA8D;AAChG,EAAE,MAAM,gBAAA,GAAmB,CAAC,KAAK,KAAqC;AACtE,IAAI,OAAOA,mBAAe,CAAC,IAAI,EAAE,KAAK,CAAC;AACvC,EAAE,CAAC;;AAEH,EAAE,OAAO,gBAAgB;AACzB;;AAIA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,MAAM,EAA0B;AACxE,EAAE,MAAM,YAAA,GAAe,CAAC,KAAK,KAA6C;AAC1E,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,CAAA,GAAIC,kBAAU,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC;AACvD;AACA,IAAI,MAAM,IAAA,GAAO,oBAAoB,CAAC,KAAK,CAAC,IAAA,GAAO,KAAK,CAAC,IAAA,GAAO,iBAAiB,CAAC;;AAElF,IAAI,OAAOD,mBAAe,CAAC,MAAM,EAAEE,kBAAU,CAAC,EAAE,IAAI,EAAE,IAAA,EAAM,EAAE,MAAM,CAAC,CAAC;AACtE,EAAE,CAAC;;AAEH,EAAE,OAAO,YAAY;AACrB;;;;"}
1
+ {"version":3,"file":"solidrouter.js","sources":["../../../src/server/solidrouter.ts"],"sourcesContent":["import type { HashRouter, MemoryRouter, Router as BaseRouter, RouteSectionProps, StaticRouter } from '@solidjs/router';\nimport type { Component, JSX, ParentProps } from 'solid-js';\nimport { mergeProps, splitProps } from 'solid-js';\nimport { createComponent } from 'solid-js/web';\n\n// We use @sentry/solid/solidrouter on the client.\n// On the server, we have to create matching components\n// in structure to avoid hydration errors.\n\n/** Pass-through component in case user didn't specify a root **/\nfunction SentryDefaultRoot(props: ParentProps): JSX.Element {\n return props.children;\n}\n\n/**\n * On the client, router hooks are used in the router's root render prop.\n * This creates a matching structure that's purely pass-through to avoid hydration errors.\n */\nfunction withSentryRouterRoot(Root: Component<RouteSectionProps>): Component<RouteSectionProps> {\n const SentryRouterRoot = (props: RouteSectionProps): JSX.Element => {\n return createComponent(Root, props);\n };\n\n return SentryRouterRoot;\n}\n\nexport type RouterType = typeof BaseRouter | typeof HashRouter | typeof MemoryRouter | typeof StaticRouter;\n\n/**\n * On the client, router hooks are used to start navigation spans.\n * This creates a matching structure that's purely pass-through to avoid hydration errors.\n */\nexport function withSentryRouterRouting(Router: RouterType): RouterType {\n const SentryRouter = (props: Parameters<RouterType>[0]): JSX.Element => {\n const [local, others] = splitProps(props, ['root']);\n // We need to wrap root here in case the user passed in their own root\n const Root = withSentryRouterRoot(local.root ? local.root : SentryDefaultRoot);\n\n return createComponent(Router, mergeProps({ root: Root }, others));\n };\n\n return SentryRouter;\n}\n"],"names":["createComponent","splitProps","mergeProps"],"mappings":";;;;;AAUA,SAAS,kBAAkB,KAAA,EAAiC;AAC1D,EAAA,OAAO,KAAA,CAAM,QAAA;AACf;AAMA,SAAS,qBAAqB,IAAA,EAAkE;AAC9F,EAAA,MAAM,gBAAA,GAAmB,CAAC,KAAA,KAA0C;AAClE,IAAA,OAAOA,mBAAA,CAAgB,MAAM,KAAK,CAAA;AAAA,EACpC,CAAA;AAEA,EAAA,OAAO,gBAAA;AACT;AAQO,SAAS,wBAAwB,MAAA,EAAgC;AACtE,EAAA,MAAM,YAAA,GAAe,CAAC,KAAA,KAAkD;AACtE,IAAA,MAAM,CAAC,OAAO,MAAM,CAAA,GAAIC,mBAAW,KAAA,EAAO,CAAC,MAAM,CAAC,CAAA;AAElD,IAAA,MAAM,OAAO,oBAAA,CAAqB,KAAA,CAAM,IAAA,GAAO,KAAA,CAAM,OAAO,iBAAiB,CAAA;AAE7E,IAAA,OAAOD,mBAAA,CAAgB,QAAQE,kBAAA,CAAW,EAAE,MAAM,IAAA,EAAK,EAAG,MAAM,CAAC,CAAA;AAAA,EACnE,CAAA;AAEA,EAAA,OAAO,YAAA;AACT;;;;"}
@@ -3,47 +3,29 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3
3
  const core = require('@sentry/core');
4
4
  const node = require('@sentry/node');
5
5
 
6
- /**
7
- * Determines if a thrown "error" is a redirect Response which Solid Start users can throw to redirect to another route.
8
- * see: https://docs.solidjs.com/solid-router/reference/data-apis/response-helpers#redirect
9
- * @param error the potential redirect error
10
- */
11
6
  function isRedirect(error) {
12
7
  if (error == null || !(error instanceof Response)) {
13
8
  return false;
14
9
  }
15
-
16
- const hasValidLocation = typeof error.headers.get('location') === 'string';
10
+ const hasValidLocation = typeof error.headers.get("location") === "string";
17
11
  const hasValidStatus = error.status >= 300 && error.status <= 308;
18
12
  return hasValidLocation && hasValidStatus;
19
13
  }
20
-
21
- /**
22
- * Filter function for low quality transactions
23
- *
24
- * Exported only for tests
25
- */
26
14
  function lowQualityTransactionsFilter(options) {
27
15
  return Object.assign(
28
- (event => {
29
- if (event.type !== 'transaction') {
16
+ ((event) => {
17
+ if (event.type !== "transaction") {
30
18
  return event;
31
19
  }
32
- // Filter out transactions for build assets
33
20
  if (event.transaction?.match(/^GET \/_build\//)) {
34
- options.debug && core.debug.log('SolidStartLowQualityTransactionsFilter filtered transaction', event.transaction);
21
+ options.debug && core.debug.log("SolidStartLowQualityTransactionsFilter filtered transaction", event.transaction);
35
22
  return null;
36
23
  }
37
24
  return event;
38
- }) ,
39
- { id: 'SolidStartLowQualityTransactionsFilter' },
25
+ }),
26
+ { id: "SolidStartLowQualityTransactionsFilter" }
40
27
  );
41
28
  }
42
-
43
- /**
44
- * Adds an event processor to filter out low quality transactions,
45
- * e.g. to filter out transactions for build assets
46
- */
47
29
  function filterLowQualityTransactions(options) {
48
30
  node.getGlobalScope().addEventProcessor(lowQualityTransactionsFilter(options));
49
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../src/server/utils.ts"],"sourcesContent":["import type { EventProcessor, Options } from '@sentry/core';\nimport { debug } from '@sentry/core';\nimport { getGlobalScope } from '@sentry/node';\n\n/**\n * Determines if a thrown \"error\" is a redirect Response which Solid Start users can throw to redirect to another route.\n * see: https://docs.solidjs.com/solid-router/reference/data-apis/response-helpers#redirect\n * @param error the potential redirect error\n */\nexport function isRedirect(error: unknown): boolean {\n if (error == null || !(error instanceof Response)) {\n return false;\n }\n\n const hasValidLocation = typeof error.headers.get('location') === 'string';\n const hasValidStatus = error.status >= 300 && error.status <= 308;\n return hasValidLocation && hasValidStatus;\n}\n\n/**\n * Filter function for low quality transactions\n *\n * Exported only for tests\n */\nexport function lowQualityTransactionsFilter(options: Options): EventProcessor {\n return Object.assign(\n (event => {\n if (event.type !== 'transaction') {\n return event;\n }\n // Filter out transactions for build assets\n if (event.transaction?.match(/^GET \\/_build\\//)) {\n options.debug && debug.log('SolidStartLowQualityTransactionsFilter filtered transaction', event.transaction);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'SolidStartLowQualityTransactionsFilter' },\n );\n}\n\n/**\n * Adds an event processor to filter out low quality transactions,\n * e.g. to filter out transactions for build assets\n */\nexport function filterLowQualityTransactions(options: Options): void {\n getGlobalScope().addEventProcessor(lowQualityTransactionsFilter(options));\n}\n"],"names":["debug","getGlobalScope"],"mappings":";;;;;AAIA;AACA;AACA;AACA;AACA;AACO,SAAS,UAAU,CAAC,KAAK,EAAoB;AACpD,EAAE,IAAI,KAAA,IAAS,IAAA,IAAQ,EAAE,KAAA,YAAiB,QAAQ,CAAC,EAAE;AACrD,IAAI,OAAO,KAAK;AAChB,EAAE;;AAEF,EAAE,MAAM,gBAAA,GAAmB,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAA,KAAM,QAAQ;AAC5E,EAAE,MAAM,cAAA,GAAiB,KAAK,CAAC,MAAA,IAAU,GAAA,IAAO,KAAK,CAAC,MAAA,IAAU,GAAG;AACnE,EAAE,OAAO,gBAAA,IAAoB,cAAc;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B,CAAC,OAAO,EAA2B;AAC/E,EAAE,OAAO,MAAM,CAAC,MAAM;AACtB,KAAK,SAAS;AACd,MAAM,IAAI,KAAK,CAAC,IAAA,KAAS,aAAa,EAAE;AACxC,QAAQ,OAAO,KAAK;AACpB,MAAM;AACN;AACA,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAAE;AACvD,QAAQ,OAAO,CAAC,KAAA,IAASA,UAAK,CAAC,GAAG,CAAC,6DAA6D,EAAE,KAAK,CAAC,WAAW,CAAC;AACpH,QAAQ,OAAO,IAAI;AACnB,MAAM;AACN,MAAM,OAAO,KAAK;AAClB,IAAI,CAAC;AACL,IAAI,EAAE,EAAE,EAAE,wCAAA,EAA0C;AACpD,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,SAAS,4BAA4B,CAAC,OAAO,EAAiB;AACrE,EAAEC,mBAAc,EAAE,CAAC,iBAAiB,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;AAC3E;;;;;;"}
1
+ {"version":3,"file":"utils.js","sources":["../../../src/server/utils.ts"],"sourcesContent":["import type { EventProcessor, Options } from '@sentry/core';\nimport { debug } from '@sentry/core';\nimport { getGlobalScope } from '@sentry/node';\n\n/**\n * Determines if a thrown \"error\" is a redirect Response which Solid Start users can throw to redirect to another route.\n * see: https://docs.solidjs.com/solid-router/reference/data-apis/response-helpers#redirect\n * @param error the potential redirect error\n */\nexport function isRedirect(error: unknown): boolean {\n if (error == null || !(error instanceof Response)) {\n return false;\n }\n\n const hasValidLocation = typeof error.headers.get('location') === 'string';\n const hasValidStatus = error.status >= 300 && error.status <= 308;\n return hasValidLocation && hasValidStatus;\n}\n\n/**\n * Filter function for low quality transactions\n *\n * Exported only for tests\n */\nexport function lowQualityTransactionsFilter(options: Options): EventProcessor {\n return Object.assign(\n (event => {\n if (event.type !== 'transaction') {\n return event;\n }\n // Filter out transactions for build assets\n if (event.transaction?.match(/^GET \\/_build\\//)) {\n options.debug && debug.log('SolidStartLowQualityTransactionsFilter filtered transaction', event.transaction);\n return null;\n }\n return event;\n }) satisfies EventProcessor,\n { id: 'SolidStartLowQualityTransactionsFilter' },\n );\n}\n\n/**\n * Adds an event processor to filter out low quality transactions,\n * e.g. to filter out transactions for build assets\n */\nexport function filterLowQualityTransactions(options: Options): void {\n getGlobalScope().addEventProcessor(lowQualityTransactionsFilter(options));\n}\n"],"names":["debug","getGlobalScope"],"mappings":";;;;;AASO,SAAS,WAAW,KAAA,EAAyB;AAClD,EAAA,IAAI,KAAA,IAAS,IAAA,IAAQ,EAAE,KAAA,YAAiB,QAAA,CAAA,EAAW;AACjD,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,mBAAmB,OAAO,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,UAAU,CAAA,KAAM,QAAA;AAClE,EAAA,MAAM,cAAA,GAAiB,KAAA,CAAM,MAAA,IAAU,GAAA,IAAO,MAAM,MAAA,IAAU,GAAA;AAC9D,EAAA,OAAO,gBAAA,IAAoB,cAAA;AAC7B;AAOO,SAAS,6BAA6B,OAAA,EAAkC;AAC7E,EAAA,OAAO,MAAA,CAAO,MAAA;AAAA,KACX,CAAA,KAAA,KAAS;AACR,MAAA,IAAI,KAAA,CAAM,SAAS,aAAA,EAAe;AAChC,QAAA,OAAO,KAAA;AAAA,MACT;AAEA,MAAA,IAAI,KAAA,CAAM,WAAA,EAAa,KAAA,CAAM,iBAAiB,CAAA,EAAG;AAC/C,QAAA,OAAA,CAAQ,KAAA,IAASA,UAAA,CAAM,GAAA,CAAI,6DAAA,EAA+D,MAAM,WAAW,CAAA;AAC3G,QAAA,OAAO,IAAA;AAAA,MACT;AACA,MAAA,OAAO,KAAA;AAAA,IACT,CAAA;AAAA,IACA,EAAE,IAAI,wCAAA;AAAyC,GACjD;AACF;AAMO,SAAS,6BAA6B,OAAA,EAAwB;AACnE,EAAAC,mBAAA,EAAe,CAAE,iBAAA,CAAkB,4BAAA,CAA6B,OAAO,CAAC,CAAA;AAC1E;;;;;;"}