Skip to content

feat(core)!: follow CDK's telemetry opt-out and remove the AWS Blocks one - #1606

Open
VarshithaPamisetty wants to merge 1 commit into
mainfrom
fix/cdk-telemetry-merge
Open

VarshithaPamisetty wants to merge 1 commit into
mainfrom
fix/cdk-telemetry-merge

Conversation

@VarshithaPamisetty

@VarshithaPamisetty VarshithaPamisetty commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

AWS Blocks telemetry had its own opt-out alongside CDK's, so a user had two switches to find and set, and opting out of CDK CLI telemetry left Blocks telemetry on. The wiring only ever ran one way: when Blocks telemetry was off the lifecycle commands passed CDK_DISABLE_CLI_TELEMETRY=1 to the cdk child, so Blocks off disabled CDK, never the reverse.

This makes CDK's setting the only one. Consent is read from disk rather than by asking the CDK CLI, because most Blocks commands never start one.

Changes

  • Blocks telemetry now follows CDK's opt-out, mirroring what the CDK CLI does rather than reinterpreting it: CDK_DISABLE_CLI_TELEMETRY set to 1 or true, and the cli-telemetry context key resolving to false, which cdk cli-telemetry --disable records in the app's cdk.context.json and which can also be set in the context of cdk.json or ~/.cdk.json. The environment match is case-sensitive and untrimmed, so TRUE and yes are not CDK's opt-out and therefore not ours, and across the context files the first one that sets the key wins, so an enable in cdk.json shadows a disable in cdk.context.json, in CDK's documented order of precedence.
  • Breaking: the Blocks opt-out is removed. AWS_BLOCKS_DISABLE_TELEMETRY, the cdk-blocks telemetry command, the blocks-telemetry binary and the telemetry.enabled key in .blocks/config.json are gone, with no fallback and no migration, so a preview user who opted out that way is opted back in until they opt out through CDK. The changeset says so plainly and ships at minor, the pre-1.0 breaking channel. The telemetry.projectId key in the same file stays, because it is an identifier rather than a consent setting and identifiers are out of scope here.
  • CDK_BLOCKS_DISABLE_TEMPLATE_METADATA is unchanged and still governs the AWSToolsMetrics template entry. It keeps the lax 1/true/yes matching, so the helper that reads it moved next to it and is now tested there against the same shared case table. --telemetry-file is unchanged, and still writes nothing when you are opted out.
  • The telemetry app task goes with the command: the script is removed from the 13 templates that shipped it, from the task list create-blocks-app writes, and from migrate's task map and renamed-alias set, so a scaffolded or migrated app no longer gets a task that resolves to nothing. Folded in from feat(blocks,create-blocks-app)!: remove the telemetry app task #1633, which is closed, so the command and the task that invoked it land together.
  • package-lock.json loses an orphaned @aws-blocks/core@0.3.0 node under packages/bb-dashboard/node_modules/@aws-blocks/bb-lambda-compute/, which was the last thing in the lockfile naming the removed blocks-telemetry bin. Its parent node does not exist and bb-dashboard depends only on core@^0.8.0, so nothing resolved through it.
  • The README telemetry section and the first-run notice now describe CDK's switch and link to https://docs.aws.amazon.com/cdk/v2/guide/cli-telemetry.html#telemetry-opt-out. The notice is still pinned byte-identical between core and create-blocks-app, which carries the same resolution so the scaffolder and the CLI agree. The telemetry test app's README and the canary workflow comment were updated to match, and an orphaned e2e test that symlinked the deleted binary and asserted the removed config key is deleted rather than left to rot. The admin dashboard's list of shipped binaries drops blocks-telemetry, and the unreleased changesets that described the removed opt-out are trimmed so one release does not both introduce and remove it. readCdkTelemetryContext and resolveDeploymentTarget now cross-reference each other, because both walk CDK's three context bags in CDK's order.

isTelemetryEnabled() now takes an optional projectRoot, threaded through both consent gates (trackCommand's early return and the re-check inside buildAndSendEvent), and through getCdkTelemetryEnv, getFrameworkSinkEnv and createFrameworkSink. The blocks-vendorize bin passes its discovered root, because it never chdirs to the project root and would otherwise resolve CDK's context from the shell's directory and miss the project's own opt-out; the production deploy passes the root it already deploys with. create-blocks-app keeps the no-argument form and resolves context from its own working directory, which is where a project's config sits when the scaffolder is run inside an existing CDK project.

Note on --no-version-reporting, which is not included. It is one of the four ways CDK's own check can refuse telemetry, but it is the only one with nothing to read: verified from canCollectTelemetry, it is taken from the parsed command-line arguments, and verified by running the CLI, versionReporting: false in cdk.json or ~/.cdk.json leaves cdk cli-telemetry --status reporting enabled while the --no-version-reporting flag reports disabled. So it exists only for the invocation that carries it, cdk-blocks has no such flag, and honouring it would mean either adding one or reading a setting CDK itself ignores for telemetry. Flagged rather than guessed at.

Note on docs/DECISIONS.md. D-010's preserved body tells a reader to combine --telemetry-file with AWS_BLOCKS_DISABLE_TELEMETRY to capture events without sending them. D-018 already superseded that clause, and this removal takes the variable away, so this PR appends a Status amendment line to D-010 in the form its two existing amendments use: it records that the variable no longer exists and that redirecting BLOCKS_TELEMETRY_ENDPOINT captures to the file without reaching the collector. The preserved body is left as written, which is how every other amended decision in that file reads.

Testing

  • Guard first, and watched fail before the gate was wired: the shared CDK case table failed 8 of its rows, one per mechanism, each as 'true' !== 'false', while every negative control held. On this head that file is 36 of 36. The removal is covered the same way, by the suites that asserted the old behaviour being converted to CDK's files rather than deleted: the --telemetry-file sink, the mid-run opt-out and the identifier-persistence cases now write cdk.context.json or ~/.cdk.json.
  • Parity against the real CLI is the evidence that the mirror is faithful: 13 of 13 on-disk setups agree with cdk cli-telemetry --status on aws-cdk 2.1146.0, including the shadowing row, the two values CDK does not act on, and the documented but non-working top-level form, which reports enabled on both sides.
  • Real CLI end to end with --telemetry-file, positive control first so an absent file proves something: the dev server emits an event with no opt-out set, emits none under each of CDK_DISABLE_CLI_TELEMETRY=1, =true, a cdk.json context opt-out, cdk.context.json and ~/.cdk.json, still emits under =yes because CDK does not act on it, and now also emits under AWS_BLOCKS_DISABLE_TELEMETRY=1, which is the removal working. 8 of 8.
  • At this head: npm run build 0 errors, npm run lint, npm run lint:deps, npm run check:api with no report drift, npm run check:imports, sync-docs:check, check:exports-consistency, check:client-user-agent, check:packed-assets, check:runtime-guard, and the four changeset guards. packages/core is 3205 tests, 0 failures. npm install leaves the lockfile unchanged and npm ci --dry-run exits 0.

Checklist

  • PR description included
  • Tests are changed or added
  • Relevant documentation is changed or added: the @aws-blocks/blocks README telemetry section and the first-run notice

@changeset-bot

changeset-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 84c2f6c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@aws-blocks/core Minor
@aws-blocks/create-blocks-app Minor
@aws-blocks/blocks Minor
@aws-blocks/admin-ui Patch
@aws-blocks/bb-logger Patch
@aws-blocks/bb-kv-store Patch
@aws-blocks/auth-common Patch
@aws-blocks/bb-app-setting Patch
@aws-blocks/bb-secret Patch
@aws-blocks/bb-database Patch
@aws-blocks/bb-auth Patch
@aws-blocks/bb-realtime Patch
@aws-blocks/bb-async-job Patch
@aws-blocks/bb-dashboard Patch
@aws-blocks/bb-cron-job Patch
@aws-blocks/bb-file-bucket Patch
@aws-blocks/bb-agent Patch
@aws-blocks/bb-knowledge-base Patch
@aws-blocks/bb-email-client Patch
@aws-blocks/bb-tracer Patch
@aws-blocks/bb-metrics Patch
@aws-blocks/bb-lambda-compute Patch
@aws-blocks/bb-container-compute Patch
@aws-blocks/bb-compute Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@VarshithaPamisetty
VarshithaPamisetty force-pushed the fix/cdk-telemetry-merge branch 6 times, most recently from 3231b82 to 96d0965 Compare November 18, 2026 11:57
cadivus
cadivus previously approved these changes Nov 18, 2026
cadivus
cadivus previously approved these changes Nov 18, 2026
… one

Blocks telemetry had its own opt-out alongside CDK's, so a user had two
switches to find and set, and opting out of CDK CLI telemetry left Blocks
telemetry on. The wiring only ever ran one way: when Blocks telemetry was
off the lifecycle commands passed CDK_DISABLE_CLI_TELEMETRY=1 to the cdk
child, so Blocks off disabled CDK, never the reverse. CDK's setting is
now the only one.

Blocks honours CDK's opt-out by mirroring the CDK CLI rather than
reinterpreting it: CDK_DISABLE_CLI_TELEMETRY set to `1` or `true`, and
the `cli-telemetry` context key resolving to `false`, which
`cdk cli-telemetry --disable` records in the app's cdk.context.json and
which can also be set in the `context` of cdk.json or ~/.cdk.json. The
environment match is case-sensitive and untrimmed, so `TRUE` and `yes`
are not CDK's opt-out and therefore not ours, and across the context
files the first one that sets the key wins, so an enable in cdk.json
shadows a disable in cdk.context.json, in CDK's documented order of
precedence. Verified empirically: 13 of 13 on-disk setups agree with
`cdk cli-telemetry --status` on aws-cdk 2.1146.0. The settings are read
from disk, not by running the CDK CLI, because most Blocks commands
never start one.

BREAKING CHANGE: the Blocks opt-out is removed.
AWS_BLOCKS_DISABLE_TELEMETRY, the `cdk-blocks telemetry` command, the
`blocks-telemetry` binary and the `telemetry.enabled` key in
.blocks/config.json are gone, with no fallback and no migration, so a
preview user who opted out that way is opted back in until they opt out
through CDK. The telemetry.projectId key in the same file stays: it is
an identifier rather than a consent setting, and identifiers are out of
scope here.

CDK_BLOCKS_DISABLE_TEMPLATE_METADATA is unchanged and still governs the
AWSToolsMetrics template entry. It keeps the lax 1/true/yes matching, so
the helper that reads it moved next to it in cdk/stack-metadata.ts and is
tested there against the same shared case table. --telemetry-file is
unchanged, and still writes nothing when you are opted out.

The README telemetry section and the first-run notice now describe CDK's
switch and link to its opt-out documentation. The notice stays pinned
byte-identical between core and create-blocks-app, which carries the same
resolution so the scaffolder and the CLI agree.

--no-version-reporting is deliberately not included. It is the one CDK
path with nothing to read: it is taken from the parsed command-line
arguments, so `versionReporting: false` in cdk.json or ~/.cdk.json leaves
`cdk cli-telemetry --status` reporting enabled while the flag reports
disabled. It exists only for the invocation that carries it, cdk-blocks
has no such flag, and honouring it would mean either adding one or
reading a setting CDK itself ignores for telemetry.

This branch is being deployed

1 in progress and 1 inactive deployments
e2e — 166b6f06 Deployed Nov 19, 2026 by VarshithaPamisetty via Swift E2E (sandbox) #7365
agent-bench — 166b6f06 Deployed Nov 19, 2026 by VarshithaPamisetty via bench / collab-presence-board · default #6405
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants