You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/wrangler/src/__tests__/metrics.test.ts
+19-4Lines changed: 19 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -92,13 +92,28 @@ describe("metrics", () => {
92
92
awaitPromise.all(dispatcher.requests);
93
93
expect(requests.count).toBe(1);
94
94
expect(std.debug).toMatchInlineSnapshot(
95
-
`"Metrics dispatcher: Posting data {\\"deviceId\\":\\"f82b1f46-eb7b-4154-aa9f-ce95f23b2288\\",\\"event\\":\\"some-event\\",\\"timestamp\\":1733961600000,\\"properties\\":{\\"category\\":\\"Workers\\",\\"wranglerVersion\\":\\"1.2.3\\",\\"os\\":\\"foo:bar\\",\\"a\\":1,\\"b\\":2}}"`
95
+
`"Metrics dispatcher: Posting data {\\"deviceId\\":\\"f82b1f46-eb7b-4154-aa9f-ce95f23b2288\\",\\"event\\":\\"some-event\\",\\"timestamp\\":1733961600000,\\"properties\\":{\\"category\\":\\"Workers\\",\\"wranglerVersion\\":\\"1.2.3\\",\\"wranglerMajorVersion\\":1,\\"wranglerMinorVersion\\":2,\\"wranglerPatchVersion\\":3,\\"os\\":\\"foo:bar\\",\\"a\\":1,\\"b\\":2}}"`
96
96
);
97
97
expect(std.out).toMatchInlineSnapshot(`""`);
98
98
expect(std.warn).toMatchInlineSnapshot(`""`);
99
99
expect(std.err).toMatchInlineSnapshot(`""`);
100
100
});
101
101
102
+
it("should include parsed wrangler version components in events",async()=>{
it("should write a debug log if the dispatcher is disabled",async()=>{
103
118
constrequests=mockMetricRequest();
104
119
constdispatcher=getMetricsDispatcher({
@@ -108,7 +123,7 @@ describe("metrics", () => {
108
123
109
124
expect(requests.count).toBe(0);
110
125
expect(std.debug).toMatchInlineSnapshot(
111
-
`"Metrics dispatcher: Dispatching disabled - would have sent {\\"deviceId\\":\\"f82b1f46-eb7b-4154-aa9f-ce95f23b2288\\",\\"event\\":\\"some-event\\",\\"timestamp\\":1733961600000,\\"properties\\":{\\"category\\":\\"Workers\\",\\"wranglerVersion\\":\\"1.2.3\\",\\"os\\":\\"foo:bar\\",\\"a\\":1,\\"b\\":2}}."`
126
+
`"Metrics dispatcher: Dispatching disabled - would have sent {\\"deviceId\\":\\"f82b1f46-eb7b-4154-aa9f-ce95f23b2288\\",\\"event\\":\\"some-event\\",\\"timestamp\\":1733961600000,\\"properties\\":{\\"category\\":\\"Workers\\",\\"wranglerVersion\\":\\"1.2.3\\",\\"wranglerMajorVersion\\":1,\\"wranglerMinorVersion\\":2,\\"wranglerPatchVersion\\":3,\\"os\\":\\"foo:bar\\",\\"a\\":1,\\"b\\":2}}."`
112
127
);
113
128
expect(std.out).toMatchInlineSnapshot(`""`);
114
129
expect(std.warn).toMatchInlineSnapshot(`""`);
@@ -128,7 +143,7 @@ describe("metrics", () => {
128
143
awaitPromise.all(dispatcher.requests);
129
144
130
145
expect(std.debug).toMatchInlineSnapshot(`
131
-
"Metrics dispatcher: Posting data {\\"deviceId\\":\\"f82b1f46-eb7b-4154-aa9f-ce95f23b2288\\",\\"event\\":\\"some-event\\",\\"timestamp\\":1733961600000,\\"properties\\":{\\"category\\":\\"Workers\\",\\"wranglerVersion\\":\\"1.2.3\\",\\"os\\":\\"foo:bar\\",\\"a\\":1,\\"b\\":2}}
146
+
"Metrics dispatcher: Posting data {\\"deviceId\\":\\"f82b1f46-eb7b-4154-aa9f-ce95f23b2288\\",\\"event\\":\\"some-event\\",\\"timestamp\\":1733961600000,\\"properties\\":{\\"category\\":\\"Workers\\",\\"wranglerVersion\\":\\"1.2.3\\",\\"wranglerMajorVersion\\":1,\\"wranglerMinorVersion\\":2,\\"wranglerPatchVersion\\":3,\\"os\\":\\"foo:bar\\",\\"a\\":1,\\"b\\":2}}
132
147
Metrics dispatcher: Failed to send request: Failed to fetch"
133
148
`);
134
149
expect(std.out).toMatchInlineSnapshot(`""`);
@@ -147,7 +162,7 @@ describe("metrics", () => {
147
162
148
163
expect(requests.count).toBe(0);
149
164
expect(std.debug).toMatchInlineSnapshot(
150
-
`"Metrics dispatcher: Source Key not provided. Be sure to initialize before sending events {\\"deviceId\\":\\"f82b1f46-eb7b-4154-aa9f-ce95f23b2288\\",\\"event\\":\\"some-event\\",\\"timestamp\\":1733961600000,\\"properties\\":{\\"category\\":\\"Workers\\",\\"wranglerVersion\\":\\"1.2.3\\",\\"os\\":\\"foo:bar\\",\\"a\\":1,\\"b\\":2}}"`
165
+
`"Metrics dispatcher: Source Key not provided. Be sure to initialize before sending events {\\"deviceId\\":\\"f82b1f46-eb7b-4154-aa9f-ce95f23b2288\\",\\"event\\":\\"some-event\\",\\"timestamp\\":1733961600000,\\"properties\\":{\\"category\\":\\"Workers\\",\\"wranglerVersion\\":\\"1.2.3\\",\\"wranglerMajorVersion\\":1,\\"wranglerMinorVersion\\":2,\\"wranglerPatchVersion\\":3,\\"os\\":\\"foo:bar\\",\\"a\\":1,\\"b\\":2}}"`
0 commit comments