GeckoViewExperimentDelegateParent.sys.mjs (2110B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 import { GeckoViewActorParent } from "resource://gre/modules/GeckoViewActorParent.sys.mjs"; 6 7 export class GeckoViewExperimentDelegateParent extends GeckoViewActorParent { 8 constructor() { 9 super(); 10 } 11 12 /** 13 * Gets experiment information on a given feature. 14 * 15 * @param feature the experiment item to retrieve information on 16 * @returns a promise of success with a JSON message or failure 17 */ 18 async getExperimentFeature(feature) { 19 return this.eventDispatcher.sendRequestForResult({ 20 type: "GeckoView:GetExperimentFeature", 21 feature, 22 }); 23 } 24 25 /** 26 * Records an exposure event, that the experiment area was encountered, on a given feature. 27 * 28 * @param feature the experiment item to record an exposure event of 29 * @returns a promise of success or failure 30 */ 31 async recordExposure(feature) { 32 return this.eventDispatcher.sendRequestForResult({ 33 type: "GeckoView:RecordExposure", 34 feature, 35 }); 36 } 37 38 /** 39 * Records an exposure event on a specific experiment feature and element. 40 * 41 * Note: Use recordExposure, if the slug is not known. 42 * 43 * @param feature the experiment item to record an exposure event of 44 * @param slug a specific experiment element 45 * @returns a promise of success or failure 46 */ 47 async recordExperimentExposure(feature, slug) { 48 return this.eventDispatcher.sendRequestForResult({ 49 type: "GeckoView:RecordExperimentExposure", 50 feature, 51 slug, 52 }); 53 } 54 55 /** 56 * For recording malformed configuration. 57 * 58 * @param feature the experiment item to record an exposure event of 59 * @param part malformed information to send 60 * @returns a promise of success or failure 61 */ 62 async recordExperimentMalformedConfig(feature, part) { 63 return this.eventDispatcher.sendRequestForResult({ 64 type: "GeckoView:RecordMalformedConfig", 65 feature, 66 part, 67 }); 68 } 69 }