Skip to content

[AT-217]: support ai_agent_button_click for ASA - #489

Merged
Mudaafi merged 4 commits into
Constructor-io:masterfrom
dmitrycnstrc:AT-217/track-cta-for-agent-asa-focused
Oct 1, 2026
Merged

Mudaafi merged 4 commits into
Constructor-io:masterfrom
dmitrycnstrc:AT-217/track-cta-for-agent-asa-focused

Conversation

@dmitrycnstrc

@dmitrycnstrc dmitrycnstrc commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Adds tracker.trackAgentButtonClick to send the new ai_agent_button_click behavioral event (Behavioral API v2). It tracks clicks on CTAs that open or start an agent experience, so we can measure ASA entry points and click-to-submit conversion.

Backend: Constructor-io/autocomplete#12668

tracker.trackAgentButtonClick({
  mode: 'chat',              // required: chat | search | qna | recommendations | query_refinement
  agentDomain: 'explorer',   // required, sent as agent_domain
  positionOnPage: 'search_bar',
  pageType: 'pdp',           // home | plp | pdp | search | collection | email_campaign | cart
  instanceId: 1,             // 1-based positive integer
});

The payload matches the final API from the backend PR:

  • agentDomain → agent_domain. domain is kept for the integration hostname in agent_overview_* events, so the two don't get mixed up.
  • mode is a strict enum on the backend. It's narrowed in the TS types; at runtime the JS only checks that it's a string.
  • search is added to pageType for the SRP.
  • mode and agentDomain are required, and instanceId has to be an integer ≥ 1. If any of these checks fail, the method returns an Error and nothing is queued.

Copilot AI lite review requested due to automatic review settings September 15, 2026 11:46
@dmitrycnstrc
dmitrycnstrc requested a review from a team as a code owner September 15, 2026 11:46

Copilot AI 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.

🟡 Changes recommended

Validate required mode and domain fields before queueing malformed events.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds tracker.trackAgentButtonClick for the ai_agent_button_click Behavioral API v2 event.

Changes:

  • Implements event tracking and parameter mapping.
  • Adds TypeScript declarations.
  • Adds tracker tests.
File summaries
File Changes
src/types/tracker.d.ts Exposes the new method and parameter types.
src/modules/tracker.js Implements the event; required mode and domain validation is still needed before queueing.
spec/src/modules/tracker.js Tests request parameters and network behavior.
Review details
  • Files reviewed: 2/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/modules/tracker.js Outdated

Copilot AI 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.

🟢 Approval recommended

No unresolved review comments remain, and the reviewed changes are covered by tests and declarations.

Review details
  • Files reviewed: 2/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Comment thread src/modules/tracker.js Outdated
bodyParams.page_type = pageType;
}

if (instanceId) {

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.

I know the instanceId is 1-based, but nothing stops you from passing a 0. Should we throw an error in that case, or are we fine with silently ignoring it?

HHHindawy
HHHindawy previously approved these changes Sep 16, 2026
…t_button_click API

- Send the agent experience as agent_domain to match the Behavioral API v2
  field (domain is reserved for the integration hostname in agent_overview events)
- Narrow mode to the strict enum: chat, search, qna, recommendations, query_refinement
- Add search to pageType

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Mudaafi
Mudaafi merged commit 5a8e7c5 into Constructor-io:master Oct 1, 2026
8 of 11 checks passed
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.

4 participants