Community生产力与协作github.com

launchdarkly/launchdarkly-metric-instrument

通过在代码库中添加 track() 调用来埋点 LaunchDarkly 指标事件。当用户想要连接事件、为指标埋点操作、为功能添加跟踪或确认事件已流入 LaunchDarkly 时使用。

launchdarkly-metric-instrument 是什么?

该技能用于在代码库中为 LaunchDarkly 指标事件进行埋点,具体方式是通过添加 track() 调用来实现。它适用于以下场景:用户需要将特定操作与 LaunchDarkly 指标关联起来,为功能添加跟踪以分析使用情况,或验证事件是否成功传输至 LaunchDarkly。该技能支持多种编程语言和框架,并提供了清晰的步骤指导,包括安装所需 SDK、引入相关模块以及编写 track() 调用代码。通过使用该技能,开发者能够高效地为其应用程序集成可观察性和分析能力,从而基于实际用户行为数据做出更优决策。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/launchdarkly/agent-skills/tree/main/skills/launchdarkly-metric-instrument

Installed? Explore more 生产力与协作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

launchdarkly-metric-instrument 是做什么的?

通过添加 track() 调用,在代码库中对 LaunchDarkly 指标事件进行埋点。当用户需要连接事件、为指标埋点操作、为功能添加跟踪或确认事件已流入 LaunchDarkly 时使用。

概述

该技能帮助开发者在代码中快速添加 LaunchDarkly 指标事件,以跟踪关键用户行为或系统操作。通过调用 track() 方法,您可以将自定义事件发送到 LaunchDarkly,用于分析功能使用情况、衡量实验结果或监控业务 KPI。

使用场景

  • 为用户注册、购买等关键业务流程添加跟踪
  • 为 A/B 测试配置指标事件
  • 验证事件是否成功发送到 LaunchDarkly

前提条件

  • 已安装 LaunchDarkly SDK(例如 launchdarkly-node-server-sdk)
  • 已配置 LaunchDarkly 客户端,具有有效的 SDK 密钥

如何使用

  1. 在项目中引入 LaunchDarkly 客户端:
const LaunchDarkly = require('launchdarkly-node-server-sdk');

const client = LaunchDarkly.init('YOUR_SDK_KEY');
  1. 在需要跟踪的操作处调用 track() 方法:
const user = {
  key: 'user-key-123',
  name: '张三',
  email: '[email protected]'
};

client.track('purchase-completed', user, { value: 99.99, currency: 'CNY' });
  1. 确保在应用关闭前刷新并关闭客户端:
client.flush();
client.close();

事件验证

您可以在 LaunchDarkly 控制台的“Data Export”或“Events”部分查看已发送的事件,以确认数据已正确流入。

支持的 SDK 语言

  • Node.js
  • Python
  • Java
  • Go
  • .NET
  • 以及其他官方 SDK

注意事项

  • 确保 track() 调用在用户上下文中执行(即提供了有效的 user 对象)
  • 可选地传递自定义数据(如度量值),以便在分析时使用
  • 合理使用事件名称,避免过度重复,防止 API 调用限制

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

launchdarkly/aiconfig-agent-graphs

DEPRECATED redirect — this skill was renamed to agent-graphs. Do not use this skill; invoke agent-graphs instead. Kept only so old references to aiconfig-agent-graphs still point users to the new name.

launchdarkly/aiconfig-ai-metrics

DEPRECATED redirect — this skill was renamed to built-in-metrics. Do not use this skill; invoke built-in-metrics instead. Kept only so old references to aiconfig-ai-metrics still point users to the new name.

launchdarkly/aiconfig-create

DEPRECATED redirect — this skill was renamed to configs-create. Do not use this skill; invoke configs-create instead. Kept only so old references to aiconfig-create still point users to the new name.

launchdarkly/aiconfig-custom-metrics

DEPRECATED redirect — this skill was renamed to custom-metrics. Do not use this skill; invoke custom-metrics instead. Kept only so old references to aiconfig-custom-metrics still point users to the new name.

launchdarkly/aiconfig-migrate

DEPRECATED redirect — this skill was renamed to migrate. Do not use this skill; invoke migrate instead. Kept only so old references to aiconfig-migrate still point users to the new name.

launchdarkly/aiconfig-online-evals

DEPRECATED redirect — this skill was renamed to online-evals. Do not use this skill; invoke online-evals instead. Kept only so old references to aiconfig-online-evals still point users to the new name.

launchdarkly/aiconfig-projects

DEPRECATED redirect — this skill was renamed to projects. Do not use this skill; invoke projects instead. Kept only so old references to aiconfig-projects still point users to the new name.

launchdarkly/aiconfig-snippets

DEPRECATED redirect — this skill was renamed to snippets. Do not use this skill; invoke snippets instead. Kept only so old references to aiconfig-snippets still point users to the new name.

launchdarkly/aiconfig-targeting

DEPRECATED redirect — this skill was renamed to configs-targeting. Do not use this skill; invoke configs-targeting instead. Kept only so old references to aiconfig-targeting still point users to the new name.

launchdarkly/aiconfig-tools

DEPRECATED redirect — this skill was renamed to tools. Do not use this skill; invoke tools instead. Kept only so old references to aiconfig-tools still point users to the new name.

launchdarkly/aiconfig-update

DEPRECATED redirect — this skill was renamed to configs-update. Do not use this skill; invoke configs-update instead. Kept only so old references to aiconfig-update still point users to the new name.

launchdarkly/aiconfig-variations

DEPRECATED redirect — this skill was renamed to configs-variations. Do not use this skill; invoke configs-variations instead. Kept only so old references to aiconfig-variations still point users to the new name.

launchdarkly/apply

Apply LaunchDarkly SDK onboarding: install dependency (or dual-SDK pair), configure env and secrets with consent, add init at entrypoint(s), verify compile. Nested under sdk-install; next is run.

launchdarkly/detect

Detect repository stack for LaunchDarkly SDK onboarding: languages, frameworks, package managers, monorepo targets, entrypoints, existing LD usage. Nested under sdk-install; next is plan.

launchdarkly/first-flag

Create a boolean first flag, add evaluation, toggle on/off for end-to-end proof. Parent onboarding Step 6; uses MCP, API, or ldcli; optional flag-create skill.

launchdarkly/launchdarkly-experiment-setup

Set up and run experiments in LaunchDarkly. Create experiments with metrics, treatments, and flag config, start iterations to collect data, swap design between iterations, and stop with a winner.

launchdarkly/launchdarkly-flag-cleanup

Safely remove a feature flag from code while preserving production behavior. Use when the user wants to remove a flag from code, delete flag references, or create a PR that hardcodes the winning variation after a rollout is complete.

launchdarkly/launchdarkly-flag-create

Create and configure LaunchDarkly feature flags in a way that fits the existing codebase. Use when the user wants to create a new flag, wrap code in a flag, add a feature toggle, or set up an experiment. Guides exploration of existing patterns before creating.

launchdarkly/launchdarkly-flag-discovery

Audit your LaunchDarkly feature flags to understand the landscape, find stale or launched flags, and assess removal readiness. Use when the user asks about flag debt, stale flags, cleanup candidates, flag health, or wants to understand their flag inventory.

launchdarkly/launchdarkly-flag-targeting

Control LaunchDarkly feature flag targeting including toggling flags on/off, percentage rollouts, targeting rules, individual targets, and copying flag configurations between environments. Use when the user wants to change who sees a flag, roll out to a percentage, add targeting rules, or promote config between environments.

相关技能