|
| 1 | +const languages = require('./languages') |
| 2 | + |
| 3 | +module.exports = { |
| 4 | + additionalProperties: false, |
| 5 | + required: [ |
| 6 | + 'event_id', |
| 7 | + 'type', |
| 8 | + 'user', |
| 9 | + 'version', |
| 10 | + 'created' |
| 11 | + ], |
| 12 | + properties: { |
| 13 | + // Required of all events |
| 14 | + event_id: { |
| 15 | + type: 'string', |
| 16 | + description: 'The unique identifier of the event.', |
| 17 | + format: 'uuid' |
| 18 | + }, |
| 19 | + type: { |
| 20 | + type: 'string', |
| 21 | + description: 'The type of the event.', |
| 22 | + enum: ['page', 'exit', 'link', 'search', 'navigate', 'survey', 'experiment'] |
| 23 | + }, |
| 24 | + user: { |
| 25 | + type: 'string', |
| 26 | + description: 'The unique identifier of the current user performing the event. Please use randomly generated values or hashed values; we don\'t want to be able to look up in a database.', |
| 27 | + format: 'uuid' |
| 28 | + }, |
| 29 | + version: { |
| 30 | + type: 'string', |
| 31 | + description: 'The version of the event schema.', |
| 32 | + pattern: /^\d+(\.\d+)?(\.\d+)?$/ |
| 33 | + }, |
| 34 | + created: { |
| 35 | + type: 'string', |
| 36 | + format: 'date-time', |
| 37 | + description: 'The time we created the event; please reference UTC.' |
| 38 | + }, |
| 39 | + token: { |
| 40 | + type: 'string', |
| 41 | + description: 'A honeypot.', |
| 42 | + maxLength: 0 |
| 43 | + }, |
| 44 | + |
| 45 | + // Content information |
| 46 | + path: { |
| 47 | + type: 'string', |
| 48 | + description: 'The browser value of `location.pathname`.', |
| 49 | + format: 'uri-reference' |
| 50 | + }, |
| 51 | + referrer: { |
| 52 | + type: 'string', |
| 53 | + description: 'The browser value of `document.referrer`.', |
| 54 | + format: 'uri-reference' |
| 55 | + }, |
| 56 | + search: { |
| 57 | + type: 'string', |
| 58 | + description: 'The browser value of `location.search`.' |
| 59 | + }, |
| 60 | + href: { |
| 61 | + type: 'string', |
| 62 | + description: 'The browser value of `location.href`.', |
| 63 | + format: 'uri' |
| 64 | + }, |
| 65 | + site_language: { |
| 66 | + type: 'string', |
| 67 | + description: 'The language the user is viewing.', |
| 68 | + enum: Object.keys(languages) |
| 69 | + }, |
| 70 | + |
| 71 | + // Device information |
| 72 | + os: { |
| 73 | + type: 'string', |
| 74 | + description: 'The type of operating system the user is working with.', |
| 75 | + enum: ['windows', 'mac', 'linux', 'ios', 'android', 'other'], |
| 76 | + default: 'other' |
| 77 | + }, |
| 78 | + os_version: { |
| 79 | + type: 'string', |
| 80 | + description: 'The version of the operating system the user is using.' |
| 81 | + }, |
| 82 | + browser: { |
| 83 | + type: 'string', |
| 84 | + description: 'The type of browser the user is browsing with.', |
| 85 | + enum: ['chrome', 'safari', 'firefox', 'edge', 'ie', 'other'], |
| 86 | + default: 'other' |
| 87 | + }, |
| 88 | + browser_version: { |
| 89 | + type: 'string', |
| 90 | + description: 'The version of the browser the user is browsing with.' |
| 91 | + }, |
| 92 | + viewport_width: { |
| 93 | + type: 'number', |
| 94 | + description: 'The viewport width, not the overall device size.', |
| 95 | + minimum: 1 |
| 96 | + }, |
| 97 | + viewport_height: { |
| 98 | + type: 'number', |
| 99 | + description: 'The viewport height, not the overall device height.', |
| 100 | + minimum: 1 |
| 101 | + }, |
| 102 | + |
| 103 | + // Location information |
| 104 | + timezone: { |
| 105 | + type: 'number', |
| 106 | + description: 'The timezone the user is in, as `new Date().getTimezoneOffset() / -60`.' |
| 107 | + }, |
| 108 | + user_language: { |
| 109 | + type: 'string', |
| 110 | + description: 'The browser value of `navigator.language`.' |
| 111 | + } |
| 112 | + }, |
| 113 | + oneOf: [{ |
| 114 | + // *** type: page *** |
| 115 | + required: [ |
| 116 | + 'path', |
| 117 | + 'href' |
| 118 | + ], |
| 119 | + properties: { |
| 120 | + type: { |
| 121 | + type: 'string', |
| 122 | + pattern: /^page$/ |
| 123 | + }, |
| 124 | + page_render_duration: { |
| 125 | + type: { |
| 126 | + type: 'number', |
| 127 | + description: 'How long the server took to render the page content, in seconds.', |
| 128 | + minimum: 0.001 |
| 129 | + } |
| 130 | + } |
| 131 | + } |
| 132 | + }, { |
| 133 | + // *** type: exit *** |
| 134 | + required: [ |
| 135 | + 'exit_page_id' |
| 136 | + ], |
| 137 | + properties: { |
| 138 | + type: { |
| 139 | + type: 'string', |
| 140 | + pattern: /^exit$/ |
| 141 | + }, |
| 142 | + exit_page_id: { |
| 143 | + type: 'string', |
| 144 | + format: 'uuid', |
| 145 | + description: 'The value of the corresponding `page` event.' |
| 146 | + // id of the "page" event |
| 147 | + }, |
| 148 | + exit_first_paint: { |
| 149 | + type: 'number', |
| 150 | + minimum: 0.001, |
| 151 | + description: 'The duration until `first-contentful-paint`, in seconds. Informs CSS performance.' |
| 152 | + }, |
| 153 | + exit_dom_interactive: { |
| 154 | + type: 'number', |
| 155 | + minimum: 0.001, |
| 156 | + description: 'The duration until `PerformanceNavigationTiming.domInteractive`, in seconds. Informs JavaScript loading performance.' |
| 157 | + }, |
| 158 | + exit_dom_complete: { |
| 159 | + type: 'number', |
| 160 | + minimum: 0.001, |
| 161 | + description: 'The duration until `PerformanceNavigationTiming.domComplete`, in seconds. Informs JavaScript execution performance.' |
| 162 | + }, |
| 163 | + exit_visit_duration: { |
| 164 | + type: 'number', |
| 165 | + minimum: 0.001, |
| 166 | + description: 'The duration of exit.timestamp - page.timestamp, in seconds. Informs bounce rate.' |
| 167 | + }, |
| 168 | + exit_scroll_length: { |
| 169 | + type: 'number', |
| 170 | + minimum: 0, |
| 171 | + maximum: 1, |
| 172 | + description: 'The percentage of how far the user scrolled on the page.' |
| 173 | + } |
| 174 | + } |
| 175 | + }, { |
| 176 | + // *** type: link *** |
| 177 | + required: [ |
| 178 | + 'link_url' |
| 179 | + ], |
| 180 | + properties: { |
| 181 | + type: { |
| 182 | + type: 'string', |
| 183 | + pattern: /^link$/ |
| 184 | + }, |
| 185 | + link_url: { |
| 186 | + type: 'string', |
| 187 | + format: 'uri', |
| 188 | + description: 'The href of the anchor tag the user clicked, or the page or object they directed their browser to.' |
| 189 | + } |
| 190 | + } |
| 191 | + }, { |
| 192 | + // *** type: search *** |
| 193 | + required: [ |
| 194 | + 'search_query' |
| 195 | + ], |
| 196 | + properties: { |
| 197 | + type: { |
| 198 | + type: 'string', |
| 199 | + pattern: /^search$/ |
| 200 | + }, |
| 201 | + search_query: { |
| 202 | + type: 'string', |
| 203 | + description: 'The actual text content of the query string the user sent to the service.' |
| 204 | + }, |
| 205 | + search_context: { |
| 206 | + type: 'string', |
| 207 | + description: 'Any additional search context, such as component searched.' |
| 208 | + } |
| 209 | + } |
| 210 | + }, { |
| 211 | + // *** type: navigate *** |
| 212 | + properties: { |
| 213 | + type: { |
| 214 | + type: 'string', |
| 215 | + pattern: /^navigate$/ |
| 216 | + }, |
| 217 | + navigate_label: { |
| 218 | + type: 'string', |
| 219 | + description: 'An identifier for where the user is navigating.' |
| 220 | + } |
| 221 | + } |
| 222 | + }, { |
| 223 | + // *** type: survey *** |
| 224 | + properties: { |
| 225 | + type: { |
| 226 | + type: 'string', |
| 227 | + pattern: /^survey$/ |
| 228 | + }, |
| 229 | + survey_vote: { |
| 230 | + type: 'boolean', |
| 231 | + description: 'Whether the user found the page helpful.' |
| 232 | + }, |
| 233 | + survey_comment: { |
| 234 | + type: 'string', |
| 235 | + description: 'Any textual comments the user wanted to provide.' |
| 236 | + }, |
| 237 | + survey_email: { |
| 238 | + type: 'string', |
| 239 | + format: 'email', |
| 240 | + description: 'The user\'s email address, if the user provided and consented.' |
| 241 | + } |
| 242 | + } |
| 243 | + }, { |
| 244 | + // *** type: experiment *** |
| 245 | + required: [ |
| 246 | + 'experiment_name', |
| 247 | + 'experiment_variation' |
| 248 | + ], |
| 249 | + properties: { |
| 250 | + type: { |
| 251 | + type: 'string', |
| 252 | + pattern: /^experiment$/ |
| 253 | + }, |
| 254 | + experiment_name: { |
| 255 | + type: 'string', |
| 256 | + description: 'The test that this event is part of.' |
| 257 | + }, |
| 258 | + experiment_variation: { |
| 259 | + type: 'string', |
| 260 | + enum: ['control', 'treatment'], |
| 261 | + description: 'The variation this user we bucketed in, such as control or treatment.' |
| 262 | + }, |
| 263 | + experiment_success: { |
| 264 | + type: 'boolean', |
| 265 | + default: true, |
| 266 | + description: 'Whether or not the user successfully performed the test goal.' |
| 267 | + } |
| 268 | + } |
| 269 | + }] |
| 270 | +} |
0 commit comments