Skip to content

feat: add isDebug option to override __DEV__ detection - #19

Open
michaelyoon wants to merge 1 commit into
aptabase:mainfrom
michaelyoon:feat/is-debug-option
Open

feat: add isDebug option to override __DEV__ detection#19
michaelyoon wants to merge 1 commit into
aptabase:mainfrom
michaelyoon:feat/is-debug-option

Conversation

@michaelyoon

Copy link
Copy Markdown

Problem

isDebug is derived from __DEV__ only. __DEV__ is false for every release build, which includes the release builds developers use for their own pre-release testing - TestFlight, an Android internal testing track, or a locally built release binary for end-to-end tests. There is currently no way to tell the SDK about that, so a developer testing their own app writes into production data and skews exactly the numbers they are trying to read.

Change

Adds an optional isDebug to AptabaseOptions:

Aptabase.init("<APP_KEY>", {
  isDebug: __DEV__ || isRunningInternalBuild(),
});

Omitting it keeps today's behavior exactly. The override is applied to the client's EnvironmentInfo next to the existing appVersion override, so it covers both events and (since 0.6.0) error reports, with no change to either dispatcher.

Deciding which builds count as debug is left to the app - that detection is platform- and distribution-specific (StoreKit's AppTransaction environment on iOS, a build-time flag elsewhere) and does not belong in the SDK.

Prior art in the other Aptabase SDKs

This is parity, not a new idea. The React Native SDK is the outlier:

  • @aptabase/web already has isDebug?: boolean in its init options (isDebug: opts.isDebug ?? getIsDebug()) - same name, same semantics as this PR.
  • aptabase-swift 0.3.11 added InitOptions(trackingMode: .asDebug / .asRelease / .readFromEnvironment).
  • aptabase-maui added IsDebugMode to AptabaseOptions.

I went with the web SDK's boolean rather than the Swift tri-state enum because isDebug?: boolean already expresses all three states in TypeScript (true / false / omitted = read from environment). Happy to rename or switch to a trackingMode-style option if you would rather match Swift.

Tests

Two tests added to src/client.spec.ts, mirroring the existing appVersion override test: one asserting the override reaches systemProps, one asserting the environment value is untouched when the option is omitted. npm test passes (78/78) and npm run build succeeds.

Also documented in the README, llms.txt and CHANGELOG.

__DEV__ is false for every release build, including internal ones such as
TestFlight, so a developer's own pre-release testing is reported as
production data with no way to opt out.

Add an optional isDebug flag to AptabaseOptions that overrides the value
read from the environment. Omitting it keeps the current __DEV__ behavior.
The override lands on the client's environment info, so it applies to both
events and error reports.

This matches the isDebug option in @aptabase/web and the trackingMode
option added to the Swift SDK in 0.3.11.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.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.

1 participant