@microsoft/applicationinsights-cfgsync-js 0.0.2
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/browser/es5/ai.cfgsync.0.0.2.cjs.js +3678 -0
- package/browser/es5/ai.cfgsync.0.0.2.cjs.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.0.2.cjs.min.js +6 -0
- package/browser/es5/ai.cfgsync.0.0.2.cjs.min.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.0.2.gbl.js +3701 -0
- package/browser/es5/ai.cfgsync.0.0.2.gbl.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.0.2.gbl.min.js +6 -0
- package/browser/es5/ai.cfgsync.0.0.2.gbl.min.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.0.2.integrity.json +66 -0
- package/browser/es5/ai.cfgsync.0.0.2.js +3705 -0
- package/browser/es5/ai.cfgsync.0.0.2.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.0.2.min.js +6 -0
- package/browser/es5/ai.cfgsync.0.0.2.min.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.cjs.js +3678 -0
- package/browser/es5/ai.cfgsync.0.cjs.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.cjs.min.js +6 -0
- package/browser/es5/ai.cfgsync.0.cjs.min.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.gbl.js +3701 -0
- package/browser/es5/ai.cfgsync.0.gbl.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.gbl.min.js +6 -0
- package/browser/es5/ai.cfgsync.0.gbl.min.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.integrity.json +66 -0
- package/browser/es5/ai.cfgsync.0.js +3705 -0
- package/browser/es5/ai.cfgsync.0.js.map +1 -0
- package/browser/es5/ai.cfgsync.0.min.js +6 -0
- package/browser/es5/ai.cfgsync.0.min.js.map +1 -0
- package/dist/es5/applicationinsights-cfgsync-js.js +3683 -0
- package/dist/es5/applicationinsights-cfgsync-js.js.map +1 -0
- package/dist/es5/applicationinsights-cfgsync-js.min.js +6 -0
- package/dist/es5/applicationinsights-cfgsync-js.min.js.map +1 -0
- package/dist-es5/CfgSyncHelperFuncs.js +170 -0
- package/dist-es5/CfgSyncHelperFuncs.js.map +1 -0
- package/dist-es5/CfgSyncPlugin.js +385 -0
- package/dist-es5/CfgSyncPlugin.js.map +1 -0
- package/dist-es5/Interfaces/ICfgSyncCdnConfig.js +6 -0
- package/dist-es5/Interfaces/ICfgSyncCdnConfig.js.map +1 -0
- package/dist-es5/Interfaces/ICfgSyncConfig.js +6 -0
- package/dist-es5/Interfaces/ICfgSyncConfig.js.map +1 -0
- package/dist-es5/Interfaces/ICfgSyncPlugin.js +6 -0
- package/dist-es5/Interfaces/ICfgSyncPlugin.js.map +1 -0
- package/dist-es5/__DynamicConstants.js +18 -0
- package/dist-es5/__DynamicConstants.js.map +1 -0
- package/dist-es5/applicationinsights-cfgsync-js.js +7 -0
- package/dist-es5/applicationinsights-cfgsync-js.js.map +1 -0
- package/package.json +64 -0
- package/tsconfig.json +28 -0
- package/types/applicationinsights-cfgsync-js.d.ts +176 -0
- package/types/applicationinsights-cfgsync-js.namespaced.d.ts +172 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Application Insights JavaScript SDK - Properties Plugin, 0.0.2
|
|
3
|
+
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// @skip-file-minify
|
|
8
|
+
// ##############################################################
|
|
9
|
+
// AUTO GENERATED FILE: This file is Auto Generated during build.
|
|
10
|
+
// ##############################################################
|
|
11
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
12
|
+
// Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!
|
|
13
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
14
|
+
export var _DYN_FEATURE_OPT_IN = "featureOptIn"; // Count: 4
|
|
15
|
+
export var _DYN_ON_CFG_CHANGE_RECEIV0 = "onCfgChangeReceive"; // Count: 2
|
|
16
|
+
export var _DYN_NON_OVERRIDE_CONFIGS = "nonOverrideConfigs"; // Count: 2
|
|
17
|
+
export var _DYN_SCHEDULE_FETCH_TIMEO1 = "scheduleFetchTimeout"; // Count: 2
|
|
18
|
+
//# sourceMappingURL=__DynamicConstants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__DynamicConstants.js.map","sources":["__DynamicConstants.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n// @skip-file-minify\r\n// ##############################################################\r\n// AUTO GENERATED FILE: This file is Auto Generated during build.\r\n// ##############################################################\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n// Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\nexport var _DYN_FEATURE_OPT_IN = \"featureOptIn\"; // Count: 4\r\nexport var _DYN_ON_CFG_CHANGE_RECEIV0 = \"onCfgChangeReceive\"; // Count: 2\r\nexport var _DYN_NON_OVERRIDE_CONFIGS = \"nonOverrideConfigs\"; // Count: 2\r\nexport var _DYN_SCHEDULE_FETCH_TIMEO1 = \"scheduleFetchTimeout\"; // Count: 2\r\n//# sourceMappingURL=__DynamicConstants.js.map"],"names":[],"mappings":";;;;AAA4D;AAC1B;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Application Insights JavaScript SDK - Properties Plugin, 0.0.2
|
|
3
|
+
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
+
*/
|
|
5
|
+
import { CfgSyncPlugin } from "./CfgSyncPlugin";
|
|
6
|
+
export { CfgSyncPlugin };
|
|
7
|
+
//# sourceMappingURL=applicationinsights-cfgsync-js.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applicationinsights-cfgsync-js.js.map","sources":["applicationinsights-cfgsync-js.js"],"sourcesContent":["import { CfgSyncPlugin } from \"./CfgSyncPlugin\";\r\nexport { CfgSyncPlugin };\r\n//# sourceMappingURL=applicationinsights-cfgsync-js.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/applicationinsights-cfgsync-js",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Microsoft Application Insights CfgSync plugin",
|
|
5
|
+
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
6
|
+
"author": "Microsoft Application Insights Team",
|
|
7
|
+
"main": "dist/es5/applicationinsights-cfgsync-js.js",
|
|
8
|
+
"module": "dist-es5/applicationinsights-cfgsync-js.js",
|
|
9
|
+
"types": "types/applicationinsights-cfgsync-js.d.ts",
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/extensions/applicationinsights-cfgsync-js"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "npm run build:esm && npm run build:browser && npm run sri && npm run dtsgen",
|
|
17
|
+
"build:esm": "grunt cfgsync",
|
|
18
|
+
"build:browser": "rollup -c rollup.config.js --bundleConfigAsCjs",
|
|
19
|
+
"rebuild": "npm run build",
|
|
20
|
+
"test": "grunt cfgsynctests",
|
|
21
|
+
"mintest": "grunt cfgsync-mintests",
|
|
22
|
+
"lint": "tslint -p tsconfig.json",
|
|
23
|
+
"dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"Microsoft Application Insights idsync plugin\"",
|
|
24
|
+
"sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js",
|
|
25
|
+
"ai-min": "grunt cfgsync-min",
|
|
26
|
+
"ai-restore": "grunt cfgsync-restore",
|
|
27
|
+
"npm-pack": "npm pack"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@microsoft/ai-test-framework": "0.0.1",
|
|
31
|
+
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
|
|
32
|
+
"@microsoft/applicationinsights-rollup-es5": "1.0.2",
|
|
33
|
+
"@microsoft/api-extractor": "^7.18.19",
|
|
34
|
+
"typescript": "^4.9.3",
|
|
35
|
+
"tslib": "^2.0.0",
|
|
36
|
+
"grunt": "^1.5.3",
|
|
37
|
+
"grunt-cli": "^1.4.3",
|
|
38
|
+
"grunt-contrib-qunit": "^6.2.1",
|
|
39
|
+
"@nevware21/grunt-ts-plugin": "^0.4.3",
|
|
40
|
+
"@nevware21/grunt-eslint-ts": "^0.2.2",
|
|
41
|
+
"globby": "^11.0.0",
|
|
42
|
+
"magic-string": "^0.25.7",
|
|
43
|
+
"pako": "^2.0.3",
|
|
44
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
45
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
46
|
+
"@rollup/plugin-replace": "^5.0.2",
|
|
47
|
+
"rollup-plugin-cleanup": "^3.2.1",
|
|
48
|
+
"rollup": "^3.20.0",
|
|
49
|
+
"qunit": "^2.11.2",
|
|
50
|
+
"sinon": "^7.3.1"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"tslib": "*"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@microsoft/dynamicproto-js": "^2.0.2",
|
|
57
|
+
"@microsoft/applicationinsights-shims": "3.0.1",
|
|
58
|
+
"@microsoft/applicationinsights-core-js": "3.0.3",
|
|
59
|
+
"@microsoft/applicationinsights-common": "3.0.3",
|
|
60
|
+
"@nevware21/ts-utils": ">= 0.10.1 < 2.x",
|
|
61
|
+
"@nevware21/ts-async": ">= 0.3.0 < 2.x"
|
|
62
|
+
},
|
|
63
|
+
"license": "MIT"
|
|
64
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"sourceMap": true,
|
|
4
|
+
"inlineSources": true,
|
|
5
|
+
"noImplicitAny": true,
|
|
6
|
+
"module": "es6",
|
|
7
|
+
"moduleResolution": "Node",
|
|
8
|
+
"target": "es5",
|
|
9
|
+
"alwaysStrict": true,
|
|
10
|
+
"suppressImplicitAnyIndexErrors": true,
|
|
11
|
+
"allowSyntheticDefaultImports": true,
|
|
12
|
+
"importHelpers": true,
|
|
13
|
+
"noEmitHelpers": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"declarationDir": "build/types",
|
|
18
|
+
"outDir": "dist-es5",
|
|
19
|
+
"rootDir": "./src",
|
|
20
|
+
"removeComments": false
|
|
21
|
+
},
|
|
22
|
+
"include": [
|
|
23
|
+
"./src/**/*.ts"
|
|
24
|
+
],
|
|
25
|
+
"exclude": [
|
|
26
|
+
"./node_modules/**"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Microsoft Application Insights idsync plugin, 0.0.2
|
|
3
|
+
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Microsoft Application Insights Team
|
|
6
|
+
* https://github.com/microsoft/ApplicationInsights-JS#readme
|
|
7
|
+
*
|
|
8
|
+
* ---------------------------------------------------------------------------
|
|
9
|
+
* This is a single combined (rollup) declaration file for the package,
|
|
10
|
+
* if you require a namespace wrapped version it is also available.
|
|
11
|
+
* - Namespaced version: types/applicationinsights-cfgsync-js.namespaced.d.ts
|
|
12
|
+
* ---------------------------------------------------------------------------
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { BaseTelemetryPlugin } from '@microsoft/applicationinsights-core-js';
|
|
16
|
+
import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js';
|
|
17
|
+
import { IConfig } from '@microsoft/applicationinsights-common';
|
|
18
|
+
import { IConfiguration } from '@microsoft/applicationinsights-core-js';
|
|
19
|
+
import { IPlugin } from '@microsoft/applicationinsights-core-js';
|
|
20
|
+
import { IProcessTelemetryContext } from '@microsoft/applicationinsights-core-js';
|
|
21
|
+
import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
|
|
22
|
+
import { ITelemetryPluginChain } from '@microsoft/applicationinsights-core-js';
|
|
23
|
+
|
|
24
|
+
export declare class CfgSyncPlugin extends BaseTelemetryPlugin implements ICfgSyncPlugin {
|
|
25
|
+
priority: number;
|
|
26
|
+
identifier: string;
|
|
27
|
+
constructor();
|
|
28
|
+
initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
29
|
+
/**
|
|
30
|
+
* Get current configs of current instance.
|
|
31
|
+
* @param config current configs
|
|
32
|
+
*/
|
|
33
|
+
getCfg(): IConfiguration & IConfig;
|
|
34
|
+
/**
|
|
35
|
+
* Manually set configs of current instance.
|
|
36
|
+
* @param config new configs
|
|
37
|
+
*/
|
|
38
|
+
setCfg(config?: IConfiguration & IConfig): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Manually broadcast configs of current instance to all other instances.
|
|
41
|
+
* @param customDetails additional details should also be sent out to other instances
|
|
42
|
+
*/
|
|
43
|
+
sync(customDetails?: any): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Manually update event name.
|
|
46
|
+
* If current instance is the main instance, then following config changes will be sent out under this new event name.
|
|
47
|
+
* If current instance is listener instances, it will listen to event details under this new name.
|
|
48
|
+
* @param eventName new event name
|
|
49
|
+
*/
|
|
50
|
+
updateEventListenerName(eventName?: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Pause the sending/receiving of events
|
|
53
|
+
*/
|
|
54
|
+
pause(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Resume the sending/receiving of events
|
|
57
|
+
*/
|
|
58
|
+
resume(): void;
|
|
59
|
+
processTelemetry(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export declare interface ICfgSyncConfig {
|
|
63
|
+
/**
|
|
64
|
+
* Identifies whether instance should receive or broadcast config changes
|
|
65
|
+
* Default to broadcast
|
|
66
|
+
*/
|
|
67
|
+
syncMode?: ICfgSyncMode;
|
|
68
|
+
/**
|
|
69
|
+
* Identifies event name that changes will be sent out with. And all listener instances will listen to event details under this name.
|
|
70
|
+
* Default to cfgsync.
|
|
71
|
+
*/
|
|
72
|
+
customEvtName?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Identifies endpoint to get config rather than core config.
|
|
75
|
+
* Default to null.
|
|
76
|
+
* If set, any core config changes will be ignored.
|
|
77
|
+
*/
|
|
78
|
+
cfgUrl?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Identifies if fetching cdn endpoint should be blocked
|
|
81
|
+
* Default to false.
|
|
82
|
+
*/
|
|
83
|
+
blkCdnCfg?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Overrides callback function to handle event details when changes are received via eventListener.
|
|
86
|
+
*/
|
|
87
|
+
onCfgChangeReceive?: (event?: ICfgSyncEvent) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Overrides sync() function to broadcast changes.
|
|
90
|
+
*/
|
|
91
|
+
overrideSyncFn?: (config?: IConfiguration & IConfig, customDetails?: any) => boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Overrides fetch function to get config from cfgUrl.
|
|
94
|
+
*/
|
|
95
|
+
overrideFetchFn?: SendGetFunction;
|
|
96
|
+
/**
|
|
97
|
+
* Identifies configs that should NOT be changed by other instances.
|
|
98
|
+
* Default to {instrumentationKey: true, connectionString: true, endpointUrl: true }
|
|
99
|
+
*/
|
|
100
|
+
nonOverrideConfigs?: NonOverrideCfg;
|
|
101
|
+
/**
|
|
102
|
+
* Identifies time interval (in ms) that should fetch from cfgUrl.
|
|
103
|
+
* Default to 30 mins, 30*60*1000ms.
|
|
104
|
+
* If set to 0, fetch will only be called once during initialization.
|
|
105
|
+
*/
|
|
106
|
+
scheduleFetchTimeout?: number;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export declare interface ICfgSyncEvent {
|
|
110
|
+
/**
|
|
111
|
+
* Identifies config changes are expected to send out to other instances.
|
|
112
|
+
*/
|
|
113
|
+
cfg?: IConfiguration & IConfig;
|
|
114
|
+
/**
|
|
115
|
+
* Identifies additional details that are expected to send out with config changes.
|
|
116
|
+
*/
|
|
117
|
+
customDetails?: any;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export declare const enum ICfgSyncMode {
|
|
121
|
+
/**
|
|
122
|
+
* Instance will NOT receive config changes or broadcast changes
|
|
123
|
+
*/
|
|
124
|
+
None = 0,
|
|
125
|
+
/**
|
|
126
|
+
* Instance will only broadcast config changes but NOT receive changes
|
|
127
|
+
*/
|
|
128
|
+
Broadcast = 1,
|
|
129
|
+
/**
|
|
130
|
+
* Instance will only receive config changes but NOT broadcast changes
|
|
131
|
+
*/
|
|
132
|
+
Receive = 2
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export declare interface ICfgSyncPlugin {
|
|
136
|
+
/**
|
|
137
|
+
* Get current configs of current instance.
|
|
138
|
+
* @param config current configs
|
|
139
|
+
*/
|
|
140
|
+
getCfg(): IConfiguration & IConfig;
|
|
141
|
+
/**
|
|
142
|
+
* Manually set configs of current instance.
|
|
143
|
+
* @param config new configs
|
|
144
|
+
*/
|
|
145
|
+
setCfg(config?: IConfiguration & IConfig): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Manually broadcast configs of current instance to all other instances.
|
|
148
|
+
* @param customDetails additional details should also be sent out to other instances
|
|
149
|
+
*/
|
|
150
|
+
sync(customDetails?: any): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Manually update event name.
|
|
153
|
+
* If current instance is the main instance, then following config changes will be sent out under this new event name.
|
|
154
|
+
* If current instance is listener instances, it will listen to event details under this new name.
|
|
155
|
+
* @param eventName new event name
|
|
156
|
+
*/
|
|
157
|
+
updateEventListenerName(eventName?: string): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Pause the sending/receiving of events
|
|
160
|
+
*/
|
|
161
|
+
pause(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Resume the sending/receiving of events
|
|
164
|
+
*/
|
|
165
|
+
resume(): void;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export declare type NonOverrideCfg<T = IConfiguration & IConfig> = {
|
|
169
|
+
[key in keyof T]?: boolean | NonOverrideCfg<T[key]> | undefined;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export declare type OnCompleteCallback = (status: number, response?: string, isAutoSync?: boolean) => void;
|
|
173
|
+
|
|
174
|
+
export declare type SendGetFunction = (url: string, oncomplete: OnCompleteCallback, isAutoSync?: boolean) => void;
|
|
175
|
+
|
|
176
|
+
export { }
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Microsoft Application Insights idsync plugin, 0.0.2
|
|
3
|
+
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Microsoft Application Insights Team
|
|
6
|
+
* https://github.com/microsoft/ApplicationInsights-JS#readme
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare namespace ApplicationInsights {
|
|
10
|
+
import { BaseTelemetryPlugin } from '@microsoft/applicationinsights-core-js';
|
|
11
|
+
import { IAppInsightsCore } from '@microsoft/applicationinsights-core-js';
|
|
12
|
+
import { IConfig } from '@microsoft/applicationinsights-common';
|
|
13
|
+
import { IConfiguration } from '@microsoft/applicationinsights-core-js';
|
|
14
|
+
import { IPlugin } from '@microsoft/applicationinsights-core-js';
|
|
15
|
+
import { IProcessTelemetryContext } from '@microsoft/applicationinsights-core-js';
|
|
16
|
+
import { ITelemetryItem } from '@microsoft/applicationinsights-core-js';
|
|
17
|
+
import { ITelemetryPluginChain } from '@microsoft/applicationinsights-core-js';
|
|
18
|
+
|
|
19
|
+
class CfgSyncPlugin extends BaseTelemetryPlugin implements ICfgSyncPlugin {
|
|
20
|
+
priority: number;
|
|
21
|
+
identifier: string;
|
|
22
|
+
constructor();
|
|
23
|
+
initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get current configs of current instance.
|
|
26
|
+
* @param config current configs
|
|
27
|
+
*/
|
|
28
|
+
getCfg(): IConfiguration & IConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Manually set configs of current instance.
|
|
31
|
+
* @param config new configs
|
|
32
|
+
*/
|
|
33
|
+
setCfg(config?: IConfiguration & IConfig): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Manually broadcast configs of current instance to all other instances.
|
|
36
|
+
* @param customDetails additional details should also be sent out to other instances
|
|
37
|
+
*/
|
|
38
|
+
sync(customDetails?: any): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Manually update event name.
|
|
41
|
+
* If current instance is the main instance, then following config changes will be sent out under this new event name.
|
|
42
|
+
* If current instance is listener instances, it will listen to event details under this new name.
|
|
43
|
+
* @param eventName new event name
|
|
44
|
+
*/
|
|
45
|
+
updateEventListenerName(eventName?: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Pause the sending/receiving of events
|
|
48
|
+
*/
|
|
49
|
+
pause(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Resume the sending/receiving of events
|
|
52
|
+
*/
|
|
53
|
+
resume(): void;
|
|
54
|
+
processTelemetry(event: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface ICfgSyncConfig {
|
|
58
|
+
/**
|
|
59
|
+
* Identifies whether instance should receive or broadcast config changes
|
|
60
|
+
* Default to broadcast
|
|
61
|
+
*/
|
|
62
|
+
syncMode?: ICfgSyncMode;
|
|
63
|
+
/**
|
|
64
|
+
* Identifies event name that changes will be sent out with. And all listener instances will listen to event details under this name.
|
|
65
|
+
* Default to cfgsync.
|
|
66
|
+
*/
|
|
67
|
+
customEvtName?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Identifies endpoint to get config rather than core config.
|
|
70
|
+
* Default to null.
|
|
71
|
+
* If set, any core config changes will be ignored.
|
|
72
|
+
*/
|
|
73
|
+
cfgUrl?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Identifies if fetching cdn endpoint should be blocked
|
|
76
|
+
* Default to false.
|
|
77
|
+
*/
|
|
78
|
+
blkCdnCfg?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Overrides callback function to handle event details when changes are received via eventListener.
|
|
81
|
+
*/
|
|
82
|
+
onCfgChangeReceive?: (event?: ICfgSyncEvent) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Overrides sync() function to broadcast changes.
|
|
85
|
+
*/
|
|
86
|
+
overrideSyncFn?: (config?: IConfiguration & IConfig, customDetails?: any) => boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Overrides fetch function to get config from cfgUrl.
|
|
89
|
+
*/
|
|
90
|
+
overrideFetchFn?: SendGetFunction;
|
|
91
|
+
/**
|
|
92
|
+
* Identifies configs that should NOT be changed by other instances.
|
|
93
|
+
* Default to {instrumentationKey: true, connectionString: true, endpointUrl: true }
|
|
94
|
+
*/
|
|
95
|
+
nonOverrideConfigs?: NonOverrideCfg;
|
|
96
|
+
/**
|
|
97
|
+
* Identifies time interval (in ms) that should fetch from cfgUrl.
|
|
98
|
+
* Default to 30 mins, 30*60*1000ms.
|
|
99
|
+
* If set to 0, fetch will only be called once during initialization.
|
|
100
|
+
*/
|
|
101
|
+
scheduleFetchTimeout?: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface ICfgSyncEvent {
|
|
105
|
+
/**
|
|
106
|
+
* Identifies config changes are expected to send out to other instances.
|
|
107
|
+
*/
|
|
108
|
+
cfg?: IConfiguration & IConfig;
|
|
109
|
+
/**
|
|
110
|
+
* Identifies additional details that are expected to send out with config changes.
|
|
111
|
+
*/
|
|
112
|
+
customDetails?: any;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const enum ICfgSyncMode {
|
|
116
|
+
/**
|
|
117
|
+
* Instance will NOT receive config changes or broadcast changes
|
|
118
|
+
*/
|
|
119
|
+
None = 0,
|
|
120
|
+
/**
|
|
121
|
+
* Instance will only broadcast config changes but NOT receive changes
|
|
122
|
+
*/
|
|
123
|
+
Broadcast = 1,
|
|
124
|
+
/**
|
|
125
|
+
* Instance will only receive config changes but NOT broadcast changes
|
|
126
|
+
*/
|
|
127
|
+
Receive = 2
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface ICfgSyncPlugin {
|
|
131
|
+
/**
|
|
132
|
+
* Get current configs of current instance.
|
|
133
|
+
* @param config current configs
|
|
134
|
+
*/
|
|
135
|
+
getCfg(): IConfiguration & IConfig;
|
|
136
|
+
/**
|
|
137
|
+
* Manually set configs of current instance.
|
|
138
|
+
* @param config new configs
|
|
139
|
+
*/
|
|
140
|
+
setCfg(config?: IConfiguration & IConfig): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Manually broadcast configs of current instance to all other instances.
|
|
143
|
+
* @param customDetails additional details should also be sent out to other instances
|
|
144
|
+
*/
|
|
145
|
+
sync(customDetails?: any): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Manually update event name.
|
|
148
|
+
* If current instance is the main instance, then following config changes will be sent out under this new event name.
|
|
149
|
+
* If current instance is listener instances, it will listen to event details under this new name.
|
|
150
|
+
* @param eventName new event name
|
|
151
|
+
*/
|
|
152
|
+
updateEventListenerName(eventName?: string): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Pause the sending/receiving of events
|
|
155
|
+
*/
|
|
156
|
+
pause(): void;
|
|
157
|
+
/**
|
|
158
|
+
* Resume the sending/receiving of events
|
|
159
|
+
*/
|
|
160
|
+
resume(): void;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
type NonOverrideCfg<T = IConfiguration & IConfig> = {
|
|
164
|
+
[key in keyof T]?: boolean | NonOverrideCfg<T[key]> | undefined;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
type OnCompleteCallback = (status: number, response?: string, isAutoSync?: boolean) => void;
|
|
168
|
+
|
|
169
|
+
type SendGetFunction = (url: string, oncomplete: OnCompleteCallback, isAutoSync?: boolean) => void;
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
}
|