This repository was archived by the owner on Sep 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathtelemetry.js
More file actions
331 lines (311 loc) · 11.8 KB
/
Copy pathtelemetry.js
File metadata and controls
331 lines (311 loc) · 11.8 KB
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
/* 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/>. */
/**
* This is a stub of the DevTools telemetry module and will be replaced by the
* full version of the file by Webpack for running inside Firefox.
*/
class Telemetry {
/**
* Time since the system wide epoch. This is not a monotonic timer but
* can be used across process boundaries.
*/
get msSystemNow() {
return 0;
}
/**
* Starts a timer associated with a telemetry histogram. The timer can be
* directly associated with a histogram, or with a pair of a histogram and
* an object.
*
* @param {String} histogramId
* A string which must be a valid histogram name.
* @param {Object} obj
* Optional parameter. If specified, the timer is associated with this
* object, meaning that multiple timers for the same histogram may be
* run concurrently, as long as they are associated with different
* objects.
*
* @returns {Boolean}
* True if the timer was successfully started, false otherwise. If a
* timer already exists, it can't be started again, and the existing
* one will be cleared in order to avoid measurements errors.
*/
start(histogramId, obj) {
return true;
}
/**
* Starts a timer associated with a keyed telemetry histogram. The timer can
* be directly associated with a histogram and its key. Similarly to
* TelemetryStopwatch.start the histogram and its key can be associated
* with an object. Each key may have multiple associated objects and each
* object can be associated with multiple keys.
*
* @param {String} histogramId
* A string which must be a valid histogram name.
* @param {String} key
* A string which must be a valid histgram key.
* @param {Object} obj
* Optional parameter. If specified, the timer is associated with this
* object, meaning that multiple timers for the same histogram may be
* run concurrently,as long as they are associated with different
* objects.
*
* @returns {Boolean}
* True if the timer was successfully started, false otherwise. If a
* timer already exists, it can't be started again, and the existing
* one will be cleared in order to avoid measurements errors.
*/
startKeyed(histogramId, key, obj) {
return true;
}
/**
* Stops the timer associated with the given histogram (and object),
* calculates the time delta between start and finish, and adds the value
* to the histogram.
*
* @param {String} histogramId
* A string which must be a valid histogram name.
* @param {Object} obj
* Optional parameter which associates the histogram timer with the
* given object.
* @param {Boolean} canceledOkay
* Optional parameter which will suppress any warnings that normally
* fire when a stopwatch is finished after being cancelled.
* Defaults to false.
*
* @returns {Boolean}
* True if the timer was succesfully stopped and the data was added
* to the histogram, False otherwise.
*/
finish(histogramId, obj, canceledOkay) {
return true;
}
/**
* Stops the timer associated with the given keyed histogram (and object),
* calculates the time delta between start and finish, and adds the value
* to the keyed histogram.
*
* @param {String} histogramId
* A string which must be a valid histogram name.
* @param {String} key
* A string which must be a valid histogram key.
* @param {Object} obj
* Optional parameter which associates the histogram timer with the
* given object.
* @param {Boolean} canceledOkay
* Optional parameter which will suppress any warnings that normally
* fire when a stopwatch is finished after being cancelled.
* Defaults to false.
*
* @returns {Boolean}
* True if the timer was succesfully stopped and the data was added
* to the histogram, False otherwise.
*/
finishKeyed(histogramId, key, obj, cancelledOkay) {
return true;
}
/**
* Log a value to a histogram.
*
* @param {String} histogramId
* Histogram in which the data is to be stored.
*/
getHistogramById(histogramId) {
return {
add: () => {}
};
}
/**
* Get a keyed histogram.
*
* @param {String} histogramId
* Histogram in which the data is to be stored.
*/
getKeyedHistogramById(histogramId) {
return {
add: () => {}
};
}
/**
* Log a value to a scalar.
*
* @param {String} scalarId
* Scalar in which the data is to be stored.
* @param value
* Value to store.
*/
scalarSet(scalarId, value) {}
/**
* Log a value to a count scalar.
*
* @param {String} scalarId
* Scalar in which the data is to be stored.
* @param value
* Value to store.
*/
scalarAdd(scalarId, value) {}
/**
* Log a value to a keyed count scalar.
*
* @param {String} scalarId
* Scalar in which the data is to be stored.
* @param {String} key
* The key within the scalar.
* @param value
* Value to store.
*/
keyedScalarAdd(scalarId, key, value) {}
/**
* Event telemetry is disabled by default. Use this method to enable it for
* a particular category.
*
* @param {Boolean} enabled
* Enabled: true or false.
*/
setEventRecordingEnabled(enabled) {
return enabled;
}
/**
* Telemetry events often need to make use of a number of properties from
* completely different codepaths. To make this possible we create a
* "pending event" along with an array of property names that we need to wait
* for before sending the event.
*
* As each property is received via addEventProperty() we check if all
* properties have been received. Once they have all been received we send the
* telemetry event.
*
* @param {Object} obj
* The telemetry event or ping is associated with this object, meaning
* that multiple events or pings for the same histogram may be run
* concurrently, as long as they are associated with different objects.
* @param {String} method
* The telemetry event method (describes the type of event that
* occurred e.g. "open")
* @param {String} object
* The telemetry event object name (the name of the object the event
* occurred on) e.g. "tools" or "setting"
* @param {String|null} value
* The telemetry event value (a user defined value, providing context
* for the event) e.g. "console"
* @param {Array} expected
* An array of the properties needed before sending the telemetry
* event e.g.
* [
* "host",
* "width"
* ]
*/
preparePendingEvent(obj, method, object, value, expected = []) {}
/**
* Adds an expected property for either a current or future pending event.
* This means that if preparePendingEvent() is called before or after sending
* the event properties they will automatically added to the event.
*
* @param {Object} obj
* The telemetry event or ping is associated with this object, meaning
* that multiple events or pings for the same histogram may be run
* concurrently, as long as they are associated with different objects.
* @param {String} method
* The telemetry event method (describes the type of event that
* occurred e.g. "open")
* @param {String} object
* The telemetry event object name (the name of the object the event
* occurred on) e.g. "tools" or "setting"
* @param {String|null} value
* The telemetry event value (a user defined value, providing context
* for the event) e.g. "console"
* @param {String} pendingPropName
* The pending property name
* @param {String} pendingPropValue
* The pending property value
*/
addEventProperty(obj, method, object, value, pendingPropName, pendingPropValue) {}
/**
* Adds expected properties for either a current or future pending event.
* This means that if preparePendingEvent() is called before or after sending
* the event properties they will automatically added to the event.
*
* @param {Object} obj
* The telemetry event or ping is associated with this object, meaning
* that multiple events or pings for the same histogram may be run
* concurrently, as long as they are associated with different objects.
* @param {String} method
* The telemetry event method (describes the type of event that
* occurred e.g. "open")
* @param {String} object
* The telemetry event object name (the name of the object the event
* occurred on) e.g. "tools" or "setting"
* @param {String|null} value
* The telemetry event value (a user defined value, providing context
* for the event) e.g. "console"
* @param {String} pendingObject
* An object containing key, value pairs that should be added to the
* event as properties.
*/
addEventProperties(obj, method, object, value, pendingObject) {}
/**
* A private method that is not to be used externally. This method is used to
* prepare a pending telemetry event for sending and then send it via
* recordEvent().
*
* @param {Object} obj
* The telemetry event or ping is associated with this object, meaning
* that multiple events or pings for the same histogram may be run
* concurrently, as long as they are associated with different objects.
* @param {String} method
* The telemetry event method (describes the type of event that
* occurred e.g. "open")
* @param {String} object
* The telemetry event object name (the name of the object the event
* occurred on) e.g. "tools" or "setting"
* @param {String|null} value
* The telemetry event value (a user defined value, providing context
* for the event) e.g. "console"
*/
_sendPendingEvent(obj, method, object, value) {}
/**
* Send a telemetry event.
*
* @param {String} method
* The telemetry event method (describes the type of event that
* occurred e.g. "open")
* @param {String} object
* The telemetry event object name (the name of the object the event
* occurred on) e.g. "tools" or "setting"
* @param {String|null} value
* The telemetry event value (a user defined value, providing context
* for the event) e.g. "console"
* @param {Object} extra
* The telemetry event extra object containing the properties that will
* be sent with the event e.g.
* {
* host: "bottom",
* width: "1024"
* }
*/
recordEvent(method, object, value, extra) {}
/**
* Sends telemetry pings to indicate that a tool has been opened.
*
* @param {String} id
* The ID of the tool opened.
* @param {String} sessionId
* Toolbox session id used when we need to ensure a tool really has a
* timer before calculating a delta.
* @param {Object} obj
* The telemetry event or ping is associated with this object, meaning
* that multiple events or pings for the same histogram may be run
* concurrently, as long as they are associated with different objects.
*/
toolOpened(id, sessionId, obj) {}
/**
* Sends telemetry pings to indicate that a tool has been closed.
*
* @param {String} id
* The ID of the tool opened.
*/
toolClosed(id, sessionId, obj) {}
}
module.exports = Telemetry;