summaryrefslogtreecommitdiffstats
path: root/toolkit/components/normandy/actions/schemas/index.sys.mjs
blob: 7ef006e905589360522ab85ae322a382f3198672 (plain)
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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

export const ActionSchemas = {
  "console-log": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Log a message to the console",
    type: "object",
    required: ["message"],
    properties: {
      message: {
        description: "Message to log to the console",
        type: "string",
        default: "",
      },
    },
  },

  "messaging-experiment": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Messaging Experiment",
    type: "object",
    required: ["slug", "branches", "isEnrollmentPaused"],
    properties: {
      slug: {
        description: "Unique identifier for this experiment",
        type: "string",
        pattern: "^[A-Za-z0-9\\-_]+$",
      },
      isEnrollmentPaused: {
        description: "If true, new users will not be enrolled in the study.",
        type: "boolean",
        default: true,
      },
      branches: {
        description: "List of experimental branches",
        type: "array",
        minItems: 1,
        items: {
          type: "object",
          required: ["slug", "value", "ratio", "groups"],
          properties: {
            slug: {
              description:
                "Unique identifier for this branch of the experiment.",
              type: "string",
              pattern: "^[A-Za-z0-9\\-_]+$",
            },
            value: {
              description: "Message content.",
              type: "object",
              properties: {},
            },
            ratio: {
              description:
                "Ratio of users who should be grouped into this branch.",
              type: "integer",
              minimum: 1,
            },
            groups: {
              description:
                "A list of experiment groups that can be used to exclude or select related experiments. May be empty.",
              type: "array",
              items: {
                type: "string",
                description: "Identifier of the group",
              },
            },
          },
        },
      },
    },
  },

  "preference-rollout": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Change preferences permanently",
    type: "object",
    required: ["slug", "preferences"],
    properties: {
      slug: {
        description:
          "Unique identifer for the rollout, used in telemetry and rollbacks",
        type: "string",
        pattern: "^[a-z0-9\\-_]+$",
      },
      preferences: {
        description: "The preferences to change, and their values",
        type: "array",
        minItems: 1,
        items: {
          type: "object",
          required: ["preferenceName", "value"],
          properties: {
            preferenceName: {
              description: "Full dotted-path of the preference being changed",
              type: "string",
            },
            value: {
              description: "Value to set the preference to",
              type: ["string", "integer", "boolean"],
            },
          },
        },
      },
    },
  },

  "preference-rollback": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Undo a preference rollout",
    type: "object",
    required: ["rolloutSlug"],
    properties: {
      rolloutSlug: {
        description: "Unique identifer for the rollout to undo",
        type: "string",
        pattern: "^[a-z0-9\\-_]+$",
      },
    },
  },

  "addon-study": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Enroll a user in an opt-out SHIELD study",
    type: "object",
    required: [
      "name",
      "description",
      "addonUrl",
      "extensionApiId",
      "isEnrollmentPaused",
    ],
    properties: {
      name: {
        description: "User-facing name of the study",
        type: "string",
        minLength: 1,
      },
      description: {
        description: "User-facing description of the study",
        type: "string",
        minLength: 1,
      },
      addonUrl: {
        description: "URL of the add-on XPI file",
        type: "string",
        format: "uri",
        minLength: 1,
      },
      extensionApiId: {
        description:
          "The record ID of the extension used for Normandy API calls.",
        type: "integer",
      },
      isEnrollmentPaused: {
        description: "If true, new users will not be enrolled in the study.",
        type: "boolean",
        default: true,
      },
    },
  },

  "addon-rollout": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Install add-on permanently",
    type: "object",
    required: ["extensionApiId", "slug"],
    properties: {
      extensionApiId: {
        description:
          "The record ID of the extension used for Normandy API calls.",
        type: "integer",
      },
      slug: {
        description:
          "Unique identifer for the rollout, used in telemetry and rollbacks.",
        type: "string",
        pattern: "^[a-z0-9\\-_]+$",
      },
    },
  },

  "addon-rollback": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Undo an add-on rollout",
    type: "object",
    required: ["rolloutSlug"],
    properties: {
      rolloutSlug: {
        description: "Unique identifer for the rollout to undo.",
        type: "string",
        pattern: "^[a-z0-9\\-_]+$",
      },
    },
  },

  "branched-addon-study": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Enroll a user in an add-on experiment, with managed branches",
    type: "object",
    required: [
      "slug",
      "userFacingName",
      "userFacingDescription",
      "branches",
      "isEnrollmentPaused",
    ],
    properties: {
      slug: {
        description: "Machine-readable identifier",
        type: "string",
        minLength: 1,
      },
      userFacingName: {
        description: "User-facing name of the study",
        type: "string",
        minLength: 1,
      },
      userFacingDescription: {
        description: "User-facing description of the study",
        type: "string",
        minLength: 1,
      },
      isEnrollmentPaused: {
        description: "If true, new users will not be enrolled in the study.",
        type: "boolean",
        default: true,
      },
      branches: {
        description: "List of experimental branches",
        type: "array",
        minItems: 1,
        items: {
          type: "object",
          required: ["slug", "ratio", "extensionApiId"],
          properties: {
            slug: {
              description:
                "Unique identifier for this branch of the experiment.",
              type: "string",
              pattern: "^[A-Za-z0-9\\-_]+$",
            },
            ratio: {
              description:
                "Ratio of users who should be grouped into this branch.",
              type: "integer",
              minimum: 1,
            },
            extensionApiId: {
              description:
                "The record ID of the add-on uploaded to the Normandy server. May be null, in which case no add-on will be installed.",
              type: ["number", "null"],
              default: null,
            },
          },
        },
      },
    },
  },

  "show-heartbeat": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Show a Heartbeat survey.",
    description: "This action shows a single survey.",

    type: "object",
    required: [
      "surveyId",
      "message",
      "thanksMessage",
      "postAnswerUrl",
      "learnMoreMessage",
      "learnMoreUrl",
    ],
    properties: {
      repeatOption: {
        type: "string",
        enum: ["once", "xdays", "nag"],
        description: "Determines how often a prompt is shown executes.",
        default: "once",
      },
      repeatEvery: {
        description:
          "For repeatOption=xdays, how often (in days) the prompt is displayed.",
        default: null,
        type: ["number", "null"],
      },
      includeTelemetryUUID: {
        type: "boolean",
        description: "Include unique user ID in post-answer-url and Telemetry",
        default: false,
      },
      surveyId: {
        type: "string",
        description: "Slug uniquely identifying this survey in telemetry",
      },
      message: {
        description: "Message to show to the user",
        type: "string",
      },
      engagementButtonLabel: {
        description:
          "Text for the engagement button. If specified, this button will be shown instead of rating stars.",
        default: null,
        type: ["string", "null"],
      },
      thanksMessage: {
        description:
          "Thanks message to show to the user after they've rated Firefox",
        type: "string",
      },
      postAnswerUrl: {
        description:
          "URL to redirect the user to after rating Firefox or clicking the engagement button",
        default: null,
        type: ["string", "null"],
      },
      learnMoreMessage: {
        description: "Message to show to the user to learn more",
        default: null,
        type: ["string", "null"],
      },
      learnMoreUrl: {
        description: "URL to show to the user when they click Learn More",
        default: null,
        type: ["string", "null"],
      },
    },
  },

  "multi-preference-experiment": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Run a feature experiment activated by a set of preferences.",
    type: "object",
    required: [
      "slug",
      "userFacingName",
      "userFacingDescription",
      "branches",
      "isEnrollmentPaused",
    ],
    properties: {
      slug: {
        description: "Unique identifier for this experiment",
        type: "string",
        pattern: "^[A-Za-z0-9\\-_]+$",
      },
      userFacingName: {
        description: "User-facing name of the experiment",
        type: "string",
        minLength: 1,
      },
      userFacingDescription: {
        description: "User-facing description of the experiment",
        type: "string",
        minLength: 1,
      },
      experimentDocumentUrl: {
        description: "URL of a document describing the experiment",
        type: "string",
        format: "uri",
        default: "",
      },
      isHighPopulation: {
        description:
          "Marks the preference experiment as a high population experiment, that should be excluded from certain types of telemetry",
        type: "boolean",
        default: "false",
      },
      isEnrollmentPaused: {
        description: "If true, new users will not be enrolled in the study.",
        type: "boolean",
        default: true,
      },
      branches: {
        description: "List of experimental branches",
        type: "array",
        minItems: 1,
        items: {
          type: "object",
          required: ["slug", "ratio", "preferences"],
          properties: {
            slug: {
              description:
                "Unique identifier for this branch of the experiment",
              type: "string",
              pattern: "^[A-Za-z0-9\\-_]+$",
            },
            ratio: {
              description:
                "Ratio of users who should be grouped into this branch",
              type: "integer",
              minimum: 1,
            },
            preferences: {
              description:
                "The set of preferences to be set if this branch is chosen",
              type: "object",
              patternProperties: {
                ".*": {
                  type: "object",
                  properties: {
                    preferenceType: {
                      description:
                        "Data type of the preference that controls this experiment",
                      type: "string",
                      enum: ["string", "integer", "boolean"],
                    },
                    preferenceBranchType: {
                      description:
                        "Controls whether the default or user value of the preference is modified",
                      type: "string",
                      enum: ["user", "default"],
                      default: "default",
                    },
                    preferenceValue: {
                      description:
                        "Value for this preference when this branch is chosen",
                      type: ["string", "number", "boolean"],
                    },
                  },
                  required: [
                    "preferenceType",
                    "preferenceBranchType",
                    "preferenceValue",
                  ],
                },
              },
            },
          },
        },
      },
    },
  },

  "single-preference-experiment": {
    $schema: "http://json-schema.org/draft-04/schema#",
    title: "Run a feature experiment activated by a preference.",
    type: "object",
    required: [
      "slug",
      "preferenceName",
      "preferenceType",
      "branches",
      "isEnrollmentPaused",
    ],
    properties: {
      slug: {
        description: "Unique identifier for this experiment",
        type: "string",
        pattern: "^[A-Za-z0-9\\-_]+$",
      },
      experimentDocumentUrl: {
        description: "URL of a document describing the experiment",
        type: "string",
        format: "uri",
        default: "",
      },
      preferenceName: {
        description:
          "Full dotted-path of the preference that controls this experiment",
        type: "string",
      },
      preferenceType: {
        description:
          "Data type of the preference that controls this experiment",
        type: "string",
        enum: ["string", "integer", "boolean"],
      },
      preferenceBranchType: {
        description:
          "Controls whether the default or user value of the preference is modified",
        type: "string",
        enum: ["user", "default"],
        default: "default",
      },
      isHighPopulation: {
        description:
          "Marks the preference experiment as a high population experiment, that should be excluded from certain types of telemetry",
        type: "boolean",
        default: "false",
      },
      isEnrollmentPaused: {
        description: "If true, new users will not be enrolled in the study.",
        type: "boolean",
        default: true,
      },
      branches: {
        description: "List of experimental branches",
        type: "array",
        minItems: 1,
        items: {
          type: "object",
          required: ["slug", "value", "ratio"],
          properties: {
            slug: {
              description:
                "Unique identifier for this branch of the experiment",
              type: "string",
              pattern: "^[A-Za-z0-9\\-_]+$",
            },
            value: {
              description: "Value to set the preference to for this branch",
              type: ["string", "number", "boolean"],
            },
            ratio: {
              description:
                "Ratio of users who should be grouped into this branch",
              type: "integer",
              minimum: 1,
            },
          },
        },
      },
    },
  },
};

// Legacy name used on Normandy server
ActionSchemas["opt-out-study"] = ActionSchemas["addon-study"];

// If running in Node.js, export the schemas.
if (typeof module !== "undefined") {
  /* globals module */
  module.exports = ActionSchemas;
}