Repository navigation
Add opt-in anonymous telemetry for the CLI family #550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
cdf407e
chore(telemetry-worker): add telemetry ingest worker
allxsmith 408e6b4
ci: harden the skills-roster check and derive skill discovery once
allxsmith e59c0cd
docs: repair skills-roster provenance pointers and bundling claims
allxsmith 805f90a
docs: add telemetry disclosure guide
allxsmith 1e5b488
feat(create-bestax): add opt-in anonymous telemetry
allxsmith 20c5492
feat(bestax-migrate): add opt-in anonymous telemetry
allxsmith b6b1a1f
feat(bestax-mcp): attribute emitted docs links with utm_source
allxsmith 453e11b
refactor(create-bestax): extract shared telemetry kernel and await pa…
allxsmith c4c7426
refactor(bestax-migrate): share telemetry kernel with create-bestax
allxsmith 1ef43ce
fix(bestax-mcp): keep URL fragments when attributing docs links
allxsmith 7f350fc
docs: note prop: slugs in the telemetry disclosure
allxsmith 5029bd2
chore: align telemetry ingest with CLI payloads and gate it in CI
allxsmith decba35
Merge branch 'fix/541-skills-roster-hardening' into feat/telemetry
allxsmith 8def8da
fix(create-bestax): gate consent on both TTYs, honor DNT and Ctrl-C
allxsmith 271ba4c
fix(bestax-migrate): stop sending changedBucket, honor Ctrl-C at consent
allxsmith 493aad2
chore(telemetry-worker): cap todo counts, derive buckets, stream the …
allxsmith b3b2a31
docs: true up the telemetry disclosure
allxsmith 9cf0c23
chore: normalize utm_source out of eval docs metrics; list telemetry-…
allxsmith da27d67
chore: add telemetry-worker to the pnpm workspace
allxsmith 1ecb5ee
ci: deploy the telemetry worker from main
allxsmith a6db102
fix(create-bestax): never send telemetry from the e2e scaffold harness
allxsmith 3a430bc
ci: make the skills vetting gate repo-aware and file-granular
allxsmith d2e568b
ci: import telemetry producer enums instead of scraping, close scope …
allxsmith 7bf859f
ci: harden-runner on the worker deploy job
allxsmith 71b18ba
chore: guard the ts resolver hook and the eval utm strip
allxsmith 06b3653
fix(bestax-migrate): name the wire caps and pin them to the worker
allxsmith 00545b4
docs: true up deploy, backstop, and utm-coverage claims
allxsmith 750b53e
fix(create-bestax): review-thread fixes across the telemetry surface
allxsmith 81df919
fix(create-bestax): fail closed on foreign consent records, gate igno…
allxsmith ec0aae3
ci: deploy wrangler from the workspace lockfile; dedupe worker tasks
allxsmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Deploys telemetry-worker to Cloudflare Workers on every main-branch change | ||
| # under telemetry-worker/**, mirroring the Pages deploy in deploy.yml: build | ||
| # happens here (wrangler bundles src/index.ts), Cloudflare only receives the | ||
| # artifact. workflow_dispatch allows a manual redeploy from the Actions tab. | ||
| # | ||
| # The only credential in this job is CLOUDFLARE_WORKERS_DEPLOY_TOKEN, an API | ||
| # token scoped to Workers Scripts:Edit + Workers Routes:Edit on bestax.io — | ||
| # deliberately separate from CLOUDFLARE_API_TOKEN (Pages) so each pipeline | ||
| # holds only what it deploys. | ||
| name: Deploy telemetry worker | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'telemetry-worker/**' | ||
| workflow_dispatch: | ||
|
allxsmith marked this conversation as resolved.
Resolved
|
||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| # Serialize deploys: two quick main pushes must not race — an older run | ||
| # finishing last would ship stale worker code. No cancel-in-progress: a | ||
| # deploy already uploading should finish, then the newer one runs. | ||
| concurrency: | ||
| group: deploy-worker | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| deploy: | ||
| name: Deploy to Cloudflare Workers | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # Rule 10 (.github/CLAUDE.md): new jobs ship with egress-policy: block — | ||
| # this is the job holding the Cloudflare deploy token. Endpoints: | ||
| # checkout (github.com trio), wrangler install (npm registry), and the | ||
| # upload itself (api.cloudflare.com). Wrangler's own metrics beacon is | ||
| # disabled below instead of allow-listing its host. | ||
| - name: Harden runner | ||
| uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0 | ||
| with: | ||
| egress-policy: block | ||
| allowed-endpoints: > | ||
| api.cloudflare.com:443 | ||
| api.github.com:443 | ||
| github.com:443 | ||
| objects.githubusercontent.com:443 | ||
| registry.npmjs.org:443 | ||
|
|
||
| - name: Checkout code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 | ||
|
allxsmith marked this conversation as resolved.
Resolved
allxsmith marked this conversation as resolved.
Resolved
|
||
| with: | ||
| # No later step needs authenticated git; don't leave the token in | ||
| # the local git config for the rest of the job. | ||
| persist-credentials: false | ||
|
|
||
| # No pnpm/Node setup: the worker is stdlib-only TypeScript with no build | ||
| # step of its own — wrangler-action installs the pinned wrangler and its | ||
| # bundler does the rest. | ||
| - name: Deploy with wrangler | ||
| uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4 | ||
|
allxsmith marked this conversation as resolved.
Resolved
|
||
| env: | ||
| WRANGLER_SEND_METRICS: 'false' | ||
| with: | ||
| apiToken: ${{ secrets.CLOUDFLARE_WORKERS_DEPLOY_TOKEN }} | ||
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| workingDirectory: telemetry-worker | ||
| wranglerVersion: '4.124.0' | ||
| command: deploy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /** | ||
| * Unit tests for `attributed`, the link tagger. | ||
| * | ||
| * The server is offline by design (openWorldHint: false), so the tag on its | ||
| * outbound links is the only attribution signal it has — these pin the | ||
| * function's contract. The emission paths themselves are asserted where the | ||
| * links surface: server.test.ts for the component link line, version.test.ts | ||
| * for the drift note. | ||
| */ | ||
| import { describe, expect, it } from '@jest/globals'; | ||
|
|
||
| import { loadComponent } from '../data.js'; | ||
| import { attributed, renderComponent } from '../format.js'; | ||
|
|
||
| describe('attributed', () => { | ||
| it('appends with ? when the URL has no query string', () => { | ||
| expect(attributed('https://bestax.io/docs/api/elements/button')).toBe( | ||
| 'https://bestax.io/docs/api/elements/button?utm_source=bestax-mcp' | ||
| ); | ||
| }); | ||
|
|
||
| it('appends with & when the URL already has one, as Storybook links do', () => { | ||
| expect( | ||
| attributed('https://bestax.io/storybook/?path=/story/elements-button') | ||
| ).toBe( | ||
| 'https://bestax.io/storybook/?path=/story/elements-button&utm_source=bestax-mcp' | ||
| ); | ||
| }); | ||
|
|
||
| it('is idempotent', () => { | ||
| const once = attributed('https://bestax.io/docs'); | ||
| expect(attributed(once)).toBe(once); | ||
| }); | ||
|
|
||
| it('returns an already-tagged URL unchanged', () => { | ||
| const tagged = 'https://bestax.io/docs?utm_source=bestax-mcp'; | ||
| expect(attributed(tagged)).toBe(tagged); | ||
| }); | ||
|
|
||
| it('is not fooled by the tag text inside a fragment', () => { | ||
| // The analytics request never sees the fragment, so this URL is NOT | ||
| // attributed yet — the already-tagged check must look at the query only. | ||
| expect(attributed('https://bestax.io/docs#utm_source=bestax-mcp')).toBe( | ||
| 'https://bestax.io/docs?utm_source=bestax-mcp#utm_source=bestax-mcp' | ||
| ); | ||
| }); | ||
|
|
||
| it('is not fooled by the tag text inside another parameter value', () => { | ||
| const url = 'https://bestax.io/docs?ref=utm_source=bestax-mcp'; | ||
| expect(attributed(url)).toBe(`${url}&utm_source=bestax-mcp`); | ||
| }); | ||
|
|
||
| it('passes non-http(s) strings through unchanged', () => { | ||
| for (const notAUrl of ['bestax://catalog', 'mailto:a@b.c', 'Button', '']) { | ||
| expect(attributed(notAUrl)).toBe(notAUrl); | ||
| } | ||
| }); | ||
|
|
||
| it('keeps a fragment after the query string', () => { | ||
| expect(attributed('https://bestax.io/docs/guides/foo#bar')).toBe( | ||
| 'https://bestax.io/docs/guides/foo?utm_source=bestax-mcp#bar' | ||
| ); | ||
| }); | ||
|
|
||
| it('inserts ahead of the fragment when a query string is already present', () => { | ||
| expect( | ||
| attributed( | ||
| 'https://bestax.io/storybook/?path=/story/elements-button#anchor' | ||
| ) | ||
| ).toBe( | ||
| 'https://bestax.io/storybook/?path=/story/elements-button&utm_source=bestax-mcp#anchor' | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('renderComponent link line', () => { | ||
| it('tags both the docs and Storybook links', async () => { | ||
| const record = await loadComponent('Button'); | ||
| const out = renderComponent(record, ['props']); | ||
| // Against the committed index: the docs URL carries no query string, the | ||
| // Storybook URL carries `?path=...` — so this exercises both separators. | ||
| expect(out).toContain(`Docs: ${record.docsUrl}?utm_source=bestax-mcp`); | ||
| expect(out).toContain( | ||
| `Storybook: ${record.storybook}&utm_source=bestax-mcp` | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.