Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Show flavour in about this app and sentry #3429

Merged
merged 2 commits into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/app/lib/entrypoints/android/main_fdroid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ void main() {
'https://f-droid.org/fr/packages/openfoodfacts.github.scrachx.openfood/',
),
),
appFlavour: 'zxing-uri',
);
}
1 change: 1 addition & 0 deletions packages/app/lib/entrypoints/android/main_google_play.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ void main() {
launchSmoothApp(
scanner: MLKitCameraScanner(),
appStore: GooglePlayStore(),
appFlavour: 'ml-play',
);
}
1 change: 1 addition & 0 deletions packages/app/lib/entrypoints/ios/main_ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ void main() {
launchSmoothApp(
scanner: MLKitCameraScanner(),
appStore: AppleAppStore('588797948'),
appFlavour: 'ml-ios',
);
}
1 change: 1 addition & 0 deletions packages/smooth_app/integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void main() {
await app.launchSmoothApp(
scanner: MockedCameraScanner(),
appStore: const MockedAppStore(),
appFlavour: 'test-runner',
screenshots: true,
);
await tester.pumpAndSettle();
Expand Down
6 changes: 5 additions & 1 deletion packages/smooth_app/lib/helpers/analytics_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:matomo_tracker/matomo_tracker.dart';
import 'package:openfoodfacts/utils/OpenFoodAPIConfiguration.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:smooth_app/main.dart';

/// Category for Matomo Events
enum AnalyticsCategory {
Expand Down Expand Up @@ -55,7 +56,9 @@ class AnalyticsHelper {

static String latestSearch = '';

static Future<void> initSentry({Function()? appRunner}) async {
static Future<void> initSentry({
required Function()? appRunner,
}) async {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();

await SentryFlutter.init(
Expand All @@ -67,6 +70,7 @@ class AnalyticsHelper {
// To set a uniform sample rate
options.tracesSampleRate = 1.0;
options.beforeSend = _beforeSend;
options.environment = flavour;
},
appRunner: appRunner,
);
Expand Down
7 changes: 5 additions & 2 deletions packages/smooth_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ import 'package:smooth_app/themes/theme_provider.dart';
import 'package:smooth_app/widgets/smooth_scaffold.dart';

late bool _screenshots;
late String flavour;

Future<void> launchSmoothApp({
required CameraScanner scanner,
required AppStore appStore,
required String appFlavour,
final bool screenshots = false,
}) async {
_screenshots = screenshots;
Expand All @@ -49,10 +51,11 @@ Future<void> launchSmoothApp({
WidgetsFlutterBinding.ensureInitialized();
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);

flavour = appFlavour;

if (kReleaseMode) {
await AnalyticsHelper.initSentry(
appRunner: () => runApp(SmoothApp(scanner, appStore)),
);
appRunner: () => runApp(SmoothApp(scanner, appStore)));
} else {
runApp(
DevicePreview(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/dialogs/smooth_alert_dialog.dart';
import 'package:smooth_app/helpers/app_helper.dart';
import 'package:smooth_app/helpers/launch_url_helper.dart';
import 'package:smooth_app/main.dart';
import 'package:smooth_app/pages/preferences/abstract_user_preferences.dart';
import 'package:smooth_app/pages/preferences/user_preferences_list_tile.dart';
import 'package:smooth_app/pages/preferences/user_preferences_page.dart';
Expand Down Expand Up @@ -121,7 +122,7 @@ class UserPreferencesFaq extends AbstractUserPreferences {
),
),
Text(
'${packageInfo.version}+${packageInfo.buildNumber}',
'${packageInfo.version}+${packageInfo.buildNumber}-$flavour',
style: themeData.textTheme.subtitle2,
)
],
Expand Down