Skip to content

Surface textComponentNames option in Metro config for autoInjectSentryLabel #6146

Description

@antonis

Problem Statement

The @sentry/babel-plugin-component-annotate supports a textComponentNames option that tells autoInjectSentryLabel which components contain text (defaults to ["Text"]). Many larger React Native apps use custom text wrapper components (e.g. MyText, StyledText, Typography) that wrap the built-in Text. These custom components are not recognized by the Babel plugin, so their text content is not used for sentry-label injection.

Solution

Surface the textComponentNames option through the Metro config's annotateReactComponents option, alongside the existing ignoredComponents and autoInjectSentryLabel options:

module.exports = withSentryConfig(config, {
  annotateReactComponents: {
    textComponentNames: ['Text', 'MyText', 'Typography'],
  },
});

This would pass the option through to the Babel plugin via SentryBabelTransformerOptions.

Context

Part of the "Making breadcrumbs data more useful" project. The autoInjectSentryLabel feature was enabled by default in #6141.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions