Harshit Metrics
SDK

Revenue & Feature Flags

Track revenue events and feature flag exposures for analytics.

Revenue tracking

Track financial transactions with structured data.

trackRevenue(payload)

metrics.trackRevenue({
  amount: 49.99,
  currency: "USD",
  orderId: "ord_abc123",
  productId: "plan_pro",
  metadata: {
    coupon: "LAUNCH20",
    billingPeriod: "annual",
  },
});

Parameters

FieldTypeRequiredDescription
amountnumberTransaction amount
currencystringISO currency code (USD, EUR, INR, etc.)
orderIdstringNoYour order/transaction ID
productIdstringNoProduct or plan identifier
metadataobjectNoAdditional key-value data

Event fired: revenue

Use cases

  • Subscription payments: Track plan upgrades, renewals, downgrades
  • E-commerce: Track purchases, refunds
  • In-app purchases: Track virtual goods, credits

Feature flag tracking

Track which feature flag variants users are exposed to. Essential for A/B testing analysis.

trackFeatureFlag(flagName, variant, metadata?)

metrics.trackFeatureFlag("new_checkout_flow", "variant_b", {
  source: "launchdarkly",
});

Parameters

FieldTypeRequiredDescription
flagNamestringThe name of the feature flag
variantstringThe variant assigned to this user
metadataobjectNoAdditional context

Event fired: feature_flag

Example: A/B test with conversion tracking

// Record the variant exposure
metrics.trackFeatureFlag("pricing_page_redesign", "control");

// Later, when the user converts
metrics.track("plan_selected", {
  metadata: {
    plan: "pro",
    pricingVariant: "control",
  },
});

You can then analyze conversion rates per variant in your dashboard by filtering events by the flagName metadata.

On this page