forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema-event.js
403 lines (386 loc) · 9.78 KB
/
schema-event.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
import languages from './languages.js'
const context = {
type: 'object',
additionalProperties: false,
required: ['event_id', 'user', 'version', 'created', 'path'],
properties: {
// Required of all events
event_id: {
type: 'string',
description: 'The unique identifier of the event.',
format: 'uuid',
},
user: {
type: 'string',
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.",
format: 'uuid',
},
version: {
type: 'string',
description: 'The version of the event schema.',
pattern: '^\\d+(\\.\\d+)?(\\.\\d+)?$', // eslint-disable-line
},
created: {
type: 'string',
format: 'date-time',
description: 'The time we created the event; please reference UTC.',
},
page_event_id: {
type: 'string',
description: 'The id of the corresponding `page` event.',
format: 'uuid',
},
// Content information
path: {
type: 'string',
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`.',
format: 'uri-reference',
},
search: {
type: 'string',
description: 'The browser value of `location.search`.',
},
href: {
type: 'string',
description: 'The browser value of `location.href`.',
format: 'uri',
},
site_language: {
type: 'string',
description: 'The language the user is viewing.',
enum: Object.keys(languages),
},
// Device information
os: {
type: 'string',
description: 'The type of operating system the user is working with.',
enum: ['windows', 'mac', 'linux', 'ios', 'android', 'cros', 'other'],
default: 'other',
},
os_version: {
type: 'string',
description: 'The version of the operating system the user is using.',
},
browser: {
type: 'string',
description: 'The type of browser the user is browsing with.',
enum: ['chrome', 'safari', 'firefox', 'edge', 'ie', 'other'],
default: 'other',
},
browser_version: {
type: 'string',
description: 'The version of the browser the user is browsing with.',
},
viewport_width: {
type: 'number',
description: 'The viewport width, not the overall device size.',
minimum: 1,
},
viewport_height: {
type: 'number',
description: 'The viewport height, not the overall device height.',
minimum: 1,
},
// Location information
timezone: {
type: 'number',
description: 'The timezone the user is in, as `new Date().getTimezoneOffset() / -60`.',
},
user_language: {
type: 'string',
description: 'The browser value of `navigator.language`.',
},
// Preference information
os_preference: {
type: 'string',
enum: ['linux', 'mac', 'windows'],
description: 'The os for examples selected by the user.',
},
application_preference: {
type: 'string',
enum: ['webui', 'cli', 'desktop', 'curl', 'codespaces'],
description: 'The application selected by the user.',
},
color_mode_preference: {
enum: ['dark', 'light', 'auto', 'auto:dark', 'auto:light'],
description: 'The color mode selected by the user.',
},
},
}
const pageSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context'],
properties: {
context,
type: {
type: 'string',
pattern: '^page$',
},
},
}
const exitSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context'],
properties: {
context,
type: {
type: 'string',
pattern: '^exit$',
},
exit_render_duration: {
type: 'number',
description: 'How long the server took to render the page content, in seconds.',
minimum: 0.001,
},
exit_first_paint: {
type: 'number',
minimum: 0.001,
description:
'The duration until `first-contentful-paint`, in seconds. Informs CSS performance.',
},
exit_dom_interactive: {
type: 'number',
minimum: 0.001,
description:
'The duration until `PerformanceNavigationTiming.domInteractive`, in seconds. Informs JavaScript loading performance.',
},
exit_dom_complete: {
type: 'number',
minimum: 0.001,
description:
'The duration until `PerformanceNavigationTiming.domComplete`, in seconds. Informs JavaScript execution performance.',
},
exit_visit_duration: {
type: 'number',
minimum: 0.001,
description:
'The duration of exit.timestamp - page.timestamp, in seconds. Informs bounce rate.',
},
exit_scroll_length: {
type: 'number',
minimum: 0,
maximum: 1,
description: 'The percentage of how far the user scrolled on the page.',
},
},
}
const linkSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context', 'link_url'],
properties: {
context,
type: {
type: 'string',
pattern: '^link$',
},
link_url: {
type: 'string',
format: 'uri',
description:
'The href of the anchor tag the user clicked, or the page or object they directed their browser to.',
},
},
}
const searchSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context', 'search_query'],
properties: {
context,
type: {
type: 'string',
pattern: '^search$',
},
search_query: {
type: 'string',
description: 'The actual text content of the query string the user sent to the service.',
},
search_context: {
type: 'string',
description: 'Any additional search context, such as component searched.',
},
},
}
const navigateSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context'],
properties: {
context,
type: {
type: 'string',
pattern: '^navigate$',
},
navigate_label: {
type: 'string',
description: 'An identifier for where the user is navigating.',
},
},
}
const surveySchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context', 'survey_vote'],
properties: {
context,
type: {
type: 'string',
pattern: '^survey$',
},
survey_vote: {
type: 'boolean',
description: 'Whether the user found the page helpful.',
},
survey_comment: {
type: 'string',
description: 'Any textual comments the user wanted to provide.',
},
survey_email: {
type: 'string',
format: 'email',
description: "The user's email address, if the user provided and consented.",
},
},
}
const experimentSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context', 'experiment_name', 'experiment_variation'],
properties: {
context,
type: {
type: 'string',
pattern: '^experiment$',
},
experiment_name: {
type: 'string',
description: 'The test that this event is part of.',
},
experiment_variation: {
type: 'string',
enum: ['control', 'treatment'],
description: 'The variation this user we bucketed in, such as control or treatment.',
},
experiment_success: {
type: 'boolean',
default: true,
description: 'Whether or not the user successfully performed the test goal.',
},
},
}
const redirectSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context', 'redirect_from', 'redirect_to'],
properties: {
context,
type: {
type: 'string',
pattern: '^redirect$',
},
redirect_from: {
type: 'string',
description: 'The requested href.',
format: 'uri-reference',
},
redirect_to: {
type: 'string',
description: 'The destination href of the redirect.',
format: 'uri-reference',
},
},
}
const clipboardSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context', 'clipboard_operation'],
properties: {
context,
type: {
type: 'string',
pattern: '^clipboard$',
},
clipboard_operation: {
type: 'string',
description: 'Which clipboard operation the user is performing.',
enum: ['copy', 'paste', 'cut'],
},
},
}
const printSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context'],
properties: {
context,
type: {
type: 'string',
pattern: '^print$',
},
},
}
const preferenceSchema = {
type: 'object',
additionalProperties: false,
required: ['type', 'context', 'preference_name', 'preference_value'],
properties: {
context,
type: {
type: 'string',
pattern: '^preference$',
},
preference_name: {
type: 'string',
enum: ['application', 'color_mode', 'os'],
description: 'The preference name, such as os, application, or color_mode',
},
preference_value: {
type: 'string',
enum: [
'webui',
'cli',
'desktop',
'curl',
'codespaces',
'dark',
'light',
'auto',
'auto:dark',
'auto:light',
'linux',
'mac',
'windows',
],
description: 'The application, color_mode, or os selected by the user.',
},
},
}
export default {
oneOf: [
pageSchema,
exitSchema,
linkSchema,
searchSchema,
navigateSchema,
surveySchema,
experimentSchema,
redirectSchema,
clipboardSchema,
printSchema,
preferenceSchema,
],
}