Skip to content

Commit

Permalink
[Main] v3.1.x change Disable UserAgent config to true by default #2028 (
Browse files Browse the repository at this point in the history
#2231)

* Update PropertiesPlugin.ts

* Update properties.tests.ts

* change test
  • Loading branch information
siyuniu-ms authored Jan 9, 2024
1 parent ef0dd4e commit efcfc02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit efcfc02

Please sign in to comment.