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

Track non-fatal issues via analytics / Sentry if consent provided #6308

Merged
merged 2 commits into from
Jul 5, 2022

Conversation

Anderas
Copy link
Contributor

@Anderas Anderas commented Jun 16, 2022

Adds Sentry as a monitoring tool to track app health metrics such as crashes and non-fatal issues logged via MXLog.failure. Using Sentry is subject to the same user consent as other crash and analytics data and is configurable from user settings.

Sentry in this PR is integrated directly into an existing Analytics class, which has some pros:

  • the rest of the application does not need to understand the difference between PostHog and Sentry, Analytics merely serves as façade
  • existing code related to starting / stoping / optingIn / optingOut of analytics would have to be duplicated in all places, if Sentry was another top-level service

The downside of this approach is giving Analytics more responsibilities than it was originally indented to have. I tried to remedy this by changing the documentation of the class, but it is still overwhelmingly aimed at tracking AnalyticEvents. Further refactors could make the split between the use cases more explicit.

Related SDK change

@Anderas Anderas requested review from a team, ismailgulek and gileluard and removed request for a team June 16, 2022 12:07
Copy link
Contributor

@ismailgulek ismailgulek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One inline comment, otherwise LGTM!


func stop() {
MXLog.debug("[SentryMonitoringClient] Stopped")
SentrySDK.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if SentrySDK.endSession makes more sense here. Not sure but feels like close is an unrecoverable action.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endSession only really rotates session IDs etc, but keeps the Sentry service running. Having tested this out close is not in fact unrecoverable and SentrySDK can be properly restarted again.

Copy link
Contributor

@gileluard gileluard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-actions
Copy link

github-actions bot commented Jun 16, 2022

📱 Scan the QR code below to install the build for this PR.
🔒 This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha.

QR code

If you can't scan the QR code you can install the build via this link: https://i.diawi.com/viHKYU

@Anderas Anderas changed the title Proposal: Track non-fatal issues via analytics if consent provided Proposal: Track non-fatal issues via analytics / Sentry if consent provided Jun 17, 2022
@Anderas Anderas changed the title Proposal: Track non-fatal issues via analytics / Sentry if consent provided Track non-fatal issues via analytics / Sentry if consent provided Jul 5, 2022
@Anderas Anderas marked this pull request as ready for review July 5, 2022 16:16
@sonarcloud
Copy link

sonarcloud bot commented Jul 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@codecov-commenter
Copy link

Codecov Report

Merging #6308 (0dea010) into develop (40e927a) will increase coverage by 0.00%.
The diff coverage is 2.38%.

@@           Coverage Diff            @@
##           develop    #6308   +/-   ##
========================================
  Coverage     6.23%    6.23%           
========================================
  Files         1443     1444    +1     
  Lines       155488   155533   +45     
  Branches     62484    62502   +18     
========================================
+ Hits          9695     9699    +4     
- Misses      145386   145427   +41     
  Partials       407      407           
Impacted Files Coverage Δ
...iot/Modules/Analytics/SentryMonitoringClient.swift 0.00% <0.00%> (ø)
Riot/Modules/Analytics/Analytics.swift 9.81% <14.28%> (+0.15%) ⬆️
...ojiPicker/Data/EmojiMart/EmojiItem+EmojiMart.swift 95.65% <0.00%> (+0.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40e927a...0dea010. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants