Skip to content

Add public API surface tracking with api-extractor #6092

@antonis

Description

@antonis

Problem

The Sentry Cocoa and Android SDKs have automated public API tracking (Cocoa uses swift-api-digester, Android uses Metalava), but the React Native SDK has no equivalent. Public API changes can slip through without explicit review, risking accidental breaking changes.

Solution

Add @microsoft/api-extractor to generate a committed .api.md baseline report and a CI check that fails if the public API changes without updating it.

This mirrors the approach used by:

  • sentry-cocoa: swift-api-digester with committed JSON baselines + api-stability.yml CI workflow
  • sentry-java (Android): Metalava with api.txt + apiCheck Gradle task
  • react-native core: @microsoft/api-extractor in scripts/js-api/

Implementation

  • Add api-extractor.json config and a dedicated tsconfig.api-extractor.json
  • Generate and commit the baseline report at packages/core/etc/sentry-react-native.api.md
  • Add api-report:generate and api-report:check scripts
  • Add a CI job in buildandtest.yml that validates the report is up to date
  • Add yarn api-report root shortcut

Developer Workflow

When changing the public API:

yarn build:sdk
yarn api-report
# Review diff in packages/core/etc/sentry-react-native.api.md
# Commit the updated report alongside code changes

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions