docbrown/app/assets/javascripts
Jeremy Friesen bde5064c9c
Skip google analytics when ga_tracking_id is nil (#15967)
* Skip google analytics when ga_tracking_id is nil

This commit involves short-circuiting Google Analytics calls when the
Forem has not configured a `Settings::General.ga_tracking_id`.  Note,
depending on your local `.env` file (or configured ENV variables) you
may have a `GA_TRACKING_ID` value set; I did, it was set to "Optional"
which overrode the database setting.

We set the HTML data properites in two places: [admin.html.erb][1] and
[application.html.erb][2].

In addition, I'm short-circuiting the local fallback analytics call (via
[Stacato][https://github.com/tpitale/staccato]).  My understanding of
Stacato, based on a cursory read, requires a Google Analytics Tracking
ID to work.

And last, we have a one off of javascript for Google Analytics tracking.

This closes #15962.

[1]:528bd2baa6/app/views/layouts/admin.html.erb (L31)
[2]:528bd2baa6/app/views/layouts/application.html.erb (L55)

How to test?

- Check your .env file to see if you have set GA_TRACKING_ID.  If so,
  unset it.
- Start with a fresh Forem instance.

- Open your browser and open the developer tools to inspect the Network
  activity.
- Open the homepage of your local Forem instance (http://localhost:3000)
- Filter your Network results for analytics.  You shouldn't see any.

Also, make sure you're disabling any blockers you might have as that
influences things.

* Commenting out GA_TRACKING_ID

Related to https://github.com/forem/forem/pull/15967

* Favor empty GA_TRACKING_ID env variable
2022-01-06 12:21:07 -05:00
..
initializers Skip google analytics when ga_tracking_id is nil (#15967) 2022-01-06 12:21:07 -05:00
lib pullToRefresh adjustments - fixing scrolling hijacking (#15644) 2021-12-02 17:00:02 +01:00
utilities Spelling fixes to live code (#15670) 2021-12-06 12:11:25 +02:00
.eslintrc.js Use a single listener for all follow buttons on a page (#14246) 2021-07-27 10:45:50 +01:00
base.js.erb Replace honeybadger-js with @honeybadger-io/js (#15770) 2021-12-15 08:39:08 -05:00
initializePage.js ✂️✂️✂️ Drop PWA (#15781) 2021-12-15 21:25:04 +01:00
jquery_s3_upload.js Ran prettier on *.js, *.jsx and *.md files. (#11586) 2020-11-23 20:45:50 -05:00