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

Analytics | Bug | Fix Autotrack and Autolink JS Errors When GA Config / GA Script Missing #1321

Merged
merged 3 commits into from Aug 9, 2019

Conversation

sghoweri
Copy link
Contributor

@sghoweri sghoweri commented Aug 7, 2019

Jira

http://vjira2:8080/browse/BDS-1724

Summary

Updates the Javascript to the @bolt/analytics-autolink and @bolt/analytics-autotrack packages to no longer throw a Javascript error if GA's Javascript never loads OR if a config for tracking external-bound links is undefined.

How To Test

  • Pull down the changes from this branch, npm run setup, and start up the local dev environment via npm start

How to test the Autotrack JS fix

  • Update the docs-site/src/templates/_site-head.twig file and comment out the window.drupalSettings config in the <head>
-    <script>
+    {#<script>
       window.drupalSettings = {
         google_analytics: {
           trackCrossDomains: ['github.com']
         }
       }
-    </script>
+    </script>#}
  • Confirm that the JS error from the @bolt/analytics-autotrack package about a non-existent window.drupalSettings.google_analytics.trackCrossDomains config option no longer occurs.

How to test the Autolink JS fix

  • Update the docs-site/src/templates/_site-head.twig file and comment out the google analytics script tag in the <head>
-    <script src="https://www.google-analytics.com/analytics.js" defer></script>
-    <script>
+    {#<script src="https://www.google-analytics.com/analytics.js" defer></script>#}
  • Confirm that the JS error from the @bolt/analytics-autolink JS package about the missing ga.getAll method no longer occurs.

…le Analytics `analytics.js` script tag doesn't exist on the page.
…own if `window.drupalSettings.google_analytics.trackCrossDomains` isn't defined
@sghoweri sghoweri added the bug label Aug 7, 2019
@sghoweri sghoweri added this to the v2.6.0 milestone Aug 7, 2019
Copy link
Collaborator

@adamszalapski adamszalapski left a comment

Choose a reason for hiding this comment

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

Everything is working as expected.

Copy link
Collaborator

@danielamorse danielamorse left a comment

Choose a reason for hiding this comment

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

Confirmed locally, approved 👍

@sghoweri sghoweri merged commit b06c92f into master Aug 9, 2019
@sghoweri sghoweri deleted the fix/autolink-and-autotrack-errors branch August 9, 2019 15:39
@sghoweri sghoweri mentioned this pull request Aug 27, 2019
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.

None yet

3 participants