wrangler 2.0.18 → 2.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/pages/dev.tsx CHANGED
@@ -8,6 +8,7 @@ import { getType } from "mime";
8
8
  import { getVarsForDev } from "../dev/dev-vars";
9
9
  import { FatalError } from "../errors";
10
10
  import { logger } from "../logger";
11
+ import * as metrics from "../metrics";
11
12
  import { getRequestContextCheckOptions } from "../miniflare-cli/request-context";
12
13
  import openInBrowser from "../open-in-browser";
13
14
  import { buildFunctions } from "./build";
@@ -172,6 +173,7 @@ export const Handler = async ({
172
173
  buildOutputDirectory: directory,
173
174
  nodeCompat,
174
175
  });
176
+ metrics.sendMetricsEvent("build pages functions");
175
177
  } catch {}
176
178
 
177
179
  watch([functionsDirectory], {
@@ -187,6 +189,7 @@ export const Handler = async ({
187
189
  buildOutputDirectory: directory,
188
190
  nodeCompat,
189
191
  });
192
+ metrics.sendMetricsEvent("build pages functions");
190
193
  });
191
194
 
192
195
  miniflareArgs = {
@@ -318,6 +321,7 @@ export const Handler = async ({
318
321
  // `startServer` might throw if user code contains errors
319
322
  const server = await miniflare.startServer();
320
323
  logger.log(`Serving at http://localhost:${port}/`);
324
+ metrics.sendMetricsEvent("run pages dev");
321
325
 
322
326
  if (process.env.BROWSER !== "none") {
323
327
  await openInBrowser(`http://localhost:${port}/`);
@@ -8,6 +8,7 @@ import { getConfigCache, saveToConfigCache } from "../config-cache";
8
8
  import { prompt } from "../dialogs";
9
9
  import { FatalError } from "../errors";
10
10
  import { logger } from "../logger";
11
+ import * as metrics from "../metrics";
11
12
  import { requireAuth } from "../user";
12
13
  import { PAGES_CONFIG_CACHE_FILENAME } from "./constants";
13
14
  import { pagesBetaWarning } from "./utils";
@@ -44,6 +45,7 @@ export async function ListHandler() {
44
45
  });
45
46
 
46
47
  render(<Table data={data}></Table>, { patchConsole: false });
48
+ metrics.sendMetricsEvent("list pages projects");
47
49
  }
48
50
 
49
51
  export const listProjects = async ({
@@ -154,4 +156,5 @@ export async function CreateHandler({
154
156
  logger.log(
155
157
  `To deploy a folder of assets, run 'wrangler pages publish [directory]'.`
156
158
  );
159
+ metrics.sendMetricsEvent("create pages project");
157
160
  }
@@ -12,6 +12,7 @@ import { getConfigCache, saveToConfigCache } from "../config-cache";
12
12
  import { prompt } from "../dialogs";
13
13
  import { FatalError } from "../errors";
14
14
  import { logger } from "../logger";
15
+ import * as metrics from "../metrics";
15
16
  import { requireAuth } from "../user";
16
17
  import { buildFunctions } from "./build";
17
18
  import { PAGES_CONFIG_CACHE_FILENAME } from "./constants";
@@ -193,6 +194,7 @@ export const Handler = async ({
193
194
  });
194
195
 
195
196
  logger.log(`✨ Successfully created the '${projectName}' project.`);
197
+ metrics.sendMetricsEvent("create pages project");
196
198
  break;
197
199
  }
198
200
  }
@@ -332,4 +334,5 @@ export const Handler = async ({
332
334
  logger.log(
333
335
  `✨ Deployment complete! Take a peek over at ${deploymentResponse.url}`
334
336
  );
337
+ metrics.sendMetricsEvent("deploy pages project");
335
338
  };
@@ -282,9 +282,9 @@ export const upload = async (
282
282
  });
283
283
  } catch (e) {
284
284
  if (attempts < MAX_UPLOAD_ATTEMPTS) {
285
- // Linear backoff, 0 second first time, then 1 second etc.
285
+ // Exponential backoff, 1 second first time, then 2 second, then 4 second etc.
286
286
  await new Promise((resolvePromise) =>
287
- setTimeout(resolvePromise, attempts++ * 1000)
287
+ setTimeout(resolvePromise, Math.pow(2, attempts++) * 1000)
288
288
  );
289
289
 
290
290
  if ((e as { code: number }).code === 8000013) {
@@ -3,6 +3,7 @@ import { readConfig } from "../config";
3
3
  import { confirm } from "../dialogs";
4
4
  import { CommandLineArgsError } from "../index";
5
5
  import { logger } from "../logger";
6
+ import * as metrics from "../metrics";
6
7
  import { parseHumanDuration } from "../parse";
7
8
  import { requireAuth } from "../user";
8
9
  import * as pubsub from ".";
@@ -50,6 +51,9 @@ export function pubSubCommands(
50
51
  logger.log(`Creating Pub/SubNamespace ${args.name}...`);
51
52
  await pubsub.createPubSubNamespace(accountId, namespace);
52
53
  logger.log(`Success! Created Pub/Sub Namespace ${args.name}`);
54
+ metrics.sendMetricsEvent("create pubsub namespace", {
55
+ sendMetrics: config.send_metrics,
56
+ });
53
57
  }
54
58
  )
55
59
  .command(
@@ -63,6 +67,9 @@ export function pubSubCommands(
63
67
  const accountId = await requireAuth(config);
64
68
 
65
69
  logger.log(await pubsub.listPubSubNamespaces(accountId));
70
+ metrics.sendMetricsEvent("list pubsub namespaces", {
71
+ sendMetrics: config.send_metrics,
72
+ });
66
73
  }
67
74
  )
68
75
  .command(
@@ -89,6 +96,9 @@ export function pubSubCommands(
89
96
  logger.log(`Deleting namespace ${args.name}...`);
90
97
  await pubsub.deletePubSubNamespace(accountId, args.name);
91
98
  logger.log(`Deleted namespace ${args.name}.`);
99
+ metrics.sendMetricsEvent("delete pubsub namespace", {
100
+ sendMetrics: config.send_metrics,
101
+ });
92
102
  }
93
103
  }
94
104
  )
@@ -111,6 +121,9 @@ export function pubSubCommands(
111
121
  logger.log(
112
122
  await pubsub.describePubSubNamespace(accountId, args.name)
113
123
  );
124
+ metrics.sendMetricsEvent("view pubsub namespace", {
125
+ sendMetrics: config.send_metrics,
126
+ });
114
127
  }
115
128
  )
116
129
  .epilogue(pubsub.pubSubBetaWarning);
@@ -178,6 +191,9 @@ export function pubSubCommands(
178
191
  logger.log(
179
192
  await pubsub.createPubSubBroker(accountId, args.namespace, broker)
180
193
  );
194
+ metrics.sendMetricsEvent("create pubsub broker", {
195
+ sendMetrics: config.send_metrics,
196
+ });
181
197
  }
182
198
  );
183
199
 
@@ -247,6 +263,9 @@ export function pubSubCommands(
247
263
  )
248
264
  );
249
265
  logger.log(`Successfully updated Pub/Sub Broker ${args.name}`);
266
+ metrics.sendMetricsEvent("update pubsub broker", {
267
+ sendMetrics: config.send_metrics,
268
+ });
250
269
  }
251
270
  );
252
271
 
@@ -268,6 +287,9 @@ export function pubSubCommands(
268
287
  const accountId = await requireAuth(config);
269
288
 
270
289
  logger.log(await pubsub.listPubSubBrokers(accountId, args.namespace));
290
+ metrics.sendMetricsEvent("list pubsub brokers", {
291
+ sendMetrics: config.send_metrics,
292
+ });
271
293
  }
272
294
  );
273
295
 
@@ -306,6 +328,9 @@ export function pubSubCommands(
306
328
  args.name
307
329
  );
308
330
  logger.log(`Deleted Pub/Sub Broker ${args.name}.`);
331
+ metrics.sendMetricsEvent("delete pubsub broker", {
332
+ sendMetrics: config.send_metrics,
333
+ });
309
334
  }
310
335
  }
311
336
  )
@@ -338,6 +363,9 @@ export function pubSubCommands(
338
363
  args.name
339
364
  )
340
365
  );
366
+ metrics.sendMetricsEvent("view pubsub broker", {
367
+ sendMetrics: config.send_metrics,
368
+ });
341
369
  }
342
370
  );
343
371
 
@@ -413,6 +441,9 @@ export function pubSubCommands(
413
441
  parsedExpiration
414
442
  )
415
443
  );
444
+ metrics.sendMetricsEvent("issue pubsub broker credentials", {
445
+ sendMetrics: config.send_metrics,
446
+ });
416
447
  }
417
448
  );
418
449
 
@@ -458,6 +489,9 @@ export function pubSubCommands(
458
489
  );
459
490
 
460
491
  logger.log(`Revoked ${args.jti.length} credential(s).`);
492
+ metrics.sendMetricsEvent("revoke pubsub broker credentials", {
493
+ sendMetrics: config.send_metrics,
494
+ });
461
495
  }
462
496
  );
463
497
 
@@ -502,6 +536,9 @@ export function pubSubCommands(
502
536
  );
503
537
 
504
538
  logger.log(`Unrevoked ${numTokens} credential(s)`);
539
+ metrics.sendMetricsEvent("unrevoke pubsub broker credentials", {
540
+ sendMetrics: config.send_metrics,
541
+ });
505
542
  }
506
543
  );
507
544
 
@@ -535,6 +572,9 @@ export function pubSubCommands(
535
572
  args.name
536
573
  )
537
574
  );
575
+ metrics.sendMetricsEvent("list pubsub broker revoked credentials", {
576
+ sendMetrics: config.send_metrics,
577
+ });
538
578
  }
539
579
  );
540
580
 
@@ -567,6 +607,9 @@ export function pubSubCommands(
567
607
  args.name
568
608
  )
569
609
  );
610
+ metrics.sendMetricsEvent("list pubsub broker public-keys", {
611
+ sendMetrics: config.send_metrics,
612
+ });
570
613
  }
571
614
  );
572
615
 
@@ -1,6 +1,7 @@
1
1
  import { fetchResult } from "./cfetch";
2
2
  import { readConfig } from "./config";
3
3
  import { logger } from "./logger";
4
+ import * as metrics from "./metrics";
4
5
  import { requireAuth } from "./user";
5
6
  import { printWranglerBanner } from ".";
6
7
  import type { ConfigPath } from ".";
@@ -113,6 +114,9 @@ export function workerNamespaceCommands(
113
114
  const config = readConfig(args.config as ConfigPath, args);
114
115
  const accountId = await requireAuth(config);
115
116
  await listWorkerNamespaces(accountId);
117
+ metrics.sendMetricsEvent("list worker namespaces", {
118
+ sendMetrics: config.send_metrics,
119
+ });
116
120
  })
117
121
  .command(
118
122
  "get <name>",
@@ -128,6 +132,9 @@ export function workerNamespaceCommands(
128
132
  const config = readConfig(args.config as ConfigPath, args);
129
133
  const accountId = await requireAuth(config);
130
134
  await getWorkerNamespaceInfo(accountId, args.name);
135
+ metrics.sendMetricsEvent("view worker namespace", {
136
+ sendMetrics: config.send_metrics,
137
+ });
131
138
  }
132
139
  )
133
140
  .command(
@@ -145,6 +152,9 @@ export function workerNamespaceCommands(
145
152
  const config = readConfig(args.config as ConfigPath, args);
146
153
  const accountId = await requireAuth(config);
147
154
  await createWorkerNamespace(accountId, args.name);
155
+ metrics.sendMetricsEvent("create worker namespace", {
156
+ sendMetrics: config.send_metrics,
157
+ });
148
158
  }
149
159
  )
150
160
  .command(
@@ -162,6 +172,9 @@ export function workerNamespaceCommands(
162
172
  const config = readConfig(args.config as ConfigPath, args);
163
173
  const accountId = await requireAuth(config);
164
174
  await deleteWorkerNamespace(accountId, args.name);
175
+ metrics.sendMetricsEvent("delete worker namespace", {
176
+ sendMetrics: config.send_metrics,
177
+ });
165
178
  }
166
179
  )
167
180
  .command(
@@ -185,6 +198,9 @@ export function workerNamespaceCommands(
185
198
  const config = readConfig(args.config as ConfigPath, args);
186
199
  const accountId = await requireAuth(config);
187
200
  await renameWorkerNamespace(accountId, args.oldName, args.newName);
201
+ metrics.sendMetricsEvent("rename worker namespace", {
202
+ sendMetrics: config.send_metrics,
203
+ });
188
204
  }
189
205
  );
190
206
  }