-
-
Notifications
You must be signed in to change notification settings - Fork 276
Firebase Remote Config Integration #2837
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
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
9d77e52
add feature flag models
denrase 16ee1e6
add FeatureFlagsIntegration
denrase 956e388
remove comments, add test
denrase 1559285
use bool type for value
denrase 3944ea1
add sentry_firebase package
denrase e9ce800
add feature flag if provided key is updated from remote config
denrase e5fdace
format
denrase 4e6bd4c
test wether subscription is canceld on close
denrase 5bfac70
add option to activate remote config
denrase db48687
Merge branch 'main' into feat/feature-flags-integration
denrase 6dc16c8
review feedback
denrase 42eea2e
Merge branch 'feat/feature-flags-integration' into fear/firebase-feat…
denrase c8b754d
Merge branch 'main' into feat/feature-flags-integration
denrase bdfaf44
format cl
denrase 4f247a5
updates
denrase aa8bcc6
Merge branch 'feat/feature-flags-integration' into fear/firebase-feat…
denrase 1f041dd
Merge branch 'main' into fear/firebase-feature-flags
denrase 112f211
add cl entry
denrase 969e12d
log message
denrase 17fd9c1
update readme
denrase 63c08b0
run flutter test
denrase 0b2b321
use flutter sdk
denrase 2a415c2
fix & format
denrase 52a5a16
fix test expectations
denrase b64acc2
update example values
denrase 213c627
fix example
denrase 28fd231
add firebase to version bump
denrase 012fd33
update yaml files
denrase 03016ba
make params named
denrase 8c85832
change name to firebase_remote_config
denrase 40a5b23
fix test and added integration
denrase eac7227
rename package folder, observe all boolean keys
denrase e147a00
fix analyze warning
denrase 214bd71
Merge branch 'main' into fear/firebase-feature-flags
buenaflor 0f6361e
Merge branch 'main' into fear/firebase-feature-flags
buenaflor e980c8d
add sample in readme
denrase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: sentry-firebase-remote-config | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- release/** | ||
pull_request: | ||
paths: | ||
- '!**/*.md' | ||
- '!**/class-diagram.svg' | ||
- '.github/workflows/firebase_remote_config.yml' | ||
- '.github/workflows/analyze.yml' | ||
- '.github/actions/dart-test/**' | ||
- '.github/actions/coverage/**' | ||
- 'dart/**' | ||
- 'flutter/**' | ||
- 'firebase_remote_config/**' | ||
|
||
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: '${{ matrix.os }} | ${{ matrix.sdk }}' | ||
runs-on: ${{ matrix.os }}-latest | ||
timeout-minutes: 30 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [macos, ubuntu, windows] | ||
sdk: [stable, beta] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/flutter-test | ||
with: | ||
directory: firebase_remote_config | ||
web: false | ||
|
||
# TODO: don't set coverage for now to finish publishing it | ||
# - uses: ./.github/actions/coverage | ||
# if: runner.os == 'Linux' && matrix.sdk == 'stable' | ||
# with: | ||
# token: ${{ secrets.CODECOV_TOKEN }} | ||
# directory: firebase_remote_config | ||
# coverage: sentry_firebase_remote_config | ||
# min-coverage: 55 | ||
|
||
analyze: | ||
uses: ./.github/workflows/analyze.yml | ||
with: | ||
package: firebase_remote_config | ||
sdk: flutter |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,20 @@ | |
// Manually track a feature flag | ||
Sentry.addFeatureFlag('my-feature', true); | ||
``` | ||
- Firebase Remote Config Integration ([#2837](https://github.com/getsentry/sentry-dart/pull/2837)) | ||
```dart | ||
// Add the integration to automatically track feature flags from firebase remote config. | ||
await SentryFlutter.init( | ||
(options) { | ||
options.dsn = 'https://[email protected]/add-your-dsn-here'; | ||
options.addIntegration( | ||
SentryFirebaseRemoteConfigIntegration( | ||
firebaseRemoteConfig: yourRirebaseRemoteConfig, | ||
), | ||
); | ||
}, | ||
); | ||
``` | ||
|
||
### Behavioral changes | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Omit committing pubspec.lock for library packages; see | ||
# https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
pubspec.lock | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: "09de023485e95e6d1225c2baa44b8feb85e0d45f" | ||
channel: "stable" | ||
|
||
project_type: package |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../CHANGELOG.md |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Sentry | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<p align="center"> | ||
<a href="https://sentry.io" target="_blank" align="center"> | ||
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280"> | ||
</a> | ||
<br /> | ||
</p> | ||
|
||
|
||
=========== | ||
|
||
<p align="center"> | ||
<a href="https://sentry.io" target="_blank" align="center"> | ||
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280"> | ||
</a> | ||
<br /> | ||
</p> | ||
|
||
Sentry integration for `firebase_remote_config` package | ||
=========== | ||
|
||
| package | build | pub | likes | popularity | pub points | | ||
|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------| ------- | | ||
| 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) | ||
|
||
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 | ||
|
||
#### Usage | ||
|
||
- Sign up for a Sentry.io account and get a DSN at https://sentry.io. | ||
|
||
- Follow the installing instructions on [pub.dev](https://pub.dev/packages/sentry/install). | ||
|
||
- Initialize the Sentry SDK using the DSN issued by Sentry.io. | ||
|
||
- Call... | ||
|
||
```dart | ||
import 'package:firebase_core/firebase_core.dart'; | ||
import 'package:firebase_remote_config_example/home_page.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
import 'package:sentry_firebase_remote_config/sentry_firebase_remote_config.dart'; | ||
|
||
import 'firebase_options.dart'; | ||
|
||
Future<void> main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
await Firebase.initializeApp( | ||
options: DefaultFirebaseOptions.currentPlatform, | ||
); | ||
|
||
final remoteConfig = FirebaseRemoteConfig.instance; | ||
await remoteConfig.setConfigSettings(RemoteConfigSettings( | ||
fetchTimeout: const Duration(minutes: 1), | ||
minimumFetchInterval: const Duration(hours: 1), | ||
)); | ||
|
||
await SentryFlutter.init( | ||
(options) { | ||
options.dsn = 'https://[email protected]/add-your-dsn-here'; | ||
|
||
final sentryFirebaseRemoteConfigIntegration = SentryFirebaseRemoteConfigIntegration( | ||
firebaseRemoteConfig: remoteConfig, | ||
// Don't call `await remoteConfig.activate();` when firebase config is updated. Per default this is true. | ||
activateOnConfigUpdated: false, | ||
); | ||
options.addIntegration(sentryFirebaseRemoteConfigIntegration); | ||
}, | ||
); | ||
|
||
runApp(const RemoteConfigApp()); | ||
} | ||
|
||
class RemoteConfigApp extends StatelessWidget { | ||
const RemoteConfigApp({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Remote Config Example', | ||
home: const HomePage(), | ||
theme: ThemeData( | ||
useMaterial3: true, | ||
primarySwatch: Colors.blue, | ||
), | ||
); | ||
} | ||
} | ||
``` | ||
|
||
#### Resources | ||
|
||
* [](https://docs.sentry.io/platforms/flutter/) | ||
* [](https://docs.sentry.io/platforms/dart/) | ||
* [](https://github.com/getsentry/sentry-dart/discussions) | ||
* [](https://discord.gg/PXa5Apfe7K) | ||
* [](https://stackoverflow.com/questions/tagged/sentry) | ||
* [](https://twitter.com/intent/follow?screen_name=getsentry) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
include: package:lints/recommended.yaml | ||
|
||
analyzer: | ||
language: | ||
strict-casts: true | ||
strict-inference: true | ||
strict-raw-types: true | ||
errors: | ||
# treat missing required parameters as a warning (not a hint) | ||
missing_required_param: error | ||
# treat missing returns as a warning (not a hint) | ||
missing_return: error | ||
# allow having TODOs in the code | ||
todo: ignore | ||
# allow self-reference to deprecated members (we do this because otherwise we have | ||
# to annotate every member in every test, assert, etc, when we deprecate something) | ||
deprecated_member_use_from_same_package: warning | ||
# ignore sentry/path on pubspec as we change it on deployment | ||
invalid_dependency: ignore | ||
exclude: | ||
- example/** | ||
- test/mocks/mocks.mocks.dart | ||
|
||
linter: | ||
rules: | ||
- prefer_final_locals | ||
- prefer_single_quotes | ||
- prefer_relative_imports | ||
- unnecessary_brace_in_string_interps | ||
- implementation_imports | ||
- require_trailing_commas | ||
- unawaited_futures |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../dart/dartdoc_options.yaml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'package:firebase_core/firebase_core.dart'; | ||
import 'package:firebase_remote_config_example/home_page.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
import 'package:sentry_firebase_remote_config/sentry_firebase_remote_config.dart'; | ||
|
||
import 'firebase_options.dart'; | ||
|
||
Future<void> main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
await Firebase.initializeApp( | ||
options: DefaultFirebaseOptions.currentPlatform, | ||
); | ||
|
||
final remoteConfig = FirebaseRemoteConfig.instance; | ||
await remoteConfig.setConfigSettings(RemoteConfigSettings( | ||
fetchTimeout: const Duration(minutes: 1), | ||
minimumFetchInterval: const Duration(hours: 1), | ||
)); | ||
|
||
await SentryFlutter.init( | ||
(options) { | ||
options.dsn = 'https://[email protected]/add-your-dsn-here'; | ||
|
||
final sentryFirebaseRemoteConfigIntegration = | ||
SentryFirebaseRemoteConfigIntegration( | ||
firebaseRemoteConfig: remoteConfig, | ||
// Don't call `await remoteConfig.activate();` when firebase config is updated. Per default this is true. | ||
activateOnConfigUpdated: false, | ||
); | ||
options.addIntegration(sentryFirebaseRemoteConfigIntegration); | ||
}, | ||
); | ||
|
||
runApp(const RemoteConfigApp()); | ||
} | ||
|
||
class RemoteConfigApp extends StatelessWidget { | ||
const RemoteConfigApp({Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Remote Config Example', | ||
home: const HomePage(), | ||
theme: ThemeData( | ||
useMaterial3: true, | ||
primarySwatch: Colors.blue, | ||
), | ||
); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
firebase_remote_config/lib/sentry_firebase_remote_config.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
library; | ||
|
||
export 'src/sentry_firebase_remote_config_integration.dart'; |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.