@microsoft/feature-management-applicationinsights-browser 2.0.0-preview.1 → 2.0.0-preview.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/dist/esm/telemetry.js +10 -18
- package/dist/esm/telemetry.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/umd/index.js +13 -23
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
- package/types/index.d.ts +2 -2
package/README.md
CHANGED
package/dist/esm/telemetry.js
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
|
+
import { createFeatureEvaluationEventProperties } from '@microsoft/feature-management';
|
|
2
|
+
|
|
1
3
|
// Copyright (c) Microsoft Corporation.
|
|
2
4
|
// Licensed under the MIT license.
|
|
5
|
+
const TARGETING_ID = "TargetingId";
|
|
6
|
+
const FEATURE_EVALUATION_EVENT_NAME = "FeatureEvaluation";
|
|
3
7
|
/**
|
|
4
8
|
* Creates a telemetry publisher that sends feature evaluation events to Application Insights.
|
|
5
9
|
* @param client The Application Insights telemetry client.
|
|
6
10
|
* @returns A callback function that takes an evaluation result and tracks an event with the evaluation details.
|
|
7
11
|
*/
|
|
8
12
|
function createTelemetryPublisher(client) {
|
|
9
|
-
return (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"Enabled": event.enabled.toString(),
|
|
13
|
-
// Ensure targetingId is string so that it will be placed in customDimensions
|
|
14
|
-
"TargetingId": event.targetingId?.toString(),
|
|
15
|
-
"Variant": event.variant?.name,
|
|
16
|
-
"VariantAssignmentReason": event.variantAssignmentReason,
|
|
17
|
-
};
|
|
18
|
-
const metadata = event.feature?.telemetry?.metadata;
|
|
19
|
-
if (metadata) {
|
|
20
|
-
for (const key in metadata) {
|
|
21
|
-
if (!(key in eventProperties)) {
|
|
22
|
-
eventProperties[key] = metadata[key];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
13
|
+
return (result) => {
|
|
14
|
+
if (result.feature === undefined) {
|
|
15
|
+
return;
|
|
25
16
|
}
|
|
26
|
-
|
|
17
|
+
const eventProperties = createFeatureEvaluationEventProperties(result);
|
|
18
|
+
client.trackEvent({ name: FEATURE_EVALUATION_EVENT_NAME }, eventProperties);
|
|
27
19
|
};
|
|
28
20
|
}
|
|
29
21
|
/**
|
|
@@ -39,7 +31,7 @@ function createTelemetryPublisher(client) {
|
|
|
39
31
|
function trackEvent(client, targetingId, event, customProperties) {
|
|
40
32
|
const properties = customProperties ? { ...customProperties } : {};
|
|
41
33
|
// Ensure targetingId is string so that it will be placed in customDimensions
|
|
42
|
-
properties[
|
|
34
|
+
properties[TARGETING_ID] = targetingId ? targetingId.toString() : "";
|
|
43
35
|
client.trackEvent(event, properties);
|
|
44
36
|
}
|
|
45
37
|
|
|
@@ -1 +1 @@
|
|
|
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\";\
|
|
1
|
+
{"version":3,"file":"telemetry.js","sources":["../../src/telemetry.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EvaluationResult, createFeatureEvaluationEventProperties } from \"@microsoft/feature-management\";\nimport { ApplicationInsights, IEventTelemetry } from \"@microsoft/applicationinsights-web\";\n\nconst TARGETING_ID = \"TargetingId\";\nconst FEATURE_EVALUATION_EVENT_NAME = \"FeatureEvaluation\";\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): (result: EvaluationResult) => void {\n return (result: EvaluationResult) => {\n if (result.feature === undefined) {\n return;\n }\n\n const eventProperties = createFeatureEvaluationEventProperties(result);\n client.trackEvent({ name: FEATURE_EVALUATION_EVENT_NAME }, 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[TARGETING_ID] = targetingId ? targetingId.toString() : \"\";\n client.trackEvent(event, properties);\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAKA,MAAM,YAAY,GAAG,aAAa;AAClC,MAAM,6BAA6B,GAAG,mBAAmB;AAEzD;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,MAA2B,EAAA;IAChE,OAAO,CAAC,MAAwB,KAAI;AAChC,QAAA,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;YAC9B;;AAGJ,QAAA,MAAM,eAAe,GAAG,sCAAsC,CAAC,MAAM,CAAC;QACtE,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,6BAA6B,EAAE,EAAE,eAAe,CAAC;AAC/E,KAAC;AACL;AAEA;;;;;;;;;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;;AAElE,IAAA,UAAU,CAAC,YAAY,CAAC,GAAG,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE;AACpE,IAAA,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC;AACxC;;;;"}
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
+
{"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.3\";\n"],"names":[],"mappings":"AAAA;AACA;AAEO,MAAM,OAAO,GAAG;;;;"}
|
package/dist/umd/index.js
CHANGED
|
@@ -1,35 +1,25 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FeatureManagementApplicationInsights = {}));
|
|
5
|
-
})(this, (function (exports) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@microsoft/feature-management')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@microsoft/feature-management'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FeatureManagementApplicationInsights = {}, global.featureManagement));
|
|
5
|
+
})(this, (function (exports, featureManagement) { 'use strict';
|
|
6
6
|
|
|
7
7
|
// Copyright (c) Microsoft Corporation.
|
|
8
8
|
// Licensed under the MIT license.
|
|
9
|
+
const TARGETING_ID = "TargetingId";
|
|
10
|
+
const FEATURE_EVALUATION_EVENT_NAME = "FeatureEvaluation";
|
|
9
11
|
/**
|
|
10
12
|
* Creates a telemetry publisher that sends feature evaluation events to Application Insights.
|
|
11
13
|
* @param client The Application Insights telemetry client.
|
|
12
14
|
* @returns A callback function that takes an evaluation result and tracks an event with the evaluation details.
|
|
13
15
|
*/
|
|
14
16
|
function createTelemetryPublisher(client) {
|
|
15
|
-
return (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"Enabled": event.enabled.toString(),
|
|
19
|
-
// Ensure targetingId is string so that it will be placed in customDimensions
|
|
20
|
-
"TargetingId": event.targetingId?.toString(),
|
|
21
|
-
"Variant": event.variant?.name,
|
|
22
|
-
"VariantAssignmentReason": event.variantAssignmentReason,
|
|
23
|
-
};
|
|
24
|
-
const metadata = event.feature?.telemetry?.metadata;
|
|
25
|
-
if (metadata) {
|
|
26
|
-
for (const key in metadata) {
|
|
27
|
-
if (!(key in eventProperties)) {
|
|
28
|
-
eventProperties[key] = metadata[key];
|
|
29
|
-
}
|
|
30
|
-
}
|
|
17
|
+
return (result) => {
|
|
18
|
+
if (result.feature === undefined) {
|
|
19
|
+
return;
|
|
31
20
|
}
|
|
32
|
-
|
|
21
|
+
const eventProperties = featureManagement.createFeatureEvaluationEventProperties(result);
|
|
22
|
+
client.trackEvent({ name: FEATURE_EVALUATION_EVENT_NAME }, eventProperties);
|
|
33
23
|
};
|
|
34
24
|
}
|
|
35
25
|
/**
|
|
@@ -45,13 +35,13 @@
|
|
|
45
35
|
function trackEvent(client, targetingId, event, customProperties) {
|
|
46
36
|
const properties = customProperties ? { ...customProperties } : {};
|
|
47
37
|
// Ensure targetingId is string so that it will be placed in customDimensions
|
|
48
|
-
properties[
|
|
38
|
+
properties[TARGETING_ID] = targetingId ? targetingId.toString() : "";
|
|
49
39
|
client.trackEvent(event, properties);
|
|
50
40
|
}
|
|
51
41
|
|
|
52
42
|
// Copyright (c) Microsoft Corporation.
|
|
53
43
|
// Licensed under the MIT license.
|
|
54
|
-
const VERSION = "2.0.0-preview.
|
|
44
|
+
const VERSION = "2.0.0-preview.3";
|
|
55
45
|
|
|
56
46
|
exports.VERSION = VERSION;
|
|
57
47
|
exports.createTelemetryPublisher = createTelemetryPublisher;
|
package/dist/umd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\";\
|
|
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, createFeatureEvaluationEventProperties } from \"@microsoft/feature-management\";\nimport { ApplicationInsights, IEventTelemetry } from \"@microsoft/applicationinsights-web\";\n\nconst TARGETING_ID = \"TargetingId\";\nconst FEATURE_EVALUATION_EVENT_NAME = \"FeatureEvaluation\";\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): (result: EvaluationResult) => void {\n return (result: EvaluationResult) => {\n if (result.feature === undefined) {\n return;\n }\n\n const eventProperties = createFeatureEvaluationEventProperties(result);\n client.trackEvent({ name: FEATURE_EVALUATION_EVENT_NAME }, 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[TARGETING_ID] = 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.3\";\n"],"names":["createFeatureEvaluationEventProperties"],"mappings":";;;;;;IAAA;IACA;IAKA,MAAM,YAAY,GAAG,aAAa;IAClC,MAAM,6BAA6B,GAAG,mBAAmB;IAEzD;;;;IAIG;IACG,SAAU,wBAAwB,CAAC,MAA2B,EAAA;QAChE,OAAO,CAAC,MAAwB,KAAI;IAChC,QAAA,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;gBAC9B;;IAGJ,QAAA,MAAM,eAAe,GAAGA,wDAAsC,CAAC,MAAM,CAAC;YACtE,MAAM,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,6BAA6B,EAAE,EAAE,eAAe,CAAC;IAC/E,KAAC;IACL;IAEA;;;;;;;;;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;;IAElE,IAAA,UAAU,CAAC,YAAY,CAAC,GAAG,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE;IACpE,IAAA,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC;IACxC;;ICxCA;IACA;AAEO,UAAM,OAAO,GAAG;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/feature-management-applicationinsights-browser",
|
|
3
|
-
"version": "2.0.0-preview.
|
|
3
|
+
"version": "2.0.0-preview.3",
|
|
4
4
|
"description": "Feature Management Application Insights Plugin for Browser provides a solution for sending feature flag evaluation events produced by the Feature Management library.",
|
|
5
5
|
"main": "./dist/umd/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@microsoft/applicationinsights-web": "^3.3.2",
|
|
45
|
-
"@microsoft/feature-management": "
|
|
45
|
+
"@microsoft/feature-management": "2.0.0-preview.3"
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
package/types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ApplicationInsights, IEventTelemetry } from '@microsoft/applicationinsi
|
|
|
6
6
|
* @param client The Application Insights telemetry client.
|
|
7
7
|
* @returns A callback function that takes an evaluation result and tracks an event with the evaluation details.
|
|
8
8
|
*/
|
|
9
|
-
declare function createTelemetryPublisher(client: ApplicationInsights): (
|
|
9
|
+
declare function createTelemetryPublisher(client: ApplicationInsights): (result: EvaluationResult) => void;
|
|
10
10
|
/**
|
|
11
11
|
* Tracks a custom event using Application Insights, ensuring that the "TargetingId"
|
|
12
12
|
* is included in the custom properties. If the "TargetingId" already exists in
|
|
@@ -21,6 +21,6 @@ declare function trackEvent(client: ApplicationInsights, targetingId: string, ev
|
|
|
21
21
|
[key: string]: any;
|
|
22
22
|
}): void;
|
|
23
23
|
|
|
24
|
-
declare const VERSION = "2.0.0-preview.
|
|
24
|
+
declare const VERSION = "2.0.0-preview.3";
|
|
25
25
|
|
|
26
26
|
export { VERSION, createTelemetryPublisher, trackEvent };
|