Skip to content

Commit

Permalink
Add hostname to events (#16419)
Browse files Browse the repository at this point in the history
...so that its easier to filter out localhost and herokuapp domains
  • Loading branch information
heiskr authored Nov 16, 2020
1 parent db4fad8 commit 714ca02
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions javascripts/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function sendEvent ({

// Content information
path: location.pathname,
hostname: location.hostname,
referrer: document.referrer,
search: location.search,
href: location.href,
Expand Down
5 changes: 5 additions & 0 deletions lib/schema-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`.',
Expand Down
11 changes: 11 additions & 0 deletions tests/rendering/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -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+',
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 714ca02

Please sign in to comment.