Skip to content

Commit 95a321a

Browse files
committed
[OTel-Sdk] Merge the 1ds-core-js changes from [Beta] for traceApi
- Address dependency issues
1 parent d7fe4e3 commit 95a321a

48 files changed

Lines changed: 831 additions & 772 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AISKU/Tests/Unit/src/CdnThrottle.tests.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
import { AppInsightsSku } from "../../../src/AISku";
2-
import { ApplicationInsightsContainer } from "../../../src/ApplicationInsightsContainer";
3-
import { IApplicationInsights } from "../../../src/IApplicationInsights";
4-
import { Snippet } from "../../../src/Snippet";
52
import { AITestClass, Assert, IFetchArgs, PollingAssert } from "@microsoft/ai-test-framework";
6-
import { IConfig, IConfiguration, LoggingSeverity, _eInternalMessageId, IThrottleInterval, IThrottleLimit, IThrottleMgrConfig } from "@microsoft/otel-core-js";
7-
import { SinonSpy } from "sinon";
8-
import { createSnippetV5 } from "./testSnippetV5";
9-
import { CdnFeatureMode, FeatureOptInMode, getGlobal, getGlobalInst, isFunction, newId } from "@microsoft/otel-core-js";
10-
import { createSnippetV6 } from "./testSnippetV6";
3+
import { IConfig, IConfiguration, _eInternalMessageId, IThrottleMgrConfig } from "@microsoft/otel-core-js";
4+
import { CdnFeatureMode, FeatureOptInMode, getGlobal, getGlobalInst } from "@microsoft/otel-core-js";
115
import { CfgSyncPlugin, ICfgSyncConfig, ICfgSyncMode } from "@microsoft/applicationinsights-cfgsync-js";
12-
import { createSyncPromise, doAwait } from "@nevware21/ts-async";
13-
import { ICfgSyncCdnConfig } from "@microsoft/applicationinsights-cfgsync-js/src/Interfaces/ICfgSyncCdnConfig";
14-
const ApplicationInsights = AppInsightsSku;
6+
import { createSyncPromise } from "@nevware21/ts-async";
157

168

179
const TestInstrumentationKey = 'b7170927-2d1c-44f1-acec-59f4e1751c11';
@@ -87,11 +79,11 @@ const sampleConfig = {
8779

8880
export class CdnThrottle extends AITestClass {
8981
private _ai: AppInsightsSku;
90-
private getAi: ApplicationInsights;
82+
private getAi: AppInsightsSku;
9183
private _config: IConfiguration | IConfig;
9284
private identifier: string;
9385
private fetchStub: any;
94-
init: ApplicationInsights;
86+
init: AppInsightsSku;
9587
private res: any;
9688
private _fetch: any;
9789
loggingSpy: any;
@@ -185,7 +177,7 @@ export class CdnThrottle extends AITestClass {
185177
}, 0);
186178
});
187179
this.fetchStub = this.sandbox.spy((doc as any), "fetch");
188-
this.init = new ApplicationInsights({
180+
this.init = new AppInsightsSku({
189181
config: {
190182
instrumentationKey: TestInstrumentationKey,
191183
featureOptIn : {["iKeyUsage"]: {mode: FeatureOptInMode.disable}},
@@ -240,7 +232,7 @@ export class CdnThrottle extends AITestClass {
240232
});
241233

242234
this.fetchStub = this.sandbox.spy((doc as any), "fetch");
243-
this.init = new ApplicationInsights({
235+
this.init = new AppInsightsSku({
244236
config: this._config,
245237
});
246238
this.init.loadAppInsights();
@@ -283,7 +275,7 @@ export class CdnThrottle extends AITestClass {
283275
};
284276

285277
this.fetchStub = this.sandbox.spy((doc as any), "fetch");
286-
this.init = new ApplicationInsights({
278+
this.init = new AppInsightsSku({
287279
config: noSetconfig,
288280
});
289281
this.init.loadAppInsights();
@@ -341,7 +333,7 @@ export class CdnThrottle extends AITestClass {
341333
}}
342334
};
343335

344-
this.init = new ApplicationInsights({
336+
this.init = new AppInsightsSku({
345337
config: config,
346338
});
347339
this.init.loadAppInsights();
@@ -382,7 +374,7 @@ export class CdnThrottle extends AITestClass {
382374
}, 0);
383375
});
384376
this.fetchStub = this.sandbox.spy((doc as any), "fetch");
385-
this.init = new ApplicationInsights({
377+
this.init = new AppInsightsSku({
386378
config: {
387379
instrumentationKey: TestInstrumentationKey,
388380
extensionConfig : {["AppInsightsCfgSyncPlugin"] : {
@@ -426,7 +418,7 @@ export class CdnThrottle extends AITestClass {
426418
}, 0);
427419
});
428420
this.fetchStub = this.sandbox.spy((doc as any), "fetch");
429-
this.init = new ApplicationInsights({
421+
this.init = new AppInsightsSku({
430422
config: {
431423
instrumentationKey: TestInstrumentationKey,
432424
extensionConfig : {["AppInsightsCfgSyncPlugin"] : {

AISKU/Tests/Unit/src/SnippetInitialization.Tests.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
BreezeChannelIdentifier, ContextTagKeys, DistributedTracingModes, IConfig, IDependencyTelemetry, RequestHeaders,
1212
utlRemoveSessionStorage, utlSetSessionStorage
1313
} from "@microsoft/otel-core-js";
14-
import { getGlobal } from "@microsoft/applicationinsights-shims";
1514
import { IPropTelemetryContext } from "@microsoft/applicationinsights-properties-js";
1615
import { dumpObj, isPromiseLike, objHasOwnProperty, strSubstring } from "@nevware21/ts-utils";
1716
import { AppInsightsSku } from "../../../src/AISku";
@@ -1060,12 +1059,12 @@ export class SnippetInitializationTests extends AITestClass {
10601059
});
10611060
}
10621061

1063-
private _initializeSnippet(snippet: Snippet): IApplicationInsights {
1062+
private _initializeSnippet(snippet: Snippet): AppInsightsSku {
10641063
try {
10651064
//this.useFakeServer = false;
10661065

10671066
// Call the initialization
1068-
((ApplicationInsightsContainer.getAppInsights(snippet, snippet.version)) as IApplicationInsights);
1067+
((ApplicationInsightsContainer.getAppInsights(snippet, snippet.version)) as AppInsightsSku);
10691068

10701069
// Setup Sinon stuff
10711070
const appInsights: AppInsightsSku = (snippet as any).appInsights;

AISKU/Tests/Unit/src/ThrottleSentMessage.tests.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ import { ApplicationInsightsContainer } from "../../../src/ApplicationInsightsCo
33
import { IApplicationInsights } from "../../../src/IApplicationInsights";
44
import { Snippet } from "../../../src/Snippet";
55
import { AITestClass, Assert } from "@microsoft/ai-test-framework";
6-
import { IConfig, IConfiguration, LoggingSeverity, _eInternalMessageId, IThrottleInterval, IThrottleLimit, IThrottleMgrConfig } from "@microsoft/otel-core-js";
7-
import { SinonSpy } from "sinon";
6+
import { IConfig, IConfiguration, _eInternalMessageId, IThrottleInterval, IThrottleLimit, IThrottleMgrConfig } from "@microsoft/otel-core-js";
87
import { createSnippetV5 } from "./testSnippetV5";
98
import { FeatureOptInMode, newId } from "@microsoft/otel-core-js";
109
import { createSnippetV6 } from "./testSnippetV6";
11-
const ApplicationInsights = AppInsightsSku;
1210

1311
const TestInstrumentationKey = 'b7170927-2d1c-44f1-acec-59f4e1751c11';
1412

@@ -27,7 +25,7 @@ const tconfig = {
2725

2826
export class ThrottleSentMessage extends AITestClass {
2927
private _ai: IApplicationInsights;
30-
private getAi: ApplicationInsights;
28+
private getAi: AppInsightsSku;
3129
private _config: IConfiguration | IConfig;
3230
private _logger;
3331

@@ -65,7 +63,7 @@ export class ThrottleSentMessage extends AITestClass {
6563
this.useFakeServer = false;
6664
this._config = this._getTestConfig();
6765

68-
const init = new ApplicationInsights({
66+
const init = new AppInsightsSku({
6967
config: this._config
7068
});
7169

@@ -197,7 +195,7 @@ export class ThrottleSentMessage extends AITestClass {
197195
let config = this._getTestConfig();
198196
config.throttleMgrCfg= {[_eInternalMessageId.InstrumentationKeyDeprecation]:tconfig, [_eInternalMessageId.DefaultThrottleMsgKey]:tconfig};
199197
config.featureOptIn = {["iKeyUsage"]: {mode: FeatureOptInMode.disable}}
200-
let init = new ApplicationInsights({
198+
let init = new AppInsightsSku({
201199
config: config
202200
});
203201

@@ -257,12 +255,12 @@ export class ThrottleSentMessage extends AITestClass {
257255
}
258256

259257

260-
private _initializeSnippet(snippet: Snippet): ApplicationInsights {
258+
private _initializeSnippet(snippet: Snippet): AppInsightsSku {
261259
try {
262260
//this.useFakeServer = false;
263261

264262
// Call the initialization
265-
((ApplicationInsightsContainer.getAppInsights(snippet, snippet.version)) as IApplicationInsights);
263+
((ApplicationInsightsContainer.getAppInsights(snippet, snippet.version)) as AppInsightsSku);
266264

267265
// Setup Sinon stuff
268266
const appInsights: AppInsightsSku = (snippet as any).appInsights;

AISKU/Tests/Unit/src/applicationinsights.e2e.tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class ApplicationInsightsTests extends AITestClass {
5151

5252
// Context
5353
private tagKeys = new ContextTagKeys();
54-
private _config;
54+
private _config: IConfiguration;
5555
private _appId: string;
5656
private _ctx: any;
5757

AISKU/Tests/Unit/src/sanitizer.e2e.tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppInsightsSku as ApplicationInsights } from "../../../src/AISku";
1+
import { AppInsightsSku, AppInsightsSku as ApplicationInsights } from "../../../src/AISku";
22
import { IApplicationInsights } from "../../../src/IApplicationInsights";
33
import { Sender } from "@microsoft/applicationinsights-channel-js";
44
import { AITestClass, Assert, PollingAssert } from "@microsoft/ai-test-framework";

AISKU/Tests/Unit/src/sender.e2e.tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppInsightsSku as ApplicationInsights } from "../../../src/AISku";
1+
import { AppInsightsSku, AppInsightsSku as ApplicationInsights } from "../../../src/AISku";
22
import { IApplicationInsights } from "../../../src/IApplicationInsights";
33
import { Sender } from "@microsoft/applicationinsights-channel-js";
44
import { BreezeChannelIdentifier, utlGetSessionStorage, utlRemoveSessionStorage } from "@microsoft/otel-core-js";

AISKU/Tests/es6-module-type-check/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"module": "dist-es5/applicationinsights-test-module-type-check.js",
1111
"types": "types/applicationinsights-test-module-type-check.d.ts",
1212
"scripts": {
13-
"clean": "git clean -xdf",
13+
"clean": "node -e \"['dist','dist-es5','build','browser','types','temp','rush-logs'].forEach(d=>{try{require('fs').rmSync(d,{recursive:true,force:true})}catch(e){}})\"",
14+
"clean-modules": "node -e \"['node_modules'].forEach(d=>{try{require('fs').rmSync(d,{recursive:true,force:true})}catch(e){}})\"",
15+
"full-clean": "npm run clean-modules && npm run clean && git clean -xdf",
1416
"build": "tsc --project tsconfig.json --noEmit",
1517
"rebuild": "npm run build",
1618
"test": "",

AISKU/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"url": "https://github.com/microsoft/ApplicationInsights-JS"
1414
},
1515
"scripts": {
16-
"clean": "rimraf dist dist-es5 build browser types temp rush-logs",
16+
"clean": "node -e \"['dist','dist-es5','build','browser','types','temp','rush-logs'].forEach(d=>{try{require('fs').rmSync(d,{recursive:true,force:true})}catch(e){}})\"",
17+
"full-clean-es6-tests": "cd Tests/es6-module-type-check && npm run full-clean && cd ../..",
18+
"full-clean": "npm run full-clean-es6-tests && git clean -xdf",
1719
"build": "npm run build:esm && npm run build:browser && npm run sri && npm run dtsgen",
1820
"build:esm": "grunt aisku",
1921
"build:browser": "rollup -c rollup.config.js --bundleConfigAsCjs",
@@ -42,8 +44,8 @@
4244
"grunt-cli": "^1.4.3",
4345
"@nevware21/ts-async": ">= 0.5.5 < 2.x",
4446
"grunt-rollup": "^12.0.0",
45-
"@nevware21/grunt-ts-plugin": "^0.5.1",
46-
"@nevware21/grunt-eslint-ts": "^0.5.1",
47+
"@nevware21/grunt-ts-plugin": "^0.5.2",
48+
"@nevware21/grunt-eslint-ts": "^0.5.2",
4749
"globby": "^11.0.0",
4850
"magic-string": "^0.25.7",
4951
"pako": "^2.0.3",
@@ -73,7 +75,7 @@
7375
"@microsoft/otel-core-js": "0.0.1-alpha",
7476
"@microsoft/applicationinsights-dependencies-js": "3.3.11",
7577
"@microsoft/applicationinsights-properties-js": "3.3.11",
76-
"@nevware21/ts-utils": ">= 0.12.6 < 2.x",
78+
"@nevware21/ts-utils": ">= 0.13.0 < 2.x",
7779
"@nevware21/ts-async": ">= 0.5.5 < 2.x"
7880
},
7981
"license": "MIT"

AISKU/src/ApplicationInsightsContainer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { throwUnsupported } from "@nevware21/ts-utils";
22
import { AppInsightsSku } from "./AISku";
3-
import { IApplicationInsights } from "./IApplicationInsights";
43
import { Snippet } from "./Snippet";
54

65
export class ApplicationInsightsContainer {
76

8-
public static getAppInsights(snippet: Snippet, version: number) : IApplicationInsights {
7+
public static getAppInsights(snippet: Snippet, version: number) : AppInsightsSku {
98
const theSku = new AppInsightsSku(snippet);
109

1110
// Two target scenarios:

AISKULight/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"types": "types/applicationinsights-web-basic.d.ts",
1010
"sideEffects": false,
1111
"scripts": {
12-
"clean": "rimraf dist dist-es5 build browser types temp rush-logs",
12+
"clean": "node -e \"['dist','dist-es5','build','browser','types','temp','rush-logs'].forEach(d=>{try{require('fs').rmSync(d,{recursive:true,force:true})}catch(e){}})\"",
13+
"full-clean": "git clean -xdf",
1314
"build": "npm run build:esm && npm run build:browser && npm run sri && npm run dtsgen",
1415
"build:esm": "grunt aiskulite",
1516
"build:browser": "rollup -c rollup.config.js --bundleConfigAsCjs",
@@ -37,8 +38,8 @@
3738
"grunt": "^1.5.3",
3839
"grunt-cli": "^1.4.3",
3940
"grunt-rollup": "^12.0.0",
40-
"@nevware21/grunt-ts-plugin": "^0.5.1",
41-
"@nevware21/grunt-eslint-ts": "^0.5.1",
41+
"@nevware21/grunt-ts-plugin": "^0.5.2",
42+
"@nevware21/grunt-eslint-ts": "^0.5.2",
4243
"globby": "^11.0.0",
4344
"magic-string": "^0.25.7",
4445
"pako": "^2.0.3",
@@ -62,7 +63,7 @@
6263
"@microsoft/applicationinsights-shims": "3.0.1",
6364
"@microsoft/applicationinsights-channel-js": "3.3.11",
6465
"@microsoft/otel-core-js": "0.0.1-alpha",
65-
"@nevware21/ts-utils": ">= 0.12.6 < 2.x",
66+
"@nevware21/ts-utils": ">= 0.13.0 < 2.x",
6667
"@nevware21/ts-async": ">= 0.5.5 < 2.x"
6768
},
6869
"license": "MIT"

0 commit comments

Comments
 (0)