Skip to content

Commit 714ca02

Browse files
authored
Add hostname to events (#16419)
...so that its easier to filter out localhost and herokuapp domains
1 parent db4fad8 commit 714ca02

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

javascripts/events.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export function sendEvent ({
6363

6464
// Content information
6565
path: location.pathname,
66+
hostname: location.hostname,
6667
referrer: document.referrer,
6768
search: location.search,
6869
href: location.href,

lib/schema-event.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ const context = {
3939
description: 'The browser value of `location.pathname`.',
4040
format: 'uri-reference'
4141
},
42+
hostname: {
43+
type: 'string',
44+
description: 'The browser value of `location.hostname.`',
45+
format: 'uri-reference'
46+
},
4247
referrer: {
4348
type: 'string',
4449
description: 'The browser value of `document.referrer`.',

tests/rendering/events.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('POST /events', () => {
4848

4949
// Content information
5050
path: '/github/docs/issues',
51+
hostname: 'github.com',
5152
referrer: 'https://github.com/github/docs',
5253
search: '?q=is%3Aissue+is%3Aopen+example+',
5354
href: 'https://github.com/github/docs/issues?q=is%3Aissue+is%3Aopen+example+',
@@ -138,6 +139,16 @@ describe('POST /events', () => {
138139
}, 400)
139140
)
140141

142+
it('should hostname be uri-reference', () =>
143+
checkEvent({
144+
...pageExample,
145+
context: {
146+
...pageExample.context,
147+
hostname: ' '
148+
}
149+
}, 400)
150+
)
151+
141152
it('should referrer be uri-reference', () =>
142153
checkEvent({
143154
...pageExample,

0 commit comments

Comments
 (0)