Skip to content

Commit f6d60c1

Browse files
update
1 parent 325fbef commit f6d60c1

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,3 +413,5 @@ examples/**/**/package-lock.json
413413

414414
# playwright test result
415415
test-results
416+
417+
**/public

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ export function trackEvent(client: ApplicationInsights, targetingId: string, eve
4848
export function createTargetingTelemetryInitializer(targetingContextAccessor: ITargetingContextAccessor): (item: ITelemetryItem) => void {
4949
return (item: ITelemetryItem) => {
5050
const targetingContext = targetingContextAccessor.getTargetingContext();
51-
if (targetingContext?.userId === undefined) {
52-
console.warn("Targeting id is undefined.");
51+
if (targetingContext !== undefined) {
52+
if (targetingContext?.userId === undefined) {
53+
console.warn("Targeting id is undefined.");
54+
}
55+
item.data = {...item.data, [TARGETING_ID]: targetingContext?.userId || ""};
5356
}
54-
item.data = {...item.data, [TARGETING_ID]: targetingContext?.userId || ""};
5557
};
5658
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ export function trackEvent(client: TelemetryClient, targetingId: string, event:
4848
export function createTargetingTelemetryProcessor(targetingContextAccessor: ITargetingContextAccessor): (envelope: Contracts.EnvelopeTelemetry) => boolean {
4949
return (envelope: Contracts.EnvelopeTelemetry) => {
5050
const targetingContext = targetingContextAccessor.getTargetingContext();
51-
if (targetingContext?.userId === undefined) {
52-
console.warn("Targeting id is undefined.");
51+
if (targetingContext !== undefined) {
52+
if (targetingContext?.userId === undefined) {
53+
console.warn("Targeting id is undefined.");
54+
}
55+
envelope.data.baseData = envelope.data.baseData || {};
56+
envelope.data.baseData.properties = {...envelope.data.baseData.properties, [TARGETING_ID]: targetingContext?.userId || ""};
5357
}
54-
envelope.data.baseData = envelope.data.baseData || {};
55-
envelope.data.baseData.properties = {...envelope.data.baseData.properties, [TARGETING_ID]: targetingContext?.userId || ""};
56-
return true; // If a telemetry processor returns false, that telemetry item isn't sent.
58+
return true;
5759
};
5860
}

0 commit comments

Comments
 (0)