Skip to content

feat(telemetry): record the template a project is created with - #2907

Merged
jariy17 merged 1 commit into
v1.xfrom
feat/create-template-telemetry
Nov 24, 2026
Merged

jariy17 merged 1 commit into
v1.xfrom
feat/create-template-telemetry

Conversation

@tejaskash

Copy link
Copy Markdown
Contributor

Description

What: agentcore create records the chosen template as a new project_template attribute on the cli.command_run metric. The flag path records the --template value (empty when omitted). The create wizard records the template for code-based projects and leaves the attribute unset for config-based (harness) projects.

Why: 1.x telemetry had no way to tell which templates projects are created from. The attribute is an enum built from the template registry, so it stays a closed set and new templates are accepted without a second edit.

Related Issue

No issue filed for this change.

Documentation PR

Not applicable.

Type of Change

  • New feature

Testing

  • Unit tests for the flag path (default, explicit template, failed create) and the wizard (template flow sets it, harness flow leaves it unset). The template assertions fail when the source change is reverted.

  • End to end with the built CLI: flag-path creates and a wizard create in a real terminal, checked through the telemetry audit file.

  • I ran bun test

  • bun run test:e2e not applicable: no deploy path changes

  • I ran bun run typecheck

  • I ran bun run lint:check

  • I ran bun run format:check

  • I ran bun run audit

  • I ran bun run secrets:check

  • I ran bun run build

  • This PR does not change command.md (the release workflow regenerates it)

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • No new docs are needed
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

agentcore create now sets project_template on cli.command_run, from the
--template flag and from the create wizard. Config-based (harness)
creates leave it unset.
@tejaskash
tejaskash requested a review from a team November 24, 2026 16:22
@agentcore-devx-automation agentcore-devx-automation Bot added the claude-security-reviewing Claude Code /security-review in progress label Nov 24, 2026
@agentcore-devx-automation

Copy link
Copy Markdown
Contributor

Claude Security Review: no high-confidence findings. (run)

@agentcore-devx-automation agentcore-devx-automation Bot removed the claude-security-reviewing Claude Code /security-review in progress label Nov 24, 2026
@github-actions github-actions Bot added the size/m PR size: M label Nov 24, 2026
@agentcore-devx-automation agentcore-devx-automation Bot added the agentcore-harness-reviewing AgentCore Harness review in progress label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Package Tarball

aws-agentcore-1.2.0.tgz

How to install

gh release download pr-2907-tarball --repo aws/agentcore-cli --pattern "*.tgz" --dir /tmp/pr-tarball
npm install -g /tmp/pr-tarball/aws-agentcore-1.2.0.tgz

@jariy17
jariy17 merged commit 722f842 into v1.x Nov 24, 2026
27 checks passed
@jariy17
jariy17 deleted the feat/create-template-telemetry branch November 24, 2026 16:25
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.57%. Comparing base (6d2b890) to head (8352fe5).
⚠️ Report is 1 commits behind head on v1.x.

Additional details and impacted files
@@           Coverage Diff           @@
##             v1.x    #2907   +/-   ##
=======================================
  Coverage   96.57%   96.57%           
=======================================
  Files         734      734           
  Lines       60950    60956    +6     
=======================================
+ Hits        58863    58869    +6     
  Misses       2087     2087           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the report, @codecov-commenter — feedback like this is exactly
how we catch the things we missed. Because this PR is already
closed, the team won't see follow-up comments here.

Would you mind opening a new issue so we can track it properly?
https://github.com/aws/agentcore-cli/issues/new/choose

If this is a security issue, please report it privately via
https://aws.amazon.com/security/vulnerability-reporting/ instead
of a public issue.

@agentcore-devx-automation agentcore-devx-automation Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AgentCore Harness Review

Verdict: Changes requested

The feature, the derived enum, and the test coverage (default --template, explicit template, failed create, wizard template vs. harness) all look right. One real behavioral issue.

project_template: undefined is emitted as a valueless attribute, not left unset

src/handlers/project/create/screen.tsx:213-215

ctx.value(CommandRunMetricEventKey)?.setAttributes({
  project_template: values.kind === "agent" ? values.template : undefined,
});

For a config-based (harness) create this writes the key with an undefined value rather than omitting it, and the key survives all the way to the collector:

  • InMemoryMetricEvent.setAttributes spreads newData in, so this.data now owns project_template (src/telemetry/client.tsx:169).
  • commandRunSchema.parse keeps an explicitly present optional key: zod's object parse assigns newResult[key] = value whenever key in input, so the parsed attrs still contain project_template: undefined.
  • OtelHistogramSink.send passes the attrs straight to histogram.record (the default AttributesProcessor is a pass-through), and the OTLP transformer's toAnyValue(undefined) returns {} — so the exported datapoint carries { key: "project_template", value: {} }.

Net effect: harness-wizard creates land in a different attribute/dimension set than runs where the attribute is genuinely absent (every non-create command), which is the opposite of the PR description's "leaves the attribute unset for config-based (harness) projects." Anything that filters or groups on "project_template absent" will treat these as a separate, empty-valued series.

The new test can't catch this: FileSystemSink serializes with JSON.stringify, which drops undefined-valued keys, so the expect(...).not.toHaveProperty("project_template") assertion in src/handlers/project/create/create.screen.test.tsx passes either way (it does still catch the more important regression — recording DEFAULT_TEMPLATE for a harness create — so it's worth keeping).

Two ways to fix, author's choice:

  1. Only set the attribute when there is one (local, smallest change):
    if (values.kind === "agent") {
      ctx.value(CommandRunMetricEventKey)?.setAttributes({ project_template: values.template });
    }
    (or a conditional spread — matches how the rest of the codebase sets optional attributes, e.g. src/index.ts:84 only sets project_format inside if (projectRoot)).
  2. Make InMemoryMetricEvent.setAttributes (src/telemetry/client.tsx:169) skip undefined values, so "set to undefined" means "unset" for every caller. This is the more robust option since this PR introduces the first undefined-valued attribute in the codebase; if you take it, please add a unit test in src/telemetry/client.test.tsx asserting the key is absent from the emitted attrs.

Everything else checks out: empty is part of PROJECT_TEMPLATE_NAMES so the flag-path default validates, the enum import creates no import cycle (handlers/project/shortcuts only reaches projectSchemas/errors at runtime), the TUI middleware only bypasses handle when no flags are passed so the flag-path recording isn't double-counted, and the failure test's InputValidationError does map to exit_reason: "failure" via shouldRecordCommandFailure.

@agentcore-devx-automation agentcore-devx-automation Bot removed the agentcore-harness-reviewing AgentCore Harness review in progress label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants