feat: add isDebug option to override __DEV__ detection - #19
Open
michaelyoon wants to merge 1 commit into
Open
Conversation
__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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
isDebugis 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
isDebugtoAptabaseOptions:Omitting it keeps today's behavior exactly. The override is applied to the client's
EnvironmentInfonext to the existingappVersionoverride, 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
AppTransactionenvironment 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/webalready hasisDebug?: booleanin its init options (isDebug: opts.isDebug ?? getIsDebug()) - same name, same semantics as this PR.aptabase-swift0.3.11 addedInitOptions(trackingMode: .asDebug / .asRelease / .readFromEnvironment).aptabase-mauiaddedIsDebugModetoAptabaseOptions.I went with the web SDK's boolean rather than the Swift tri-state enum because
isDebug?: booleanalready expresses all three states in TypeScript (true/false/ omitted = read from environment). Happy to rename or switch to atrackingMode-style option if you would rather match Swift.Tests
Two tests added to
src/client.spec.ts, mirroring the existingappVersionoverride test: one asserting the override reachessystemProps, one asserting the environment value is untouched when the option is omitted.npm testpasses (78/78) andnpm run buildsucceeds.Also documented in the README,
llms.txtand CHANGELOG.