Skip to content

feat(expo): Add withSentryExpoSerializers for easy metro configuration #3454

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 8 commits into from
Dec 7, 2023

Conversation

krystofwoldrich
Copy link
Member

@krystofwoldrich krystofwoldrich commented Dec 7, 2023

📢 Type of change

  • New feature

📜 Description

This PR adds withSentryExpoSerializers which overrides an existing custom serializer in the config and replaces it with the combination of Expo and Sentry serializers.

💡 Motivation and Context

Expo projects by default include Expo serializers and replacing them with Sentry serializers might lose some functions. withSentryExpoSerializers simplifies otherwise verbose setup like this:

Before

const { getDefaultConfig } = require('expo/metro-config');
const { mergeConfig } = require('metro');
const { createSentryMetroSerializer } = require("@sentry/react-native/metro");
const { withExpoSerializers } = require('@expo/metro-config/build/serializer/withExpoSerializers');

const config = getDefaultConfig(__dirname);

const sentryConfig = {
  serializer: {
    customSerializer: createSentryMetroSerializer()
  }
};

const finalConfig = mergeConfig(config, sentryConfig);

module.exports = withExpoSerializers(finalConfig);

After

const { getDefaultConfig } = require('expo/metro-config');
const { withSentryExpoSerializers } = require("@sentry/react-native/metro");

const config = getDefaultConfig(__dirname);
module.exports = withSentryExpoSerializers(config);

💚 How did you test it?

sample app

📝 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

Copy link
Contributor

github-actions bot commented Dec 7, 2023

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

Generated by 🚫 dangerJS against c6b13be

Copy link
Contributor

github-actions bot commented Dec 7, 2023

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 437.00 ms 469.08 ms 32.08 ms
Size 17.73 MiB 19.84 MiB 2.11 MiB

Copy link
Contributor

github-actions bot commented Dec 7, 2023

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 375.84 ms 412.92 ms 37.08 ms
Size 7.15 MiB 8.11 MiB 988.28 KiB

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.

LGTM!

Base automatically changed from kw-bump-to-expo-49 to expo December 7, 2023 15:33
@krystofwoldrich krystofwoldrich merged commit 817bb8d into expo Dec 7, 2023
@krystofwoldrich krystofwoldrich deleted the kw-add-with-sentry-expo-serializer branch December 7, 2023 16:39
Copy link
Contributor

github-actions bot commented Dec 7, 2023

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1275.16 ms 1282.52 ms 7.36 ms
Size 2.36 MiB 2.88 MiB 524.09 KiB

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