analytics

bởi sentry

Công cụ và khám phá các sự kiện analytics trong giao diện người dùng của Sentry. Sử dụng khi thêm theo dõi vào các nút, trang, cửa sổ modal hoặc tương tác tùy chỉnh, khi định nghĩa mới…

npx skills add https://github.com/getsentry/sentry --skill analytics

Analytics Instrumentation

Add analytics events to Sentry's frontend UI using established patterns.

Answering "How Many People Do X?"

When the user asks about usage, adoption, or interaction counts for a feature:

  1. Find the event: search Amplitude first (fastest), fall back to grepping the codebase.
  2. If the Amplitude MCP is connected, query the data directly and report results.
  3. If no matching event exists, tell the user the event is not tracked — then use AskUserQuestion to ask whether they want to instrument it. Do not proceed to instrumentation without explicit confirmation.

Read references/amplitude-mcp.md for the full discovery and querying workflow.

Before Any Change: Search First

NEVER create a new event without checking if one already exists.

  1. Search static/app/utils/analytics/ for events matching the feature domain.
  2. Grep for keywords related to the interaction (e.g., clicked, viewed, created).
  3. If a matching event exists, reuse it — add parameters if needed rather than creating a duplicate.
grep -rn "keyword" static/app/utils/analytics/ --include="*.tsx"

Event Naming Rules

RuleExample
Use snake_case with dots as separatorsfeedback.list-item-selected
First segment = feature domaindashboards2., issue_details., feedback.
Middle segments = section/context (optional)dashboards2.edit.
Last segment = action.clicked, .viewed, .created, .changed
Match the existing domain file's prefixIf events are in feedbackAnalyticsEvents.tsx, use feedback. prefix

Standard action suffixes:

User actionSuffix
Clicks a button/link.clicked or _clicked
Views a page.viewed
Submits a form.submitted or .created
Changes a setting.changed
Renders/loads content.rendered or .loaded
Dismisses UI.dismissed
Opens a modal/panel.opened

Choose the Right Tracking Pattern

What to trackPatternOpen reference
Page view on route navigationRoute analytics hooksreferences/tracking-patterns.md § Route-Level
Button or link clickButton analyticsEventKey propreferences/tracking-patterns.md § Button
Custom interaction (toggle, drag, select)trackAnalytics() callreferences/tracking-patterns.md § Manual
Modal or panel open/closetrackAnalytics() in handlerreferences/tracking-patterns.md § Manual
UI area context for eventsAnalyticsArea wrapperreferences/tracking-patterns.md § Area Context

When You Need to Define a New Event

Read references/event-definitions.md for step-by-step instructions.

Common Mistakes and Debugging

Read references/troubleshooting.md when:

  • An event isn't firing or appearing in Amplitude
  • You see TypeScript errors when calling trackAnalytics
  • You need to debug analytics locally
  • You're unsure whether an event needs an Amplitude name

Key Files

FilePurpose
static/app/utils/analytics.tsxMaster registry — all event maps merged, trackAnalytics export
static/app/utils/analytics/{domain}AnalyticsEvents.tsxDomain-specific event type definitions and name maps
static/app/utils/analytics/makeAnalyticsFunction.tsxFactory that creates typed trackAnalytics — do not call directly
static/app/utils/routeAnalytics/useRouteAnalyticsEventNames.tsxHook for route-level page view event names
static/app/utils/routeAnalytics/useRouteAnalyticsParams.tsxHook for route-level page view parameters
static/app/components/analyticsArea.tsxAnalyticsArea component and useAnalyticsArea hook
static/app/components/core/button/types.tsxButton analytics props (analyticsEventKey, analyticsEventName, analyticsParams)

Interaction Rules

Users of this skill may be less technical. Use AskUserQuestion at every decision point instead of dumping plans or code.

SituationAction
Event not found, user asked a data questionUse AskUserQuestion: "This isn't tracked yet. Want me to add instrumentation?"
User confirms they want instrumentationGo straight to implementation. Do not show code previews or step-by-step plans — just make the changes and summarize what you did.
Implementation is done, needs user action (e.g., Reload registration)State the remaining step clearly in your summary.

Never dump code blocks as a "plan" and then ask "Want me to make these changes?" — either present a short plain-English summary via AskUserQuestion for confirmation, or proceed directly if the user already asked for instrumentation.

Event Pipeline

Every trackAnalytics call flows through the GetSentry override in static/gsApp/utils/rawTrackAnalyticsEvent.tsx:

DestinationWhen it firesWhat it usesHow to query
ReloadAlwayseventKeyRedash
AmplitudeWhen eventName is non-null and org existseventNameAmplitude UI or MCP
PendoSame as AmplitudeeventNamePendo
  • Set eventName to a string (e.g., 'Logs Trace Link Clicked') to send to both Reload and Amplitude. This is the default for almost all events.
  • Set eventName to null only for high-volume events that would be too expensive for Amplitude. These are Reload-only and queryable via Redash.
  • Reload accepts events with allow_no_schema: true — no separate registration step is needed.
  • When searching for events, note that Reload-only events (null name) will not appear in Amplitude search. Fall back to grepping the codebase if Amplitude returns no results.

Non-Negotiable Constraints

  1. trackAnalytics() calls must be type-safe. Every event key passed to trackAnalytics() must exist in a *EventParameters type and be registered in the domain's event map. This enforces that organization is always passed and that call sites sharing the same event key use consistent parameters. Declarative helpers — button analyticsEventKey/analyticsParams props and useRouteAnalyticsParams — are exempt because each instance is a one-off: two buttons labeled "Save" are inherently different (different forms, different contexts), so there are no shared call sites and less value in centralized types.
  2. Prefer declarative helpers. Use button analytics props and route analytics hooks when they fit. Fall back to trackAnalytics() only for interactions those helpers don't cover.
  3. All events flow through trackAnalytics() or built-in helpers. Never call window.analytics, Amplitude.track(), or any other analytics SDK directly.
  4. Organization context is automatic. Pass organization to trackAnalytics — the override system handles the rest.
  5. Reuse over create. Always search for existing events before defining new ones.
  6. One event per interaction. Do not fire multiple events for the same user action.
  7. No PII in event parameters. Never include user emails, IP addresses, full names, or other personally identifiable information. Use opaque IDs (org ID, user ID) when identity context is needed.

Thêm skills từ sentry

generate-frontend-forms
sentry
Hướng dẫn tạo biểu mẫu bằng hệ thống biểu mẫu mới của Sentry. Sử dụng khi triển khai biểu mẫu, trường biểu mẫu, xác thực hoặc chức năng tự động lưu.
official
sentry-snapshots-cocoa
sentry
Thiết lập đầy đủ Sentry Snapshots cho các dự án Apple/Cocoa. Sử dụng khi được yêu cầu "thiết lập SnapshotPreviews", "thiết lập kiểm thử snapshot Apple", "tải lên snapshot Apple lên…
official
architecture-review
sentry
Đánh giá sức khỏe mã nguồn ở cấp độ nhân viên. Phát hiện các module nguyên khối, lỗi âm thầm, khoảng trống an toàn kiểu dữ liệu, lỗ hổng độ phủ kiểm thử và các vấn đề về thân thiện với LLM.
official
linear-type-labeler
sentry
Phân loại các vấn đề Linear và áp dụng nhãn Loại từ hệ thống phân loại nhãn của không gian làm việc Sentry dựa trên nội dung tiêu đề và mô tả của từng vấn đề.
official
sentry-flutter-sdk
sentry
Thiết lập đầy đủ Sentry SDK cho Flutter và Dart. Sử dụng khi được yêu cầu "thêm Sentry vào Flutter", "cài đặt sentry_flutter", "thiết lập Sentry trong Dart", hoặc cấu hình lỗi…
official
sentry-svelte-sdk
sentry
Thiết lập đầy đủ Sentry SDK cho Svelte và SvelteKit. Sử dụng khi được yêu cầu "thêm Sentry vào Svelte", "thêm Sentry vào SvelteKit", "cài đặt @sentry/sveltekit", hoặc cấu hình…
official
vercel-react-best-practices
sentry
Hướng dẫn tối ưu hiệu suất React và Next.js từ Vercel Engineering. Kỹ năng này nên được sử dụng khi viết, xem xét hoặc tái cấu trúc mã React/Next.js…
official
sentry-tanstack-start-sdk
sentry
Thiết lập đầy đủ Sentry SDK cho TanStack Start React. Sử dụng khi được yêu cầu "thêm Sentry vào TanStack Start", "cài đặt @sentry/tanstackstart-react", hoặc cấu hình lỗi…
official