Skip to content

Conversation

zhiyuanliang-ms
Copy link
Contributor

@zhiyuanliang-ms zhiyuanliang-ms commented Sep 14, 2024

Usage:

import { ApplicationInsights } from "@microsoft/applicationinsights-web"
import { FeatureManager, ConfigurationObjectFeatureFlagProvider } from "@microsoft/feature-management";
import { trackEvent, createTelemetryPublisher } from "@microsoft/feature-management-applicationinsights-browser";

const appInsights = new ApplicationInsights({ config: {
    connectionString: CONNECTION_STRING
}});
appInsights.loadAppInsights();

const publishTelemetry = createTelemetryPublisher(appInsights);
const provider = new ConfigurationObjectFeatureFlagProvider(jsonObject);
const featureManager = new FeatureManager(provider, {onFeatureEvaluated: publishTelemetry});

// FeatureEvaluation event will be emitted when a feature flag is evaluated
featureManager.getVariant("TestFeature", {userId : TARGETING_ID}).then((variant) => { /* do something*/ });

// Emit a custom event with targeting id attached.
trackEvent(appInsights, TARGETING_ID, {name: "TestEvent"}, {"Tag": "Some Value"});

@zhiyuanliang-ms zhiyuanliang-ms force-pushed the zhiyuanliang/appinsights-browser-package branch from d3aa37c to b3ccd9d Compare September 14, 2024 13:57
@zhiyuanliang-ms zhiyuanliang-ms merged commit e546a47 into preview Oct 11, 2024
3 checks passed
@zhiyuanliang-ms zhiyuanliang-ms deleted the zhiyuanliang/appinsights-browser-package branch October 11, 2024 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants