Enable session storage experiment, fix E2E tests

This commit is contained in:
Kamil Szostak 2016-05-17 16:39:58 -07:00
Родитель 23def85249
Коммит 74ca2f3d2e
9 изменённых файлов: 153 добавлений и 89 удалений

Просмотреть файл

@ -90,12 +90,12 @@
-->
<SemanticVersionMajor>0</SemanticVersionMajor>
<SemanticVersionMinor>22</SemanticVersionMinor>
<SemanticVersionPatch>12</SemanticVersionPatch>
<SemanticVersionPatch>14</SemanticVersionPatch>
<!--
Date when Semantic Version was changed.
Update for every public release.
-->
<SemanticVersionDate>2016-05-09</SemanticVersionDate>
<SemanticVersionDate>2016-05-17</SemanticVersionDate>
<!--
Pre-release version is used to distinguish internally built NuGet packages.
Pre-release version = Minutes since semantic version was set, divided by 5 (to make it fit in a UInt16).

Просмотреть файл

@ -15,8 +15,20 @@ class DisableTelemetryTests extends TestClass {
sinon.fakeServer["restore"]();
this.useFakeTimers = false;
this.clock.restore();
this.errorSpy = this.sandbox.spy(Microsoft.ApplicationInsights.Sender, "_onError");
this.successSpy = this.sandbox.stub(Microsoft.ApplicationInsights.Sender, "_onSuccess");
var config = {
enableSessionStorageBuffer: () => false,
endpointUrl: () => null,
emitLineDelimitedJson: () => null,
maxBatchSizeInBytes: () => null,
maxBatchInterval: () => null,
disableTelemetry: () => null
};
var sender = new Microsoft.ApplicationInsights.Sender(config);
this.errorSpy = this.sandbox.spy(sender, "_onError");
this.successSpy = this.sandbox.stub(sender, "_onSuccess");
this.loggingSpy = this.sandbox.stub(Microsoft.ApplicationInsights._InternalLogging, "throwInternalUserActionable");
}
@ -59,7 +71,7 @@ class DisableTelemetryTests extends TestClass {
boilerPlateAsserts();
}
}
var assertNoMessages = () => {
var message = "polling for no messages: " + new Date().toISOString();
Assert.ok(true, message);

Просмотреть файл

@ -4,9 +4,12 @@
class PublicApiTests extends TestClass {
public errorSpy;
public successSpy;
public loggingSpy;
public errorSpy: SinonSpy;
public successSpy: SinonSpy;
public loggingSpy: SinonSpy;
private delay: number;
private testAi: Microsoft.ApplicationInsights.AppInsights;
/** Method called before the start of each test method */
public testInitialize() {
@ -14,8 +17,9 @@ class PublicApiTests extends TestClass {
sinon.fakeServer["restore"]();
this.useFakeTimers = false;
this.clock.restore();
this.errorSpy = this.sandbox.spy(Microsoft.ApplicationInsights.Sender, "_onError");
this.successSpy = this.sandbox.stub(Microsoft.ApplicationInsights.Sender, "_onSuccess");
this.errorSpy = this.sandbox.spy(this.testAi.context._sender, "_onError");
this.successSpy = this.sandbox.stub(this.testAi.context._sender, "_onSuccess");
this.loggingSpy = this.sandbox.stub(Microsoft.ApplicationInsights._InternalLogging, "throwInternalUserActionable");
}
@ -31,8 +35,8 @@ class PublicApiTests extends TestClass {
config.endpointUrl = "https://dc.services.visualstudio.com/v2/track";
config.instrumentationKey = "3e6a441c-b52b-4f39-8944-f81dd6c2dc46";
var delay = config.maxBatchInterval + 100;
var testAi = new Microsoft.ApplicationInsights.AppInsights(config);
this.delay = config.maxBatchInterval + 100;
this.testAi = new Microsoft.ApplicationInsights.AppInsights(config);
var boilerPlateAsserts = () => {
Assert.ok(this.successSpy.called, "success");
@ -68,17 +72,17 @@ class PublicApiTests extends TestClass {
this.testCaseAsync({
name: "TelemetryContext: track event",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
testAi.trackEvent("test");
this.testAi.trackEvent("test");
}
].concat(asserts)
});
this.testCaseAsync({
name: "TelemetryContext: track exception",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
var exception = null;
@ -86,7 +90,7 @@ class PublicApiTests extends TestClass {
window["a"]["b"]();
} catch (e) {
exception = e;
testAi.trackException(e);
this.testAi.trackException(e);
}
Assert.ok(exception);
@ -96,12 +100,12 @@ class PublicApiTests extends TestClass {
this.testCaseAsync({
name: "TelemetryContext: track metric",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
console.log("* calling trackMetric " + new Date().toISOString());
for (var i = 0; i < 100; i++) {
testAi.trackMetric("test" + i, Math.round(100 * Math.random()));
this.testAi.trackMetric("test" + i, Math.round(100 * Math.random()));
}
console.log("* done calling trackMetric " + new Date().toISOString());
}
@ -110,27 +114,27 @@ class PublicApiTests extends TestClass {
this.testCaseAsync({
name: "TelemetryContext: track trace",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
testAi.trackTrace("test");
this.testAi.trackTrace("test");
}
].concat(asserts)
});
this.testCaseAsync({
name: "TelemetryContext: track page view",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
testAi.trackPageView();
this.testAi.trackPageView();
}
].concat(asserts)
});
this.testCaseAsync({
name: "TelemetryContext: track all types in batch",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
var exception = null;
@ -142,22 +146,22 @@ class PublicApiTests extends TestClass {
Assert.ok(exception);
testAi.trackEvent("test");
testAi.trackException(exception);
testAi.trackMetric("test", Math.round(100 * Math.random()));
testAi.trackTrace("test");
testAi.trackPageView();
this.testAi.trackEvent("test");
this.testAi.trackException(exception);
this.testAi.trackMetric("test", Math.round(100 * Math.random()));
this.testAi.trackTrace("test");
this.testAi.trackPageView();
}
].concat(asserts)
});
this.testCaseAsync({
name: "TelemetryContext: track all types in a large batch",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
for (var i = 0; i < 100; i++) {
testAi.trackMetric("test", Math.round(100 * Math.random()));
this.testAi.trackMetric("test", Math.round(100 * Math.random()));
}
}
].concat(asserts)

Просмотреть файл

@ -4,9 +4,8 @@
class Sanitizer2ETests extends TestClass {
private errorSpy;
private successSpy;
private loggingSpy;
private config: any;
private delay: number;
/** Method called before the start of each test method */
public testInitialize() {
@ -14,9 +13,6 @@ class Sanitizer2ETests extends TestClass {
sinon.fakeServer["restore"]();
this.useFakeTimers = false;
this.clock.restore();
this.errorSpy = this.sandbox.spy(Microsoft.ApplicationInsights.Sender, "_onError");
this.successSpy = this.sandbox.stub(Microsoft.ApplicationInsights.Sender, "_onSuccess");
this.loggingSpy = this.sandbox.stub(Microsoft.ApplicationInsights._InternalLogging, "throwInternalUserActionable");
}
/** Method called after each test method has completed */
@ -25,41 +21,61 @@ class Sanitizer2ETests extends TestClass {
this.useFakeTimers = true;
}
private setAppInsights() {
var testAi = new Microsoft.ApplicationInsights.AppInsights(this.config);
var sender = this.sandbox.spy(testAi.context._sender, "send");
var errorSpy = this.sandbox.spy(testAi.context._sender, "_onError");
var successSpy = this.sandbox.spy(testAi.context._sender, "_onSuccess");
var loggingSpy = this.sandbox.spy(Microsoft.ApplicationInsights._InternalLogging, "throwInternalUserActionable");
return {
appInsights: testAi,
sender: sender,
errorSpy: errorSpy,
successSpy: successSpy,
loggingSpy: loggingSpy,
restore: () => {
}
};
}
public registerTests() {
var config = Microsoft.ApplicationInsights.Initialization.getDefaultConfig();
config.maxBatchInterval = 1000;
config.endpointUrl = "https://dc.services.visualstudio.com/v2/track";
config.instrumentationKey = "3e6a441c-b52b-4f39-8944-f81dd6c2dc46";
this.config = Microsoft.ApplicationInsights.Initialization.getDefaultConfig();
this.config.maxBatchInterval = 100;
this.config.endpointUrl = "https://dc.services.visualstudio.com/v2/track";
this.config.instrumentationKey = "3e6a441c-b52b-4f39-8944-f81dd6c2dc46";
var delay = config.maxBatchInterval + 100;
var testAi = new Microsoft.ApplicationInsights.AppInsights(config);
this.delay = this.config.maxBatchInterval + 500;
var boilerPlateAsserts = () => {
Assert.ok(this.successSpy.called, "success");
Assert.ok(!this.errorSpy.called, "no error sending");
var boilerPlateAsserts = (mocks: any) => {
Assert.ok(mocks.successSpy.called, "success");
Assert.ok(!mocks.errorSpy.called, "no error sending");
}
var asserts = [];
asserts.push(() => {
var asserts = (mocks: any) => {
var message = "polling: " + new Date().toISOString();
Assert.ok(true, message);
console.log(message);
if (this.successSpy.called) {
boilerPlateAsserts();
if (mocks.successSpy.called) {
boilerPlateAsserts(mocks);
this.testCleanup();
} else if (this.errorSpy.called || this.loggingSpy.called) {
boilerPlateAsserts();
} else if (mocks.errorSpy.called || mocks.loggingSpy.called) {
boilerPlateAsserts(mocks);
}
});
asserts.push(() => Assert.ok(this.successSpy.called, "success"));
Assert.ok(mocks.successSpy.called, "success")
};
var aiT1;
this.testCaseAsync({
name: "Sanitizer2ETests: Data platform accepts sanitized names",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
aiT1 = this.setAppInsights();
var properties = {
"property1%^~`": "hello",
"property2*&#+": "world"
@ -69,16 +85,22 @@ class Sanitizer2ETests extends TestClass {
"measurement@|": 300
};
testAi.trackMetric("test", 5);
aiT1.appInsights.trackMetric("test", 5);
},
() => {
asserts(aiT1);
}
].concat(asserts)
]
});
var aiT2;
this.testCaseAsync({
name: "Sanitizer2ETests: Data platform accepts legal charater set names",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
aiT2 = this.setAppInsights();
var properties = {
"abcdefghijklmnopqrstuvwxyz": "hello",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ": "world"
@ -88,29 +110,41 @@ class Sanitizer2ETests extends TestClass {
"(1234567890/ \_-.)": 300
};
testAi.trackMetric("test", 5);
aiT2.appInsights.trackMetric("test", 5);
},
() => {
asserts(aiT2);
}
].concat(asserts)
]
});
var aiT3;
this.testCaseAsync({
name: "Sanitizer2ETests: Data platform accepts up to 150 charaters for names",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
aiT3 = this.setAppInsights();
var len = 150;
var name = new Array(len + 1).join('a');
testAi.trackMetric(name, 5);
aiT3.appInsights.trackMetric(name, 5);
},
() => {
asserts(aiT3);
}
].concat(asserts)
]
});
var aiT4;
this.testCaseAsync({
name: "Sanitizer2ETests: Data platform accepts up to 1024 charaters for values",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
aiT4 = this.setAppInsights()
var len = 1024;
var value = new Array(len + 1).join('a');
@ -118,36 +152,51 @@ class Sanitizer2ETests extends TestClass {
"testProp": value
};
testAi.trackMetric("test", 5);
aiT4.appInsights.trackMetric("test", 5);
},
() => {
asserts(aiT4);
}
].concat(asserts)
]
});
var aiT5;
this.testCaseAsync({
name: "Sanitizer2ETests: Data platform accepts up to 2048 charaters for url",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
aiT5 = this.setAppInsights()
var len = 2048;
var url = "http://hello.com/";
url = url + new Array(len - url.length + 1).join('a');
testAi.trackPageView("test", url);
aiT5.appInsights.trackPageView("test", url);
},
() => {
asserts(aiT5);
}
].concat(asserts)
]
});
var aiT6;
this.testCaseAsync({
name: "Sanitizer2ETests: Data platform accepts up to 32768 charaters for messages",
stepDelay: delay,
stepDelay: this.delay,
steps: [
() => {
aiT6 = this.setAppInsights();
var len = 32768;
var message = new Array(len + 1).join('a');
testAi.trackTrace(message, 5);
aiT6.appInsights.trackTrace(message, 5);
},
() => {
asserts(aiT6);
}
].concat(asserts)
]
});
}
}

Просмотреть файл

@ -80,7 +80,7 @@ class SnippetTests extends TestClass {
Assert.deepEqual("test", pv.url, "url was set correctly");
Assert.deepEqual({ property: "p1" }, pv.properties, "properties were set correctly");
Assert.deepEqual({ measurement: 5 }, pv.measurements, "measurements were set correctly");
}
]
});
@ -104,7 +104,7 @@ class SnippetTests extends TestClass {
var count = 2 + this.timingOffset;
Assert.equal(count, senderSpy66V2V1.sender.callCount, "v2 send called " + count + " times");
this.boilerPlateAsserts(senderSpy66V2V1);
}
]
});
@ -172,7 +172,7 @@ class SnippetTests extends TestClass {
var count = 5 + this.timingOffset;
Assert.equal(count, sender.sender.callCount, "send called " + count + " times");
this.boilerPlateAsserts(sender);
}
]
});
@ -216,8 +216,8 @@ class SnippetTests extends TestClass {
window["appInsights"].maxBatchInterval = 1;
var appIn = <Microsoft.ApplicationInsights.AppInsights>window[this.name];
var sender = this.sandbox.spy(appIn.context._sender, "send");
var errorSpy = this.sandbox.spy(Microsoft.ApplicationInsights.Sender, "_onError");
var successSpy = this.sandbox.spy(Microsoft.ApplicationInsights.Sender, "_onSuccess");
var errorSpy = this.sandbox.spy(appIn.context._sender, "_onError");
var successSpy = this.sandbox.spy(appIn.context._sender, "_onSuccess");
var loggingSpy = this.sandbox.spy(Microsoft.ApplicationInsights._InternalLogging, "throwInternalUserActionable");
return {
@ -226,10 +226,6 @@ class SnippetTests extends TestClass {
successSpy: successSpy,
loggingSpy: loggingSpy,
restore: () => {
}
};
}

Просмотреть файл

@ -13,7 +13,7 @@ module Microsoft.ApplicationInsights {
"use strict";
export var Version = "0.22.12";
export var Version = "0.22.14";
export interface IConfig {
instrumentationKey: string;
@ -103,6 +103,9 @@ module Microsoft.ApplicationInsights {
enableSessionStorageBuffer: () => this.config.enableSessionStorageBuffer
}
// enable session storage buffer experiment
this.config.enableSessionStorageBuffer = new SplitTest().isEnabled(this.config.instrumentationKey, 10); ;
this.context = new ApplicationInsights.TelemetryContext(configGetters);
this._pageViewManager = new Microsoft.ApplicationInsights.Telemetry.PageViewManager(this, this.config.overridePageViewDuration);
@ -425,7 +428,7 @@ module Microsoft.ApplicationInsights {
private SendCORSException(properties: any) {
var exceptionData = Microsoft.ApplicationInsights.Telemetry.Exception.CreateSimpleException(
"Script error.", "Error", "unknown", "unknown",
"The browsers same-origin policy prevents us from getting the details of this exception.The exception occurred in a script loaded from an origin different than the web page.For cross- domain error reporting you can use crossorigin attribute together with appropriate CORS HTTP headers.For more information please see http://www.w3.org/TR/cors/.",
"The browser's same-origin policy prevents us from getting the details of this exception.The exception occurred in a script loaded from an origin different than the web page.For cross- domain error reporting you can use crossorigin attribute together with appropriate CORS HTTP headers.For more information please see http://www.w3.org/TR/cors/.",
0, null);
exceptionData.properties = properties;

Просмотреть файл

@ -1,7 +1,7 @@
{
{
"name": "applicationinsights-js",
"main": "dist/ai.0.js",
"version": "0.22.12",
"version": "0.22.14",
"homepage": "https://github.com/Microsoft/ApplicationInsights-JS",
"authors": [
"Max Shekhovtsov <mashekho@microsoft.com>"

Просмотреть файл

@ -26,7 +26,7 @@ if (-Not ($version -match "\d+\.\d+\.\d+")) {
$packagesJson.version = $version
$packagesJson = $packagesJson | ConvertTo-Json
$packagesJson = $packagesJson -replace "\\u0026", "&"
$packagesJson | Out-File $packageJsonPath
[System.IO.File]::WriteAllLines($packageJsonPath, $packagesJson)
# update bower.json
$bowerJsonPath = Join-Path $jsSdkDir -ChildPath "bower.json"
@ -35,7 +35,7 @@ $bowerJson.version = $version
$bowerJson = $bowerJson | ConvertTo-Json
$bowerJson = $bowerJson -replace "\\u003c", "<"
$bowerJson = $bowerJson -replace "\\u003e", ">"
$bowerJson | Out-File $bowerJsonPath
[System.IO.File]::WriteAllLines($bowerJsonPath, $bowerJson)
# update JavaScript\JavaScriptSDK\AppInsights.ts
$appInsightsTsPath = Join-Path $jsSdkDir -ChildPath "JavaScript\JavaScriptSDK\AppInsights.ts"
@ -46,7 +46,7 @@ if (-Not ($appInsightsTs -match "export var Version = `"\d+\.\d+\.\d+`"")) {
# continue on error
} else {
$appInsightsTs = $appInsightsTs -replace "export var Version = `"\d+\.\d+\.\d+`"", "export var Version = `"$version`""
$appInsightsTs | Out-File $appInsightsTsPath
[System.IO.File]::WriteAllLines($appInsightsTsPath, $appInsightsTs)
}
# update global.props

Просмотреть файл

@ -1,6 +1,6 @@
{
{
"name": "applicationinsights-js",
"version": "0.22.12",
"version": "0.22.14",
"description": "[Application Insights](https://azure.microsoft.com/services/application-insights/) tells you about your app\u0027s performance and usage. By adding a few lines of code to your web pages, you get data about how many users you have, which pages are most popular, how fast pages load, whether they throw exceptions, and more. And you can add code to track more detailed user activity.",
"main": "dist/ai.0.js",
"scripts": {