reactotron icon indicating copy to clipboard operation
reactotron copied to clipboard

feat(reactotron-app): Add basic analytics to Reactotron app with `react-ga4`

Open markrickert opened this issue 1 year ago • 3 comments

This adds google analytics to the reactotron app for basic feature and usage metrics. It's implemented using react-ga4 but the codebase can easily be switched to another service is we want.

The first time the user opens the app after upgrading to this version, they'll be presented with this screen:

Screenshot 2024-01-17 at 4 02 39 PM

Clicking the red "NO" button changes their user setting to opt-out of anonymous analytics. A user that opens the app and clicks "NO" should have zero analytics calls send to google-analytics.

Clicking the green "YES" button saves the user setting and starts allowing tracking calls to be sent to google analytics.

We are tracking the following things:

  1. Screen views (with a hook that just listens to the path of react-router)
  2. Interface button click events
  3. Keyboard shortcut usage
  4. Custom command usage statistics including the title of the custom command that was run.

Users can opt in or out of this feature by going to Reactotron -> Settings (which opens the settings json file in their default editor.

Screenshot 2024-01-17 at 4 16 41 PM

Editing this file to have the analyticsOptOut be true or false and then restarting the app will turn this setting on and off.

Screenshot 2024-01-17 at 5 15 38 PM

Things that we need to do before this can move out of draft status:

  • [ ] Create a new google analytics property for Reactotron in our master InfiniteRed account and change the GA4_KEY variable.
  • [ ] Look for other things that could benefit from usage tracking
  • [ ] Brainstorm a way to track plugin usage (redux, mst, mmkv, etc)
  • [ ] Validate verbiage for the Opt-in/out screen.

markrickert avatar Jan 18 '24 00:01 markrickert

I also found this discussion from a VERY long time ago #723 where @jamonholmgren had already mocked up a screen and verbiage.

markrickert avatar Jan 24 '24 16:01 markrickert

@markrickert I rebased this on top of master. One thing I noticed when I was working with it was that setting the analyticsOptOut: "unknown" causes the application to break. It appears that's the default value and what should trigger the dialog to appear. Instead I get errors in console and a blank screen. I tested this both before and after rebasing master into this branch.

morganick avatar Apr 12 '24 15:04 morganick