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: Add Sentry Babel Transformer #3916

Merged
merged 16 commits into from
Jul 3, 2024

Conversation

krystofwoldrich
Copy link
Member

@krystofwoldrich krystofwoldrich commented Jun 26, 2024

📢 Type of change

  • New feature

📜 Description

This PR adds @sentry/babel-plugin-component-annotate to @sentry/react-native/metro.

Example use RN 0.72 and newer:

// For Expo
const { getSentryExpoConfig } = require("@sentry/react-native/metro");
const config = getSentryExpoConfig(__dirname, { annotateReactComponents: true });

// For RN
const m = mergeConfig(getDefaultConfig(__dirname), config);

module.exports = withSentryConfig(m, {
  annotateReactComponents: true, // default false
});

For RN 0.65 to 0.71 (these version did not have default config in metro.config.js but applied it later, that changed in 0.72):

const config  = {
  transformer: {
	babelTransformerPath: require.resolve('metro-babel-transformer'),
	// this must be adjust to appropriate babel transformer for given RN version
  },
};

💡 Motivation and Context

💚 How did you test it?

sample apps, e2e tests, unit tests

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • All tests passing
  • No breaking changes

🔮 Next steps

  • Add docs

Copy link
Contributor

github-actions bot commented Jun 26, 2024

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

Generated by 🚫 dangerJS against 6463a17

@krystofwoldrich krystofwoldrich changed the title Kw/add-sentry-babel-transaformer feat: Add Sentry Babel Transformer Jun 26, 2024
Copy link
Contributor

github-actions bot commented Jun 26, 2024

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1215.96 ms 1219.10 ms 3.14 ms
Size 2.36 MiB 3.05 MiB 702.87 KiB

Baseline results on branch: feat/replay

Startup times

Revision Plain With Sentry Diff
063bfce+dirty 1224.27 ms 1219.66 ms -4.61 ms
41db11d+dirty 1207.36 ms 1210.32 ms 2.96 ms
376301c+dirty 1215.73 ms 1219.80 ms 4.06 ms

App size

Revision Plain With Sentry Diff
063bfce+dirty 2.36 MiB 3.05 MiB 702.78 KiB
41db11d+dirty 2.36 MiB 3.04 MiB 698.69 KiB
376301c+dirty 2.36 MiB 3.05 MiB 702.83 KiB

Previous results on branch: kw/add-sentry-babel-transaformer

Startup times

Revision Plain With Sentry Diff
fd77856+dirty 1230.60 ms 1222.46 ms -8.15 ms
3ae09f5+dirty 1219.96 ms 1217.64 ms -2.32 ms

App size

Revision Plain With Sentry Diff
fd77856+dirty 2.36 MiB 3.05 MiB 702.80 KiB
3ae09f5+dirty 2.36 MiB 3.05 MiB 702.85 KiB

Copy link
Contributor

github-actions bot commented Jun 26, 2024

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1241.69 ms 1245.53 ms 3.84 ms
Size 2.92 MiB 3.61 MiB 710.19 KiB

Baseline results on branch: feat/replay

Startup times

Revision Plain With Sentry Diff
063bfce+dirty 1225.38 ms 1218.06 ms -7.31 ms
41db11d+dirty 1208.60 ms 1210.47 ms 1.87 ms
376301c+dirty 1224.74 ms 1227.00 ms 2.26 ms

App size

Revision Plain With Sentry Diff
063bfce+dirty 2.92 MiB 3.61 MiB 710.22 KiB
41db11d+dirty 2.92 MiB 3.61 MiB 705.84 KiB
376301c+dirty 2.92 MiB 3.61 MiB 709.95 KiB

Previous results on branch: kw/add-sentry-babel-transaformer

Startup times

Revision Plain With Sentry Diff
fd77856+dirty 1245.06 ms 1254.37 ms 9.30 ms
3ae09f5+dirty 1228.45 ms 1236.63 ms 8.18 ms

App size

Revision Plain With Sentry Diff
fd77856+dirty 2.92 MiB 3.61 MiB 710.01 KiB
3ae09f5+dirty 2.92 MiB 3.61 MiB 709.96 KiB

Base automatically changed from kw/add-replay-network-breadcrumb to feat/replay June 27, 2024 14:45
Copy link
Contributor

github-actions bot commented Jun 27, 2024

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 371.65 ms 408.49 ms 36.84 ms
Size 7.15 MiB 8.31 MiB 1.17 MiB

Baseline results on branch: feat/replay

Startup times

Revision Plain With Sentry Diff
41db11d+dirty 374.57 ms 415.25 ms 40.68 ms
376301c+dirty 353.80 ms 388.54 ms 34.74 ms

App size

Revision Plain With Sentry Diff
41db11d+dirty 7.15 MiB 8.31 MiB 1.16 MiB
376301c+dirty 7.15 MiB 8.31 MiB 1.17 MiB

Previous results on branch: kw/add-sentry-babel-transaformer

Startup times

Revision Plain With Sentry Diff
fd77856+dirty 333.29 ms 360.62 ms 27.33 ms

App size

Revision Plain With Sentry Diff
fd77856+dirty 7.15 MiB 8.31 MiB 1.17 MiB

Copy link
Contributor

github-actions bot commented Jun 28, 2024

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 417.02 ms 451.45 ms 34.43 ms
Size 17.73 MiB 20.04 MiB 2.30 MiB

Baseline results on branch: feat/replay

Startup times

Revision Plain With Sentry Diff
063bfce 469.96 ms 516.38 ms 46.42 ms
41db11d 429.33 ms 451.24 ms 21.91 ms
376301c 445.52 ms 474.70 ms 29.18 ms

App size

Revision Plain With Sentry Diff
063bfce 17.73 MiB 20.04 MiB 2.30 MiB
41db11d 17.73 MiB 20.04 MiB 2.30 MiB
376301c 17.73 MiB 20.04 MiB 2.30 MiB

Previous results on branch: kw/add-sentry-babel-transaformer

Startup times

Revision Plain With Sentry Diff
fd77856 445.88 ms 456.24 ms 10.36 ms
3ae09f5 437.38 ms 465.81 ms 28.43 ms

App size

Revision Plain With Sentry Diff
fd77856 17.73 MiB 20.04 MiB 2.30 MiB
3ae09f5 17.73 MiB 20.04 MiB 2.30 MiB

@krystofwoldrich krystofwoldrich marked this pull request as ready for review June 28, 2024 19:04
@krystofwoldrich krystofwoldrich marked this pull request as draft June 28, 2024 19:10
@krystofwoldrich krystofwoldrich marked this pull request as ready for review June 28, 2024 19:10
Copy link
Collaborator

@vaind vaind left a comment

Choose a reason for hiding this comment

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

This goes well beyond my understanding of the ecosystem but the I approve of the idea, because it's exactly what I wanted to do at first, I just didn't know how.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
Copy link
Member

@lforst lforst left a comment

Choose a reason for hiding this comment

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

Take with a grain of salt because I am no expert but nothing in this PR looks completely off to me.

src/js/tools/sentryBabelTransformer.ts Show resolved Hide resolved
*/
export function withSentryBabelTransformer(config: MetroConfig): MetroConfig {
const defaultBabelTransformerPath = config.transformer && config.transformer.babelTransformerPath;
logger.debug('Default Babel transformer path from `config.transformer`:', defaultBabelTransformerPath);
Copy link
Member

Choose a reason for hiding this comment

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

The Sentry SDK logger is mostly intended to be used when the SDK is initialized. For build tooling we usually don't rely on it. I would do a good ol' console.log instead.

src/js/tools/metroconfig.ts Show resolved Hide resolved
src/js/tools/sentryBabelTransformerUtils.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@lucas-zimerman lucas-zimerman left a comment

Choose a reason for hiding this comment

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

Looks good to me from my part, LGTM!

@krystofwoldrich krystofwoldrich merged commit 6067ecc into feat/replay Jul 3, 2024
41 of 42 checks passed
@krystofwoldrich krystofwoldrich deleted the kw/add-sentry-babel-transaformer branch July 3, 2024 15:49
@0Calories
Copy link
Member

Thanks for expanding support to react native! This looks great

bruno-garcia added a commit that referenced this pull request Jul 15, 2024
* feat(replay): Add Mobile Replay Alpha (#3714)

* feat(sample): add running indicator (animation overlay) (#3903)

* feat(replay): Add breadcrumbs mapping from RN to RRWeb format (#3846)

* feat(replay): Add network breadcrumbs (#3912)

* fix(replay): Add tests for touch events (#3924)

* feat(replay): Filter Sentry event breadcrumbs (#3925)

* fix(changelog): Add latest native SDKs details

* release: 5.25.0-alpha.2

* misc(samples): Add console anything examples for replay testing (#3928)

* feat: Add Sentry Babel Transformer (#3916)

* fix(replay): Add app lifecycle breadcrumbs conversion tests (#3932)

* chore(deps): bump sentry-android to 7.12.0-alpha.3

* chore(deps): bump sentry-android to 7.12.0-alpha.4

* fix(replay): Mask SVGs from `react-native-svg` when `maskAllVectors=true` (#3930)

* fix(replay): Add missing properties to android nav breadcrumbs (#3942)

* release: 5.26.0-alpha.3

* misc(replay): Add Mobile Replay Public Beta changelog (#3943)

---------

Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com>
Co-authored-by: Ivan Dlugos <dlugos.ivan@gmail.com>
Co-authored-by: getsentry-bot <bot@sentry.io>
Co-authored-by: getsentry-bot <bot@getsentry.com>
Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com>
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
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.

5 participants