Skip to content

Commit 781b5f3

Browse files
committed
move types out of send-event.ts
1 parent ecbd52f commit 781b5f3

File tree

3 files changed

+115
-116
lines changed

3 files changed

+115
-116
lines changed

packages/wrangler/src/metrics/metrics-dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
writeMetricsConfig,
1919
} from "./metrics-config";
2020
import type { MetricsConfigOptions } from "./metrics-config";
21-
import type { CommonEventProperties, Events } from "./send-event";
21+
import type { CommonEventProperties, Events } from "./types";
2222

2323
const SPARROW_URL = "https://sparrow.cloudflare.com";
2424

packages/wrangler/src/metrics/send-event.ts

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -114,118 +114,3 @@ export async function sendMetricsEvent(
114114
logger.debug("Error sending metrics event", err);
115115
}
116116
}
117-
118-
export type CommonEventProperties = {
119-
/** The version of the Wrangler client that is sending the event. */
120-
wranglerVersion: string;
121-
/**
122-
* The platform that the Wrangler client is running on.
123-
*/
124-
osPlatform: string;
125-
/**
126-
* The platform version that the Wrangler client is running on.
127-
*/
128-
osVersion: string;
129-
/**
130-
* The package manager that the Wrangler client is using.
131-
*/
132-
packageManager: string | undefined;
133-
/**
134-
* The version of node that the Wrangler client is running on.
135-
*/
136-
nodeVersion: string;
137-
/**
138-
* Whether this is the first time the user has used the wrangler client.
139-
*/
140-
isFirstUsage: boolean;
141-
/**
142-
* What format is the configuration file? No content from the actual configuration file is sent.
143-
*/
144-
configFileType: "toml" | "json" | "jsonc" | "none" | "invalid";
145-
/**
146-
* Randomly generated id to tie together started, completed or errored events from one command run
147-
*/
148-
amplitude_session_id: number;
149-
/**
150-
* Tracks the order of events in a session (one command run = one session)
151-
*/
152-
amplitude_event_id: number;
153-
/**
154-
* Whether the Wrangler client is running in CI
155-
*/
156-
isCI: boolean;
157-
/**
158-
* Whether the Wrangler client is running in an interactive instance
159-
*/
160-
isInteractive: boolean;
161-
/**
162-
* A list of normalised argument names/flags that were passed in or are set by default.
163-
* Excludes boolean flags set to false.
164-
*/
165-
argsUsed: string[];
166-
/**
167-
* Same as argsUsed except concatenated for convenience in Amplitude
168-
*/
169-
argsCombination: string;
170-
};
171-
172-
/** We send a metrics event at the start and end of a command run */
173-
export type Events =
174-
| {
175-
name: "wrangler command started";
176-
properties: CommonEventProperties & {
177-
/**
178-
* The command that was used, e.g. `wrangler dev`
179-
*/
180-
command: string;
181-
/**
182-
* The args and flags that were passed in when running the command.
183-
* All user-inputted string values are redacted, except for some cases where there are set options.
184-
*/
185-
args: Record<string, unknown>;
186-
};
187-
}
188-
| {
189-
name: "wrangler command completed";
190-
properties: CommonEventProperties & {
191-
/**
192-
* The command that was used, e.g. `wrangler dev`
193-
*/
194-
command: string | undefined;
195-
/**
196-
* The args and flags that were passed in when running the command.
197-
* All user-inputted string values are redacted, except for some cases where there are set options.
198-
*/
199-
args: Record<string, unknown> | undefined;
200-
/**
201-
* The time elapsed between the "wrangler command started" and "wrangler command completed" events
202-
*/
203-
durationMs: number;
204-
durationMinutes: number;
205-
durationSeconds: number;
206-
};
207-
}
208-
| {
209-
name: "wrangler command errored";
210-
properties: CommonEventProperties & {
211-
/**
212-
* The command that was used, e.g. `wrangler dev`
213-
*/
214-
command: string | undefined;
215-
/**
216-
* The args and flags that were passed in when running the command.
217-
* All user-inputted string values are redacted, except for some cases where there are set options.
218-
*/
219-
args: Record<string, unknown> | undefined;
220-
/**
221-
* The time elapsed between the "wrangler command started" and "wrangler command errored" events
222-
*/
223-
durationMs: number;
224-
durationMinutes: number;
225-
durationSeconds: number;
226-
/**
227-
* Type of error, e.g. UserError, APIError. Does not include stack trace or error message.
228-
*/
229-
errorType: string | undefined;
230-
};
231-
};
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
export type CommonEventProperties = {
2+
/** The version of the Wrangler client that is sending the event. */
3+
wranglerVersion: string;
4+
/**
5+
* The platform that the Wrangler client is running on.
6+
*/
7+
osPlatform: string;
8+
/**
9+
* The platform version that the Wrangler client is running on.
10+
*/
11+
osVersion: string;
12+
/**
13+
* The package manager that the Wrangler client is using.
14+
*/
15+
packageManager: string | undefined;
16+
/**
17+
* The version of node that the Wrangler client is running on.
18+
*/
19+
nodeVersion: string;
20+
/**
21+
* Whether this is the first time the user has used the wrangler client.
22+
*/
23+
isFirstUsage: boolean;
24+
/**
25+
* What format is the configuration file? No content from the actual configuration file is sent.
26+
*/
27+
configFileType: "toml" | "json" | "jsonc" | "none" | "invalid";
28+
/**
29+
* Randomly generated id to tie together started, completed or errored events from one command run
30+
*/
31+
amplitude_session_id: number;
32+
/**
33+
* Tracks the order of events in a session (one command run = one session)
34+
*/
35+
amplitude_event_id: number;
36+
/**
37+
* Whether the Wrangler client is running in CI
38+
*/
39+
isCI: boolean;
40+
/**
41+
* Whether the Wrangler client is running in an interactive instance
42+
*/
43+
isInteractive: boolean;
44+
/**
45+
* A list of normalised argument names/flags that were passed in or are set by default.
46+
* Excludes boolean flags set to false.
47+
*/
48+
argsUsed: string[];
49+
/**
50+
* Same as argsUsed except concatenated for convenience in Amplitude
51+
*/
52+
argsCombination: string;
53+
};
54+
55+
/** We send a metrics event at the start and end of a command run */
56+
export type Events =
57+
| {
58+
name: "wrangler command started";
59+
properties: CommonEventProperties & {
60+
/**
61+
* The command that was used, e.g. `wrangler dev`
62+
*/
63+
command: string;
64+
/**
65+
* The args and flags that were passed in when running the command.
66+
* All user-inputted string values are redacted, except for some cases where there are set options.
67+
*/
68+
args: Record<string, unknown>;
69+
};
70+
}
71+
| {
72+
name: "wrangler command completed";
73+
properties: CommonEventProperties & {
74+
/**
75+
* The command that was used, e.g. `wrangler dev`
76+
*/
77+
command: string | undefined;
78+
/**
79+
* The args and flags that were passed in when running the command.
80+
* All user-inputted string values are redacted, except for some cases where there are set options.
81+
*/
82+
args: Record<string, unknown> | undefined;
83+
/**
84+
* The time elapsed between the "wrangler command started" and "wrangler command completed" events
85+
*/
86+
durationMs: number;
87+
durationMinutes: number;
88+
durationSeconds: number;
89+
};
90+
}
91+
| {
92+
name: "wrangler command errored";
93+
properties: CommonEventProperties & {
94+
/**
95+
* The command that was used, e.g. `wrangler dev`
96+
*/
97+
command: string | undefined;
98+
/**
99+
* The args and flags that were passed in when running the command.
100+
* All user-inputted string values are redacted, except for some cases where there are set options.
101+
*/
102+
args: Record<string, unknown> | undefined;
103+
/**
104+
* The time elapsed between the "wrangler command started" and "wrangler command errored" events
105+
*/
106+
durationMs: number;
107+
durationMinutes: number;
108+
durationSeconds: number;
109+
/**
110+
* Type of error, e.g. UserError, APIError. Does not include stack trace or error message.
111+
*/
112+
errorType: string | undefined;
113+
};
114+
};

0 commit comments

Comments
 (0)