analytics-events
БесплатноБез исполняемых скриптовНе проверенAdd product analytics events to track user interactions in the Metabase frontend
от metabase★ 50 742 звезды на GitHubОб этом скилле
Frontend Analytics Events Skill
This skill helps you add product analytics (Snowplow) events to track user interactions in the Metabase frontend codebase.
Quick Reference
Analytics events in Metabase use Snowplow with typed event schemas. Simple events are declared where they are used — trackSimpleEvent is generic and validates the payload at the call site.
Key Files:
frontend/src/metabase/analytics/event.ts- Core tracking functions,trackSimpleEvent/trackSchemaEvent(import frommetabase/analytics)frontend/src/metabase-types/analytics/event.ts- The sharedSimpleEventSchemaonly. Do not add event types here (see below)frontend/src/metabase-types/analytics/schema.ts- Schema registry (custom/legacy schemas only)- Feature-specific
analytics.tsfiles - Where your tracking functions and any local types live
Quick Checklist
When adding a new analytics event:
- Pick an event name (snake_case, past tense)
- Add a tracking function to the feature's
analytics.tsfile, callingtrackSimpleEvent() - Keep any field unions (e.g.
"success" | "failure") as local types in that same file - Import and call the tracking function at the interaction point
- Do not add an event type to
metabase-types/analytics/event.tsor to any union
Event Schema Types
1. Simple Events (Most Common)
Use SimpleEventSchema for straightforward tracking. It supports these standard fields:
type SimpleEventSchema = {
event: string; // Required: Event name (snake_case)
target_id?: number | null; // Optional: ID of affected entity
triggered_from?: string | null; // Optional: UI location/context
duration_ms?: number | null; // Optional: Duration in milliseconds
result?: string | null; // Optional: Outcome (e.g., "success", "failure")
event_detail?: string | null; // Optional: Additional detail/variant
};
When to use: 90% of events fit this schema. Use for clicks, opens, closes, creates, deletes, etc.
trackSimpleEvent is generic and enforces this schema on the object literal you pass it:
// frontend/src/metabase/analytics/event.ts
export function trackSimpleEvent<
T extends SimpleEventSchema &
Record<Exclude<keyof T, keyof SimpleEventSchema>, never>,
>(event: T) {
trackSchemaEvent("simple_event", event);
}
That means a missing event or any field outside SimpleEventSchema is a compile error at the call
site. There is no separate event type to declare and no satisfies clause to add — the old
ValidateEvent<...> helper is no longer exported and is not part of the workflow.
trackSchemaEvent is generic too: it correlates the schema name with the payload type, so you can't
send a dashboard event under the simple_event schema.
2. Custom Schemas (legacy, no events are being added)
Consider adding new event schema only in very special cases.
Examples: DashboardEventSchema, CleanupEventSchema, QuestionEventSchema
Step-by-Step: Adding a Simple Event
Example: Track when a user applies filters in a table picker
Step 1: Create Tracking Functions
In your feature's analytics.ts file (e.g., enterprise/frontend/src/metabase-enterprise/data-studio/analytics.ts):
import { trackSimpleEvent } from "metabase/analytics";
export const trackDataStudioTablePickerFiltersApplied = () => {
trackSimpleEvent({
event: "data_studio_table_picker_filters_applied",
});
};
export const trackDataStudioTablePickerFiltersCleared = () => {
trackSimpleEvent({
event: "data_studio_table_picker_filters_cleared",
});
};
Step 2: Use in Components
Import and call the tracking function at the interaction point:
import {
trackDataStudioTablePickerFiltersApplied,
trackDataStudioTablePickerFiltersCleared,
} from "metabase-enterprise/data-studio/analytics";
function FilterPopover({ filters, onSubmit }) {
const handleReset = () => {
trackDataStudioTablePickerFiltersCleared(); // <- Track here
onSubmit(emptyFilters);
};
return (
<form
onSubmit={(event) => {
event.preventDefault();
trackDataStudioTablePickerFiltersApplied(); // <- Track here
onSubmit(form);
}}
>
{/* form content */}
</form>
);
}
Using SimpleEventSchema Fields
All examples below live in the feature's own analytics.ts — nothing is registered centrally.
Example: Event with target_id
export const trackDataStudioLibraryCreated = (id: CollectionId) => {
trackSimpleEvent({
event: "data_studio_library_created",
target_id: Number(id),
});
};
// Usage
trackDataStudioLibraryCreated(newLibrary.id);
Example: Event with triggered_from
// Local union, exported only if another feature needs to pass the same value
export type NewButtonLocation = "app-bar" | "empty-collection";
export const trackNewBut
Установить analytics-events в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditGrepGlobFAQ
Что делает скилл analytics-events?
Add product analytics events to track user interactions in the Metabase frontend
Как установить скилл analytics-events?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл analytics-events запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic