본문으로 건너뛰기
Skillpedia
분석 및 스프레드시트7.6k · #13186

tracking

하는 일

이 스킬은 앱이 하나의 추적 함수를 통해 하나 이상의 분석 서비스에 사용 이벤트를 보내는 방법을 설명합니다. 분석을 추가하거나 새 분석 제공자를 연결하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓사용자가 앱에서 새 메모를 저장하는 것 같은 이벤트를 기록하고 싶을 때.
  • ✓환경 설정을 통해 내장 분석 서비스를 설정할 때.
  • ✓다른 서비스를 위해 맞춤 분석 제공자를 추가할 때.

스킬 링크

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/tracking/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/tracking/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 앱에서 누군가 새 메모를 저장할 때 추적해서, 제 분석 도구에서 볼 수 있게 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

앱은 각 이벤트를 하나의 추적 함수로 보내 연결된 모든 제공자에게 전달합니다. 제공자는 환경 변수로 설정되며 묶음으로 보내고, 실패가 사용자를 막지는 않습니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Tracking

Rule

The tracking system provides a single server-side track() call that fans out to all registered providers, plus the browser-side trackEvent() counterpart. Built-in providers auto-register from env vars - set the var and tracking starts. Custom providers can be registered for any analytics backend. Both surfaces are best-effort and never block request handling.

How It Works

  1. At server startup, registerBuiltinProviders() checks env vars and registers any configured providers.
  2. Application code calls track(eventName, properties, source) from actions, plugins, or server routes.
  3. The registry fans out the event to every registered provider. Errors are caught and logged -- a failing provider never crashes the caller.
  4. Built-in providers batch HTTP calls (flush every 10 seconds or 50 events, whichever comes first). Each send times out after 10 seconds.

API

track(name, properties?, source?)

Fire an analytics event. source is either a { userId, anonymousId, sessionId } meta object or an action's ctx passed straight through.

import { track } from "@agent-native/core/tracking";

// From an action — pass ctx; userId comes from ctx.userEmail.
run: async ({ name }, ctx) => {
  track("meal.logged", { mealName: name, calories: 350 }, ctx);
};

// From a plugin or route with no ctx.
track(
  "meal.logged",
  { mealName: "Salad", calories: 350 },
  { userId: "user@example.com" },
);

The caller's browser session comes from the ambient request context (RequestContext.browserSessionId, set from the X-Agent-Native-Session-Id header), so it resolves the same whether the UI called the action or the agent did. Pass sessionId in the meta object to override it — routes that run outside a request context, such as /_agent-native/track, do exactly that. Providers map it to their own session field: $session_id for PostHog (which joins the event to session replay), session_id as a property for Mixpanel and Amplitude, a top-level sessionId for webhooks and Agent-Native Analytics. It is absent for callers with no browser — cron, CLI, MCP, A2A.

identify(userId, traits?)

Identify a user with traits. Forwarded to providers that support it.

import { identify } from "@agent-native/core/tracking";

identify("user@example.com", { plan: "pro", company: "ExampleCo" });

registerTrackingProvider(provider)

Register a custom provider.

import { registerTrackingProvider } from "@agent-native/core/tracking";

registerTrackingProvider({
  name: "my-analytics",
  track(event) {
    // Send event to your backend
  },
  identify(userId, traits) {
    // Optional
  },
  flush() {
    // Optional -- called on graceful shutdown
  },
});

flushTracking()

Flush all providers (call before process exit).

Built-in Providers

Set the env var and the provider auto-registers at startup. No SDK dependencies -- all providers use raw HTTP.

Provider Env vars
PostHog POSTHOG_API_KEY (required), POSTHOG_HOST (optional, defaults to https://us.i.posthog.com), POSTHOG_ERROR_TRACKING=false (optional opt-out)
Mixpanel MIXPANEL_TOKEN
Amplitude AMPLITUDE_API_KEY
Agent-Native Analytics AGENT_NATIVE_ANALYTICS_PUBLIC_KEY (server), AGENT_NATIVE_ANALYTICS_ENDPOINT (optional, defaults to https://analytics.agent-native.com/track)
Webhook TRACKING_WEBHOOK_URL (required), TRACKING_WEBHOOK_AUTH (optional, sent as Authorization header)

Multiple providers can be active simultaneously. All receive every event.

Browser-side trackEvent() also forwards to Agent-Native Analytics when VITE_AGENT_NATIVE_ANALYTICS_PUBLIC_KEY is present. Use VITE_AGENT_NATIVE_ANALYTICS_ENDPOINT to override the default browser endpoint. The built-in Agent-Nat

자주 묻는 질문

분석 서비스가 실패하면 앱이 망가지나요?

아니요. 오류는 잡혀서 기록되므로 요청은 계속 진행됩니다.

어떤 서비스가 내장되어 있나요?

이 스킬은 PostHog, Mixpanel, Amplitude와 일반 웹훅을 나열합니다.

이벤트는 어떻게 보내나요?

내장 제공자는 이벤트를 묶어 보내며, 10초마다 또는 50개마다 중 먼저 도달하는 쪽에 전송합니다.

상세 정보

작성자의 원본 설명

Server-side analytics tracking with pluggable providers. Use when adding analytics events, registering custom tracking providers, or configuring built-in providers (PostHog, Mixpanel, Amplitude, Webhook).

repo: BuilderIO/agent-native

인기도

GitHub 스타
7.6k
순위
#13186
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬