@microsoft/feature-management-applicationinsights-browser
Advanced tools
@@ -11,7 +11,7 @@ // Copyright (c) Microsoft Corporation. | ||
| const eventProperties = { | ||
| "FeatureName": event.feature?.id, | ||
| "FeatureName": event.feature ? event.feature.id : "", | ||
| "Enabled": event.enabled.toString(), | ||
| // Ensure targetingId is string so that it will be placed in customDimensions | ||
| "TargetingId": event.targetingId?.toString(), | ||
| "Variant": event.variant?.name, | ||
| "TargetingId": event.targetingId ? event.targetingId.toString() : "", | ||
| "Variant": event.variant ? event.variant.name : "", | ||
| "VariantAssignmentReason": event.variantAssignmentReason, | ||
@@ -43,3 +43,3 @@ }; | ||
| // Ensure targetingId is string so that it will be placed in customDimensions | ||
| properties["TargetingId"] = targetingId?.toString(); | ||
| properties["TargetingId"] = targetingId ? targetingId.toString() : ""; | ||
| client.trackEvent(event, properties); | ||
@@ -46,0 +46,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"telemetry.js","sources":["../../src/telemetry.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EvaluationResult } from \"@microsoft/feature-management\";\nimport { ApplicationInsights } from \"@microsoft/applicationinsights-web\";\nimport { IEventTelemetry } from \"@microsoft/applicationinsights-web\";\n\n/**\n * Creates a telemetry publisher that sends feature evaluation events to Application Insights.\n * @param client The Application Insights telemetry client.\n * @returns A callback function that takes an evaluation result and tracks an event with the evaluation details.\n */\nexport function createTelemetryPublisher(client: ApplicationInsights): (event: EvaluationResult) => void {\n return (event: EvaluationResult) => {\n const eventProperties = {\n \"FeatureName\": event.feature?.id,\n \"Enabled\": event.enabled.toString(),\n // Ensure targetingId is string so that it will be placed in customDimensions\n \"TargetingId\": event.targetingId?.toString(),\n \"Variant\": event.variant?.name,\n \"VariantAssignmentReason\": event.variantAssignmentReason,\n };\n\n const metadata = event.feature?.telemetry?.metadata;\n if (metadata) {\n for (const key in metadata) {\n if (!(key in eventProperties)) {\n eventProperties[key] = metadata[key];\n }\n }\n }\n\n client.trackEvent({ name: \"FeatureEvaluation\" }, eventProperties);\n };\n}\n\n/**\n * Tracks a custom event using Application Insights, ensuring that the \"TargetingId\"\n * is included in the custom properties. If the \"TargetingId\" already exists in\n * the provided custom properties, it will be overwritten.\n *\n * @param client The Application Insights client instance used to track the event.\n * @param targetingId The unique targeting identifier that will be included in the custom properties.\n * @param event The event telemetry object to be tracked, containing event details.\n * @param customProperties (Optional) Additional properties to include in the event telemetry.\n */\nexport function trackEvent(client: ApplicationInsights, targetingId: string, event: IEventTelemetry, customProperties?: {[key: string]: any}): void {\n const properties = customProperties ? { ...customProperties } : {};\n // Ensure targetingId is string so that it will be placed in customDimensions\n properties[\"TargetingId\"] = targetingId?.toString();\n client.trackEvent(event, properties);\n}\n"],"names":[],"mappings":"AAAA;AACA;AAMA;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,MAA2B,EAAA;IAChE,OAAO,CAAC,KAAuB,KAAI;AAC/B,QAAA,MAAM,eAAe,GAAG;AACpB,YAAA,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE;AAChC,YAAA,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;;AAEnC,YAAA,aAAa,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE;AAC5C,YAAA,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI;YAC9B,yBAAyB,EAAE,KAAK,CAAC,uBAAuB;SAC3D,CAAC;QAEF,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;QACpD,IAAI,QAAQ,EAAE;AACV,YAAA,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;AACxB,gBAAA,IAAI,EAAE,GAAG,IAAI,eAAe,CAAC,EAAE;oBAC3B,eAAe,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;iBACxC;aACJ;SACJ;QAED,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,eAAe,CAAC,CAAC;AACtE,KAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;AASG;AACG,SAAU,UAAU,CAAC,MAA2B,EAAE,WAAmB,EAAE,KAAsB,EAAE,gBAAuC,EAAA;AACxI,IAAA,MAAM,UAAU,GAAG,gBAAgB,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,EAAE,CAAC;;IAEnE,UAAU,CAAC,aAAa,CAAC,GAAG,WAAW,EAAE,QAAQ,EAAE,CAAC;AACpD,IAAA,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACzC;;;;"} | ||
| {"version":3,"file":"telemetry.js","sources":["../../src/telemetry.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EvaluationResult } from \"@microsoft/feature-management\";\nimport { ApplicationInsights } from \"@microsoft/applicationinsights-web\";\nimport { IEventTelemetry } from \"@microsoft/applicationinsights-web\";\n\n/**\n * Creates a telemetry publisher that sends feature evaluation events to Application Insights.\n * @param client The Application Insights telemetry client.\n * @returns A callback function that takes an evaluation result and tracks an event with the evaluation details.\n */\nexport function createTelemetryPublisher(client: ApplicationInsights): (event: EvaluationResult) => void {\n return (event: EvaluationResult) => {\n const eventProperties = {\n \"FeatureName\": event.feature ? event.feature.id : \"\",\n \"Enabled\": event.enabled.toString(),\n // Ensure targetingId is string so that it will be placed in customDimensions\n \"TargetingId\": event.targetingId ? event.targetingId.toString() : \"\",\n \"Variant\": event.variant ? event.variant.name : \"\",\n \"VariantAssignmentReason\": event.variantAssignmentReason,\n };\n\n const metadata = event.feature?.telemetry?.metadata;\n if (metadata) {\n for (const key in metadata) {\n if (!(key in eventProperties)) {\n eventProperties[key] = metadata[key];\n }\n }\n }\n\n client.trackEvent({ name: \"FeatureEvaluation\" }, eventProperties);\n };\n}\n\n/**\n * Tracks a custom event using Application Insights, ensuring that the \"TargetingId\"\n * is included in the custom properties. If the \"TargetingId\" already exists in\n * the provided custom properties, it will be overwritten.\n *\n * @param client The Application Insights client instance used to track the event.\n * @param targetingId The unique targeting identifier that will be included in the custom properties.\n * @param event The event telemetry object to be tracked, containing event details.\n * @param customProperties (Optional) Additional properties to include in the event telemetry.\n */\nexport function trackEvent(client: ApplicationInsights, targetingId: string, event: IEventTelemetry, customProperties?: {[key: string]: any}): void {\n const properties = customProperties ? { ...customProperties } : {};\n // Ensure targetingId is string so that it will be placed in customDimensions\n properties[\"TargetingId\"] = targetingId ? targetingId.toString() : \"\";\n client.trackEvent(event, properties);\n}\n"],"names":[],"mappings":"AAAA;AACA;AAMA;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,MAA2B,EAAA;IAChE,OAAO,CAAC,KAAuB,KAAI;AAC/B,QAAA,MAAM,eAAe,GAAG;AACpB,YAAA,aAAa,EAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE;AACpD,YAAA,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;;AAEnC,YAAA,aAAa,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE;AACpE,YAAA,SAAS,EAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE;YAClD,yBAAyB,EAAE,KAAK,CAAC,uBAAuB;SAC3D,CAAC;QAEF,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;QACpD,IAAI,QAAQ,EAAE;AACV,YAAA,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;AACxB,gBAAA,IAAI,EAAE,GAAG,IAAI,eAAe,CAAC,EAAE;oBAC3B,eAAe,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;iBACxC;aACJ;SACJ;QAED,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,eAAe,CAAC,CAAC;AACtE,KAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;AASG;AACG,SAAU,UAAU,CAAC,MAA2B,EAAE,WAAmB,EAAE,KAAsB,EAAE,gBAAuC,EAAA;AACxI,IAAA,MAAM,UAAU,GAAG,gBAAgB,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,EAAE,CAAC;;AAEnE,IAAA,UAAU,CAAC,aAAa,CAAC,GAAG,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC;AACtE,IAAA,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACzC;;;;"} |
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| const VERSION = "2.0.0-preview.1"; | ||
| const VERSION = "2.0.0-preview.2"; | ||
| export { VERSION }; | ||
| //# sourceMappingURL=version.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const VERSION = \"2.0.0-preview.1\";\n"],"names":[],"mappings":"AAAA;AACA;AAEO,MAAM,OAAO,GAAG;;;;"} | ||
| {"version":3,"file":"version.js","sources":["../../src/version.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const VERSION = \"2.0.0-preview.2\";\n"],"names":[],"mappings":"AAAA;AACA;AAEO,MAAM,OAAO,GAAG;;;;"} |
@@ -17,7 +17,7 @@ (function (global, factory) { | ||
| const eventProperties = { | ||
| "FeatureName": event.feature?.id, | ||
| "FeatureName": event.feature ? event.feature.id : "", | ||
| "Enabled": event.enabled.toString(), | ||
| // Ensure targetingId is string so that it will be placed in customDimensions | ||
| "TargetingId": event.targetingId?.toString(), | ||
| "Variant": event.variant?.name, | ||
| "TargetingId": event.targetingId ? event.targetingId.toString() : "", | ||
| "Variant": event.variant ? event.variant.name : "", | ||
| "VariantAssignmentReason": event.variantAssignmentReason, | ||
@@ -49,3 +49,3 @@ }; | ||
| // Ensure targetingId is string so that it will be placed in customDimensions | ||
| properties["TargetingId"] = targetingId?.toString(); | ||
| properties["TargetingId"] = targetingId ? targetingId.toString() : ""; | ||
| client.trackEvent(event, properties); | ||
@@ -56,3 +56,3 @@ } | ||
| // Licensed under the MIT license. | ||
| const VERSION = "2.0.0-preview.1"; | ||
| const VERSION = "2.0.0-preview.2"; | ||
@@ -59,0 +59,0 @@ exports.VERSION = VERSION; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../src/telemetry.ts","../../src/version.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EvaluationResult } from \"@microsoft/feature-management\";\nimport { ApplicationInsights } from \"@microsoft/applicationinsights-web\";\nimport { IEventTelemetry } from \"@microsoft/applicationinsights-web\";\n\n/**\n * Creates a telemetry publisher that sends feature evaluation events to Application Insights.\n * @param client The Application Insights telemetry client.\n * @returns A callback function that takes an evaluation result and tracks an event with the evaluation details.\n */\nexport function createTelemetryPublisher(client: ApplicationInsights): (event: EvaluationResult) => void {\n return (event: EvaluationResult) => {\n const eventProperties = {\n \"FeatureName\": event.feature?.id,\n \"Enabled\": event.enabled.toString(),\n // Ensure targetingId is string so that it will be placed in customDimensions\n \"TargetingId\": event.targetingId?.toString(),\n \"Variant\": event.variant?.name,\n \"VariantAssignmentReason\": event.variantAssignmentReason,\n };\n\n const metadata = event.feature?.telemetry?.metadata;\n if (metadata) {\n for (const key in metadata) {\n if (!(key in eventProperties)) {\n eventProperties[key] = metadata[key];\n }\n }\n }\n\n client.trackEvent({ name: \"FeatureEvaluation\" }, eventProperties);\n };\n}\n\n/**\n * Tracks a custom event using Application Insights, ensuring that the \"TargetingId\"\n * is included in the custom properties. If the \"TargetingId\" already exists in\n * the provided custom properties, it will be overwritten.\n *\n * @param client The Application Insights client instance used to track the event.\n * @param targetingId The unique targeting identifier that will be included in the custom properties.\n * @param event The event telemetry object to be tracked, containing event details.\n * @param customProperties (Optional) Additional properties to include in the event telemetry.\n */\nexport function trackEvent(client: ApplicationInsights, targetingId: string, event: IEventTelemetry, customProperties?: {[key: string]: any}): void {\n const properties = customProperties ? { ...customProperties } : {};\n // Ensure targetingId is string so that it will be placed in customDimensions\n properties[\"TargetingId\"] = targetingId?.toString();\n client.trackEvent(event, properties);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const VERSION = \"2.0.0-preview.1\";\n"],"names":[],"mappings":";;;;;;IAAA;IACA;IAMA;;;;IAIG;IACG,SAAU,wBAAwB,CAAC,MAA2B,EAAA;QAChE,OAAO,CAAC,KAAuB,KAAI;IAC/B,QAAA,MAAM,eAAe,GAAG;IACpB,YAAA,aAAa,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE;IAChC,YAAA,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;;IAEnC,YAAA,aAAa,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE;IAC5C,YAAA,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI;gBAC9B,yBAAyB,EAAE,KAAK,CAAC,uBAAuB;aAC3D,CAAC;YAEF,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;YACpD,IAAI,QAAQ,EAAE;IACV,YAAA,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;IACxB,gBAAA,IAAI,EAAE,GAAG,IAAI,eAAe,CAAC,EAAE;wBAC3B,eAAe,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;qBACxC;iBACJ;aACJ;YAED,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,eAAe,CAAC,CAAC;IACtE,KAAC,CAAC;IACN,CAAC;IAED;;;;;;;;;IASG;IACG,SAAU,UAAU,CAAC,MAA2B,EAAE,WAAmB,EAAE,KAAsB,EAAE,gBAAuC,EAAA;IACxI,IAAA,MAAM,UAAU,GAAG,gBAAgB,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,EAAE,CAAC;;QAEnE,UAAU,CAAC,aAAa,CAAC,GAAG,WAAW,EAAE,QAAQ,EAAE,CAAC;IACpD,IAAA,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACzC;;ICnDA;IACA;AAEO,UAAM,OAAO,GAAG;;;;;;;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../src/telemetry.ts","../../src/version.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EvaluationResult } from \"@microsoft/feature-management\";\nimport { ApplicationInsights } from \"@microsoft/applicationinsights-web\";\nimport { IEventTelemetry } from \"@microsoft/applicationinsights-web\";\n\n/**\n * Creates a telemetry publisher that sends feature evaluation events to Application Insights.\n * @param client The Application Insights telemetry client.\n * @returns A callback function that takes an evaluation result and tracks an event with the evaluation details.\n */\nexport function createTelemetryPublisher(client: ApplicationInsights): (event: EvaluationResult) => void {\n return (event: EvaluationResult) => {\n const eventProperties = {\n \"FeatureName\": event.feature ? event.feature.id : \"\",\n \"Enabled\": event.enabled.toString(),\n // Ensure targetingId is string so that it will be placed in customDimensions\n \"TargetingId\": event.targetingId ? event.targetingId.toString() : \"\",\n \"Variant\": event.variant ? event.variant.name : \"\",\n \"VariantAssignmentReason\": event.variantAssignmentReason,\n };\n\n const metadata = event.feature?.telemetry?.metadata;\n if (metadata) {\n for (const key in metadata) {\n if (!(key in eventProperties)) {\n eventProperties[key] = metadata[key];\n }\n }\n }\n\n client.trackEvent({ name: \"FeatureEvaluation\" }, eventProperties);\n };\n}\n\n/**\n * Tracks a custom event using Application Insights, ensuring that the \"TargetingId\"\n * is included in the custom properties. If the \"TargetingId\" already exists in\n * the provided custom properties, it will be overwritten.\n *\n * @param client The Application Insights client instance used to track the event.\n * @param targetingId The unique targeting identifier that will be included in the custom properties.\n * @param event The event telemetry object to be tracked, containing event details.\n * @param customProperties (Optional) Additional properties to include in the event telemetry.\n */\nexport function trackEvent(client: ApplicationInsights, targetingId: string, event: IEventTelemetry, customProperties?: {[key: string]: any}): void {\n const properties = customProperties ? { ...customProperties } : {};\n // Ensure targetingId is string so that it will be placed in customDimensions\n properties[\"TargetingId\"] = targetingId ? targetingId.toString() : \"\";\n client.trackEvent(event, properties);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const VERSION = \"2.0.0-preview.2\";\n"],"names":[],"mappings":";;;;;;IAAA;IACA;IAMA;;;;IAIG;IACG,SAAU,wBAAwB,CAAC,MAA2B,EAAA;QAChE,OAAO,CAAC,KAAuB,KAAI;IAC/B,QAAA,MAAM,eAAe,GAAG;IACpB,YAAA,aAAa,EAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE;IACpD,YAAA,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;;IAEnC,YAAA,aAAa,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE;IACpE,YAAA,SAAS,EAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE;gBAClD,yBAAyB,EAAE,KAAK,CAAC,uBAAuB;aAC3D,CAAC;YAEF,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC;YACpD,IAAI,QAAQ,EAAE;IACV,YAAA,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE;IACxB,gBAAA,IAAI,EAAE,GAAG,IAAI,eAAe,CAAC,EAAE;wBAC3B,eAAe,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;qBACxC;iBACJ;aACJ;YAED,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,eAAe,CAAC,CAAC;IACtE,KAAC,CAAC;IACN,CAAC;IAED;;;;;;;;;IASG;IACG,SAAU,UAAU,CAAC,MAA2B,EAAE,WAAmB,EAAE,KAAsB,EAAE,gBAAuC,EAAA;IACxI,IAAA,MAAM,UAAU,GAAG,gBAAgB,GAAG,EAAE,GAAG,gBAAgB,EAAE,GAAG,EAAE,CAAC;;IAEnE,IAAA,UAAU,CAAC,aAAa,CAAC,GAAG,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC;IACtE,IAAA,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IACzC;;ICnDA;IACA;AAEO,UAAM,OAAO,GAAG;;;;;;;;;;"} |
+1
-1
| { | ||
| "name": "@microsoft/feature-management-applicationinsights-browser", | ||
| "version": "2.0.0-preview.1", | ||
| "version": "2.0.0-preview.2", | ||
| "description": "Feature Management Application Insights Plugin for Browser provides a solution for sending feature flag evaluation events produced by the Feature Management library.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/umd/index.js", |
+1
-1
@@ -24,4 +24,4 @@ import { EvaluationResult } from '@microsoft/feature-management'; | ||
| declare const VERSION = "2.0.0-preview.1"; | ||
| declare const VERSION = "2.0.0-preview.2"; | ||
| export { VERSION, createTelemetryPublisher, trackEvent }; |
20729
2.85%