Skip to content

Commit

Permalink
feat: send metrics for command start/complete/error (#7267)
Browse files Browse the repository at this point in the history
* stop collecting userId in telemetry

Co-authored-by: emily-shen <emily-shen@users.noreply.github.com>

* implement telemetry collection

* infer errorType based on the constructor name

* implement common event properties

* log common event properties

Co-authored-by: Edmund Hung <me@edmund.dev>

* respect metric enabled/disabled

* remove dispatcher.identify

* include SPARROW_SOURCE_KEY in PR pre-release build

* fix tests

* ensure debug log covers the request failed message

* replace SPARROW_SOURCE_KEY regardless whethe env exists

---------

Co-authored-by: Edmund Hung <edmund@cloudflare.com>
Co-authored-by: emily-shen <emily-shen@users.noreply.github.com>
Co-authored-by: Edmund Hung <me@edmund.dev>
  • Loading branch information
4 people authored Nov 19, 2024
1 parent ddc9292 commit a776819
Show file tree
Hide file tree
Showing 12 changed files with 312 additions and 326 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/create-pullrequest-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
run: node .github/prereleases/2-build-pack-upload.mjs
env:
NODE_ENV: "production"
# this is the "test/staging" key for sparrow analytics
SPARROW_SOURCE_KEY: "5adf183f94b3436ba78d67f506965998"
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_PUBLIC_KEY: ${{ secrets.ALGOLIA_PUBLIC_KEY }}
SENTRY_DSN: "https://9edbb8417b284aa2bbead9b4c318918b@sentry10.cfdata.org/583"
Expand Down
2 changes: 2 additions & 0 deletions packages/wrangler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"selfsigned": "^2.0.1",
"source-map": "^0.6.1",
"unenv": "npm:unenv-nightly@2.0.0-20241024-111401-d4156ac",
"which-pm-runs": "^1.1.0",
"workerd": "1.20241106.1",
"xxhash-wasm": "^1.0.1"
},
Expand Down Expand Up @@ -115,6 +116,7 @@
"@types/shell-quote": "^1.7.2",
"@types/signal-exit": "^3.0.1",
"@types/supports-color": "^8.1.1",
"@types/which-pm-runs": "^1.0.0",
"@types/ws": "^8.5.7",
"@types/yargs": "^17.0.22",
"@vitest/ui": "catalog:default",
Expand Down
6 changes: 3 additions & 3 deletions packages/wrangler/scripts/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ async function buildMain(flags: BuildFlags = {}) {
__RELATIVE_PACKAGE_PATH__,
"import.meta.url": "import_meta_url",
"process.env.NODE_ENV": `'${process.env.NODE_ENV || "production"}'`,
...(process.env.SPARROW_SOURCE_KEY
? { SPARROW_SOURCE_KEY: `"${process.env.SPARROW_SOURCE_KEY}"` }
: {}),
"process.env.SPARROW_SOURCE_KEY": JSON.stringify(
process.env.SPARROW_SOURCE_KEY ?? ""
),
...(process.env.ALGOLIA_APP_ID
? { ALGOLIA_APP_ID: `"${process.env.ALGOLIA_APP_ID}"` }
: {}),
Expand Down
Loading

0 comments on commit a776819

Please sign in to comment.