diff --git a/extensions/applicationinsights-properties-js/Tests/Unit/src/properties.tests.ts b/extensions/applicationinsights-properties-js/Tests/Unit/src/properties.tests.ts index eff8fdd04..7a2cde097 100644 --- a/extensions/applicationinsights-properties-js/Tests/Unit/src/properties.tests.ts +++ b/extensions/applicationinsights-properties-js/Tests/Unit/src/properties.tests.ts @@ -634,18 +634,20 @@ export class PropertiesTests extends AITestClass { }); this.testCase({ - name: 'User: track is triggered if user context is first time initialized', + name: 'User: track is triggered if user context is first time initialized and _disableUserInitMessage is set to false', + useFakeTimers: true, test: () => { - // setup var setCookieStub = this.sandbox.stub(this as any, "_setCookie").callsFake(() => {}); - var loggingStub = this.sandbox.stub(this.core.logger, "logInternalMessage"); - - // Act Assert.ok(setCookieStub.notCalled, 'Cookie not yet generated'); - Assert.ok(loggingStub.notCalled, 'logInternalMessage is not yet triggered'); - this.properties.initialize(this.getEmptyConfig(), this.core, []); + this.core.initialize(this.getEmptyConfig(), [this.properties]); Assert.ok(setCookieStub.called, 'Cookie generated'); + var loggingStub = this.sandbox.stub(this.core.logger, "logInternalMessage"); + Assert.ok(loggingStub.notCalled, 'logInternalMessage is not yet triggered'); + + this.core.config["disableUserInitMessage"] = false; + this.clock.tick(1000); + // Assert Assert.equal(true, this.properties.context.user.isNewUser, 'current user is a new user'); const item: ITelemetryItem = {name: 'item'}; diff --git a/extensions/applicationinsights-properties-js/src/PropertiesPlugin.ts b/extensions/applicationinsights-properties-js/src/PropertiesPlugin.ts index c24e9c7a1..842e620d9 100644 --- a/extensions/applicationinsights-properties-js/src/PropertiesPlugin.ts +++ b/extensions/applicationinsights-properties-js/src/PropertiesPlugin.ts @@ -126,7 +126,7 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr _distributedTraceCtx = null; _previousTraceCtx = null; _context = null; - _disableUserInitMessage = false; + _disableUserInitMessage = true; } function _populateDefaults(config: IConfiguration & IConfig) { @@ -139,7 +139,7 @@ export default class PropertiesPlugin extends BaseTelemetryPlugin implements IPr if (config.storagePrefix){ utlSetStoragePrefix(config.storagePrefix); } - _disableUserInitMessage = config.disableUserInitMessage || false; + _disableUserInitMessage = config.disableUserInitMessage === false ? false : true; _extensionConfig = ctx.getExtCfg(identifier, _defaultConfig); // Test hook to allow accessing the internal values -- explicitly not defined as an available property on the class