Add four new analytics fields to event context (#57930)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -98,6 +98,7 @@ export function sendEvent<T extends EventType>({
|
|||||||
|
|
||||||
// Content information
|
// Content information
|
||||||
referrer: getReferrer(document.referrer),
|
referrer: getReferrer(document.referrer),
|
||||||
|
title: document.title,
|
||||||
href: location.href, // full URL
|
href: location.href, // full URL
|
||||||
hostname: location.hostname, // origin without protocol or port
|
hostname: location.hostname, // origin without protocol or port
|
||||||
path: location.pathname, // path without search or host
|
path: location.pathname, // path without search or host
|
||||||
@@ -118,6 +119,9 @@ export function sendEvent<T extends EventType>({
|
|||||||
is_headless: isHeadless(),
|
is_headless: isHeadless(),
|
||||||
viewport_width: document.documentElement.clientWidth,
|
viewport_width: document.documentElement.clientWidth,
|
||||||
viewport_height: document.documentElement.clientHeight,
|
viewport_height: document.documentElement.clientHeight,
|
||||||
|
screen_width: window.screen.width,
|
||||||
|
screen_height: window.screen.height,
|
||||||
|
pixel_ratio: window.devicePixelRatio || 1,
|
||||||
|
|
||||||
// Location information
|
// Location information
|
||||||
timezone: new Date().getTimezoneOffset() / -60,
|
timezone: new Date().getTimezoneOffset() / -60,
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ const context = {
|
|||||||
description: 'The browser value of `document.referrer`.',
|
description: 'The browser value of `document.referrer`.',
|
||||||
format: 'uri-reference',
|
format: 'uri-reference',
|
||||||
},
|
},
|
||||||
|
title: {
|
||||||
|
type: 'string',
|
||||||
|
description: 'The browser value of `document.title`.',
|
||||||
|
},
|
||||||
href: {
|
href: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'The browser value of `location.href`.',
|
description: 'The browser value of `location.href`.',
|
||||||
@@ -142,12 +146,27 @@ const context = {
|
|||||||
viewport_width: {
|
viewport_width: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The viewport width, not the overall device size.',
|
description: 'The viewport width, not the overall device size.',
|
||||||
minimum: 1,
|
minimum: 0,
|
||||||
},
|
},
|
||||||
viewport_height: {
|
viewport_height: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: 'The viewport height, not the overall device height.',
|
description: 'The viewport height, not the overall device height.',
|
||||||
minimum: 1,
|
minimum: 0,
|
||||||
|
},
|
||||||
|
screen_width: {
|
||||||
|
type: 'number',
|
||||||
|
description: 'The screen width of the device.',
|
||||||
|
minimum: 0,
|
||||||
|
},
|
||||||
|
screen_height: {
|
||||||
|
type: 'number',
|
||||||
|
description: 'The screen height of the device.',
|
||||||
|
minimum: 0,
|
||||||
|
},
|
||||||
|
pixel_ratio: {
|
||||||
|
type: 'number',
|
||||||
|
description: 'The device pixel ratio.',
|
||||||
|
minimum: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Location information
|
// Location information
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ describe('POST /events', () => {
|
|||||||
path: '/github/docs/issues',
|
path: '/github/docs/issues',
|
||||||
hostname: 'github.com',
|
hostname: 'github.com',
|
||||||
referrer: 'https://github.com/github/docs',
|
referrer: 'https://github.com/github/docs',
|
||||||
|
title: 'Issues · github/docs',
|
||||||
search: '?q=is%3Aissue+is%3Aopen+example+',
|
search: '?q=is%3Aissue+is%3Aopen+example+',
|
||||||
href: 'https://github.com/github/docs/issues?q=is%3Aissue+is%3Aopen+example+',
|
href: 'https://github.com/github/docs/issues?q=is%3Aissue+is%3Aopen+example+',
|
||||||
path_language: 'en',
|
path_language: 'en',
|
||||||
@@ -44,6 +45,9 @@ describe('POST /events', () => {
|
|||||||
is_headless: false,
|
is_headless: false,
|
||||||
viewport_width: 1418,
|
viewport_width: 1418,
|
||||||
viewport_height: 501,
|
viewport_height: 501,
|
||||||
|
screen_width: 1920,
|
||||||
|
screen_height: 1080,
|
||||||
|
pixel_ratio: 2,
|
||||||
|
|
||||||
// Location information
|
// Location information
|
||||||
timezone: -7,
|
timezone: -7,
|
||||||
@@ -64,6 +68,7 @@ describe('POST /events', () => {
|
|||||||
path: '/github/docs/issues',
|
path: '/github/docs/issues',
|
||||||
hostname: 'github.com',
|
hostname: 'github.com',
|
||||||
referrer: 'https://github.com/github/docs',
|
referrer: 'https://github.com/github/docs',
|
||||||
|
title: 'Issues · github/docs',
|
||||||
search: '?q=is%3Aissue+is%3Aopen+example+',
|
search: '?q=is%3Aissue+is%3Aopen+example+',
|
||||||
href: 'https://github.com/github/docs/issues?q=is%3Aissue+is%3Aopen+example+',
|
href: 'https://github.com/github/docs/issues?q=is%3Aissue+is%3Aopen+example+',
|
||||||
path_language: 'en',
|
path_language: 'en',
|
||||||
@@ -76,6 +81,9 @@ describe('POST /events', () => {
|
|||||||
is_headless: false,
|
is_headless: false,
|
||||||
viewport_width: 1418,
|
viewport_width: 1418,
|
||||||
viewport_height: 501,
|
viewport_height: 501,
|
||||||
|
screen_width: 1920,
|
||||||
|
screen_height: 1080,
|
||||||
|
pixel_ratio: 2,
|
||||||
|
|
||||||
// Location information
|
// Location information
|
||||||
timezone: -7,
|
timezone: -7,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export type EventProps = {
|
|||||||
created: string
|
created: string
|
||||||
page_event_id: string
|
page_event_id: string
|
||||||
referrer: string
|
referrer: string
|
||||||
|
title?: string
|
||||||
href: string
|
href: string
|
||||||
hostname: string
|
hostname: string
|
||||||
path: string
|
path: string
|
||||||
@@ -31,9 +32,10 @@ export type EventProps = {
|
|||||||
hash: string
|
hash: string
|
||||||
path_language: string
|
path_language: string
|
||||||
path_version: string
|
path_version: string
|
||||||
|
path_product?: string
|
||||||
path_article: string
|
path_article: string
|
||||||
path_document_type: string
|
page_document_type: string
|
||||||
path_type: string
|
page_type: string
|
||||||
status: number
|
status: number
|
||||||
is_logged_in: boolean
|
is_logged_in: boolean
|
||||||
dotcom_user: string
|
dotcom_user: string
|
||||||
@@ -42,15 +44,21 @@ export type EventProps = {
|
|||||||
os_version: string
|
os_version: string
|
||||||
browser: string
|
browser: string
|
||||||
browser_version: string
|
browser_version: string
|
||||||
|
is_headless: boolean
|
||||||
|
viewport_width?: number
|
||||||
|
viewport_height?: number
|
||||||
|
screen_width?: number
|
||||||
|
screen_height?: number
|
||||||
|
pixel_ratio?: number
|
||||||
timezone: number
|
timezone: number
|
||||||
user_language: string
|
user_language: string
|
||||||
|
os_preference: string
|
||||||
application_preference: string
|
application_preference: string
|
||||||
color_mode_preference: string
|
color_mode_preference: string
|
||||||
os_preference: string
|
|
||||||
code_display_preference: string
|
code_display_preference: string
|
||||||
|
experiment_variation?: string
|
||||||
event_group_key?: string
|
event_group_key?: string
|
||||||
event_group_id?: string
|
event_group_id?: string
|
||||||
is_headless: boolean
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user