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

Issue/#169 incorrect count anon users #170

Merged
merged 10 commits into from
Apr 27, 2024

Conversation

WahiduzzamanKhan
Copy link
Contributor

Closes #169

Changes description

  • Added prefix to the auto generated username for anonymous users.
  • Remove the Total Anonymous Users valueBox from the Analytics app.

Definition of done

  • Have you read the Contributing Guidelines?
  • NEWS.md file has been updated
  • Development version has been bumped (x.y.z.90XX)
  • Issue has been linked with this PR (via Closing keywords or right sidebar under Development)

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.

All anonymous users are being tracked as a single one if track_anonymous = FALSE

diff --git a/inst/examples/app/instrumentation/app.R b/inst/examples/app/instrumentation/app.R
index a6c9722..e7cf8bf 100644
--- a/inst/examples/app/instrumentation/app.R
+++ b/inst/examples/app/instrumentation/app.R
@@ -112,7 +112,8 @@ counter_server <- function(id) {
 shinyApp(ui = ui, server = function(input, output, session) {
   telemetry$start_session(
     track_values = TRUE,
-    navigation_input_id = "uisidebar"
+    navigation_input_id = "uisidebar",
+    track_anonymous_user = FALSE
   )
 
   # server code

I think this could be solved by either:

  1. When counting users: add every unique session without user (is.na(.data$username))
    • see below
  2. On Telemetry$get_user the default value returns a unique string (such as paste0("anon_user_", session$token) or a generated one)
total_users <- length(
  unique(
    selected_log_data() %>%
      dplyr::filter(.data$type == "login") %>%
      dplyr::filter(.data$username != "") %>%
      dplyr::pull(.data$username)
  )
) + 
  length(
    unique(
      selected_log_data() %>%
        dplyr::filter(.data$type == "login") %>%
        dplyr::filter(is.na(.data$username)) %>%
        dplyr::pull(.data$session)
    )
  )

R/telemetry.R Outdated Show resolved Hide resolved
@WahiduzzamanKhan
Copy link
Contributor Author

All anonymous users are being tracked as a single one if track_anonymous = FALSE

diff --git a/inst/examples/app/instrumentation/app.R b/inst/examples/app/instrumentation/app.R
index a6c9722..e7cf8bf 100644
--- a/inst/examples/app/instrumentation/app.R
+++ b/inst/examples/app/instrumentation/app.R
@@ -112,7 +112,8 @@ counter_server <- function(id) {
 shinyApp(ui = ui, server = function(input, output, session) {
   telemetry$start_session(
     track_values = TRUE,
-    navigation_input_id = "uisidebar"
+    navigation_input_id = "uisidebar",
+    track_anonymous_user = FALSE
   )
 
   # server code

I think this could be solved by either:

  1. When counting users: add every unique session without user (is.na(.data$username))

    • see below
  2. On Telemetry$get_user the default value returns a unique string (such as paste0("anon_user_", session$token) or a generated one)

total_users <- length(
  unique(
    selected_log_data() %>%
      dplyr::filter(.data$type == "login") %>%
      dplyr::filter(.data$username != "") %>%
      dplyr::pull(.data$username)
  )
) + 
  length(
    unique(
      selected_log_data() %>%
        dplyr::filter(.data$type == "login") %>%
        dplyr::filter(is.na(.data$username)) %>%
        dplyr::pull(.data$session)
    )
  )

all the suggested changes have been implemented.

  • tracking for anonymous users have been disabled in the instrumentation app
  • the username of the anonymous users when track_anonymous_user = FALSE follows the form anon_user_<session$token>

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 diff was just to show how to test the application.

I've reverted it.

All good! Have a great weekend

@WahiduzzamanKhan WahiduzzamanKhan merged commit 57205d3 into main Apr 27, 2024
7 of 8 checks passed
@WahiduzzamanKhan WahiduzzamanKhan deleted the issue/#169-incorrect-count-anon-users branch April 27, 2024 05:14
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.

[Bug]: Anonymous users are not counted correctly on analytics dashboard
2 participants