Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pageViewData: check for duration in part C data #836

Merged
merged 2 commits into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,54 @@ export class SenderTests extends TestClass {
}
});

this.testCase({
name: "AppInsightsTests: AppInsights Envelope created for Page View with duration in customProperties Part C",
test: () => {
// setup
let inputEnvelope: ITelemetryItem = {
name: "test",
time: new Date("2018-06-12").toISOString(),
iKey: "iKey",
ext: {
"user": {
"localId": "TestId",
"authId": "AuthenticatedId",
"id": "TestId"
},
"trace": {
"traceID": "1528B5FF-6455-4657-BE77-E6664CAC72DC",
"parentID": "1528B5FF-6455-4657-BE77-E6664CACEEEE"
}
},
tags: [{"ai.user.accountId": "TestAccountId"}],
baseType: "PageviewData",
baseData: {
"name": "Page View Name",
"uri": "https://fakeUri.com",
properties: {
"property1": "val1",
"property2": "val2",
},
measurements: {
"measurement1": 50.0,
"measurement2": 1.3,
}
},
data: {
"duration": 300000
}
};

// Act
let appInsightsEnvelope = Sender.constructEnvelope(inputEnvelope, this._instrumentationKey, null);
let baseData = appInsightsEnvelope.data.baseData;

// Assert duration
let resultDuration = baseData.duration;
Assert.equal("00:05:00.000", resultDuration);
}
});

this.testCase({
name: 'Envelope: custom properties are put into envelope for Exception data type',
test: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,14 @@ export class PageViewEnvelopeCreator extends EnvelopeCreator {
// Since duration is not part of the domain properties in Common Schema, extract it from part C
let duration = undefined;
if (!CoreUtils.isNullOrUndefined(telemetryItem.baseData) &&
!CoreUtils.isNullOrUndefined(telemetryItem.baseData.properties)) {
!CoreUtils.isNullOrUndefined(telemetryItem.baseData.properties) &&
!CoreUtils.isNullOrUndefined(telemetryItem.baseData.properties.duration)) { // from part B properties
duration = telemetryItem.baseData.properties.duration;
delete telemetryItem.baseData.properties.duration;
} else if (!CoreUtils.isNullOrUndefined(telemetryItem.data) &&
!CoreUtils.isNullOrUndefined(telemetryItem.data["duration"])) { // from custom properties
duration = telemetryItem.data["duration"];
delete telemetryItem.data["duration"];
}

let bd = telemetryItem.baseData as IPageViewTelemetryInternal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export class ApplicationInsights implements IAppInsights, ITelemetryPlugin, IApp
config.sessionExpirationMs = 24 * 60 * 60 * 1000;
config.disableExceptionTracking = Util.stringToBoolOrDefault(config.disableExceptionTracking);
config.autoTrackPageVisitTime = Util.stringToBoolOrDefault(config.autoTrackPageVisitTime);
config.overridePageViewDuration = Util.stringToBoolOrDefault(config.overridePageViewDuration);

if (isNaN(config.samplingPercentage) || config.samplingPercentage <= 0 || config.samplingPercentage >= 100) {
config.samplingPercentage = 100;
Expand Down