Skip to content

Commit 325fbef

Browse files
update
1 parent 08c037c commit 325fbef

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
export { createTelemetryPublisher, trackEvent, createTargetingTelemetryInitializer } from "./telemetry.js";
4+
export { createTargetingTelemetryInitializer, createTelemetryPublisher, trackEvent } from "./telemetry.js";
55
export { VERSION } from "./version.js";

src/feature-management-applicationinsights-browser/src/telemetry.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
import { EvaluationResult, createFeatureEvaluationEventProperties, TargetingContextAccessor } from "@microsoft/feature-management";
4+
import { EvaluationResult, createFeatureEvaluationEventProperties, ITargetingContextAccessor } from "@microsoft/feature-management";
55
import { ApplicationInsights, IEventTelemetry, ITelemetryItem } from "@microsoft/applicationinsights-web";
66

77
const TARGETING_ID = "TargetingId";
@@ -45,9 +45,9 @@ export function trackEvent(client: ApplicationInsights, targetingId: string, eve
4545
* @param targetingContextAccessor The accessor function to get the targeting context.
4646
* @returns A telemetry initializer that attaches targeting id to telemetry items.
4747
*/
48-
export function createTargetingTelemetryInitializer(targetingContextAccessor: TargetingContextAccessor): (item: ITelemetryItem) => void {
48+
export function createTargetingTelemetryInitializer(targetingContextAccessor: ITargetingContextAccessor): (item: ITelemetryItem) => void {
4949
return (item: ITelemetryItem) => {
50-
const targetingContext = targetingContextAccessor();
50+
const targetingContext = targetingContextAccessor.getTargetingContext();
5151
if (targetingContext?.userId === undefined) {
5252
console.warn("Targeting id is undefined.");
5353
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
export { createTelemetryPublisher, trackEvent, createTargetingTelemetryProcessor } from "./telemetry.js";
4+
export { createTargetingTelemetryProcessor, createTelemetryPublisher, trackEvent } from "./telemetry.js";
55
export { VERSION } from "./version.js";

src/feature-management-applicationinsights-node/src/telemetry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
import { EvaluationResult, createFeatureEvaluationEventProperties, TargetingContextAccessor } from "@microsoft/feature-management";
4+
import { EvaluationResult, createFeatureEvaluationEventProperties, ITargetingContextAccessor } from "@microsoft/feature-management";
55
import { TelemetryClient, Contracts } from "applicationinsights";
66

77
const TARGETING_ID = "TargetingId";
@@ -45,14 +45,14 @@ export function trackEvent(client: TelemetryClient, targetingId: string, event:
4545
* @param targetingContextAccessor The accessor function to get the targeting context.
4646
* @returns A telemetry processor that attaches targeting id to telemetry envelopes.
4747
*/
48-
export function createTargetingTelemetryProcessor(targetingContextAccessor: TargetingContextAccessor): (envelope: Contracts.EnvelopeTelemetry) => boolean {
48+
export function createTargetingTelemetryProcessor(targetingContextAccessor: ITargetingContextAccessor): (envelope: Contracts.EnvelopeTelemetry) => boolean {
4949
return (envelope: Contracts.EnvelopeTelemetry) => {
50-
const targetingContext = targetingContextAccessor();
50+
const targetingContext = targetingContextAccessor.getTargetingContext();
5151
if (targetingContext?.userId === undefined) {
5252
console.warn("Targeting id is undefined.");
5353
}
5454
envelope.data.baseData = envelope.data.baseData || {};
55-
envelope.data.baseData.properties = {...envelope.data.baseData.properties, [TARGETING_ID]: targetingContext.userId};
55+
envelope.data.baseData.properties = {...envelope.data.baseData.properties, [TARGETING_ID]: targetingContext?.userId || ""};
5656
return true; // If a telemetry processor returns false, that telemetry item isn't sent.
5757
};
5858
}

0 commit comments

Comments
 (0)