Skip to content

repo sync #730

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

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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