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

Adds Shiny error tracking (#116) #162

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

arunkodati77
Copy link
Contributor

@arunkodati77 arunkodati77 commented Apr 4, 2024

Closes #116

Changes description

There are two implementations for this issue
1) Supports Newer versions of shiny(>=1.8.1):

   -  uses `unhandledError()` from latest version of shiny (1.8.1) to log error message (global error handler). 

This unhandledError() will be triggered when an error occurred and before the session end and contains the error object (Making it suitable for logging root cause of the error).

2) Supports older versions of shiny(<1.8.1):

   - Uses shiny javascript event i.e `shiny:error`, This js function will also get triggered after error and before session end, However it only captures Javascript/UI Errors in output elements.

Examples:
a) Able to log errors: Will log 'Object x not found error'

        output$plot1 <- renderPlot({
             x/y
            })

b) Unable to log: Not able to log before app stops running

            observe({
            x/y 
           })

Note1: We also added public method log_error(output_id, message). Such that user can use this method log errors from their 'try-catch' block.

Note2: (Will add this after discussion) In Older versions, we can also capture other errors in shiny reactive elements, By using , options(shiny.error = function(){.....})
The only drawback is, we won't get the error object to identify the root cause of the issue.

@codecov-commenter
Copy link

codecov-commenter commented Apr 4, 2024

Codecov Report

Attention: Patch coverage is 0% with 30 lines in your changes are missing coverage. Please review.

Project coverage is 29.92%. Comparing base (bfbce9c) to head (ce33809).

❗ Current head ce33809 differs from pull request most recent head 2040b7d. Consider uploading reports for the commit 2040b7d to get more accurate results

Files Patch % Lines
R/telemetry.R 0.00% 18 Missing ⚠️
R/ui_elements.R 0.00% 12 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #162      +/-   ##
==========================================
- Coverage   30.48%   29.92%   -0.57%     
==========================================
  Files          16       16              
  Lines        1476     1504      +28     
==========================================
  Hits          450      450              
- Misses       1026     1054      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

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

The code looks good. Can you detail some examples apps to test it?

Mainly, a way to test it to see limitations before v1.8.1

@@ -125,7 +127,8 @@ Telemetry <- R6::R6Class( # nolint object_name_linter
navigation_input_id = NULL,
session = shiny::getDefaultReactiveDomain(),
username = NULL,
track_anonymous_user = TRUE
track_anonymous_user = TRUE,
track_errors = TRUE
Copy link
Contributor

Choose a reason for hiding this comment

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

Should also have an assertion checkmate::assert_flag(track_errors)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

R/telemetry.R Outdated
#' and when a username is not explicitly defined.`TRUE` by default
#' and when a username is not explicitly defined.`TRUE` by default.
#' @param track_errors flag that indicates if the basic telemetry should
#' track the errors. `TRUE` by default
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider adding here a description that there is a limitation on the errors' information on versions before shiny 1.8.1.

@averissimo averissimo self-assigned this Apr 4, 2024
@arunkodati77
Copy link
Contributor Author

The code looks good. Can you detail some examples apps to test it?

Mainly, a way to test it to see limitations before v1.8.1

Added in the PR Description

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.

[Feature]: Include Shiny errors
3 participants