Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nuxt): Add option autoInjectServerSentry (no default import()) #14553

Merged
merged 10 commits into from
Dec 6, 2024

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Dec 3, 2024

As injecting the dynamic import() came with a bunch of challenges related to how the build output looks like, this default is changed to make users use the --import CLI flag.

This PR basically reverts this: #13958

Copy link

codecov bot commented Dec 3, 2024

❌ 5 Tests Failed:

Tests completed Failed Passed Skipped
245 5 240 8
View the top 3 failed tests by shortest run time
tracing.server.test.ts sends a server action transaction on pageload
Stack Traces | 30s run time
tracing.server.test.ts:5:1 sends a server action transaction on pageload
errors.server.test.ts server-side errorscaptures api fetch error (fetched on click)
Stack Traces | 30s run time
errors.server.test.ts:5:3 captures api fetch error (fetched on click)
tracing.test.ts distributed tracingcapture a distributed pageload trace
Stack Traces | 30s run time
tracing.test.ts:7:3 capture a distributed pageload trace

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@s1gr1d s1gr1d force-pushed the sig/import-flag-default branch from b8caf04 to d435ce2 Compare December 4, 2024 10:05
@s1gr1d s1gr1d requested review from andreiborza and Lms24 December 5, 2024 13:05
@s1gr1d s1gr1d marked this pull request as ready for review December 5, 2024 13:05
@@ -54,15 +58,15 @@ export default defineNuxtModule<ModuleOptions>({
const serverConfigFile = findDefaultSdkInitFile('server');

if (serverConfigFile) {
if (moduleOptions.dynamicImportForServerEntry === false) {
if (moduleOptions.autoInjectServerSentry !== 'experimental_dynamic-import') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: What if this option is undefined (i.e. people add --import)? Do we still need to inject the top level import?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only when the server config file is added and resolved properly (which is done in the rollup plugin with the dynamic import()), this is not needed.

In the other cases (user provided --import or top-level import), the file is not resolved properly and the import of the sentry release injection file is missing (leads to an error). By adding the import of the server config in the plugin template, the imports are resolved correctly.

However, it does not actually import the file and initialize the SDK a second time. So this is just for resolving. But I can add a comment for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah maybe I mixed something up here. Feel free to add a comment but disregard my comment otherwise :)

/**
* Extracts the filename from a path.
*/
export function getFilenameFromPath(path: string): string | null {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: any reason to use this over path.basename?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's not only a path, it's the full node command like node whatever/path/index.mjs, but I can change the function signature to make it more clear.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaict, path.basename handles such a scenario:

image

but no strong feelings. If we stick with this implementation, let's just make sure we document why we need it instead of using the builtin :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it generally works but my tests where I checked for a Windows-style string and for a string like this node ./server/, path.basename did not work.

@s1gr1d s1gr1d requested review from mydea and Lms24 December 5, 2024 14:36
@s1gr1d s1gr1d merged commit 121ae07 into develop Dec 6, 2024
127 checks passed
@s1gr1d s1gr1d deleted the sig/import-flag-default branch December 6, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants