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

Commit 4d4d3fc

Browse files
Mike RatcliffejasonLaster
authored andcommitted
Add Telemetry.js (#1065)
* Add Telemetry.js * Added toolOpened() and toolClosed() * Remove close parameter from toolClosed() * bump packages
1 parent 471c617 commit 4d4d3fc

File tree

5 files changed

+457
-3
lines changed

5 files changed

+457
-3
lines changed

packages/devtools-launchpad/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "devtools-launchpad",
3-
"version": "0.0.121",
3+
"version": "0.0.123",
44
"license": "MPL-2.0",
55
"description":
66
"The Launchpad makes it easy to build a developer tool for Firefox, Chrome, and Node.",
@@ -56,7 +56,7 @@
5656
"devtools-connection": "^0.0.9",
5757
"devtools-contextmenu": "^0.0.8",
5858
"devtools-mc-assets": "^0.0.5",
59-
"devtools-modules": "^0.0.36",
59+
"devtools-modules": "^0.0.37",
6060
"devtools-sprintf-js": "^1.0.3",
6161
"express": "^4.13.4",
6262
"express-static": "^1.2.5",

packages/devtools-modules/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const KeyShortcuts = require("./src/key-shortcuts");
1010
const { ZoomKeys } = require("./src/zoom-keys");
1111
const EventEmitter = require("./src/utils/event-emitter");
1212
const SourceUtils = require("./src/source-utils");
13+
const Telemetry = require("./src/utils/telemetry")
1314
const { getUnicodeHostname, getUnicodeUrlPath, getUnicodeUrl } =
1415
require("./src/unicode-url");
1516

@@ -22,6 +23,7 @@ module.exports = {
2223
ZoomKeys,
2324
EventEmitter,
2425
SourceUtils,
26+
Telemetry,
2527
getUnicodeHostname,
2628
getUnicodeUrlPath,
2729
getUnicodeUrl,

packages/devtools-modules/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "devtools-modules",
3-
"version": "0.0.36",
3+
"version": "0.0.37",
44
"description": "DevTools Modules from M-C",
55
"main": "index.js",
66
"scripts": {
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
const Telemetry = require("../utils/telemetry");
2+
const telemetry = new Telemetry();
3+
4+
describe("telemetry shim", () => {
5+
it("msSystemNow", () => {
6+
expect(() => {
7+
telemetry.msSystemNow;
8+
}).not.toThrow();
9+
});
10+
11+
it("start", () => {
12+
expect(() => {
13+
telemetry.start("foo", this);
14+
}).not.toThrow();
15+
});
16+
17+
it("startKeyed", () => {
18+
expect(() => {
19+
telemetry.startKeyed("foo", "bar", this);
20+
}).not.toThrow();
21+
});
22+
23+
it("finish", () => {
24+
expect(() => {
25+
telemetry.finish("foo", this);
26+
}).not.toThrow();
27+
});
28+
29+
it("finishKeyed", () => {
30+
expect(() => {
31+
telemetry.finishKeyed("foo", "bar", this);
32+
}).not.toThrow();
33+
});
34+
35+
it("getHistogramById", () => {
36+
expect(() => {
37+
telemetry.getHistogramById("foo").add(3);
38+
}).not.toThrow();
39+
});
40+
41+
it("getKeyedHistogramById", () => {
42+
expect(() => {
43+
telemetry.getKeyedHistogramById("foo").add("foo", 3);
44+
}).not.toThrow();
45+
});
46+
47+
it("scalarSet", () => {
48+
expect(() => {
49+
telemetry.scalarSet("foo", 3);
50+
}).not.toThrow();
51+
});
52+
53+
it("scalarAdd", () => {
54+
expect(() => {
55+
telemetry.scalarAdd("foo", 3);
56+
}).not.toThrow();
57+
});
58+
59+
it("keyedScalarAdd", () => {
60+
expect(() => {
61+
telemetry.keyedScalarAdd("foo", "bar", 3);
62+
}).not.toThrow();
63+
});
64+
65+
it("setEventRecordingEnabled", () => {
66+
expect(() => {
67+
telemetry.setEventRecordingEnabled("foo", true);
68+
}).not.toThrow();
69+
});
70+
71+
it("preparePendingEvent", () => {
72+
expect(() => {
73+
telemetry.preparePendingEvent(
74+
"devtools.main", "open", "inspector", null, ["foo", "bar"]);
75+
}).not.toThrow();
76+
});
77+
78+
it("addEventProperty", () => {
79+
expect(() => {
80+
telemetry.addEventProperty(
81+
"devtools.main", "open", "inspector", "foo", "1");
82+
}).not.toThrow();
83+
});
84+
85+
it("addEventProperties", () => {
86+
expect(() => {
87+
telemetry.addEventProperties("devtools.main", "open", "inspector", {
88+
"foo": "1",
89+
"bar": "2"
90+
});
91+
}).not.toThrow();
92+
});
93+
94+
it("_sendPendingEvent", () => {
95+
expect(() => {
96+
telemetry._sendPendingEvent("devtools.main", "open", "inspector", null);
97+
}).not.toThrow();
98+
});
99+
100+
it("recordEvent", () => {
101+
expect(() => {
102+
telemetry.recordEvent("devtools.main", "open", "inspector", null, {
103+
"foo": "1",
104+
"bar": "2"
105+
});
106+
}).not.toThrow();
107+
});
108+
109+
it("toolOpened", () => {
110+
expect(() => {
111+
telemetry.toolOpened("foo");
112+
}).not.toThrow();
113+
});
114+
115+
it("toolClosed", () => {
116+
expect(() => {
117+
telemetry.toolClosed("foo");
118+
}).not.toThrow();
119+
});
120+
});

0 commit comments

Comments
 (0)