diff --git a/src/events/components/events.ts b/src/events/components/events.ts index b3a4ea19d4..bcb56b34be 100644 --- a/src/events/components/events.ts +++ b/src/events/components/events.ts @@ -98,6 +98,7 @@ export function sendEvent({ // Content information referrer: getReferrer(document.referrer), + title: document.title, href: location.href, // full URL hostname: location.hostname, // origin without protocol or port path: location.pathname, // path without search or host @@ -118,6 +119,9 @@ export function sendEvent({ is_headless: isHeadless(), viewport_width: document.documentElement.clientWidth, viewport_height: document.documentElement.clientHeight, + screen_width: window.screen.width, + screen_height: window.screen.height, + pixel_ratio: window.devicePixelRatio || 1, // Location information timezone: new Date().getTimezoneOffset() / -60, diff --git a/src/events/lib/schema.ts b/src/events/lib/schema.ts index 8db06bd96f..e16260bb5b 100644 --- a/src/events/lib/schema.ts +++ b/src/events/lib/schema.ts @@ -44,6 +44,10 @@ const context = { description: 'The browser value of `document.referrer`.', format: 'uri-reference', }, + title: { + type: 'string', + description: 'The browser value of `document.title`.', + }, href: { type: 'string', description: 'The browser value of `location.href`.', @@ -142,12 +146,27 @@ const context = { viewport_width: { type: 'number', description: 'The viewport width, not the overall device size.', - minimum: 1, + minimum: 0, }, viewport_height: { type: 'number', 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 diff --git a/src/events/tests/middleware.ts b/src/events/tests/middleware.ts index 40e0ce8af7..084401720e 100644 --- a/src/events/tests/middleware.ts +++ b/src/events/tests/middleware.ts @@ -32,6 +32,7 @@ describe('POST /events', () => { path: '/github/docs/issues', hostname: 'github.com', referrer: 'https://github.com/github/docs', + title: 'Issues · github/docs', search: '?q=is%3Aissue+is%3Aopen+example+', href: 'https://github.com/github/docs/issues?q=is%3Aissue+is%3Aopen+example+', path_language: 'en', @@ -44,6 +45,9 @@ describe('POST /events', () => { is_headless: false, viewport_width: 1418, viewport_height: 501, + screen_width: 1920, + screen_height: 1080, + pixel_ratio: 2, // Location information timezone: -7, @@ -64,6 +68,7 @@ describe('POST /events', () => { path: '/github/docs/issues', hostname: 'github.com', referrer: 'https://github.com/github/docs', + title: 'Issues · github/docs', search: '?q=is%3Aissue+is%3Aopen+example+', href: 'https://github.com/github/docs/issues?q=is%3Aissue+is%3Aopen+example+', path_language: 'en', @@ -76,6 +81,9 @@ describe('POST /events', () => { is_headless: false, viewport_width: 1418, viewport_height: 501, + screen_width: 1920, + screen_height: 1080, + pixel_ratio: 2, // Location information timezone: -7, diff --git a/src/events/types.ts b/src/events/types.ts index b66f5e3061..cbe3c53023 100644 --- a/src/events/types.ts +++ b/src/events/types.ts @@ -24,6 +24,7 @@ export type EventProps = { created: string page_event_id: string referrer: string + title?: string href: string hostname: string path: string @@ -31,9 +32,10 @@ export type EventProps = { hash: string path_language: string path_version: string + path_product?: string path_article: string - path_document_type: string - path_type: string + page_document_type: string + page_type: string status: number is_logged_in: boolean dotcom_user: string @@ -42,15 +44,21 @@ export type EventProps = { os_version: string browser: string browser_version: string + is_headless: boolean + viewport_width?: number + viewport_height?: number + screen_width?: number + screen_height?: number + pixel_ratio?: number timezone: number user_language: string + os_preference: string application_preference: string color_mode_preference: string - os_preference: string code_display_preference: string + experiment_variation?: string event_group_key?: string event_group_id?: string - is_headless: boolean } }