Skip to content

feat(sveltekit): Add SDK setup code#249

Merged
Lms24 merged 5 commits intolms/sveltekit-supportfrom
lms/sveltekit-sdk-init
Apr 19, 2023
Merged

feat(sveltekit): Add SDK setup code#249
Lms24 merged 5 commits intolms/sveltekit-supportfrom
lms/sveltekit-sdk-init

Conversation

@Lms24
Copy link
Copy Markdown
Member

@Lms24 Lms24 commented Apr 18, 2023

This PR adds basic SDK setup code generation to the wizard.

During SDK setup, we distinguish between two cases for each SvelteKit (client and server) hook file:

  • If no hook file exists, we can just copy our hooks file template with the complete instrumentation. Great! 🎉
  • If there is a pre-existing hooks file, we partially merge it with a Sentry import and init call and request additional manual intervention from the user

With this PR, there are still four three manual steps required to get the SDK working. The wizard will prompt the user to do each step with simple code examples:

  • If hooks files were merged, users need to manually add error and request handlers (1-3 steps)
  • Regardless of hooks files, users need to add our plugin to their Vite config.

Theoretically, we can further automate the merging process, as well as adjusting the Vite config. However, this requires AST modification and before I start with that, I want to get this out. The goal is of course to get rid of all manual steps. A very promising library for AST manipulation is magicast 👀

Example flow without pre-existing hooks files:
image

#skip-changelog

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 18, 2023

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 96d548f

@Lms24 Lms24 force-pushed the lms/sveltekit-sdk-init branch from f85fcf8 to 7f7c37b Compare April 18, 2023 15:39
@Lms24 Lms24 requested review from AbhiPrasad and lforst April 18, 2023 15:39
@Lms24 Lms24 self-assigned this Apr 18, 2023
// sessions when an error occurs.
replaysOnErrorSampleRate: 1.0,

integrations: [new Sentry.Replay()],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

giga-l: Maybe a note that users can remove this if they don't intend to use replay? (bundle size and all)

export const handle = sequence(sentryHandle);

// If you have a custom error handler, pass it to `handleErrorWithSentry`
export const handleError = handleErrorWithSentry(); No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

super-giga-l: Do we wanna add a newline at the end of these template files? I think it's pretty common everywhere.

@Lms24 Lms24 force-pushed the lms/sveltekit-cli-config branch 3 times, most recently from e1b5b8b to 4c1eb25 Compare April 19, 2023 12:41
Base automatically changed from lms/sveltekit-cli-config to lms/sveltekit-support April 19, 2023 12:43
@Lms24 Lms24 force-pushed the lms/sveltekit-sdk-init branch from 6429d39 to 5e4fc8c Compare April 19, 2023 12:49
@Lms24 Lms24 merged commit 59c07d4 into lms/sveltekit-support Apr 19, 2023
@Lms24 Lms24 deleted the lms/sveltekit-sdk-init branch April 19, 2023 12:58
Lms24 added a commit that referenced this pull request Apr 19, 2023
Add basic SDK setup code generation to the wizard. 

During SDK setup, we distinguish between two cases for each SvelteKit (client and server) hook file:
* If no hook file exists, we can just copy our hooks file template with the complete instrumentation. Great! 🎉
* If there is a pre-existing hooks file, we partially merge it with a Sentry import and init call and request additional manual intervention from the user
Lms24 added a commit that referenced this pull request Apr 21, 2023
Add basic SDK setup code generation to the wizard. 

During SDK setup, we distinguish between two cases for each SvelteKit (client and server) hook file:
* If no hook file exists, we can just copy our hooks file template with the complete instrumentation. Great! 🎉
* If there is a pre-existing hooks file, we partially merge it with a Sentry import and init call and request additional manual intervention from the user
Lms24 added a commit that referenced this pull request May 3, 2023
Add basic SDK setup code generation to the wizard. 

During SDK setup, we distinguish between two cases for each SvelteKit (client and server) hook file:
* If no hook file exists, we can just copy our hooks file template with the complete instrumentation. Great! 🎉
* If there is a pre-existing hooks file, we partially merge it with a Sentry import and init call and request additional manual intervention from the user
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.

2 participants