From f0a3671f3861e7994b8dc3a61f8b5724542375c9 Mon Sep 17 00:00:00 2001 From: Karlie-777 <79606506+Karlie-777@users.noreply.github.com> Date: Tue, 1 Oct 2024 11:19:04 -0700 Subject: [PATCH] update (#2426) --- .../Unit/src/ApplicationInsightsCore.Tests.ts | 19 +++++++++++++++++++ .../src/JavaScriptSDK/AppInsightsCore.ts | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) 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; }