Skip to content

Commit

Permalink
repo sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Octomerger authored Oct 22, 2020
2 parents cfb498e + 8940279 commit 76cffb2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 45 deletions.
13 changes: 0 additions & 13 deletions javascripts/google-analytics.js

This file was deleted.

2 changes: 0 additions & 2 deletions javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import explorer from './explorer'
import search from './search'
import nav from './nav'
import browserDateFormatter from 'browser-date-formatter'
import googleAnalytics from './google-analytics'
import deprecationBanner from './deprecation-banner'
import sidebar from './sidebar'
import wrapCodeTerms from './wrap-code-terms'
Expand All @@ -23,7 +22,6 @@ document.addEventListener('DOMContentLoaded', async () => {
search()
nav()
browserDateFormatter()
googleAnalytics()
deprecationBanner()
sidebar()
wrapCodeTerms()
Expand Down
9 changes: 3 additions & 6 deletions javascripts/print.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { sendEvent } from './events'

export default function () {
const printButton = document.querySelector('.js-print')

Expand All @@ -10,11 +12,6 @@ export default function () {

// Track print events
window.onbeforeprint = function () {
// Ensure that Google Analytics was registered
if (!window.ga) return
const category = 'Print'
const action = 'print'
const label = 'print'
window.ga('send', 'event', category, action, label)
sendEvent({ type: 'print' })
}
}
26 changes: 2 additions & 24 deletions tests/browser/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,6 @@ describe('algolia browser search', () => {
})
})

describe('google analytics', () => {
it('is set on page load with expected properties', async () => {
await page.goto('http://localhost:4001/en/actions')

// check that GA global object exists and is a function
const gaObjectType = await page.evaluate(() => typeof window.ga)
expect(gaObjectType).toBe('function')

// check that default tracker is set
// https://developers.google.com/analytics/devguides/collection/analyticsjs/ga-object-methods-reference#getByName
const gaDefaultTracker = await page.evaluate(() => window.ga.getByName('t0'))
expect('filters' in gaDefaultTracker).toBe(true)
expect(Object.keys(gaDefaultTracker)).toHaveLength(3)

// check that default cookies are set
// https://developers.google.com/analytics/devguides/collection/analyticsjs/cookie-usage#analyticsjs
const cookies = await page.cookies()
expect(cookies.some(cookie => cookie.name === '_gat')).toBe(true)
expect(cookies.some(cookie => cookie.name === '_gid')).toBe(true)
})
})

describe('helpfulness', () => {
it('sends an event to /events when submitting form', async () => {
// Visit a page that displays the prompt
Expand All @@ -122,8 +100,8 @@ describe('helpfulness', () => {
// Track network requests
await page.setRequestInterception(true)
page.on('request', request => {
// Ignore GET to google analytics
if (!/\/events/.test(request.method())) return request.continue()
// Ignore GET requests
if (!/\/events$/.test(request.url())) return request.continue()
expect(request.method()).toMatch(/POST|PUT/)
request.respond({
contentType: 'application/json',
Expand Down

0 comments on commit 76cffb2

Please sign in to comment.