TF-4269 Enable sentry for iOS#4271
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughConsolidates Sentry symbol upload CI into a platform-aware GitHub Actions step (iOS and Android), makes release creation idempotent, and treats missing artifacts as warnings. Adds SentryConfig serialization ( Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This PR has been deployed to https://linagora.github.io/tmail-flutter/4271. |
tddang-linagora
left a comment
There was a problem hiding this comment.
All logs in this file are warning log, but all information in this file that is saved to keychain is essential for NSE to handle incoming notification in background. If one ever fails, it will be invisible to both developers and users, making the push notification breaks silently.
- Consider update the logs to error in necessary places.
952501e to
22fed14
Compare
1a5695b to
df487c6
Compare
1ae04ad to
b6d0b6c
Compare
Added |
8dad25d to
c53d43a
Compare
ea6e5cf to
9c463ba
Compare
4b00f05 to
8dd43d8
Compare
d035b78 to
8690f8d
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
ios/Podfile (1)
41-47: Consider adding a safeguard for Sentry/HybridSDK version drift.The hard-coded pin on line 46 (version
8.56.2) is currently correct forsentry_flutter 9.8.0. However, ifsentry_flutteris upgraded to require a different HybridSDK version, this pin can become stale and cause silent conflicts duringpod install. Adding a CI check (e.g., comparing the pin against the resolved version inPodfile.lock) or documenting an upgrade procedure would help prevent this maintenance gap.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ios/Podfile` around lines 41 - 47, The Podfile currently hard-pins pod 'Sentry/HybridSDK', '8.56.2' inside target 'TwakeMailNSE' which can drift from the version required by sentry_flutter; add a safeguard by implementing a CI validation that reads the pinned version in the Podfile (pod 'Sentry/HybridSDK', '8.56.2') and compares it to the resolved Sentry/HybridSDK entry in Podfile.lock (or the CocoaPods resolver output), failing the build if they differ, and/or add a small README entry next to the target block describing the required upgrade steps for sentry_flutter and how to update the HybridSDK pin.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/release.yaml:
- Around line 118-168: Parallel matrix legs both call sentry-cli releases new
"$SENTRY_RELEASE" and sentry-cli releases finalize "$SENTRY_RELEASE", causing
duplicate releases and race conditions; fix by making release
creation/finalization idempotent or moving them out of the matrix: either (A)
before calling sentry-cli releases new use sentry-cli releases info
"$SENTRY_RELEASE" -q and only call releases new if that check fails, and ensure
finalize runs only after all upload steps complete, or (B) move the
create/finalize steps into a dedicated non-matrix job that depends on the
Android/iOS symbol-upload jobs so uploads finish before sentry-cli releases
finalize is called.
In `@core/lib/utils/sentry/sentry_config.dart`:
- Around line 101-115: The SentryConfig.toJson() is missing the dist field so
distribution info isn't sent; update the Dart SentryConfig.toJson() to include
'dist': dist, ensure the SentryConfig class retains the dist property, and add a
matching optional dist property to the iOS NSE model (SentryConfig.swift) and
set options.dist = config.dist when initializing Sentry in the NSE
initialization code so NSE events carry the distribution value.
In `@ios/TwakeMailNSE/NotificationService.swift`:
- Around line 17-19: The NSE can reuse process memory and retain prior Sentry
user context; to prevent stale user attribution, clear the Sentry user at the
start of NotificationService.didReceive(_:withContentHandler:) and also during
cleanup in serviceExtensionTimeWillExpire(); call your Sentry clearing API
(e.g., SentryManager.shared.clearUser() or Sentry.setUser(nil)) before any new
event capture and ensure setSentryUser(...) is only called after a fresh valid
session is resolved.
In `@ios/TwakeMailNSE/Utils/SentryManager.swift`:
- Around line 53-63: The capture wrappers (SentryManager.capture(error:) and
capture(message:)) currently only enqueue events and can be lost if the
Notification Service Extension is suspended; after calling
SentrySDK.capture(error: ...) or SentrySDK.capture(message: ...), call
SentrySDK.flush(timeout:) with a short bounded timeout (e.g., 0.3 seconds) to
force delivery before the extension exits; keep the existing isInitialized
guard, perform the capture then immediately call SentrySDK.flush(timeout: 0.3)
(or a configurable short timeout) and ensure this flush is used in early-return
and serviceExtensionTimeWillExpire() paths to improve NSE delivery reliability.
In `@lib/features/mailbox_dashboard/presentation/sentry_ecosystem.dart`:
- Around line 47-49: The wrapper method _saveSentryConfigToKeychain is calling
IOSSharingManager.saveSentryConfigToKeychain without awaiting its Future, so
setUp may complete before the Keychain write finishes; change
_saveSentryConfigToKeychain to be async and await
IOSSharingManager.saveSentryConfigToKeychain when PlatformInfo.isIOS is true,
and do the same for the other equivalent call used later (the second invocation
around the setUp flow) so any errors are observed and the write completes before
setup returns.
---
Nitpick comments:
In `@ios/Podfile`:
- Around line 41-47: The Podfile currently hard-pins pod 'Sentry/HybridSDK',
'8.56.2' inside target 'TwakeMailNSE' which can drift from the version required
by sentry_flutter; add a safeguard by implementing a CI validation that reads
the pinned version in the Podfile (pod 'Sentry/HybridSDK', '8.56.2') and
compares it to the resolved Sentry/HybridSDK entry in Podfile.lock (or the
CocoaPods resolver output), failing the build if they differ, and/or add a small
README entry next to the target block describing the required upgrade steps for
sentry_flutter and how to update the HybridSDK pin.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 774b68cb-3aca-4e4c-a08e-37d96184208d
⛔ Files ignored due to path filters (1)
ios/Podfile.lockis excluded by!**/*.lock
📒 Files selected for processing (16)
.github/workflows/release.yamlcore/lib/utils/sentry/sentry_config.dartdocs/adr/0084-ios-sentry-dsym-dart-symbols-automation.mdios/Podfileios/Runner.xcodeproj/project.pbxprojios/TwakeMailNSE/Keychain/KeychainController.swiftios/TwakeMailNSE/Model/KeychainSharingSession.swiftios/TwakeMailNSE/Model/SentryConfig.swiftios/TwakeMailNSE/NotificationService.swiftios/TwakeMailNSE/Utils/SentryManager.swiftios/fastlane/Fastfilelib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dartlib/features/mailbox_dashboard/presentation/sentry_ecosystem.dartlib/features/push_notification/data/keychain/keychain_sharing_manager.dartlib/main/utils/ios_sharing_manager.darttest/features/push_notification/data/keychain/keychain_sharing_manager_test.dart
…in NSE Breadcrumbs are only flushed to Sentry when attached to a capture event. Since every addBreadcrumb call was immediately followed by a return, those breadcrumbs were never sent. Replace them with capture(message:) so each early exit is recorded as a Sentry event directly.
… Android Replace last_git_tag with pubspec.yaml as the source for sentry_release to match the same version string that CI uses when uploading symbols. This guarantees consistency between what the app reports to Sentry and what the release.yaml workflow uses for symbol uploads.
… push - Add breadcrumb after foreground check so it only fires on background processing - Fix ADR and CI/Fastfile comments: pubspec is always X.Y.Z, no -rc suffix
There was a problem hiding this comment.
Code Health Improved
(1 files improve in Code Health)
Gates Passed
3 Quality Gates Passed
See analysis details in CodeScene
View Improvements
| File | Code Health Impact | Categories Improved |
|---|---|---|
| NotificationService.swift | 9.84 → 10.00 | Bumpy Road Ahead |
Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
Issue
#4269
Blocker
Resolved
Summary by CodeRabbit
New Features
Chores
Documentation