Skip to content

Commit f44e8ab

Browse files
update
1 parent 170759a commit f44e8ab

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

articles/azure-app-configuration/feature-management-javascript-reference.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,11 +669,15 @@ const featureManager = new FeatureManager(featureProvider, { onFeatureEvaluated
669669
670670
The JavaScript feature management library provide extension packages that integration with [Application Insights](/azure/azure-monitor/app/app-insights-overview) sdks.
671671
672+
The Application Insights offers different sdks for [web](https://www.npmjs.com/package/@microsoft/applicationinsights-web) and [Node.js](https://www.npmjs.com/package/applicationinsights) scenarios. Please select the correct extension packages for your application.
673+
674+
### [Browser](#tab/browser)
675+
672676
If your application runs in the browser, install the `"@microsoft/feature-management-applicationinsights-browser"` package. The following example shows how you can create a built-in Application Insights telemetry publisher and register it to the feature manager.
673677
674678
``` javascript
675679
import { ApplicationInsights } from "@microsoft/applicationinsights-web"
676-
import { createTelemetryPublisher } from "@microsoft/feature-management-applicationinsights-browser"
680+
import { createTelemetryPublisher, trackEvent } from "@microsoft/feature-management-applicationinsights-browser"
677681

678682
const appInsights = new ApplicationInsights({ config: {
679683
connectionString: "<your-connection-string>"
@@ -683,8 +687,36 @@ appInsights.loadAppInsights();
683687
...
684688
const telemetryPublisher = createTelemetryPublisher(appInsights);
685689
const featureManager = new FeatureManager(ffProvider, { onFeatureEvaluated: telemetryPublisher});
690+
691+
...
692+
// Emit a custom event with targeting id attached.
693+
trackEvent(appInsights, TARGETING_ID, {name: "TestEvent"}, {"Tag": "Some Value"});
686694
```
687695
696+
### [Node.js](#tab/nodejs)
697+
698+
If your application runs in the Node.js, install the `"@microsoft/feature-management-applicationinsights-node"` package. The following example shows how you can create a built-in Application Insights telemetry publisher and register it to the feature manager.
699+
700+
``` javascript
701+
import ApplicationInsights from "applicationinsights"
702+
import { createTelemetryPublisher, trackEvent } from "@microsoft/feature-management-applicationinsights-node"
703+
704+
const appInsights = new ApplicationInsights({ config: {
705+
connectionString: "<your-connection-string>"
706+
}});
707+
appInsights.loadAppInsights();
708+
709+
...
710+
const telemetryPublisher = createTelemetryPublisher(appInsights.defaultClient);
711+
const featureManager = new FeatureManager(ffProvider, { onFeatureEvaluated: telemetryPublisher});
712+
713+
...
714+
// Emit a custom event with targeting id attached.
715+
trackEvent(appInsights.defaultClient, TARGETING_ID, {name: "TestEvent"});
716+
```
717+
718+
---
719+
688720
The telemetry publisher sends `FeatureEvaluation` custom events to the Application Insights when a feature flag enabled with telemetry is evaluated. The custom event follows the [FeatureEvaluationEvent](https://github.com/microsoft/FeatureManagement/tree/main/Schema/FeatureEvaluationEvent) schema.
689721
690722
:::zone-end

0 commit comments

Comments
 (0)