summaryrefslogtreecommitdiffstats
path: root/toolkit/components/normandy/actions/MessagingExperimentAction.sys.mjs
blob: 393d2cc3f28c09d1b04302f9a2a3d2aafa55f43a (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
/* 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/. */

import { BaseStudyAction } from "resource://normandy/actions/BaseStudyAction.sys.mjs";

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
  ActionSchemas: "resource://normandy/actions/schemas/index.sys.mjs",
  ExperimentManager: "resource://nimbus/lib/ExperimentManager.sys.mjs",
});

const RECIPE_SOURCE = "normandy";

export class MessagingExperimentAction extends BaseStudyAction {
  constructor() {
    super();
    this.manager = lazy.ExperimentManager;
  }
  get schema() {
    return lazy.ActionSchemas["messaging-experiment"];
  }

  async _run(recipe) {
    if (recipe.arguments) {
      await this.manager.onRecipe(recipe.arguments, RECIPE_SOURCE);
    }
  }

  async _finalize() {
    this.manager.onFinalize(RECIPE_SOURCE);
  }
}