Skip to content

ref(serverless): Convert integrations to functional approach #10329

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

Merged
merged 7 commits into from
Jan 29, 2024

Conversation

AbhiPrasad
Copy link
Member

This PR updates the serverless integrations to use the functional approach, and rewrites all of the serverless unit tests.

In the unit test rewrite we remove the usage of global mocks and instead do per file mocks. I dislike the amount of mocks that still exist, but to prevent any regressions I only tried to translate the test code.

@AbhiPrasad AbhiPrasad requested review from mydea, a team and ale-cota and removed request for a team January 24, 2024 21:32
Copy link
Contributor

github-actions bot commented Jan 24, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 78.12 KB (-0.03% 🔽)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 69.33 KB (-0.03% 🔽)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 73.22 KB (-0.04% 🔽)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.95 KB (-0.03% 🔽)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 33.35 KB (-0.09% 🔽)
@sentry/browser (incl. browserTracingIntegration) - Webpack (gzipped) 33.2 KB (-0.22% 🔽)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.33 KB (+0.01% 🔺)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 31.34 KB (+0.01% 🔺)
@sentry/browser - Webpack (gzipped) 22.6 KB (-0.02% 🔽)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 75.89 KB (-0.09% 🔽)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.44 KB (-0.09% 🔽)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 33.32 KB (-0.14% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.51 KB (-0.03% 🔽)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 212.53 KB (-0.01% 🔽)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 100.54 KB (-0.02% 🔽)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 73.44 KB (+0.13% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 36.4 KB (-0.17% 🔽)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69.73 KB (-0.04% 🔽)
@sentry/react - Webpack (gzipped) 22.63 KB (-0.02% 🔽)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 86.4 KB (-0.04% 🔽)
@sentry/nextjs Client - Webpack (gzipped) 50.7 KB (-0.05% 🔽)
@sentry-internal/feedback - Webpack (gzipped) 17.21 KB (-0.04% 🔽)

export const AWSServices = convertIntegrationFnToClass(
INTEGRATION_NAME,
awsServicesIntegration,
) as IntegrationClass<Integration>;
Copy link
Member

Choose a reason for hiding this comment

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

let's also add:

export type AWSServices = typeof AWSServices;

right away here (same for the gcp stuff)!

Copy link
Member Author

Choose a reason for hiding this comment

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

do we have to also export the type from the index?

Copy link
Member

Choose a reason for hiding this comment

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

otherwise this does not work anymore (it does not work with the stuff I migrated):

import {AWSServices} from '@sentry/serverless';

let a: AWSServices | undefined;
// instead you need to do this:
let b: typeof AWSServices | undefined;

This is very unlikely to affect somebody, but for consistency we should do that (and also for all other integrations, just didn't get to it yet...)

@AbhiPrasad AbhiPrasad force-pushed the abhi-serverless-func branch from 6f3cde4 to 6b2a174 Compare January 25, 2024 21:49
@AbhiPrasad AbhiPrasad enabled auto-merge (squash) January 29, 2024 22:08
@AbhiPrasad AbhiPrasad merged commit ea85419 into develop Jan 29, 2024
@AbhiPrasad AbhiPrasad deleted the abhi-serverless-func branch January 29, 2024 22:11
@AbhiPrasad AbhiPrasad self-assigned this Jan 29, 2024
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