diff --git a/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts b/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts index e11aae210..04743ad3c 100644 --- a/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts +++ b/shared/AppInsightsCore/Tests/Unit/src/ApplicationInsightsCore.Tests.ts @@ -256,6 +256,25 @@ export class ApplicationInsightsCoreTests extends AITestClass { } }); + this.testCase({ + name: "ApplicationInsightsCore: PerfMgr should be created as expected", + test: () => { + let channelPlugin = new TestChannelPlugin(); + const appInsightsCore = new AppInsightsCore(); + appInsightsCore.initialize( + { + instrumentationKey: "testIkey", + channels: [[channelPlugin]], + enablePerfMgr: true + } as IConfiguration, + + []); + let perfMgr = appInsightsCore.getPerfMgr(); + Assert.ok(perfMgr, "perfMgr should be created without customized createPerfMgr function"); + } + }); + + this.testCase({ name: "ApplicationInsightsCore: Initialization initializes setNextPlugin", diff --git a/shared/AppInsightsCore/src/JavaScriptSDK/AppInsightsCore.ts b/shared/AppInsightsCore/src/JavaScriptSDK/AppInsightsCore.ts index bf778af42..008fbf7b7 100644 --- a/shared/AppInsightsCore/src/JavaScriptSDK/AppInsightsCore.ts +++ b/shared/AppInsightsCore/src/JavaScriptSDK/AppInsightsCore.ts @@ -1299,7 +1299,9 @@ export class AppInsightsCore im let enablePerfMgr = details.cfg.enablePerfMgr; if (enablePerfMgr) { let createPerfMgr = details.cfg.createPerfMgr; - if (prevCfgPerfMgr !== createPerfMgr) { + // for preCfgPerfMgr = createPerfMgr = null + // initial createPerfMgr function should be _createPerfManager + if ((prevCfgPerfMgr !== createPerfMgr) || !prevCfgPerfMgr) { if (!createPerfMgr) { createPerfMgr = _createPerfManager; }