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(core): Add lifecycle hooks #7370

Merged
merged 11 commits into from Mar 8, 2023
Merged

feat(core): Add lifecycle hooks #7370

merged 11 commits into from Mar 8, 2023

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Mar 7, 2023

Closes #7343

This PR adds a basic schema for hooks in the SDK. They live on the client.

Currently there are three hooks defined, but none of them are implemented. They are beforeTransaction, transactionFinish, and beforeEnvelope.

@AbhiPrasad AbhiPrasad self-assigned this Mar 7, 2023
packages/types/src/client.ts Outdated Show resolved Hide resolved
packages/types/src/hooks.ts Outdated Show resolved Hide resolved
@AbhiPrasad AbhiPrasad marked this pull request as ready for review March 8, 2023 15:23
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.22 KB (+0.51% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 62.89 KB (+0.6% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.85 KB (+0.53% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 55.8 KB (+0.56% 🔺)
@sentry/browser - Webpack (gzipped + minified) 20.6 KB (+0.5% 🔺)
@sentry/browser - Webpack (minified) 67.32 KB (+0.5% 🔺)
@sentry/react - Webpack (gzipped + minified) 20.62 KB (+0.47% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 48.36 KB (+0.18% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 27.35 KB (+0.33% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.62 KB (+0.41% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.15 KB (+0.08% 🔺)
@sentry/replay - Webpack (gzipped + minified) 37.16 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.01 KB (+0.18% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 54.31 KB (+0.16% 🔺)

@mydea
Copy link
Member

mydea commented Mar 8, 2023

I pushed some changes onto this branch to use generics for type safety. I tried it locally and it seems to give me correct type safety as long as you specify the generic. Not sure if there is a way to enforce to provide the generic, not infer it 😅 but you can at least opt into type safety this way, and as an additional plus you only need to edit/add new hook types in a single place now!

@mydea
Copy link
Member

mydea commented Mar 8, 2023

cc @AbhiPrasad & @lforst refactored this again based on our discussion, looks good now I think, and the tests should also cover this decently (both the client & testclient case)

@AbhiPrasad AbhiPrasad enabled auto-merge (squash) March 8, 2023 18:18
@AbhiPrasad AbhiPrasad merged commit 3eeef09 into develop Mar 8, 2023
@AbhiPrasad AbhiPrasad deleted the abhi-hooks branch March 8, 2023 19:16
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 hook interface to BaseClient and Client type
3 participants