发布

  • [OPIK-5692] [BE][FE] feat: add agent config & runner analytics events (#6338)

    frostbyte_neo 发布于 2026-04-17 12:37:44 +00:00

    • [OPIK-5692] [BE][FE] feat: add agent config & runner analytics events

    Add PostHog instrumentation for agent configs and sandbox runner to
    track Opik 2.0 launch metrics defined in OPIK-5245.

    Backend (3 events via AnalyticsService):

    • opik_agent_config_saved: fired in createAgentConfig() and
      updateAgentConfig() to capture both UI and SDK config creation.
    • opik_agent_config_deployed: fired in createOrUpdateEnvs() and
      setEnvByBlueprintName() to capture all deployment paths.
    • opik_sandbox_job_created: fired in createJob() to capture runner
      adoption across UI and API.

    Frontend (1 event via trackEvent):

    • opik_agent_config_ui_deployed: fired from DeployToPopover with
      UI-specific context (is_new_prod) not available at the BE endpoint.

    All BE calls wrapped in try/catch to avoid disrupting primary
    operations. User identity resolved automatically via the updated
    AnalyticsService.resolveIdentity().

    • fix(analytics): address Baz review — dedup deploy helpers and fix blueprint_id
    • Consolidated trackAgentConfigDeployed and trackAgentConfigDeployedByName
      into a shared trackAgentConfigDeployedEvent helper (dedup)
    • Changed blueprint_id to collect all distinct IDs instead of findFirst(),
      avoiding mis-attribution when envs reference different blueprints
    • fix(analytics): add opik_ prefix to event names and fix blueprint_id type inconsistency

    Address PR review comments: prefix all analytics events with opik_ per
    instrumentation guidelines, and separate blueprint_id (UUID) from
    blueprint_name (display name) to prevent type mixing in deployed events.
    Also update the analytics skill to document property naming conventions.

    • fix(analytics): address Boris's PR review comments
    • Remove try/catch wrappers around analytics calls (fire-and-forget)
    • Add workspace_id to all analytics events
    • Emit one event per env instead of comma-separated aggregation
    • Track implicit prod deployment on first config creation
    • Soften SKILL.md _id naming rule (thread_id is human-readable)
    • chore: revert unrelated package-lock.json changes

    • fix(analytics): move tracking to service layer for consistent event properties

    Move analytics tracking from AgentConfigsResource to AgentConfigServiceImpl
    so both deploy paths (by-ID and by-name) emit consistent event properties
    (always blueprint_id + blueprint_name).

    • fix(analytics): coerce deployed_to_prod to string in frontend

    Aligns frontend event type with backend String.valueOf() serialization
    so deployed_to_prod is consistently a string across all emitters.

    • fix(analytics): move sandbox_job_created tracking to service layer

    Move opik_sandbox_job_created event from LocalRunnersResource to
    EndpointJobServiceImpl for consistency with agent config tracking.

    • fix: add missing AnalyticsService param to test constructors

    • fix: use resolved projectId in analytics callbacks to avoid NPE

    Move doOnNext callbacks inside flatMap scope so they use the resolved
    projectId variable instead of blueprint.projectId() which is null.
    Verified with 66 passing AgentConfigsResourceTest tests.

    下载附件