@bolt/analytics-autolink
Advanced tools
Comparing version 2.5.1 to 2.6.0-beta.1
@@ -6,14 +6,9 @@ const path = require('path'); | ||
describe('analytics autolinker', () => { | ||
let page, context; | ||
let page; | ||
beforeAll(async () => { | ||
context = await global.__BROWSER__.createIncognitoBrowserContext(); | ||
}); | ||
beforeEach(async () => { | ||
page = await context.newPage(); | ||
page = await global.__BROWSER__.newPage(); | ||
await page.goto('http://127.0.0.1:4444/', { | ||
waitUntil: 'networkidle0', | ||
timeout: 0, | ||
waitLoad: true, | ||
waitNetworkIdle: true, // defaults to false | ||
}); | ||
@@ -26,2 +21,6 @@ | ||
afterEach(async () => { | ||
await page.close(); | ||
}); | ||
test('autolinker does not modify component URLs already containing an _ga query string', async function() { | ||
@@ -46,3 +45,3 @@ await page.addScriptTag({ | ||
expect(currentUrl).toContain('_ga=1234'); | ||
}, 60000); | ||
}, 120000); | ||
@@ -68,3 +67,3 @@ test('autolinker updates the URLs of a <bolt-button> with an external url (2nd in the config) + rendering to the Shadow DOM', async function() { | ||
expect(currentUrl).toContain('_ga'); | ||
}, 60000); | ||
}, 120000); | ||
@@ -80,3 +79,3 @@ test('autolinker tracks the URLs of a <bolt-button> with an external url (2nd in the config) + rendering to the Shadow DOM - even after re-rendering', async function() { | ||
btn.textContent = 'External URL - Shadow DOM Test'; | ||
btn.setAttribute('url', 'https://www.pega.com'); | ||
btn.setAttribute('url', 'https://developer.mozilla.org'); | ||
document.body.appendChild(btn); | ||
@@ -99,3 +98,3 @@ }); | ||
expect(currentUrl).toContain('brightcove.com'); | ||
}, 60000); | ||
}, 120000); | ||
@@ -121,3 +120,3 @@ test('autolinker updates the URLs of a <bolt-button> with an external url + rendering to the Shadow DOM', async function() { | ||
expect(currentUrl).toContain('_ga'); | ||
}, 60000); | ||
}, 120000); | ||
@@ -144,3 +143,3 @@ test('autolinker updates the URLs of <bolt-button>s with external urls + render to the light DOM', async function() { | ||
expect(currentUrl).toContain('_ga'); | ||
}, 60000); | ||
}, 120000); | ||
@@ -156,3 +155,3 @@ test('autolinker does not track <bolt-button>s with urls not containing domains in the config', async function() { | ||
btn.textContent = 'External URL - Untracked Domain'; | ||
btn.setAttribute('url', 'https://www.pega.com'); | ||
btn.setAttribute('url', 'https://developer.mozilla.org'); | ||
document.body.appendChild(btn); | ||
@@ -167,3 +166,3 @@ }); | ||
expect(currentUrl).not.toContain('_ga'); | ||
}, 60000); | ||
}, 120000); | ||
@@ -190,3 +189,3 @@ test('autolinker updates the URLs of a <bolt-link> with an external url + rendering to the Shadow DOM', async function() { | ||
expect(currentUrl).toContain('_ga'); | ||
}, 60000); | ||
}, 120000); | ||
@@ -213,3 +212,3 @@ test('autolinker updates the URLs of a <bolt-link> with an external url + rendering to the light DOM', async function() { | ||
expect(currentUrl).toContain('_ga'); | ||
}, 60000); | ||
}, 120000); | ||
@@ -226,3 +225,3 @@ test('autolinker does not track <bolt-link>s with urls not containing domains in the config', async function() { | ||
link.style.display = 'inline-block'; // for some strange reason, without any :host styles or this, puppeteer can't seem to find this DOM node to click on | ||
link.setAttribute('url', 'https://www.pega.com'); | ||
link.setAttribute('url', 'https://developer.mozilla.org'); | ||
document.body.appendChild(link); | ||
@@ -237,3 +236,3 @@ }); | ||
expect(currentUrl).not.toContain('_ga'); | ||
}, 60000); | ||
}, 120000); | ||
@@ -255,4 +254,4 @@ test('the correct inline config for specifying autolink domains inside Drupal exists', async function() { | ||
expect(config).toBe('pega.com'); | ||
}, 60000); | ||
expect(config).toBe('developer.mozilla.org'); | ||
}, 120000); | ||
@@ -272,3 +271,3 @@ test('allow Drupal to configure which domains get configured / tracked by autolink.', async function() { | ||
'External URL - Normally Untracked But Now Tracked Domain'; | ||
btn.setAttribute('url', 'https://www.pega.com'); | ||
btn.setAttribute('url', 'https://developer.mozilla.org'); | ||
document.body.appendChild(btn); | ||
@@ -283,3 +282,3 @@ }); | ||
expect(currentUrl).toContain('_ga'); | ||
}, 60000); | ||
}, 120000); | ||
}); |
// example configuration of how data used to mock up the GA config getting used in Drupal | ||
window.drupalSettings = { | ||
google_analytics: { | ||
trackCrossDomains: ['pega.com'], | ||
trackCrossDomains: ['developer.mozilla.org'], | ||
}, | ||
@@ -6,0 +6,0 @@ }; |
@@ -6,2 +6,14 @@ # Change Log | ||
# [2.6.0-beta.1](https://github.com/bolt-design-system/bolt/compare/v2.5.6...v2.6.0-beta.1) (2019-08-09) | ||
### Bug Fixes | ||
* fix lint issue ([9e82e93](https://github.com/bolt-design-system/bolt/commit/9e82e93)) | ||
* update @bolt/analytics-autolink to catch errors thrown if a Google Analytics `analytics.js` script tag doesn't exist on the page. ([41bd669](https://github.com/bolt-design-system/bolt/commit/41bd669)) | ||
## [2.5.1](https://github.com/bolt-design-system/bolt/compare/v2.5.0...v2.5.1) (2019-06-21) | ||
@@ -8,0 +20,0 @@ |
10
index.js
@@ -48,5 +48,13 @@ import URLSearchParams from '@ungap/url-search-params'; // URLSearchParams poly for older browsers | ||
} | ||
const trackers = ga.getAll(); | ||
// account for ga.getAll not existing on the page | ||
let trackers; | ||
try { | ||
trackers = ga.getAll(); | ||
} catch (err) { | ||
console.warn(err); | ||
return; | ||
} | ||
try { | ||
window.bolt.autolink.domains = | ||
@@ -53,0 +61,0 @@ window.drupalSettings.google_analytics.trackCrossDomains; |
{ | ||
"name": "@bolt/analytics-autolink", | ||
"description": "Adds Google Analytics tracking support to the Bolt Design System.", | ||
"version": "2.5.1", | ||
"version": "2.6.0-beta.1", | ||
"license": "MIT", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "3b8fc70c5c68de6e2f2e50fcfe6f516c77fa044f" | ||
"gitHead": "51f13de7bcf3ba349eca28f04de23fd23129cf90" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22773
344
2