Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
launchdarkly avatar

Launchdarkly Metric Instrument

  • 2.8k installs
  • 23 repo stars
  • Updated August 5, 2026
  • launchdarkly/agent-skills

launchdarkly-metric-instrument is an agent skill that Instrument a LaunchDarkly metric event in a codebase by adding a track() call. Use when the user wants to wire up an eve.

About

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 This skill requires the remotely hosted LaunchDarkly MCP server to be configured in your environment Required MCP tools list metric events verify events are flowing after instrumentation Optional MCP tools enhance workflow get project retrieve the SDK key for the right environment when SDK initialization is needed Before writing any code understand the LaunchDarkly setup already in this codebase The launchdarkly metric instrument agent skill provides documented workflows prerequisites triggers and safety guidance from its SKILL md source Agents load it when user requests match the description and follow step by step instructions without inventing capabilities It integrates with standard agent tooling for the tasks inputs outputs and failure modes described in the repository documentation

  • name: launchdarkly-metric-instrument
  • description: "Instrument a LaunchDarkly metric event in a codebase by adding a track() call. Use when the user wants to
  • compatibility: Requires the remotely hosted LaunchDarkly MCP server
  • Follow launchdarkly-metric-instrument SKILL.md steps and documented constraints.
  • Follow launchdarkly-metric-instrument SKILL.md steps and documented constraints.

Launchdarkly Metric Instrument by the numbers

  • 2,774 all-time installs (skills.sh)
  • +68 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #285 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

launchdarkly-metric-instrument capabilities & compatibility

Capabilities
name: launchdarkly metric instrument · description: "instrument a launchdarkly metric e · compatibility: requires the remotely hosted laun · follow launchdarkly metric instrument skill.md s
Use cases
orchestration
From the docs

What launchdarkly-metric-instrument says it does

name: launchdarkly-metric-instrument
SKILL.md
description: "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,
SKILL.md
compatibility: Requires the remotely hosted LaunchDarkly MCP server
SKILL.md
npx skills add https://github.com/launchdarkly/agent-skills --skill launchdarkly-metric-instrument

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs2.8k
repo stars23
Security audit3 / 3 scanners passed
Last updatedAugust 5, 2026
Repositorylaunchdarkly/agent-skills

When should an agent use launchdarkly-metric-instrument and what problem does it solve?

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 tha

Who is it for?

Developers invoking launchdarkly-metric-instrument as documented in the skill source.

Skip if: Skip when requirements fall outside launchdarkly-metric-instrument documented scope.

When should I use this skill?

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 tha

What you get

Outputs aligned with the launchdarkly-metric-instrument SKILL.md workflow and stated deliverables.

  • track() code snippets
  • SDK initialization boilerplate

By the numbers

  • Covers @launchdarkly/node-server-sdk v9+ and launchdarkly-node-server-sdk v6–v8

Files

SKILL.mdMarkdownGitHub ↗

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:

  • list-metric-events — verify events are flowing after instrumentation

Optional MCP tools (enhance workflow):

  • get-project — retrieve the SDK key for the right environment when SDK initialization is needed

Workflow

Step 1: Detect the SDK

Before writing any code, understand the LaunchDarkly setup already in this codebase.

1. 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.

2. Search for SDK imports and initialization if no track() calls exist:

  • Check package.json, requirements.txt, go.mod, Gemfile, *.csproj for 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

3. Determine client-side or server-side. This is the most critical distinction — it determines the track() signature:

SDK typetrack() 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.

1. 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.

2. Install the appropriate SDK using the detected package manager. See SDK Track Patterns for the right package name per language.

3. Get the SDK key using get-project — fetch the project and choose the key for the environment the user wants to instrument (typically production or staging for initial testing).

4. 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.

1. 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.

2. 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

3. 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?

4. 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.
  • `metricValue` only for `value` metrics. For count and occurrence metrics, omit metricValue entirely.
  • Respect wrapper patterns. If the codebase wraps LD calls behind a utility (featureFlags.track(), analytics.ldTrack()), add the new call through that wrapper — not by calling ldClient directly.
  • Match the event key exactly. track() event keys are case-sensitive. Use the exact string that the metric was created with.

See SDK Track Patterns for full per-language examples.

Step 5: Verify

Guide the user to trigger the action in their local or staging environment. Then use list-metric-events to confirm the event key appears:

list-metric-events(projectKey, environmentKey)

If the event key appears: confirm success and show a summary.

If the event key is absent after triggering, work through this checklist:

ProblemCheck
Wrong event key casingDoes the track() call match the metric's event key exactly?
SDK not initializedIs ldClient initialized before the track() call runs?
Server-side: wrong contextIs the context passed to track() the same context used for variation() calls?
Client-side: no flag evaluation firstHas the SDK initialized and identified the user before track() is called?
Wrong environmentIs list-metric-events querying the same environment where the action was triggered?
Data delaylist-metric-events shows the last 90 days with up to ~5 min delay — try again in a moment

Surface a summary once verified:

✓ Event flowing: checkout-completed
  Seen in: production
  
Next: this event is now ready to back a metric. Use the metric-create skill to set one up,
or attach an existing metric to your experiment.

Important Context

  • `track()` calls only count in experiments when a flag is evaluated first. The event is correlated to an experiment participant because LD saw a variation() call from that context. If the user triggers the action without evaluating any flag, the event may still be ingested but won't appear in experiment results.
  • Client-side SDKs flush events on an interval (default ~30 seconds) or on page unload. In tests, you may need to call ldClient.flush() explicitly to see events appear immediately.
  • Server-side SDKs also buffer events. Calling ldClient.flush() after track() in development ensures the event is sent before the process exits or the test ends.
  • `metricValue` units must match the metric definition. If the metric was created with unit ms, pass milliseconds. Passing seconds into a milliseconds metric will produce silently wrong results.
  • The `data` parameter is for custom metadata, not the metric value. Pass extra context (order ID, category, etc.) in data. Pass the numeric measurement in metricValue.

References

  • SDK Track Patternstrack() call syntax, initialization, and package names for every supported SDK

Related skills

Forks & variants (1)

Launchdarkly Metric Instrument has 1 known copy in the catalog totaling 40 installs. They canonicalize to this original listing.

How it compares

Pick launchdarkly-metric-instrument over launchdarkly-metric-create when you already have a metric defined and only need correct SDK track() code in your application.

FAQ

What is 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 fea

When should I use 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 fea

Is launchdarkly-metric-instrument safe to install?

Review the Security Audits panel on this page before production use.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.