File: nsIGleanPing.idl

package info (click to toggle)
firefox-esr 140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,539,276 kB
  • sloc: cpp: 7,381,286; javascript: 6,388,710; ansic: 3,710,139; python: 1,393,780; xml: 628,165; asm: 426,918; java: 184,004; sh: 65,742; makefile: 19,302; objc: 13,059; perl: 12,912; yacc: 4,583; cs: 3,846; pascal: 3,352; lex: 1,720; ruby: 1,226; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (96 lines) | stat: -rw-r--r-- 3,616 bytes parent folder | download | duplicates (8)
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
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* 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/. */

#include "nsISupports.idl"

[scriptable, function, uuid(e5447f62-4b03-497c-81e9-6ab683d20380)]
interface nsIGleanPingTestCallback : nsISupports
{
  void call(in ACString aReason);
};

[scriptable, function, uuid(576baf9b-3f90-48aa-b35b-89a9638cc823)]
interface nsIGleanPingSubmitCallback : nsISupports
{
  Promise call();
};

[scriptable, uuid(5223a48b-687d-47ff-a629-fd4a72d1ecfa)]
interface nsIGleanPing : nsISupports
{
  /**
   * Collect and submit the ping for eventual upload.
   *
   * This will collect all stored data to be included in the ping.
   * Data with lifetime `ping` will then be reset.
   *
   * If the ping is configured with `send_if_empty = false`
   * and the ping currently contains no content,
   * it will not be queued for upload.
   * If the ping is configured with `send_if_empty = true`
   * it will be queued for upload even if empty.
   *
   * Pings always contain the `ping_info` and `client_info` sections.
   * See [ping sections](https://mozilla.github.io/glean/book/user/pings/index.html#ping-sections)
   * for details.
   *
   * @param aReason - Optional. The reason the ping is being submitted.
   *                  Must match one of the configured `reason_codes`.
   */
  void submit([optional] in ACString aReason);

  /**
   * **Test-only API**
   *
   * Register a callback to be called right before this ping is next submitted.
   * The provided function is called exactly once before submitting.
   *
   * Note: The callback will be called on any call to submit.
   * A ping might not be sent afterwards, e.g. if the ping is empty and
   * `send_if_empty` is `false`.
   *
   * Prefer using `testSubmission` over this function when possible because it
   * will assert that the ping is submitted.
   *
   * @param aCallback - The callback to call on the next submit.
   */
  void testBeforeNextSubmit(in nsIGleanPingTestCallback aCallback);

  /**
   * Enable or disable a ping.
   *
   * Disabling a ping causes all data for that ping to be removed from storage
   * and all pending pings of that type to be deleted.
   *
   * @param aValue When true, enable metric collection.
   */
  void setEnabled(in boolean aValue);

  /**
   * **Test-only API**
   *
   * Register a callback to be called right before this ping is next submitted.
   * Then immediately try to trigger ping submission by calling the second callback.
   *
   * NB: To support both sync and async submit callbacks, this function also has
   *     to be async. As such, you must await the result.
   *
   * @param aCallback - The callback to call on the next submit.
   * @param aSubmitCallback - The callback that should trigger ping submission.
   *                          This may be an async function.
   * @param aSubmitTimeout - An optional timemout after which this function will
   *                         reject the returned promise if `aTestCallback` has
   *                         not been called.
   *
   * @returns A promise that resolves after ping submission but rejects if
   *         `aCallback` was not called after the promise returned by
   *         `aSubmitCallback` resolves.
   */
  [implicit_jscontext]
  Promise testSubmission(
    in nsIGleanPingTestCallback aTestCallback,
    in nsIGleanPingSubmitCallback aSubmitCallback,
    [optional] in unsigned long aSubmitTimeoutMs);
};