From 714ca0263b860ac4be759944703fdf8749b71d95 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Mon, 16 Nov 2020 09:49:12 -0800 Subject: [PATCH] Add `hostname` to events (#16419) ...so that its easier to filter out localhost and herokuapp domains --- javascripts/events.js | 1 + lib/schema-event.js | 5 +++++ tests/rendering/events.js | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/javascripts/events.js b/javascripts/events.js index 4a05744635..1f60567b63 100644 --- a/javascripts/events.js +++ b/javascripts/events.js @@ -63,6 +63,7 @@ export function sendEvent ({ // Content information path: location.pathname, + hostname: location.hostname, referrer: document.referrer, search: location.search, href: location.href, diff --git a/lib/schema-event.js b/lib/schema-event.js index bf7fcb429e..059a9112f1 100644 --- a/lib/schema-event.js +++ b/lib/schema-event.js @@ -39,6 +39,11 @@ const context = { description: 'The browser value of `location.pathname`.', format: 'uri-reference' }, + hostname: { + type: 'string', + description: 'The browser value of `location.hostname.`', + format: 'uri-reference' + }, referrer: { type: 'string', description: 'The browser value of `document.referrer`.', diff --git a/tests/rendering/events.js b/tests/rendering/events.js index e7912ee80c..547f93a2f5 100644 --- a/tests/rendering/events.js +++ b/tests/rendering/events.js @@ -48,6 +48,7 @@ describe('POST /events', () => { // Content information path: '/github/docs/issues', + hostname: 'github.com', referrer: 'https://github.com/github/docs', search: '?q=is%3Aissue+is%3Aopen+example+', href: 'https://github.com/github/docs/issues?q=is%3Aissue+is%3Aopen+example+', @@ -138,6 +139,16 @@ describe('POST /events', () => { }, 400) ) + it('should hostname be uri-reference', () => + checkEvent({ + ...pageExample, + context: { + ...pageExample.context, + hostname: ' ' + } + }, 400) + ) + it('should referrer be uri-reference', () => checkEvent({ ...pageExample,