launchdarkly-metric-instrument
Instrument a LaunchDarkly metric event in a codebase by adding a track() call. Use when the user wants to wire up an event, instrument an action for a metric…
от launchdarkly★ 32 звезды на GitHub
Установить launchdarkly-metric-instrument в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
LaunchDarkly Metric Instrument
You're using a skill that will guide you through adding a track() call to a codebase so a LaunchDarkly metric can measure it. Your job is to detect the SDK in use, find the right place in code to add the call, write it correctly, and verify that events are reaching LaunchDarkly.
Prerequisites
This skill requires the remotely hosted LaunchDarkly MCP server to be configured in your environment.
Required MCP tools:
get-metric-events— verify events are flowing after instrumentation
Optional MCP tools (enhance workflow):
get-sdk-key— retrieve the server-side SDK key for the right environment when SDK initialization is needed (get-environmentfor a client-side ID or mobile key)
Workflow
Step 1: Detect the SDK
Before writing any code, understand the LaunchDarkly setup already in this codebase.
Search for existing
track()calls. This is the fastest signal:- Look for
ldClient.track(,.track(,ld.track( - If any exist, they tell you the SDK type, call signature, and context pattern in one shot — mirror those exactly.
- Look for
Search for SDK imports and initialization if no
track()calls exist:- Check
package.json,requirements.txt,go.mod,Gemfile,*.csprojfor an LD SDK dependency - Look for
LDClient,ldclient,launchdarkly-server-sdk,launchdarkly-node-server-sdk,launchdarkly-react-client-sdk, etc. - Find the initialization block to understand how the client is accessed across the codebase
- Check
Determine client-side or server-side. This is the most critical distinction — it determines the
track()signature:SDK type track()signatureNotes Server-side (Node, Python, Go, Java, Ruby, .NET) ldClient.track(eventKey, context, data?, metricValue?)Context required per call Client-side (React, browser JS) ldClient.track(eventKey, data?, metricValue?)Context set at init, not per call See SDK Track Patterns for full examples by language.
Step 2: Install & Initialize (if SDK not present)
Skip this step if the SDK is already in the codebase.
Detect the package manager from lockfiles:
package-lock.json/yarn.lock/pnpm-lock.yaml→ npm/yarn/pnpm;Pipfile.lock/poetry.lock→ pip/poetry;go.sum→ go modules;Gemfile.lock→ bundler.Install the appropriate SDK using the detected package manager. See SDK Track Patterns for the right package name per language.
Get the SDK key using
get-sdk-key(server-side) orget-environment(client-side ID, mobile key) — pick the environment the user wants to instrument (typicallyproductionorstagingfor initial testing).Add SDK initialization following the patterns already in this codebase. If there's a central config or service layer, add the LD client there. See SDK Track Patterns for initialization examples.
Step 3: Find the Right Placement
Locate where in the code the user action or event occurs.
Ask if you're not sure where the action happens. Don't guess at placement — a
track()call in the wrong location (e.g. a render method instead of a submit handler) produces misleading data.Look for signals of the right location:
- Form submissions, button click handlers, API route completions, mutation hooks
- Existing analytics calls (
segment.track(),mixpanel.track(),gtag()) — these are often co-located with where LD track calls should go - Comments like
// TODO: track this
Show the candidate location to the user before writing anything:
I'll add the track() call here, in the checkout submit handler (src/checkout/CheckoutForm.tsx, line 47). Does that look right?Proceed once confirmed (or if you're confident enough from codebase signals).
Step 4: Write the track() Call
Write the call following the patterns found in Step 1.
Server-side SDKs — context is required:
ldClient.track('checkout-completed', context);
Client-side SDKs — context is implicit:
ldClient.track('checkout-completed');
For value metrics — include metricValue with the numeric measurement:
// Server-side: latency metric (ms)
ldClient.track('api-response-time', context, null, responseTimeMs);
// Client-side: revenue metric
ldClient.track('purchase-completed', { orderId }, purchaseAmountUSD);
Key rules:
- Match the existing context. Don't construct a new context inline. Find where the codebase already builds its context/user object (used for
variation()calls) and use the same one. This is how LD correlates the event to the right experiment participant. metricValueonly forvaluemetrics. Forcountandoccurrencemetrics, omitmetricValueentirely.- **Respect w
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/sdk-track-patterns.md
FAQ
Что делает скилл launchdarkly-metric-instrument?
Instrument a LaunchDarkly metric event in a codebase by adding a track() call. Use when the user wants to wire up an event, instrument an action for a metric, add tracking to a feature, or confirm that an event is flowing to LaunchDarkly.
Как установить скилл launchdarkly-metric-instrument?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл launchdarkly-metric-instrument запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…