analytics-instrumentation

analytics-instrumentation is a skill for Claude Code, Codex from comet-ml/opik. It costs 43 tokens per session (4,131 once invoked), scanned A, original, Apache-2.0.

Guidance for recording product-usage events from Opik's frontend, backend, or Python SDK. These events pass through Segment, an event-routing service, to PostHog for analysis.

In plain words
What is it for?
Use it when adding an event for an action such as onboarding, creating an evaluation suite, or starting an optimization. It explains where to define events and how to send them.
Why use it?
It keeps analytics event names and tracking behavior consistent and ensures tracking remains safe when analytics is unavailable, such as in the open-source version.

Skill for Claude CodeCodex

About the project

Opik is an open-source platform for tracing, evaluating, and monitoring applications that use large language models, retrieval systems, or AI agents. Teams use it to inspect agent activity, manage prompts, run evaluations, and monitor these applications in production.

comet-ml/opik · 21,799 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/comet-ml/opik/analytics-instrumentation
Any agent
npx skills add comet-ml/opik --skill analytics-instrumentation
Clone the repo
git clone --depth 1 https://github.com/comet-ml/opik

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for analytics-instrumentation

README.md
[![agentmods](https://agentmods.dev/badge/skills/comet-ml/opik/analytics-instrumentation.svg)](https://agentmods.dev/skills/comet-ml/opik/analytics-instrumentation)
Your own site
<a href="https://agentmods.dev/skills/comet-ml/opik/analytics-instrumentation"><img src="https://agentmods.dev/badge/skills/comet-ml/opik/analytics-instrumentation.svg" alt="Measured on agentmods" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,131 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00043 $0.04131
Opus 5 $0.00022 $0.02065
Sonnet 5 $0.00009 $0.00826
Haiku 4.5 $0.00004 $0.00413

Measured 5d ago against content hash 5d5b2e16bd2a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

analytics-instrumentation scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/analytics-instrumentation/SKILL.md · 326 lines

How it starts

The opening of the file, as written. The whole thing — 326 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Analytics Instrumentation

Event Naming

All events MUST be prefixed with opik_. Segment routes opik_* events to PostHog. The tooling enforces this automatically, but event names defined in code should already include the prefix.

Examples: opik_onboarding_agent_name_submitted, opik_eval_suite_created, opik_optimization_created

Frontend Events

Files

  • Tracking utility: apps/opik-frontend/src/lib/analytics/tracking.ts (mode-agnostic; safe to import from any project code)
  • Segment init: apps/opik-frontend/src/plugins/comet/analytics/index.ts (comet-only)
  • Plugin init: apps/opik-frontend/src/plugins/comet/init.tsx (comet-only)

Adding a new event

  1. Add the event name to the OpikEvent const in tracking.ts:
export const OpikEvent = {
  ONBOARDING_AGENT_NAME_SUBMITTED: "opik_onboarding_agent_name_submitted",
} as const;
  1. Call trackEvent from the component or hook where the action happens:
import { trackEvent, OpikEvent } from "@/lib/analytics/tracking";

trackEvent(OpikEvent.ONBOARDING_AGENT_NAME_SUBMITTED, {
  agent_name: agentName,
});

How it works

  • trackEvent() safely no-ops when Segment isn't loaded (OSS mode)
  • opik_ prefix is enforced at runtime as a safety net
  • OPIK_ANALYTICS_ENVIRONMENT is injected into event properties automatically by trackEvent()
  • Frontend custom events flow through Segment (same pipeline as backend): Segment → PostHog
  • PostHog still handles automatic pageviews, user identification, and feature flags directly

Backend Events

Files

  • Service: apps/opik-backend/src/main/java/com/comet/opik/infrastructure/bi/AnalyticsService.java
  • Config: apps/opik-backend/src/main/java/com/comet/opik/infrastructure/AnalyticsConfig.java
  • YAML config: apps/opik-backend/config.yml (under analytics:)

API

AnalyticsService exposes two overloads:

void trackEvent(String eventType, Map<String, String> properties);
void trackEvent(String eventType, Map<String, String> properties, String identity);

Read the full file on GitHub · 326 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 326 lines · 43 tokens per session scan A 5d5b2e16bd2a

Subscribe to this mod's changes

analytics-instrumentation is a skill published in the GitHub repository comet-ml/opik (21,799 stars, last pushed today), licensed Apache-2.0. It adds 43 tokens to every session and 4,131 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.