-
Notifications
You must be signed in to change notification settings - Fork 109
TF-4136 Add sentry for web #4137
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
Open
dab246
wants to merge
4
commits into
improvement/tf-4136-re-standardize-the-logger
Choose a base branch
from
improvement/tf-4136-add-sentry
base: improvement/tf-4136-re-standardize-the-logger
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fd61646
TF-4136 Add config Sentry
dab246 63fe9a4
TF-4136 Add document to configuration for Sentry
dab246 47253be
TF-4136 Remove all content-length in header request of mock unit test…
dab246 f3f5b70
TF-4136 security(sentry): scrub sensitive headers without mutating HT…
dab246 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ dependencies: | |
|
|
||
| json_annotation: 4.8.0 | ||
|
|
||
| dio: 5.0.0 | ||
| dio: 5.2.0 | ||
|
|
||
| http_mock_adapter: 0.4.2 | ||
|
|
||
|
|
||
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
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,43 @@ | ||
| import 'package:core/utils/app_logger.dart'; | ||
| import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
|
|
||
| class EnvLoader { | ||
| const EnvLoader._(); | ||
|
|
||
| static const String envFileName = 'env.file'; | ||
| static const String appFCMConfigurationPath = "configurations/env.fcm"; | ||
hoangdat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| static Future<void> loadEnvFile() async { | ||
| await loadConfigFromEnv(); | ||
| final mapEnvData = Map<String, String>.from(dotenv.env); | ||
dab246 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| await loadFcmConfigFileToEnv( | ||
| currentMapEnvData: mapEnvData, | ||
| onCallBack: () async { | ||
| await loadConfigFromEnv(); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| static Future<void> loadFcmConfigFileToEnv({ | ||
| Map<String, String>? currentMapEnvData, | ||
| Future<void> Function()? onCallBack, | ||
| }) async { | ||
| try { | ||
| await dotenv.load( | ||
| fileName: appFCMConfigurationPath, | ||
| mergeWith: currentMapEnvData ?? {}, | ||
| ); | ||
| } catch (e) { | ||
| logWarning('EnvLoader::loadFcmConfigFileToEnv: Exception = $e'); | ||
| await onCallBack?.call(); | ||
| } | ||
| } | ||
|
|
||
| static Future<void> loadConfigFromEnv() async { | ||
| try { | ||
| await dotenv.load(fileName: envFileName); | ||
| } catch (e) { | ||
| logWarning('EnvLoader::loadConfigFromEnv:Exception = $e'); | ||
| } | ||
| } | ||
| } | ||
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,74 @@ | ||
| import 'package:core/utils/application_manager.dart'; | ||
| import 'package:core/utils/build_utils.dart'; | ||
| import 'package:core/utils/config/env_loader.dart'; | ||
| import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
|
|
||
| /// Holds configuration values for initializing Sentry. | ||
| class SentryConfig { | ||
| // DSN (Data Source Name) endpoint for the Sentry project | ||
| final String dsn; | ||
|
|
||
| // Running environment (production/staging/dev) | ||
| final String environment; | ||
|
|
||
| // Current app release version | ||
| final String release; | ||
|
|
||
| // // Performance monitoring: Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing | ||
| final double tracesSampleRate; | ||
|
|
||
| // Optional profiling | ||
| final double profilesSampleRate; | ||
|
|
||
| // Enable logs to be sent to Sentry. To use Sentry.logger.fmt | ||
| final bool enableLogs; | ||
|
|
||
| // Debug logs during development | ||
| final bool isDebug; | ||
|
|
||
| // Automatically attaches a screenshot when capturing an error or exception. | ||
| final bool attachScreenshot; | ||
|
|
||
| // Check if Sentry is available | ||
| final bool isAvailable; | ||
|
|
||
| SentryConfig({ | ||
| required this.dsn, | ||
| required this.environment, | ||
| required this.release, | ||
| this.tracesSampleRate = 1.0, | ||
| this.profilesSampleRate = 1.0, | ||
| this.enableLogs = true, | ||
| this.isDebug = BuildUtils.isDebugMode, | ||
| this.attachScreenshot = false, | ||
| this.isAvailable = false, | ||
| }); | ||
|
|
||
| /// Load configuration from an env file. | ||
| static Future<SentryConfig> load() async { | ||
| await EnvLoader.loadConfigFromEnv(); | ||
|
|
||
| final sentryAvailable = dotenv.get('SENTRY_ENABLED', fallback: 'false'); | ||
|
|
||
| final isAvailable = sentryAvailable == 'true'; | ||
| final sentryDSN = dotenv.get('SENTRY_DSN', fallback: ''); | ||
| final sentryEnvironment = dotenv.get('SENTRY_ENVIRONMENT', fallback: ''); | ||
|
|
||
| if (!isAvailable) { | ||
| throw Exception('Sentry is not available'); | ||
| } | ||
|
|
||
| if (sentryDSN.trim().isEmpty || sentryEnvironment.trim().isEmpty) { | ||
| throw Exception('Sentry configuration is missing'); | ||
| } | ||
|
|
||
| final appVersion = await ApplicationManager().getVersion(); | ||
|
|
||
| return SentryConfig( | ||
| dsn: sentryDSN, | ||
| environment: sentryEnvironment, | ||
| release: appVersion, | ||
| isAvailable: isAvailable, | ||
| ); | ||
| } | ||
| } |
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.