Skip to content

fix: move Sentry DSN and Mixpanel token to dart-define env vars (#40)#45

Merged
matisiekpl merged 3 commits into
matisiekpl:mainfrom
chrisdebian:fix/40-sentry-dsn-env
Jun 10, 2026
Merged

fix: move Sentry DSN and Mixpanel token to dart-define env vars (#40)#45
matisiekpl merged 3 commits into
matisiekpl:mainfrom
chrisdebian:fix/40-sentry-dsn-env

Conversation

@chrisdebian

Copy link
Copy Markdown
Contributor

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:

  • Replace the hardcoded Sentry DSN in lib/main.dart with const 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.
  • Replace the hardcoded Mixpanel token in lib/constants.dart with const String.fromEnvironment('MIXPANEL_TOKEN').
  • Add .env.example documenting both variables and the --dart-define invocation pattern for local builds and CI.

Usage for production builds:

flutter build apk \
  --dart-define=SENTRY_DSN=https://xxx@yyy.ingest.sentry.io/zzz \
  --dart-define=MIXPANEL_TOKEN=your_token_here

In CI, store both values as repository secrets and inject via --dart-define in the build step.

Test plan

  • flutter test — 35 tests pass
  • flutter analyze lib/main.dart lib/constants.dart — no issues
  • Verify Sentry receives events in a production build with DSN injected
  • Verify app runs normally (Sentry/Mixpanel disabled) when built without --dart-define values

Closes #40

…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.
@netlify

netlify Bot commented Jun 4, 2026

Copy link
Copy Markdown

Deploy Preview for aedmap ready!

Name Link
🔨 Latest commit 7e797dd
🔍 Latest deploy log https://app.netlify.com/projects/aedmap/deploys/6a29156320ee260008ac45ba
😎 Deploy Preview https://deploy-preview-45--aedmap.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov-commenter

codecov-commenter commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 45 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@c0c30ea). Learn more about missing BASE report.

Files with missing lines Patch % Lines
lib/main.dart 0.00% 14 Missing ⚠️
lib/repositories/points_repository.dart 0.00% 11 Missing ⚠️
lib/bloc/edit/edit_cubit.dart 0.00% 9 Missing ⚠️
lib/screens/photo/photo_source_bottom_sheet.dart 0.00% 4 Missing ⚠️
lib/screens/map/map_header.dart 0.00% 2 Missing ⚠️
lib/bloc/feedback/feedback_cubit.dart 0.00% 1 Missing ⚠️
lib/bloc/points/points_cubit.dart 0.00% 1 Missing ⚠️
lib/bloc/routing/routing_cubit.dart 0.00% 1 Missing ⚠️
lib/screens/map/bottom_panel.dart 0.00% 1 Missing ⚠️
.../screens/pending_changes/pending_changes_page.dart 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@matisiekpl matisiekpl merged commit 025546b into matisiekpl:main Jun 10, 2026
6 checks passed
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.

Security: Sentry DSN hardcoded in lib/main.dart

3 participants