Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 892737f

Browse files
authored
[sync] Bug 1491879 - Fix telemetry support for multiple tabs / windows r=nchevobbe (#1096)
1 parent 22c19c1 commit 892737f

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

packages/devtools-modules/src/utils/telemetry.js

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,10 @@ class Telemetry {
172172
* Event telemetry is disabled by default. Use this method to enable it for
173173
* a particular category.
174174
*
175-
* @param {String} category
176-
* The telemetry event category e.g. "devtools.main"
177175
* @param {Boolean} enabled
178176
* Enabled: true or false.
179177
*/
180-
setEventRecordingEnabled(category, enabled) {
178+
setEventRecordingEnabled(enabled) {
181179
return enabled;
182180
}
183181

@@ -191,9 +189,10 @@ class Telemetry {
191189
* properties have been received. Once they have all been received we send the
192190
* telemetry event.
193191
*
194-
* @param {String} category
195-
* The telemetry event category (a group name for events and helps to
196-
* avoid name conflicts) e.g. "devtools.main"
192+
* @param {Object} obj
193+
* The telemetry event or ping is associated with this object, meaning
194+
* that multiple events or pings for the same histogram may be run
195+
* concurrently, as long as they are associated with different objects.
197196
* @param {String} method
198197
* The telemetry event method (describes the type of event that
199198
* occurred e.g. "open")
@@ -211,16 +210,17 @@ class Telemetry {
211210
* "width"
212211
* ]
213212
*/
214-
preparePendingEvent(category, method, object, value, expected = []) {}
213+
preparePendingEvent(obj, method, object, value, expected = []) {}
215214

216215
/**
217216
* Adds an expected property for either a current or future pending event.
218217
* This means that if preparePendingEvent() is called before or after sending
219218
* the event properties they will automatically added to the event.
220219
*
221-
* @param {String} category
222-
* The telemetry event category (a group name for events and helps to
223-
* avoid name conflicts) e.g. "devtools.main"
220+
* @param {Object} obj
221+
* The telemetry event or ping is associated with this object, meaning
222+
* that multiple events or pings for the same histogram may be run
223+
* concurrently, as long as they are associated with different objects.
224224
* @param {String} method
225225
* The telemetry event method (describes the type of event that
226226
* occurred e.g. "open")
@@ -235,23 +235,17 @@ class Telemetry {
235235
* @param {String} pendingPropValue
236236
* The pending property value
237237
*/
238-
addEventProperty(
239-
category,
240-
method,
241-
object,
242-
value,
243-
pendingPropName,
244-
pendingPropValue
245-
) {}
238+
addEventProperty(obj, method, object, value, pendingPropName, pendingPropValue) {}
246239

247240
/**
248241
* Adds expected properties for either a current or future pending event.
249242
* This means that if preparePendingEvent() is called before or after sending
250243
* the event properties they will automatically added to the event.
251244
*
252-
* @param {String} category
253-
* The telemetry event category (a group name for events and helps to
254-
* avoid name conflicts) e.g. "devtools.main"
245+
* @param {Object} obj
246+
* The telemetry event or ping is associated with this object, meaning
247+
* that multiple events or pings for the same histogram may be run
248+
* concurrently, as long as they are associated with different objects.
255249
* @param {String} method
256250
* The telemetry event method (describes the type of event that
257251
* occurred e.g. "open")
@@ -265,16 +259,17 @@ class Telemetry {
265259
* An object containing key, value pairs that should be added to the
266260
* event as properties.
267261
*/
268-
addEventProperties(category, method, object, value, pendingObject) {}
262+
addEventProperties(obj, method, object, value, pendingObject) {}
269263

270264
/**
271265
* A private method that is not to be used externally. This method is used to
272266
* prepare a pending telemetry event for sending and then send it via
273267
* recordEvent().
274268
*
275-
* @param {String} category
276-
* The telemetry event category (a group name for events and helps to
277-
* avoid name conflicts) e.g. "devtools.main"
269+
* @param {Object} obj
270+
* The telemetry event or ping is associated with this object, meaning
271+
* that multiple events or pings for the same histogram may be run
272+
* concurrently, as long as they are associated with different objects.
278273
* @param {String} method
279274
* The telemetry event method (describes the type of event that
280275
* occurred e.g. "open")
@@ -285,14 +280,11 @@ class Telemetry {
285280
* The telemetry event value (a user defined value, providing context
286281
* for the event) e.g. "console"
287282
*/
288-
_sendPendingEvent(category, method, object, value) {}
283+
_sendPendingEvent(obj, method, object, value) {}
289284

290285
/**
291286
* Send a telemetry event.
292287
*
293-
* @param {String} category
294-
* The telemetry event category (a group name for events and helps to
295-
* avoid name conflicts) e.g. "devtools.main"
296288
* @param {String} method
297289
* The telemetry event method (describes the type of event that
298290
* occurred e.g. "open")
@@ -310,23 +302,30 @@ class Telemetry {
310302
* width: "1024"
311303
* }
312304
*/
313-
recordEvent(category, method, object, value, extra) {}
305+
recordEvent(method, object, value, extra) {}
314306

315307
/**
316308
* Sends telemetry pings to indicate that a tool has been opened.
317309
*
318310
* @param {String} id
319311
* The ID of the tool opened.
312+
* @param {String} sessionId
313+
* Toolbox session id used when we need to ensure a tool really has a
314+
* timer before calculating a delta.
315+
* @param {Object} obj
316+
* The telemetry event or ping is associated with this object, meaning
317+
* that multiple events or pings for the same histogram may be run
318+
* concurrently, as long as they are associated with different objects.
320319
*/
321-
toolOpened(id) {}
320+
toolOpened(id, sessionId, obj) {}
322321

323322
/**
324323
* Sends telemetry pings to indicate that a tool has been closed.
325324
*
326325
* @param {String} id
327326
* The ID of the tool opened.
328327
*/
329-
toolClosed(id) {}
328+
toolClosed(id, sessionId, obj) {}
330329
}
331330

332331
module.exports = Telemetry;

0 commit comments

Comments
 (0)