Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.
This repository was archived by the owner on May 30, 2024. It is now read-only.

Calls to track not populating an experiment with data #271

@alexdmiller

Description

@alexdmiller

Describe the bug

I created a feature flag, a metric, and an experiment which uses that feature flag and metric. I am not able to consistently log metrics to my experiment using client.track(...) when there is a time delay between evaluating the feature flag and tracking the metric.

To reproduce

The following code fails to populate the experiment with data.

import * as LaunchDarkly from 'launchdarkly-node-server-sdk';

const LD_KEY = '...';
const DELAY = 30000; // 30 seconds

(async () => {
  const context: LaunchDarkly.LDContext = {
    kind: 'user',
    key: `user-key-alex`,
    firstName: 'Alex',
    lastName: 'Miller',
    email: 'alexmiller@gmail.com',
  };
  const client = LaunchDarkly.init(LD_KEY, { stream: false });
  await client.waitForInitialization();
  await client.variation('myFeature', context, false);

  // Pause between evaluating feature flag and tracking metric
  await new Promise(resolve => setTimeout(resolve, DELAY));

  client.track('myMetric', context, null, 10);
  await client.flush();
  client.close();
})();

However, if I change DELAY to DELAY = 10000 (10 seconds), then the experiment is populated with data.

Expected behavior

I would not expect a time delay between evaluating a feature flag and tracking a metric to have an impact on whether the data shows up in the experiment.

SDK version

launchdarkly-node-server-sdk@7.0.0

Language version, developer tools

Node v14.19.3

OS/platform

MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions