|
| 1 | +<p align="center"> |
| 2 | + <a href="https://sentry.io" target="_blank" align="center"> |
| 3 | + <img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280"> |
| 4 | + </a> |
| 5 | + <br /> |
| 6 | +</p> |
| 7 | + |
| 8 | + |
| 9 | +=========== |
| 10 | + |
| 11 | +<p align="center"> |
| 12 | + <a href="https://sentry.io" target="_blank" align="center"> |
| 13 | + <img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280"> |
| 14 | + </a> |
| 15 | + <br /> |
| 16 | +</p> |
| 17 | + |
| 18 | +Sentry integration for `firebase_remote_config` package |
| 19 | +=========== |
| 20 | + |
| 21 | +| package | build | pub | likes | popularity | pub points | |
| 22 | +|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------| ------- | |
| 23 | +| sentry_firebase_remote_config | [](https://github.com/getsentry/sentry-dart/actions?query=workflow%3Asentry-firebase) | [](https://pub.dev/packages/sentry_firebase_remote_config) | [](https://pub.dev/packages/sentry_firebase_remote_config/score) | [](https://pub.dev/packages/sentry_firebase_remote_config/score) | [](https://pub.dev/packages/sentry_firebase_remote_config/score) |
| 24 | + |
| 25 | +Integration for [`firebase_remote_config`](https://pub.dev/packages/firebase_remote_config) package. Track changes to firebase boolean values as feature flags in Sentry.io |
| 26 | + |
| 27 | +#### Usage |
| 28 | + |
| 29 | +- Sign up for a Sentry.io account and get a DSN at https://sentry.io. |
| 30 | + |
| 31 | +- Follow the installing instructions on [pub.dev](https://pub.dev/packages/sentry/install). |
| 32 | + |
| 33 | +- Initialize the Sentry SDK using the DSN issued by Sentry.io. |
| 34 | + |
| 35 | +- Call... |
| 36 | + |
| 37 | +```dart |
| 38 | +import 'package:firebase_core/firebase_core.dart'; |
| 39 | +import 'package:firebase_remote_config_example/home_page.dart'; |
| 40 | +import 'package:flutter/material.dart'; |
| 41 | +import 'package:sentry_flutter/sentry_flutter.dart'; |
| 42 | +import 'package:sentry_firebase_remote_config/sentry_firebase_remote_config.dart'; |
| 43 | +
|
| 44 | +import 'firebase_options.dart'; |
| 45 | +
|
| 46 | +Future<void> main() async { |
| 47 | + WidgetsFlutterBinding.ensureInitialized(); |
| 48 | + await Firebase.initializeApp( |
| 49 | + options: DefaultFirebaseOptions.currentPlatform, |
| 50 | + ); |
| 51 | +
|
| 52 | + final remoteConfig = FirebaseRemoteConfig.instance; |
| 53 | + await remoteConfig.setConfigSettings(RemoteConfigSettings( |
| 54 | + fetchTimeout: const Duration(minutes: 1), |
| 55 | + minimumFetchInterval: const Duration(hours: 1), |
| 56 | + )); |
| 57 | +
|
| 58 | + await SentryFlutter.init( |
| 59 | + (options) { |
| 60 | + options.dsn = 'https://[email protected]/add-your-dsn-here'; |
| 61 | +
|
| 62 | + final sentryFirebaseRemoteConfigIntegration = SentryFirebaseRemoteConfigIntegration( |
| 63 | + firebaseRemoteConfig: remoteConfig, |
| 64 | + // Don't call `await remoteConfig.activate();` when firebase config is updated. Per default this is true. |
| 65 | + activateOnConfigUpdated: false, |
| 66 | + ); |
| 67 | + options.addIntegration(sentryFirebaseRemoteConfigIntegration); |
| 68 | + }, |
| 69 | + ); |
| 70 | +
|
| 71 | + runApp(const RemoteConfigApp()); |
| 72 | +} |
| 73 | +
|
| 74 | +class RemoteConfigApp extends StatelessWidget { |
| 75 | + const RemoteConfigApp({Key? key}) : super(key: key); |
| 76 | +
|
| 77 | + @override |
| 78 | + Widget build(BuildContext context) { |
| 79 | + return MaterialApp( |
| 80 | + title: 'Remote Config Example', |
| 81 | + home: const HomePage(), |
| 82 | + theme: ThemeData( |
| 83 | + useMaterial3: true, |
| 84 | + primarySwatch: Colors.blue, |
| 85 | + ), |
| 86 | + ); |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +#### Resources |
| 92 | + |
| 93 | +* [](https://docs.sentry.io/platforms/flutter/) |
| 94 | +* [](https://docs.sentry.io/platforms/dart/) |
| 95 | +* [](https://github.com/getsentry/sentry-dart/discussions) |
| 96 | +* [](https://discord.gg/PXa5Apfe7K) |
| 97 | +* [](https://stackoverflow.com/questions/tagged/sentry) |
| 98 | +* [](https://twitter.com/intent/follow?screen_name=getsentry) |
0 commit comments