feat: add --user-agent flag for caller-identified telemetry#1102
Merged
Conversation
Adds an opt-in caller identifier so skills, plugins, and integrations that wrap the CLI can be distinguished from direct human usage. Exposed as `--user-agent` on every command under the `apify` entrypoint and via the `APIFY_CLI_USER_AGENT` env var (flag wins over env). The resolved value is sanitized (control chars stripped, capped at 256 chars) and attached to telemetry as `callerAgent` — named to avoid collision with Segment's existing `context.userAgent`. Scoped to the public `apify` entrypoint only; the `actor` entrypoint rejects it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The flag is --user-agent and env var is APIFY_CLI_USER_AGENT, so the telemetry field should match. Collision with Segment's context.userAgent is not a concern because the two live in distinct objects (properties vs context). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
l2ysho
reviewed
Apr 22, 2026
Contributor
l2ysho
left a comment
There was a problem hiding this comment.
some small nits (nonblocking), but no opinion over context.userAgent vs. properties.userAgent, lets wait for @vladfrangu with this one
…scope Why: test-cli is set by testRunCommand() for test harnessing, but no test exercises --user-agent through that path. Keeping it in the Set contradicts the comment above scoping the flag to the public apify entrypoint. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
vladfrangu
approved these changes
Apr 24, 2026
Member
vladfrangu
left a comment
There was a problem hiding this comment.
I guess its fine in properties but ask the analytics team
vystrcild
pushed a commit
to apify/agent-skills
that referenced
this pull request
Apr 28, 2026
…emetry attribution Adds --user-agent apify-agent-skills/apify-ultimate-scraper to every apify CLI example in the apify-ultimate-scraper skill (SKILL.md, gotchas.md, actor-index.md, and four workflow guidance files), plus a top-level rule in SKILL.md documenting the convention. Bumps the CLI prerequisite to v1.5.0+ since the flag was introduced in apify/apify-cli#1102. This lets us distinguish skill-driven CLI invocations from generic human usage in Mixpanel/Segment via properties.userAgent, and aligns with the existing apify-agent-skills/<slug> naming convention used in actor_run.meta_user_agent data feeding dashboards.apify.com/dashboards/276. Refs: apify/apify-cli#1102 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
--user-agentflag /APIFY_CLI_USER_AGENTenv var) so skills, plugins, and integrations that wrap the CLI can be distinguished from direct human usage in telemetry.userAgent.apifyentrypoint only; theactorentrypoint (which runs inside Actor Docker images) rejects it.Test plan
yarn lintyarn buildyarn test:local— 21 new unit tests forresolveUserAgentForTelemetry, flag registration, and end-to-end telemetry wiring all pass. (Two pre-existing Python fixture failures are unrelated.)properties.userAgentcoexistence withcontext.userAgentin Segment payloads is acceptable (different objects, distinct meaning).Closes: #1100