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

ref(sveltekit): Split up universal and server load wrappers #7652

Merged
merged 2 commits into from Mar 30, 2023

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 29, 2023

This PR splits up the previously generic handleLoadWithSentry wrapper function into two functions on the server side:

  • handleLoadWithSentry to wrap universal load on server and client
  • handleServerLoadWithSentry to wrap server load on the server (duh)

It further adjusts types on the client as well as on the server side to return a generic. The very liberal typing of the functions' generic is on purpose because any type that's more narrowed down (e.g. T extends Load) would create a type error with the users' actual load types. These types (e.g. PageData or ServerLayoutData) are generated at build time per route/page. Hence, we cannot access them.

If we manage to get the handleLoad hook into SvelteKit we should deprecate these functions and use that new handler which we'll also be able to type better.

Furthermore, I extracted some common trace propagation data extraction logic and added/adjusted tests.

closes #7526

I'll update the readme in a separate PR as more than just the load function section needs to be updated.

@Lms24 Lms24 requested a review from AbhiPrasad March 29, 2023 14:18
@Lms24 Lms24 force-pushed the lms/sveltekit-split-load-serverload branch from 262ff62 to 87f0538 Compare March 29, 2023 14:18
* @param origLoad SvelteKit user defined universal `load` function
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export declare function wrapLoadWithSentry<T extends (...args: any) => any>(origLoad: T): T;
Copy link
Member

Choose a reason for hiding this comment

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

Can we use unknown instead of any?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't 😢
image

I guess we specifically need any to stop type checking (?)

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.62 KB (-0.02% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 64.4 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 19.15 KB (-0.01% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 56.78 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 21.53 KB (0%)
@sentry/browser - Webpack (minified) 72 KB (0%)
@sentry/react - Webpack (gzipped + minified) 21.55 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 51.98 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 28.16 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 26.36 KB (-0.01% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 44.74 KB (0%)
@sentry/replay - Webpack (gzipped + minified) 38.86 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 63.41 KB (-0.01% 🔽)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 56.49 KB (-0.01% 🔽)

@Lms24 Lms24 merged commit dc0179c into develop Mar 30, 2023
27 checks passed
@Lms24 Lms24 deleted the lms/sveltekit-split-load-serverload branch March 30, 2023 06:34
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.

Add Sveltekit server-side performance monitoring instrumentation
2 participants