docbrown/app/assets/javascripts/initializers
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
..
initializeAllTagEditButtons.js Ran prettier on *.js, *.jsx and *.md files. (#11586) 2020-11-23 20:45:50 -05:00
initializeArchivedPostFilter.js Fixes archived button in dashboard for PWA (#8930) 2020-06-26 11:26:12 -04:00
initializeArticleDate.js Ran prettier on *.js, *.jsx and *.md files. (#11586) 2020-11-23 20:45:50 -05:00
initializeArticleReactions.js Zappat0n/add rate limit model everywhere 11500 (#14609) 2021-09-23 10:49:19 +01:00
initializeBaseTracking.js.erb Skip google analytics when ga_tracking_id is nil (#15967) 2022-01-06 12:21:07 -05:00
initializeBaseUserData.js Article layout (#14753) 2021-09-30 19:08:06 +02:00
initializeBodyData.js Creator Onboarding: Creator Setup View (#14728) 2021-11-01 15:50:08 -04:00
initializeBroadcast.js Hide active broadcasts from /connect routes (#10312) 2020-09-14 11:28:18 +02:00
initializeColorPicker.js Move the color picker to its own initializer file (#11693) 2020-12-01 15:34:44 +02:00
initializeCommentDate.js Fix lint in initializeCommentDate.js (#4319) [ci skip] 2019-10-09 14:33:52 -04:00
initializeCommentPreview.js Fixed twitter timeline display in comments preview (#12542) 2021-02-15 17:09:18 +01:00
initializeCommentsPage.js.erb Hiding comments: an option to hide or keep children (#15178) 2021-11-18 11:57:40 +03:00
initializeCreditsPage.js Refactor: initializeCreditsPage.js (#4312) [ci skip] 2019-10-08 12:33:28 -04:00
initializeDashboardSort.js [deploy] Dashboard updates (#8879) 2020-06-25 13:10:17 -04:00
initializeDateTimeHelpers.js [deploy] Add local_date helper to handle dates with respect of user timezone (#9285) 2020-07-16 08:45:44 -06:00
initializeDrawerSliders.js Remove swipe gestures and other unnecessary code (#12027) 2020-12-30 12:17:29 -05:00
initializeHeroBannerClose.js Add missing aria label for campaign close button (#12489) 2021-01-29 17:51:18 -05:00
initializeLocalStorageRender.js Use a single listener for all follow buttons on a page (#14246) 2021-07-27 10:45:50 +01:00
initializeOnboardingTaskCard.js Fix TypeError: userData is null in initializeOnboardingTaskCard.js (#9298) [deploy] 2020-07-14 07:32:57 -07:00
initializePaymentPointers.js Check for meta payment pointer first before attempting to load (#9722) 2020-08-10 18:12:48 -04:00
initializePodcastPlayback.js Using a Form Object that will persist for the Creator Settings Form (#15684) 2021-12-10 17:07:40 +02:00
initializeReadingListIcons.js [15 min fix] Update flaky test in loggedOutFlows (#14271) 2021-07-19 15:25:41 +02:00
initializeSettings.js Layout updates (#8107) 2020-06-04 16:12:17 +02:00
initializeSponsorshipVisibility.js Use a single listener for all follow buttons on a page (#14246) 2021-07-27 10:45:50 +01:00
initializeTimeFixer.js Ran prettier on *.js, *.jsx and *.md files. (#11586) 2020-11-23 20:45:50 -05:00
initializeUserProfilePage.js Optimise dropdowns for accessibility - Profile page (#13916) 2021-06-14 12:31:23 +01:00
initializeVideoPlayback.js ForemMobile namespaced functions (#15212) 2021-11-23 15:25:29 -06:00
initNotifications.js Add comment notification test to Cypress, including a11y improvements to notification page (#15842) 2021-12-21 15:42:13 +00:00
initScrolling.js Spelling (#15702) 2021-12-07 06:59:10 -07:00
runtime.js ✂️✂️✂️ Drop PWA (#15781) 2021-12-15 21:25:04 +01:00