fix: move Sentry DSN and Mixpanel token to dart-define env vars (#40)#45
Merged
Merged
Conversation
…siekpl#40) Both values were hardcoded in source — anyone with read access to the repo could send events to the project's Sentry org or Mixpanel account. Replace with const String.fromEnvironment(): - SENTRY_DSN in lib/main.dart (guarded: Sentry skipped if absent) - MIXPANEL_TOKEN in lib/constants.dart Add .env.example documenting both variables and the --dart-define invocation pattern. Add .env.example to .gitignore. For production builds, store both values as CI secrets and inject via --dart-define at build time.
✅ Deploy Preview for aedmap ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #45 +/- ##
=======================================
Coverage ? 22.78%
=======================================
Files ? 52
Lines ? 3516
Branches ? 0
=======================================
Hits ? 801
Misses ? 2715
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Fixes #40.
Both secrets were hardcoded in source, meaning anyone with read access to the repository could send arbitrary events to the project's Sentry organisation or Mixpanel account.
Changes:
lib/main.dartwithconst String.fromEnvironment('SENTRY_DSN'). If the variable is absent (e.g. a local dev build without the secret), Sentry initialisation is skipped entirely rather than crashing with an invalid DSN.lib/constants.dartwithconst String.fromEnvironment('MIXPANEL_TOKEN')..env.exampledocumenting both variables and the--dart-defineinvocation pattern for local builds and CI.Usage for production builds:
In CI, store both values as repository secrets and inject via
--dart-definein the build step.Test plan
flutter test— 35 tests passflutter analyze lib/main.dart lib/constants.dart— no issues--dart-definevaluesCloses #40