From bde5f6b1cb1762d9a377a5c57399a5bd1d9b06b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Uek=C3=B6tter?= Date: Wed, 3 Jan 2024 11:58:40 +0100 Subject: [PATCH] Add app flavor to `flutter_context` (#1799) * Add app flavor * fix changelog --- CHANGELOG.md | 1 + .../event_processor/flutter_enricher_event_processor.dart | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71483dab8e..55773a0b75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Add `ConnectivityIntegration` for web ([#1765](https://github.com/getsentry/sentry-dart/pull/1765)) - We only get the info if online/offline on web platform. The added breadcrumb is set to either `wifi` or `none`. - APM for isar ([#1726](https://github.com/getsentry/sentry-dart/pull/1726)) +- Starting with Flutter 3.16, Sentry adds the [`appFlavor`](https://api.flutter.dev/flutter/services/appFlavor-constant.html) to the `flutter_context` ([#1799](https://github.com/getsentry/sentry-dart/pull/1799)) ## 7.14.0 diff --git a/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart b/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart index a4d04573a6..615c7a4974 100644 --- a/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart +++ b/flutter/lib/src/event_processor/flutter_enricher_event_processor.dart @@ -153,6 +153,7 @@ class FlutterEnricherEventProcessor implements EventProcessor { // See https://github.com/flutter/flutter/issues/83919 // 'window_is_visible': _window.viewConfiguration.visible, if (renderer != null) 'renderer': renderer, + if (_appFlavor != null) 'appFlavor': _appFlavor!, }; } @@ -266,3 +267,10 @@ class FlutterEnricherEventProcessor implements EventProcessor { return null; } } + +/// Copied from https://api.flutter.dev/flutter/services/appFlavor-constant.html +/// As soon as Flutter 3.16 is the minimal supported version of Sentry, this +/// can be replaced with the property from the link above. +const String? _appFlavor = String.fromEnvironment('FLUTTER_APP_FLAVOR') != '' + ? String.fromEnvironment('FLUTTER_APP_FLAVOR') + : null;