Merge pull request #498 from Microsoft/gruntBuild
Migrate to grunt build
This commit is contained in:
Коммит
c11540596a
|
@ -161,3 +161,10 @@ $RECYCLE.BIN/
|
|||
|
||||
# Visual studio 2015 user specific files
|
||||
JavaScript/.vs
|
||||
|
||||
# Temp directories
|
||||
bundle/
|
||||
node_modules/
|
||||
|
||||
# Grunt
|
||||
.tscache
|
|
@ -8,6 +8,6 @@
|
|||
!/bower.json
|
||||
!/README.md
|
||||
!/API-reference.md
|
||||
!/JavaScript/JavaScriptSDK.Module/AppInsightsModule.js
|
||||
!/bundle/ai.module.*
|
||||
!/dist/ai.js
|
||||
!/dist/ai.0.js
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"typescript.tsdk": "./node_modules/typescript/lib",
|
||||
"files.exclude": {
|
||||
"**/dist": true,
|
||||
"**/.tscache": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"version": "0.1.0",
|
||||
"command": "grunt",
|
||||
"isShellCommand": true,
|
||||
"showOutput": "always",
|
||||
"tasks": [
|
||||
{
|
||||
"taskName": "default",
|
||||
"args": [],
|
||||
"isBuildCommand": true,
|
||||
"problemMatcher": [
|
||||
"$lessCompile",
|
||||
"$tsc",
|
||||
"$jshint"
|
||||
]
|
||||
},
|
||||
{
|
||||
"taskName": "module",
|
||||
"args": [],
|
||||
"isBuildCommand": true,
|
||||
"problemMatcher": [
|
||||
"$lessCompile",
|
||||
"$tsc",
|
||||
"$jshint"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
// Ignore this file. See https://github.com/grunt-ts/grunt-ts/issues/77
|
|
@ -55,10 +55,13 @@ module Microsoft.ApplicationInsights {
|
|||
session: Context.ISession;
|
||||
|
||||
/**
|
||||
* Adds telemetry initializer to the collection. Telemetry initializers will be called one by one
|
||||
* before telemetry item is pushed for sending and in the order they were added.
|
||||
* Adds a telemetry initializer to the collection. Telemetry initializers will be called one by one,
|
||||
* in the order they were added, before the telemetry item is pushed for sending.
|
||||
* If one of the telemetry initializers returns false or throws an error then the telemetry item will not be sent.
|
||||
* If it returns true or doesn't return any value the event will be passed to the next telemetry initializer and
|
||||
* send to the cloud (if not rejected by other initializers).
|
||||
*/
|
||||
addTelemetryInitializer(telemetryInitializer: (envelope: Microsoft.ApplicationInsights.IEnvelope) => boolean);
|
||||
addTelemetryInitializer(telemetryInitializer: (envelope: Microsoft.ApplicationInsights.IEnvelope) => boolean | void);
|
||||
|
||||
/**
|
||||
* Tracks telemetry object.
|
||||
|
|
|
@ -21,4 +21,4 @@ module Microsoft.ApplicationInsights {
|
|||
tags: { [name: string]: any };
|
||||
data: any;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
|
||||
module Microsoft.ApplicationInsights {
|
||||
module Microsoft.ApplicationInsights {
|
||||
|
||||
"use strict";
|
||||
|
||||
export interface ISerializable {
|
||||
/**
|
||||
* The set of fields for a serializeable object.
|
||||
* The set of fields for a serializable object.
|
||||
* This defines the serialization order and a value of true/false
|
||||
* for each field defines whether the field is required or not.
|
||||
*/
|
||||
aiDataContract: any;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,11 +64,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(true, expiration.substr(0, "expires=".length) === "expires=", "ai_user cookie expiration part should start with expires=");
|
||||
var expirationDate = new Date(expiration.substr("expires=".length));
|
||||
Assert.equal(true, expirationDate > (new Date), "ai_user cookie expiration should be in the future");
|
||||
|
||||
// cleanup
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -102,11 +97,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(true, expiration.substr(0, "expires=".length) === "expires=", "ai_user cookie expiration part should start with expires=");
|
||||
var expirationDate = new Date(expiration.substr("expires=".length));
|
||||
Assert.equal(true, expirationDate > (new Date), "ai_user cookie expiration should be in the future");
|
||||
|
||||
// cleanup
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -126,7 +116,6 @@ class UserContextTests extends TestClass {
|
|||
// verify
|
||||
Assert.equal(authId, user.authenticatedId, "user auth id was set from cookie");
|
||||
Assert.equal(accountId, user.accountId, "user account id was not set from cookie");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -142,7 +131,6 @@ class UserContextTests extends TestClass {
|
|||
|
||||
// verify
|
||||
Assert.equal(authId, user.authenticatedId, "user auth id was set from cookie");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -158,7 +146,6 @@ class UserContextTests extends TestClass {
|
|||
// verify
|
||||
Assert.equal(undefined, user.authenticatedId, "user auth id was not set");
|
||||
Assert.equal(undefined, user.accountId, "user account id was not set");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -176,7 +163,6 @@ class UserContextTests extends TestClass {
|
|||
|
||||
// verify
|
||||
Assert.equal(config.accountId(), user.accountId, "user account id was set from back compat");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -194,7 +180,6 @@ class UserContextTests extends TestClass {
|
|||
// verify
|
||||
Assert.equal(authAndAccountId[0], user.authenticatedId, "user auth id was set");
|
||||
Assert.equal(cookieStub.calledWithExactly('ai_authUser', encodeURI(authAndAccountId.join('|')), null), true, "user auth id and account id cookie was set");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -212,7 +197,6 @@ class UserContextTests extends TestClass {
|
|||
// verify
|
||||
Assert.equal(authAndAccountId[0], user.authenticatedId, "user auth id was set");
|
||||
Assert.equal(cookieStub.calledWithExactly('ai_authUser', encodeURI(authAndAccountId.join('|')), null), true, "user auth id cookie was set");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -231,7 +215,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(authAndAccountId[0], user.authenticatedId, "user auth id was set");
|
||||
Assert.equal(null, user.accountId, "user account id was not set");
|
||||
Assert.equal(cookieStub.calledWithExactly('ai_authUser', encodeURI(authAndAccountId[0]), null), true, "user auth id cookie was set");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -243,6 +226,7 @@ class UserContextTests extends TestClass {
|
|||
var user = new Microsoft.ApplicationInsights.Context.User(this.getEmptyConfig());
|
||||
var loggingStub = this.sandbox.stub(Microsoft.ApplicationInsights._InternalLogging, "throwInternal");
|
||||
cookieStub.reset();
|
||||
loggingStub.reset();
|
||||
|
||||
// act
|
||||
user.setAuthenticatedUserContext(null);
|
||||
|
@ -252,8 +236,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(undefined, user.accountId, "user account id was not set");
|
||||
Assert.equal(cookieStub.notCalled, true, "cookie was not set");
|
||||
Assert.equal(loggingStub.calledOnce, true, "Warning was logged");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -264,6 +246,8 @@ class UserContextTests extends TestClass {
|
|||
var cookieStub = this.sandbox.stub(Microsoft.ApplicationInsights.Util, "setCookie");
|
||||
var user = new Microsoft.ApplicationInsights.Context.User(this.getEmptyConfig());
|
||||
var loggingStub = this.sandbox.stub(Microsoft.ApplicationInsights._InternalLogging, "throwInternal");
|
||||
cookieStub.reset();
|
||||
loggingStub.reset();
|
||||
|
||||
// act
|
||||
user.setAuthenticatedUserContext(undefined, undefined);
|
||||
|
@ -273,8 +257,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(undefined, user.accountId, "user account id was not set");
|
||||
Assert.equal(cookieStub.notCalled, true, "cookie was not set");
|
||||
Assert.equal(loggingStub.calledOnce, true, "Warning was logged");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -285,6 +267,8 @@ class UserContextTests extends TestClass {
|
|||
var cookieStub = this.sandbox.stub(Microsoft.ApplicationInsights.Util, "setCookie");
|
||||
var user = new Microsoft.ApplicationInsights.Context.User(this.getEmptyConfig());
|
||||
var loggingStub = this.sandbox.stub(Microsoft.ApplicationInsights._InternalLogging, "throwInternal");
|
||||
cookieStub.reset();
|
||||
loggingStub.reset();
|
||||
|
||||
// act
|
||||
user.setAuthenticatedUserContext(undefined, '1234');
|
||||
|
@ -294,8 +278,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(undefined, user.accountId, "user account id was not set");
|
||||
Assert.equal(cookieStub.notCalled, true, "cookie was not set");
|
||||
Assert.equal(loggingStub.calledOnce, true, "Warning was logged");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -316,8 +298,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(undefined, user.accountId, "user account id was not set");
|
||||
Assert.equal(cookieStub.notCalled, true, "cookie was not set");
|
||||
Assert.equal(loggingStub.calledOnce, true, "Warning was logged");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -339,8 +319,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(undefined, user.accountId, "user account id was not set");
|
||||
Assert.equal(cookieStub.notCalled, true, "cookie was not set");
|
||||
Assert.equal(loggingStub.calledOnce, true, "Warning was logged");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -361,8 +339,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(authAndAccountId[1], user.accountId, "user account id was set");
|
||||
Assert.equal(cookieStub.calledWithExactly('ai_authUser', encodeURI(authAndAccountId.join('|')), null), true, "user auth id cookie was set");
|
||||
Assert.equal(loggingStub.notCalled, true, "No warnings");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -381,7 +357,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(undefined, user.authenticatedId, "user auth id was cleared");
|
||||
Assert.equal(undefined, user.accountId, "user account id was cleared");
|
||||
Assert.equal(cookieStub.calledWithExactly('ai_authUser'), true, "cookie was deleted");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -399,7 +374,6 @@ class UserContextTests extends TestClass {
|
|||
Assert.equal(undefined, user.authenticatedId, "user auth id was cleared");
|
||||
Assert.equal(undefined, user.accountId, "user account id was cleared");
|
||||
Assert.equal(cookieStub.calledWithExactly('ai_authUser'), true, "cookie was deleted");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ class SenderTests extends TestClass {
|
|||
return xhr;
|
||||
});
|
||||
|
||||
XDomainRequest = <any>(() => {
|
||||
window["XDomainRequest"] = <any>(() => {
|
||||
var xdr = new this.xhr;
|
||||
xdr.onload = xdr.onreadystatechange;
|
||||
xdr.responseText = 200;
|
||||
|
@ -247,7 +247,7 @@ class SenderTests extends TestClass {
|
|||
return xhr;
|
||||
});
|
||||
|
||||
XDomainRequest = <any>(() => {
|
||||
window["XDomainRequest"] = <any>(() => {
|
||||
var xdr = new this.xhr;
|
||||
xdr.onload = xdr.onreadystatechange;
|
||||
xdr.responseText = 206;
|
||||
|
@ -298,7 +298,7 @@ class SenderTests extends TestClass {
|
|||
// setup
|
||||
var xdr = new this.xhr;
|
||||
XMLHttpRequest = <any>(() => { });
|
||||
XDomainRequest = <any>(() => {
|
||||
window["XDomainRequest"] = <any>(() => {
|
||||
xdr.onload = xdr.onreadystatechange;
|
||||
xdr.responseText = 200;
|
||||
return xdr;
|
||||
|
@ -838,7 +838,7 @@ class SenderTests extends TestClass {
|
|||
return xhr;
|
||||
});
|
||||
|
||||
XDomainRequest = <any>(() => {
|
||||
window["XDomainRequest"] = <any>(() => {
|
||||
var xdr = new this.xhr;
|
||||
xdr.onload = xdr.onreadystatechange;
|
||||
xdr.responseText = 206;
|
||||
|
@ -863,7 +863,7 @@ class SenderTests extends TestClass {
|
|||
return xhr;
|
||||
});
|
||||
|
||||
XDomainRequest = <any>(() => {
|
||||
window["XDomainRequest"] = <any>(() => {
|
||||
var xdr = new this.xhr;
|
||||
xdr.onload = xdr.onreadystatechange;
|
||||
xdr.responseText = 206;
|
||||
|
@ -1111,12 +1111,17 @@ class SenderTests extends TestClass {
|
|||
this.testCase({
|
||||
name: "SenderTests: send() is using BeaconAPI sender if the BeaconAPI is enabled",
|
||||
test: () => {
|
||||
if (!navigator.sendBeacon) {
|
||||
navigator['sendBeacon'] = (url: string, data?: any) => { return true; };
|
||||
}
|
||||
|
||||
// enable beacon API and mock sender
|
||||
var config = this.getDefaultConfig();
|
||||
config.isBeaconApiDisabled = () => false;
|
||||
|
||||
var sender = <SenderWrapper>new Microsoft.ApplicationInsights.Sender(config);
|
||||
sender.beaconStub = this.sandbox.stub((<any>navigator), "sendBeacon");
|
||||
sender.beaconStub = this.sandbox.stub((
|
||||
navigator), "sendBeacon");
|
||||
|
||||
Assert.ok(sender, "sender was constructed");
|
||||
Assert.ok(Microsoft.ApplicationInsights.Util.IsBeaconApiSupported(), "Beacon API is supported");
|
||||
|
@ -1134,12 +1139,16 @@ class SenderTests extends TestClass {
|
|||
this.testCase({
|
||||
name: "SenderTests: send() is not using BeaconAPI sender if the BeaconAPI is disabled",
|
||||
test: () => {
|
||||
if (!navigator.sendBeacon) {
|
||||
navigator['sendBeacon'] = (url: string, data?: any) => { return true; };
|
||||
}
|
||||
|
||||
// enable beacon API and mock sender
|
||||
var config = this.getDefaultConfig();
|
||||
config.isBeaconApiDisabled = () => true;
|
||||
|
||||
var sender = <SenderWrapper>new Microsoft.ApplicationInsights.Sender(config);
|
||||
sender.beaconStub = this.sandbox.stub((<any>navigator), "sendBeacon");
|
||||
sender.beaconStub = this.sandbox.stub((navigator), "sendBeacon");
|
||||
|
||||
Assert.ok(sender, "sender was constructed");
|
||||
Assert.ok(Microsoft.ApplicationInsights.Util.IsBeaconApiSupported(), "Beacon API is supported");
|
||||
|
|
|
@ -18,7 +18,7 @@ class SplitTestTests extends TestClass {
|
|||
name: "SplitTestTests: ",
|
||||
test: () => {
|
||||
var sut = new Microsoft.ApplicationInsights.SplitTest();
|
||||
var guids = getGuids(10000);
|
||||
var guids = getGuids(10000);
|
||||
var enabledPercent = 20;
|
||||
var acceptedErrorPercent = 2;
|
||||
|
||||
|
@ -26,19 +26,20 @@ class SplitTestTests extends TestClass {
|
|||
var totalCount = guids.length;
|
||||
var enabledCount = 0;
|
||||
guids.forEach((guid) => {
|
||||
console.log(guid);
|
||||
if (sut.isEnabled(guid, enabledPercent))
|
||||
++enabledCount;
|
||||
});
|
||||
|
||||
// Assert.ok(false);
|
||||
|
||||
// Validate
|
||||
var actualEnabledPercent = (enabledCount / totalCount) * 100;
|
||||
Assert.ok(
|
||||
(actualEnabledPercent < enabledPercent + acceptedErrorPercent) &&
|
||||
(actualEnabledPercent > enabledPercent - acceptedErrorPercent),
|
||||
"Enabled percent does not fall into expected range (" + enabledPercent + " +- " + acceptedErrorPercent + "): " + actualEnabledPercent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -191,13 +191,7 @@ Error: testmessage2\n\
|
|||
Assert.equal(expectedTypeName, actual.exceptions[0].typeName);
|
||||
Assert.equal(expectedDetails, actual.exceptions[0].stack);
|
||||
Assert.equal(true, actual.exceptions[0].hasFullStack);
|
||||
|
||||
Assert.equal(0, actual.exceptions[0].parsedStack[0].level);
|
||||
Assert.equal(expectedAssembly, actual.exceptions[0].parsedStack[0].assembly);
|
||||
Assert.equal(expectedFileName, actual.exceptions[0].parsedStack[0].fileName);
|
||||
Assert.equal(expectedLineNumber, actual.exceptions[0].parsedStack[0].line);
|
||||
Assert.equal("unknown", actual.exceptions[0].parsedStack[0].method);
|
||||
|
||||
Assert.equal(undefined, actual.exceptions[0].parsedStack);
|
||||
Assert.equal(expectedHandledAt, actual.handledAt);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -89,13 +89,14 @@ class PageViewPerformanceTelemetryTests extends ContractTestHelper {
|
|||
name: name + "PageViewPerformanceTelemetry measurements are correct",
|
||||
test: () => {
|
||||
|
||||
var timing = <PerformanceTiming>{};
|
||||
timing.navigationStart = 1;
|
||||
timing.connectEnd = 10;
|
||||
timing.requestStart = 11;
|
||||
timing.responseStart = 30;
|
||||
timing.responseEnd = 42;
|
||||
timing.loadEventEnd = 60;
|
||||
var timing = {
|
||||
navigationStart: 1,
|
||||
connectEnd: 10,
|
||||
requestStart: 11,
|
||||
responseStart: 30,
|
||||
responseEnd: 42,
|
||||
loadEventEnd: 60,
|
||||
};
|
||||
|
||||
var timingSpy = this.sandbox.stub(Microsoft.ApplicationInsights.Telemetry.PageViewPerformance, "getPerformanceTiming", () => {
|
||||
return timing;
|
||||
|
@ -118,13 +119,14 @@ class PageViewPerformanceTelemetryTests extends ContractTestHelper {
|
|||
name: name + "PageViewPerformanceTelemetry detects when perf data is sent by the browser incorrectly and doesn't send it",
|
||||
test: () => {
|
||||
|
||||
var timing = <PerformanceTiming>{};
|
||||
timing.navigationStart = 1;
|
||||
timing.connectEnd = 40;
|
||||
timing.requestStart = 11;
|
||||
timing.responseStart = 30;
|
||||
timing.responseEnd = 42;
|
||||
timing.loadEventEnd = 60;
|
||||
var timing = {
|
||||
navigationStart: 1,
|
||||
connectEnd: 40,
|
||||
requestStart: 11,
|
||||
responseStart: 30,
|
||||
responseEnd: 42,
|
||||
loadEventEnd: 60,
|
||||
};
|
||||
|
||||
var timingSpy = this.sandbox.stub(Microsoft.ApplicationInsights.Telemetry.PageViewPerformance, "getPerformanceTiming", () => {
|
||||
return timing;
|
||||
|
@ -154,15 +156,21 @@ class PageViewPerformanceTelemetryTests extends ContractTestHelper {
|
|||
test: () => {
|
||||
// mock user agent
|
||||
let originalUserAgent = navigator.userAgent;
|
||||
this.setUserAgent("Googlebot/2.1");
|
||||
try {
|
||||
this.setUserAgent("Googlebot/2.1");
|
||||
} catch (ex) {
|
||||
Assert.ok(true, 'cannot run this test in the current setup - try Chrome');
|
||||
return;
|
||||
}
|
||||
|
||||
var timing = <PerformanceTiming>{};
|
||||
timing.navigationStart = 1;
|
||||
timing.connectEnd = 2;
|
||||
timing.requestStart = 3;
|
||||
timing.responseStart = 30;
|
||||
timing.responseEnd = 42;
|
||||
timing.loadEventEnd = 60;
|
||||
var timing = {
|
||||
navigationStart: 1,
|
||||
connectEnd: 2,
|
||||
requestStart: 3,
|
||||
responseStart: 30,
|
||||
responseEnd: 42,
|
||||
loadEventEnd: 60,
|
||||
};
|
||||
|
||||
var timingSpy = this.sandbox.stub(Microsoft.ApplicationInsights.Telemetry.PageViewPerformance, "getPerformanceTiming", () => {
|
||||
return timing;
|
||||
|
@ -197,20 +205,21 @@ class PageViewPerformanceTelemetryTests extends ContractTestHelper {
|
|||
// see comment PageViewPerformance constructor on how timing data is calculated
|
||||
// here we set values, so each metric will be exactly 3600000 (1h).
|
||||
let timingModifiers = [(timing) => timing.loadEventEnd = 3600001,
|
||||
(timing) => timing.connectEnd = 3600001,
|
||||
(timing) => timing.responseStart = 3600003,
|
||||
(timing) => timing.responseEnd = 3600030,
|
||||
(timing) => timing.loadEventEnd = 3600042];
|
||||
(timing) => timing.connectEnd = 3600001,
|
||||
(timing) => timing.responseStart = 3600003,
|
||||
(timing) => timing.responseEnd = 3600030,
|
||||
(timing) => timing.loadEventEnd = 3600042];
|
||||
|
||||
for (var i = 0; i < timingModifiers.length; i++) {
|
||||
|
||||
var timing = <PerformanceTiming>{};
|
||||
timing.navigationStart = 1;
|
||||
timing.connectEnd = 2;
|
||||
timing.requestStart = 3;
|
||||
timing.responseStart = 30;
|
||||
timing.responseEnd = 42;
|
||||
timing.loadEventEnd = 60;
|
||||
var timing = {
|
||||
navigationStart: 1,
|
||||
connectEnd: 2,
|
||||
requestStart: 3,
|
||||
responseStart: 30,
|
||||
responseEnd: 42,
|
||||
loadEventEnd: 60,
|
||||
};
|
||||
|
||||
// change perf timing value
|
||||
timingModifiers[i](timing);
|
||||
|
|
|
@ -7,7 +7,7 @@ class RemoteDependencyTests extends ContractTestHelper {
|
|||
private exception;
|
||||
private static id = "someid";
|
||||
private static method = "GET";
|
||||
private static name = "testName"
|
||||
private static testName = "testName"
|
||||
private static url = "http://myurl.com/"
|
||||
private static hostName = "myurl.com";
|
||||
private static totalTime = 123;
|
||||
|
@ -17,7 +17,7 @@ class RemoteDependencyTests extends ContractTestHelper {
|
|||
constructor() {
|
||||
super(
|
||||
() => new Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData(
|
||||
RemoteDependencyTests.id, RemoteDependencyTests.name, RemoteDependencyTests.url, RemoteDependencyTests.totalTime, RemoteDependencyTests.success, RemoteDependencyTests.resultCode, RemoteDependencyTests.method),
|
||||
RemoteDependencyTests.id, RemoteDependencyTests.testName, RemoteDependencyTests.url, RemoteDependencyTests.totalTime, RemoteDependencyTests.success, RemoteDependencyTests.resultCode, RemoteDependencyTests.method),
|
||||
"RemoteDependencyTelemetryTests");
|
||||
}
|
||||
|
||||
|
@ -29,14 +29,14 @@ class RemoteDependencyTests extends ContractTestHelper {
|
|||
name: name + "Constructor parameters are set correctly",
|
||||
test: () => {
|
||||
var telemetry = new Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData(
|
||||
RemoteDependencyTests.id, RemoteDependencyTests.url, RemoteDependencyTests.name, RemoteDependencyTests.totalTime, RemoteDependencyTests.success, RemoteDependencyTests.resultCode, RemoteDependencyTests.method);
|
||||
RemoteDependencyTests.id, RemoteDependencyTests.url, RemoteDependencyTests.testName, RemoteDependencyTests.totalTime, RemoteDependencyTests.success, RemoteDependencyTests.resultCode, RemoteDependencyTests.method);
|
||||
|
||||
Assert.equal("00:00:00.123", telemetry.duration, "value should be set correctly");
|
||||
Assert.equal(RemoteDependencyTests.success, telemetry.success, "success should be set correctly");
|
||||
Assert.equal(RemoteDependencyTests.resultCode, telemetry.resultCode, "resultCode should be set correctly");
|
||||
Assert.equal("GET /", telemetry.name, "name gets correct value");
|
||||
Assert.equal(RemoteDependencyTests.hostName, telemetry.target, "target gets correct value");
|
||||
Assert.equal(RemoteDependencyTests.name, telemetry.data, "data should be set correctly");
|
||||
Assert.equal(RemoteDependencyTests.testName, telemetry.data, "data should be set correctly");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -76,11 +76,11 @@ class RemoteDependencyTests extends ContractTestHelper {
|
|||
name: name + "Duration field is populated as expected",
|
||||
test: () => {
|
||||
var telemetry = new Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData(
|
||||
RemoteDependencyTests.id, RemoteDependencyTests.url, RemoteDependencyTests.name, 86400000, RemoteDependencyTests.success, RemoteDependencyTests.resultCode, RemoteDependencyTests.method);
|
||||
RemoteDependencyTests.id, RemoteDependencyTests.url, RemoteDependencyTests.testName, 86400000, RemoteDependencyTests.success, RemoteDependencyTests.resultCode, RemoteDependencyTests.method);
|
||||
|
||||
Assert.equal("1.00:00:00.000", telemetry.duration, "value should be set correctly");
|
||||
telemetry = new Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData(
|
||||
RemoteDependencyTests.id, RemoteDependencyTests.url, RemoteDependencyTests.name, 86400026, RemoteDependencyTests.success, RemoteDependencyTests.resultCode, RemoteDependencyTests.method);
|
||||
RemoteDependencyTests.id, RemoteDependencyTests.url, RemoteDependencyTests.testName, 86400026, RemoteDependencyTests.success, RemoteDependencyTests.resultCode, RemoteDependencyTests.method);
|
||||
|
||||
Assert.equal("1.00:00:00.026", telemetry.duration, "value should be set correctly");
|
||||
}
|
||||
|
|
|
@ -141,21 +141,21 @@ class UtilTests extends TestClass {
|
|||
// mock cookies
|
||||
((document) => {
|
||||
var cookies = {};
|
||||
document.__defineGetter__('cookie', () => {
|
||||
(<any>document).__defineGetter__('cookie', () => {
|
||||
var output = [];
|
||||
for (var cookieName in cookies) {
|
||||
output.push(cookieName + "=" + cookies[cookieName]);
|
||||
}
|
||||
return output.join(";");
|
||||
});
|
||||
document.__defineSetter__('cookie', (s) => {
|
||||
(<any>document).__defineSetter__('cookie', (s) => {
|
||||
var indexOfSeparator = s.indexOf("=");
|
||||
var key = s.substr(0, indexOfSeparator);
|
||||
var value = s.substring(indexOfSeparator + 1);
|
||||
cookies[key] = value;
|
||||
return key + "=" + value;
|
||||
});
|
||||
document.clearCookies = () => {
|
||||
(<any>document).clearCookies = () => {
|
||||
cookies = {};
|
||||
};
|
||||
})(document);
|
||||
|
|
|
@ -202,7 +202,7 @@ class AjaxTests extends TestClass {
|
|||
try {
|
||||
// Mocking window performance (sinon doesn't have it).
|
||||
// tick() is similar to sinon's clock.tick()
|
||||
window.performance = <any>{
|
||||
(<any>window).performance = <any>{
|
||||
current: 0,
|
||||
|
||||
now: function () {
|
||||
|
@ -238,7 +238,7 @@ class AjaxTests extends TestClass {
|
|||
Assert.ok(this.trackDependencySpy.calledOnce, "TrackAjax should be called");
|
||||
Assert.equal(expectedResponseDuration, this.trackDependencySpy.args[0][4], "Ajax duration should match expected duration");
|
||||
} finally {
|
||||
window.performance = initialPerformance;
|
||||
(<any>window.performance).performance = initialPerformance;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -667,7 +667,12 @@ class AppInsightsTests extends TestClass {
|
|||
|
||||
// mock user agent
|
||||
let originalUserAgent = navigator.userAgent;
|
||||
this.setUserAgent("Googlebot/2.1");
|
||||
try {
|
||||
this.setUserAgent("Googlebot/2.1");
|
||||
} catch (ex) {
|
||||
Assert.ok(true, 'cannot run this test in the current setup - try Chrome');
|
||||
return;
|
||||
}
|
||||
|
||||
// act
|
||||
appInsights.trackPageView();
|
||||
|
@ -856,9 +861,15 @@ class AppInsightsTests extends TestClass {
|
|||
|
||||
var appInsights = new Microsoft.ApplicationInsights.AppInsights(snippet);
|
||||
|
||||
Assert.equal(false, appInsights.context._config.isBeaconApiDisabled(), "Beacon API enabled");
|
||||
Assert.equal(false, appInsights.context._config.enableSessionStorageBuffer(), "Session storage disabled");
|
||||
Assert.equal(65536, appInsights.context._config.maxBatchSizeInBytes(), "Max batch size overriden by Beacon API payload limitation");
|
||||
if (Microsoft.ApplicationInsights.Util.IsBeaconApiSupported()) {
|
||||
Assert.equal(false, appInsights.context._config.isBeaconApiDisabled(), "Beacon API enabled");
|
||||
Assert.equal(false, appInsights.context._config.enableSessionStorageBuffer(), "Session storage disabled");
|
||||
Assert.equal(65536, appInsights.context._config.maxBatchSizeInBytes(), "Max batch size overriden by Beacon API payload limitation");
|
||||
} else {
|
||||
Assert.equal(false, appInsights.context._config.isBeaconApiDisabled(), "Beacon API enabled");
|
||||
Assert.equal(true, appInsights.context._config.enableSessionStorageBuffer(), "Session storage disabled");
|
||||
Assert.equal(1000000, appInsights.context._config.maxBatchSizeInBytes(), "Max batch size overriden by Beacon API payload limitation");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -866,7 +877,7 @@ class AppInsightsTests extends TestClass {
|
|||
name: "AppInsights._onerror creates a dump of unexpected error thrown by trackException for logging",
|
||||
test: () => {
|
||||
var sut = new Microsoft.ApplicationInsights.AppInsights(this.getAppInsightsSnippet());
|
||||
var dumpSpy = this.sandbox.spy(Microsoft.ApplicationInsights.Util, "dump")
|
||||
var dumpSpy = this.sandbox.stub(Microsoft.ApplicationInsights.Util, "dump")
|
||||
var unexpectedError = new Error();
|
||||
var stub = this.sandbox.stub(sut, "trackException").throws(unexpectedError);
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/// <reference path="../../JavaScriptSDK/appInsights.ts" />
|
||||
|
||||
// This file was copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/applicationinsights-js/applicationinsights-js-tests.ts
|
||||
// This file was copied from https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/applicationinsights-js/applicationinsights-js-tests.ts
|
||||
// and is used to validate ApplicationInsights-JS definition types.
|
||||
// If you have to change this file, plese update the DefinitelyTyped repo too - https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/applicationinsights-js
|
||||
// If you have to change this file, plese update the DefinitelyTyped repo too - https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/applicationinsights-js
|
||||
|
||||
var config: Microsoft.ApplicationInsights.IConfig = {
|
||||
const config: Microsoft.ApplicationInsights.IConfig = {
|
||||
instrumentationKey: "<your iKey>",
|
||||
endpointUrl: "endpointUrl",
|
||||
emitLineDelimitedJson: false,
|
||||
|
@ -27,28 +27,31 @@ var config: Microsoft.ApplicationInsights.IConfig = {
|
|||
disableCorrelationHeaders: true,
|
||||
disableFlushOnBeforeUnload: false,
|
||||
enableSessionStorageBuffer: false,
|
||||
cookieDomain: ""
|
||||
cookieDomain: "",
|
||||
isCookieUseDisabled: true,
|
||||
isRetryDisabled: true,
|
||||
isStorageUseDisabled: true
|
||||
};
|
||||
|
||||
var appInsights: Microsoft.ApplicationInsights.IAppInsights = {
|
||||
config: config,
|
||||
config,
|
||||
context: null,
|
||||
queue: null,
|
||||
|
||||
startTrackPage(name?: string) { return null; },
|
||||
stopTrackPage(name?: string, url?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null; },
|
||||
trackPageView(name?: string, url?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }, duration?: number) { return null; },
|
||||
startTrackEvent(name: string) { return null },
|
||||
stopTrackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null },
|
||||
trackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null },
|
||||
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null },
|
||||
trackException(exception: Error, handledAt?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }, severityLevel?: AI.SeverityLevel) { return null },
|
||||
trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: { [name: string]: string; }) { return null },
|
||||
trackTrace(message: string, properties?: { [name: string]: string; }) { return null },
|
||||
flush() { return null },
|
||||
setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string) { return null },
|
||||
clearAuthenticatedUserContext() { return null },
|
||||
_onerror(message: string, url: string, lineNumber: number, columnNumber: number, error: Error) { return null }
|
||||
startTrackEvent(name: string) { return null; },
|
||||
stopTrackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null; },
|
||||
trackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null; },
|
||||
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number) { return null; },
|
||||
trackException(exception: Error, handledAt?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }, severityLevel?: AI.SeverityLevel) { return null; },
|
||||
trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: { [name: string]: string; }) { return null; },
|
||||
trackTrace(message: string, properties?: { [name: string]: string; }, severityLevel?: AI.SeverityLevel) { return null; },
|
||||
flush() { return null; },
|
||||
setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string) { return null; },
|
||||
clearAuthenticatedUserContext() { return null; },
|
||||
_onerror(message: string, url: string, lineNumber: number, columnNumber: number, error: Error) { return null; }
|
||||
};
|
||||
|
||||
// trackPageView
|
||||
|
@ -77,6 +80,10 @@ appInsights.trackException(new Error("sample error"), "handledAt", null, null);
|
|||
// trackTrace
|
||||
appInsights.trackTrace("message");
|
||||
appInsights.trackTrace("message", null);
|
||||
appInsights.trackTrace("message", { a: '1', b: '2' }, AI.SeverityLevel.Error);
|
||||
|
||||
// trackDependency
|
||||
appInsights.trackDependency("id", "POST", "http://example.com/test/abc", "/test/abc", null, true, null);
|
||||
|
||||
// flush
|
||||
appInsights.flush();
|
||||
|
@ -88,9 +95,8 @@ appInsights.setAuthenticatedUserContext("userId", "accountId");
|
|||
// set config dynamically
|
||||
appInsights.config.instrumentationKey = "<new key>";
|
||||
|
||||
|
||||
// TelementryContext
|
||||
var context: Microsoft.ApplicationInsights.ITelemetryContext = appInsights.context;
|
||||
const context: Microsoft.ApplicationInsights.ITelemetryContext = appInsights.context;
|
||||
|
||||
context.application.ver = "v0.0.0";
|
||||
context.application.build = "1.1.1";
|
||||
|
@ -110,51 +116,65 @@ context.operation.id = "1";
|
|||
context.operation.syntheticSource = "testAgent";
|
||||
|
||||
// track
|
||||
var data = new Microsoft.Telemetry.Base();
|
||||
var envelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(data, "name");
|
||||
const data = new Microsoft.Telemetry.Base();
|
||||
const envelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(data, "name");
|
||||
|
||||
context.track(envelope);
|
||||
|
||||
context.addTelemetryInitializer((envelope) => false);
|
||||
context.addTelemetryInitializer(envelope => false);
|
||||
context.addTelemetryInitializer(envelope => { });
|
||||
|
||||
// a sample from: https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md#example
|
||||
context.addTelemetryInitializer(envelope => {
|
||||
let telemetryItem = envelope.data.baseData;
|
||||
if (envelope.name === Microsoft.ApplicationInsights.Telemetry.PageView.envelopeType) {
|
||||
telemetryItem.url = "URL CENSORED";
|
||||
}
|
||||
telemetryItem.properties = telemetryItem.properties || {};
|
||||
telemetryItem.properties["globalProperty"] = "boo";
|
||||
});
|
||||
|
||||
// track event
|
||||
var eventObj = new Microsoft.ApplicationInsights.Telemetry.Event("test", null, null);
|
||||
var eventData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Event>(Microsoft.ApplicationInsights.Telemetry.Event.dataType, eventObj);
|
||||
var eventEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(eventData, Microsoft.ApplicationInsights.Telemetry.Event.envelopeType);
|
||||
const eventObj = new Microsoft.ApplicationInsights.Telemetry.Event("test", null, null);
|
||||
const eventData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Event>(Microsoft.ApplicationInsights.Telemetry.Event.dataType, eventObj);
|
||||
const eventEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(eventData, Microsoft.ApplicationInsights.Telemetry.Event.envelopeType);
|
||||
context.track(eventEnvelope);
|
||||
|
||||
// track exception
|
||||
var exceptionObj = new Microsoft.ApplicationInsights.Telemetry.Exception(new Error(), "handledAt", null, null, AI.SeverityLevel.Critical);
|
||||
var exceptionData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Exception>(Microsoft.ApplicationInsights.Telemetry.Exception.dataType, exceptionObj);
|
||||
var exceptionEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(exceptionData, Microsoft.ApplicationInsights.Telemetry.Exception.envelopeType);
|
||||
const exceptionObj = new Microsoft.ApplicationInsights.Telemetry.Exception(new Error(), "handledAt", null, null, AI.SeverityLevel.Critical);
|
||||
const exceptionData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Exception>(
|
||||
Microsoft.ApplicationInsights.Telemetry.Exception.dataType, exceptionObj);
|
||||
const exceptionEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(exceptionData, Microsoft.ApplicationInsights.Telemetry.Exception.envelopeType);
|
||||
context.track(exceptionEnvelope);
|
||||
|
||||
// track metric
|
||||
var metricObj = new Microsoft.ApplicationInsights.Telemetry.Metric("name", 1234, 1, 0, 100, null);
|
||||
var metricData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Metric>(Microsoft.ApplicationInsights.Telemetry.Metric.dataType, metricObj);
|
||||
var metricEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(metricData, Microsoft.ApplicationInsights.Telemetry.Metric.envelopeType);
|
||||
const metricObj = new Microsoft.ApplicationInsights.Telemetry.Metric("name", 1234, 1, 0, 100, null);
|
||||
const metricData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Metric>(Microsoft.ApplicationInsights.Telemetry.Metric.dataType, metricObj);
|
||||
const metricEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(metricData, Microsoft.ApplicationInsights.Telemetry.Metric.envelopeType);
|
||||
context.track(metricEnvelope);
|
||||
|
||||
// track page view
|
||||
var pageViewObj = new Microsoft.ApplicationInsights.Telemetry.PageView("page name", "url", 999, null, null);
|
||||
var pageViewData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.PageView>(Microsoft.ApplicationInsights.Telemetry.PageView.dataType, pageViewObj);
|
||||
var pageViewEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(pageViewData, Microsoft.ApplicationInsights.Telemetry.PageView.envelopeType);
|
||||
const pageViewObj = new Microsoft.ApplicationInsights.Telemetry.PageView("page name", "url", 999, null, null);
|
||||
const pageViewData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.PageView>(Microsoft.ApplicationInsights.Telemetry.PageView.dataType, pageViewObj);
|
||||
const pageViewEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(pageViewData, Microsoft.ApplicationInsights.Telemetry.PageView.envelopeType);
|
||||
context.track(pageViewEnvelope);
|
||||
|
||||
// track page view performance
|
||||
var pageViewPerfObj = new Microsoft.ApplicationInsights.Telemetry.PageViewPerformance("page name", "url", 999, null, null);
|
||||
var pageViewPerfData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.PageViewPerformance>(Microsoft.ApplicationInsights.Telemetry.PageViewPerformance.dataType, pageViewPerfObj);
|
||||
var pageViewPerfEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(pageViewPerfData, Microsoft.ApplicationInsights.Telemetry.PageViewPerformance.envelopeType);
|
||||
const pageViewPerfObj = new Microsoft.ApplicationInsights.Telemetry.PageViewPerformance("page name", "url", 999, null, null);
|
||||
const pageViewPerfData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.PageViewPerformance>(
|
||||
Microsoft.ApplicationInsights.Telemetry.PageViewPerformance.dataType, pageViewPerfObj);
|
||||
const pageViewPerfEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(pageViewPerfData, Microsoft.ApplicationInsights.Telemetry.PageViewPerformance.envelopeType);
|
||||
context.track(pageViewPerfEnvelope);
|
||||
|
||||
// track remote dependency
|
||||
var remoteDepObj = new Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData("id", "url", "command", 1, true, 1234, "GET");
|
||||
var remoteDepData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData>(Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.dataType, remoteDepObj);
|
||||
var remoteDepEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(remoteDepData, Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.envelopeType);
|
||||
const remoteDepObj = new Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData("id", "url", "command", 1, true, 1234, "GET");
|
||||
const remoteDepData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData>(
|
||||
Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.dataType, remoteDepObj);
|
||||
const remoteDepEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(remoteDepData, Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.envelopeType);
|
||||
context.track(pageViewPerfEnvelope);
|
||||
|
||||
// track trace
|
||||
var traceObj = new Microsoft.ApplicationInsights.Telemetry.Trace("message", null);
|
||||
var traceData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Trace>(Microsoft.ApplicationInsights.Telemetry.Trace.dataType, traceObj);
|
||||
var traceEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(traceData, Microsoft.ApplicationInsights.Telemetry.Trace.envelopeType);
|
||||
const traceObj = new Microsoft.ApplicationInsights.Telemetry.Trace("message", null);
|
||||
const traceData = new Microsoft.ApplicationInsights.Telemetry.Common.Data<Microsoft.ApplicationInsights.Telemetry.Trace>(Microsoft.ApplicationInsights.Telemetry.Trace.dataType, traceObj);
|
||||
const traceEnvelope = new Microsoft.ApplicationInsights.Telemetry.Common.Envelope(traceData, Microsoft.ApplicationInsights.Telemetry.Trace.envelopeType);
|
||||
context.track(traceEnvelope);
|
|
@ -0,0 +1 @@
|
|||
// grunt-ts creates this file to help TypeScript find the compilation root of your project. If you wish to get to stop creating it, specify a `rootDir` setting in the Gruntfile ts `options`. See https://github.com/TypeStrong/grunt-ts#rootdir for details. Note that `rootDir` goes under `options`, and is case-sensitive. This message was revised in grunt-ts v6. Note that `rootDir` requires TypeScript 1.5 or higher.
|
|
@ -16,21 +16,6 @@ class DisableTelemetryTests extends TestClass {
|
|||
this.useFakeTimers = false;
|
||||
this.clock.restore();
|
||||
|
||||
var config = {
|
||||
enableSessionStorageBuffer: () => false,
|
||||
endpointUrl: () => null,
|
||||
emitLineDelimitedJson: () => null,
|
||||
maxBatchSizeInBytes: () => null,
|
||||
maxBatchInterval: () => null,
|
||||
disableTelemetry: () => null,
|
||||
isRetryDisabled: () => null,
|
||||
isBeaconApiDisabled: () => 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, "throwInternal");
|
||||
}
|
||||
|
||||
|
@ -45,7 +30,7 @@ class DisableTelemetryTests extends TestClass {
|
|||
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";
|
||||
config.instrumentationKey = "b7170927-2d1c-44f1-acec-59f4e1751c11";
|
||||
|
||||
var delay = config.maxBatchInterval + 10;
|
||||
|
||||
|
@ -96,6 +81,9 @@ class DisableTelemetryTests extends TestClass {
|
|||
var testAiNoMessages = new Microsoft.ApplicationInsights.AppInsights(config);
|
||||
testAiNoMessages.config.disableTelemetry = true;
|
||||
|
||||
this.errorSpy = this.sandbox.stub(testAiNoMessages.context._sender, "_onError");
|
||||
this.successSpy = this.sandbox.stub(testAiNoMessages.context._sender, "_onSuccess");
|
||||
|
||||
var exception = null;
|
||||
try {
|
||||
window["a"]["b"]();
|
||||
|
@ -122,6 +110,9 @@ class DisableTelemetryTests extends TestClass {
|
|||
var testAiNoMessages = new Microsoft.ApplicationInsights.AppInsights(config);
|
||||
testAiNoMessages.config.disableTelemetry = true;
|
||||
|
||||
this.errorSpy = this.sandbox.stub(testAiNoMessages.context._sender, "_onError");
|
||||
this.successSpy = this.sandbox.stub(testAiNoMessages.context._sender, "_onSuccess");
|
||||
|
||||
var exception = null;
|
||||
try {
|
||||
window["a"]["b"]();
|
||||
|
@ -142,6 +133,9 @@ class DisableTelemetryTests extends TestClass {
|
|||
var testAi = new Microsoft.ApplicationInsights.AppInsights(config);
|
||||
testAi.config.disableTelemetry = false;
|
||||
|
||||
this.errorSpy = this.sandbox.stub(testAi.context._sender, "_onError");
|
||||
this.successSpy = this.sandbox.stub(testAi.context._sender, "_onSuccess");
|
||||
|
||||
var exception = null;
|
||||
try {
|
||||
window["a"]["b"]();
|
|
@ -13,7 +13,7 @@
|
|||
window.AIResults.push(result);
|
||||
});
|
||||
</script>
|
||||
<script src="autoCollection.tests.js"></script>
|
||||
<script src="../../../bundle/test/e2e/DisableTelemetry.tests.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
|
@ -1,24 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Cache-control" content="no-Cache" />
|
||||
<title>Tests for Application Insights JavaScript API</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.18.0.css">
|
||||
<script src="http://code.jquery.com/qunit/qunit-1.18.0.js"></script>
|
||||
<script src="http://sinonjs.org/releases/sinon-1.17.2.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.AIResults = [];
|
||||
QUnit.testDone(function(result) {
|
||||
window.AIResults.push(result);
|
||||
});
|
||||
</script>
|
||||
<!--<script src="sprint70Snippet.js"></script>-->
|
||||
<script src="DisableTelemetryTests.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<div id="error-message"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -13,7 +13,7 @@
|
|||
window.AIResults.push(result);
|
||||
});
|
||||
</script>
|
||||
<script src="ValidateApiTests.js"></script>
|
||||
<script src="../../../bundle/test/e2e/PublicApiTests.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
|
@ -1,5 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Cache-control" content="no-Cache" />
|
||||
|
@ -9,15 +10,18 @@
|
|||
<script src="http://sinonjs.org/releases/sinon-1.17.2.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.AIResults = [];
|
||||
QUnit.testDone(function(result) {
|
||||
QUnit.testDone(function (result) {
|
||||
window.AIResults.push(result);
|
||||
});
|
||||
|
||||
</script>
|
||||
<script src="SanitizerE2E.Tests.js"></script>
|
||||
<script src="../../../bundle/test/e2e/SanitizerE2E.tests.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<div id="error-message"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,5 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Cache-control" content="no-Cache" />
|
||||
|
@ -9,15 +10,18 @@
|
|||
<script src="http://sinonjs.org/releases/sinon-1.17.2.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.AIResults = [];
|
||||
QUnit.testDone(function(result) {
|
||||
QUnit.testDone(function (result) {
|
||||
window.AIResults.push(result);
|
||||
});
|
||||
|
||||
</script>
|
||||
<script src="SenderE2E.tests.js"></script>
|
||||
<script src="../../../bundle/test/e2e/SenderE2E.tests.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<div id="error-message"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1,5 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Cache-control" content="no-Cache" />
|
||||
|
@ -9,15 +10,18 @@
|
|||
<script src="http://sinonjs.org/releases/sinon-1.17.2.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.AIResults = [];
|
||||
QUnit.testDone(function(result) {
|
||||
QUnit.testDone(function (result) {
|
||||
window.AIResults.push(result);
|
||||
});
|
||||
|
||||
</script>
|
||||
<script src="PublicApiTests.js"></script>
|
||||
<script src="../../../bundle/test/e2e/ValidateApi.tests.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<div id="error-message"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -13,7 +13,7 @@
|
|||
window.AIResults.push(result);
|
||||
});
|
||||
</script>
|
||||
<script src="snippet.tests.js"></script>
|
||||
<script src="../../../bundle/test/e2e/Snippet.tests.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
|
|
|
@ -68,27 +68,6 @@ $testSnippet = $testSnippet -replace "CDN_URL",$aiPath
|
|||
$testSnippet += $queueTest
|
||||
$testSnippet | out-file "$($projectDir)\E2ETests\testSnippet.js"
|
||||
|
||||
# add snippet to error test files
|
||||
$instrumentation = gc "$($projectDir)\E2ETests\autoCollectionTemplates\instrumentation.js"
|
||||
$files = @("ajax.html", "errorDom.html", "errorScriptGlobal.html", "errorScriptNested.html", "errorScriptSyntax.html")
|
||||
foreach ($file in $files) {
|
||||
$content = gc "$($projectDir)\E2ETests\autoCollectionTemplates\$($file)"
|
||||
|
||||
$strSnippet = ""
|
||||
foreach ($line in $edgePrefix) {
|
||||
$strSnippet += $line + "`r`n "
|
||||
}
|
||||
|
||||
$strInstrumentation = ""
|
||||
foreach ($line in $instrumentation) {
|
||||
$strInstrumentation += $line + "`r`n "
|
||||
}
|
||||
|
||||
$content = $content -replace 'PREFIX_PLACEHOLDER', $strSnippet
|
||||
$content = $content -replace 'INSTRUMENTATION_PLACEHOLDER', $strInstrumentation
|
||||
$content | out-file "$($projectDir)\E2ETests\$($file)"
|
||||
}
|
||||
|
||||
# add snippet to performance test file
|
||||
$content = gc "$($projectDir)\Selenium\testPageNoAppInsights.html"
|
||||
$strSnippet = ""
|
||||
|
|
|
@ -33,7 +33,7 @@ class PublicApiTests extends TestClass {
|
|||
var config = Microsoft.ApplicationInsights.Initialization.getDefaultConfig();
|
||||
config.maxBatchInterval = 100;
|
||||
config.endpointUrl = "https://dc.services.visualstudio.com/v2/track";
|
||||
config.instrumentationKey = "3e6a441c-b52b-4f39-8944-f81dd6c2dc46";
|
||||
config.instrumentationKey = "b7170927-2d1c-44f1-acec-59f4e1751c11";
|
||||
|
||||
this.delay = config.maxBatchInterval + 100;
|
||||
this.testAi = new Microsoft.ApplicationInsights.AppInsights(config);
|
|
@ -44,7 +44,7 @@ class Sanitizer2ETests extends TestClass {
|
|||
this.config = Microsoft.ApplicationInsights.Initialization.getDefaultConfig();
|
||||
this.config.maxBatchInterval = 1000;
|
||||
this.config.endpointUrl = "https://dc.services.visualstudio.com/v2/track";
|
||||
this.config.instrumentationKey = "3e6a441c-b52b-4f39-8944-f81dd6c2dc46";
|
||||
this.config.instrumentationKey = "b7170927-2d1c-44f1-acec-59f4e1751c11";
|
||||
|
||||
this.delay = 100;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference path="..\TestFramework\Common.ts" />
|
||||
/// <reference path="../../javascriptsdk/appinsights.ts" />
|
||||
/// <reference path="../../javascriptsdk/initialization.ts" />
|
||||
/// <reference path="../../JavaScriptsdk/appinsights.ts" />
|
||||
/// <reference path="../../JavaScriptsdk/initialization.ts" />
|
||||
|
||||
class SenderE2ETests extends TestClass {
|
||||
|
||||
|
@ -30,8 +30,7 @@ class SenderE2ETests extends TestClass {
|
|||
public getAiClient(config: Microsoft.ApplicationInsights.IConfig): Microsoft.ApplicationInsights.AppInsights {
|
||||
config.maxBatchInterval = this.maxBatchInterval;
|
||||
config.endpointUrl = "https://dc.services.visualstudio.com/v2/track";
|
||||
config.instrumentationKey = "3e6a441c-b52b-4f39-8944-f81dd6c2dc46";
|
||||
|
||||
config.instrumentationKey = "b7170927-2d1c-44f1-acec-59f4e1751c11";
|
||||
|
||||
return new Microsoft.ApplicationInsights.AppInsights(config);
|
||||
}
|
||||
|
@ -44,6 +43,10 @@ class SenderE2ETests extends TestClass {
|
|||
stepDelay: this.delay,
|
||||
steps: [
|
||||
() => {
|
||||
if (!(<any>navigator).sendBeacon) {
|
||||
(<any>navigator)['sendBeacon'] = (url: any, data: any) => { };
|
||||
}
|
||||
|
||||
var config = Microsoft.ApplicationInsights.Initialization.getDefaultConfig();
|
||||
config.isBeaconApiDisabled = false;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference path="..\TestFramework\Common.ts" />
|
||||
/// <reference path="../../javascriptsdk/appinsights.ts" />
|
||||
/// <reference path="../../javascriptsdk/initialization.ts" />
|
||||
/// <reference path="../TestFramework/Common.ts" />
|
||||
/// <reference path="../../JavaScriptSDK/AppInsights.ts" />
|
||||
/// <reference path="../../JavaScriptSDK/Initialization.ts" />
|
||||
|
||||
class ValidateTests extends TestClass {
|
||||
|
||||
|
@ -18,7 +18,7 @@ class ValidateTests extends TestClass {
|
|||
this.config = Microsoft.ApplicationInsights.Initialization.getDefaultConfig();
|
||||
this.config.maxBatchInterval = 100;
|
||||
this.config.endpointUrl = "https://dc.services.visualstudio.com/v2/validate";
|
||||
this.config.instrumentationKey = "3e6a441c-b52b-4f39-8944-f81dd6c2dc46";
|
||||
this.config.instrumentationKey = "b7170927-2d1c-44f1-acec-59f4e1751c11";
|
||||
this.config.enableSessionStorageBuffer = false;
|
||||
|
||||
this.delay = this.config.maxBatchInterval + 100;
|
||||
|
@ -71,7 +71,10 @@ class ValidateTests extends TestClass {
|
|||
Assert.ok(!this.successSpy.called, "success not called");
|
||||
Assert.ok(this.errorSpy.called, "error called");
|
||||
|
||||
var result = JSON.parse(this.errorSpy.args[0][1]);
|
||||
let response = this.errorSpy.args[0][1] as string;
|
||||
response = response.replace("XMLHttpRequest,Status:400,Response:", "");
|
||||
|
||||
var result = JSON.parse(response);
|
||||
|
||||
Assert.equal(1, result.itemsReceived, "backend received wrong number of elements");
|
||||
Assert.equal(0, result.itemsAccepted, "backend accepted invalid number of events");
|
|
@ -1,325 +0,0 @@
|
|||
/// <reference path="../../javascriptsdk/telemetry/exception.ts" />
|
||||
/// <reference path="..\TestFramework\Common.ts" />
|
||||
/// <reference path="../../javascriptsdk/appinsights.ts" />
|
||||
|
||||
class AutoCollectionTests extends TestClass {
|
||||
|
||||
/** Turns on/off sinon's syncronous implementation of setTimeout. On by default. */
|
||||
public errorSpy: SinonSpy;
|
||||
|
||||
/** Method called before the start of each test method */
|
||||
public testInitialize() {
|
||||
this.useFakeTimers = false;
|
||||
this.clock.restore();
|
||||
this.errorSpy = this.getListener("ErrorSpy");
|
||||
}
|
||||
|
||||
/** Method called after each test method has completed */
|
||||
public testCleanup() {
|
||||
this.useFakeTimers = true;
|
||||
this.errorSpy.reset();
|
||||
}
|
||||
|
||||
public registerTests() {
|
||||
var delay = 5000;
|
||||
|
||||
this.testCaseAsync({
|
||||
name: "AutoCollection: ajax",
|
||||
stepDelay: delay,
|
||||
steps: [
|
||||
() => {
|
||||
this.loadErrorTest("ajax");
|
||||
}
|
||||
].concat(this.poll(() => {
|
||||
return this.verifyAjax(this.errorSpy, [
|
||||
{
|
||||
name: "https://code.jquery.com/jquery-2.1.4.min.js",
|
||||
success: true,
|
||||
commandName: "/jquery-2.1.4.min.js",
|
||||
dependencyTypeName: "Ajax",
|
||||
dependencyKind: 1,
|
||||
dependencySource: 2
|
||||
},
|
||||
{
|
||||
name: "https://dc.services.visualstudio.com/v2/track",
|
||||
success: false,
|
||||
commandName: "/v2/track",
|
||||
dependencyTypeName: "Ajax",
|
||||
dependencyKind: 1,
|
||||
dependencySource: 2
|
||||
},
|
||||
{
|
||||
name: "https://dc.services.visualstudio.com/v2/track",
|
||||
commandName: "/v2/track",
|
||||
success: false,
|
||||
dependencyTypeName: "Ajax",
|
||||
dependencyKind: 1,
|
||||
dependencySource: 2
|
||||
},
|
||||
{
|
||||
name: "https://dc.services.visualstudio.com/v2/track",
|
||||
commandName: "/v2/track",
|
||||
success: false,
|
||||
dependencyTypeName: "Ajax",
|
||||
dependencyKind: 1,
|
||||
dependencySource: 2
|
||||
}
|
||||
]);
|
||||
}))
|
||||
});
|
||||
|
||||
//var errorDomSpy = this.getListener("errorDom");
|
||||
this.testCaseAsync({
|
||||
name: "AutoCollection: errorDom",
|
||||
stepDelay: delay,
|
||||
steps: [
|
||||
() => {
|
||||
this.loadErrorTest("errorDom");
|
||||
}
|
||||
].concat(this.poll(() => {
|
||||
return this.verifyErrorMessages(this.errorSpy, [
|
||||
//General Error message
|
||||
"NotFoundError",
|
||||
|
||||
// Safari specific error message
|
||||
"An attempt was made to reference a Node in a context where it does not exist"
|
||||
], 1);
|
||||
}))
|
||||
});
|
||||
|
||||
//var errorScriptGlobalSpy = this.getListener("errorScriptGlobal");
|
||||
this.testCaseAsync({
|
||||
name: "AutoCollection: errorScriptGlobal",
|
||||
stepDelay: delay,
|
||||
steps: [
|
||||
() => {
|
||||
this.loadErrorTest("errorScriptGlobal");
|
||||
}
|
||||
].concat(this.poll(() => {
|
||||
return this.verifyErrorMessages(this.errorSpy, [
|
||||
// General errors
|
||||
"undefinedObject is not defined",
|
||||
|
||||
// IE specific error messages
|
||||
"Object doesn't support property or method 'unsupportedMethod'",
|
||||
"The use of a keyword for an identifier is invalid",
|
||||
"Array length must be a finite positive integer",
|
||||
"Cannot assign to a function result",
|
||||
"'undefinedObject' is undefined",
|
||||
"Boolean.prototype.toString: 'this' is not a Boolean object",
|
||||
"Function expected",
|
||||
|
||||
// Chrome specific error messages
|
||||
"Invalid array length",
|
||||
"Invalid left-hand side in assignment",
|
||||
"Boolean.prototype.toString is not generic",
|
||||
"object is not a function",
|
||||
"undefined is not a function",
|
||||
|
||||
// Firefox specific error messages
|
||||
"obj.unsupportedMethod is not a function",
|
||||
"invalid array length",
|
||||
"invalid assignment left-hand side",
|
||||
"toString method called on incompatible Object",
|
||||
"o is not a function",
|
||||
|
||||
// Safari specific error messages
|
||||
"'undefined' is not a function",
|
||||
"Array size is not a small enough positive integer",
|
||||
"Left side of assignment is not a reference",
|
||||
"Can't find variable: undefinedObject",
|
||||
"Type error",
|
||||
"'[object Object]' is not a function (evaluating 'o()')"
|
||||
], 7);
|
||||
}))
|
||||
});
|
||||
|
||||
//var errorScriptNestedSpy = this.getListener("errorScriptNested");
|
||||
this.testCaseAsync({
|
||||
name: "AutoCollection: errorScriptNested",
|
||||
stepDelay: delay,
|
||||
steps: [
|
||||
() => {
|
||||
this.loadErrorTest("errorScriptNested");
|
||||
}
|
||||
].concat(this.poll(() => {
|
||||
return this.verifyErrorMessages(this.errorSpy, [
|
||||
//General Error message
|
||||
"first is not defined",
|
||||
"afterFullAiLoads",
|
||||
|
||||
// IE specific error messages
|
||||
"'first' is undefined",
|
||||
"Unable to get property 'exist' of undefined or null reference",
|
||||
|
||||
// Chrome specific error messages
|
||||
"Cannot read property 'exist' of undefined",
|
||||
|
||||
// Firefox specific error messages
|
||||
"no element found",
|
||||
"window.doesNot is undefined",
|
||||
|
||||
// Safari specific error messages
|
||||
"Can't find variable: first",
|
||||
"'undefined' is not an object"
|
||||
], 3);
|
||||
}))
|
||||
});
|
||||
|
||||
//var errorScriptSyntaxSpy = this.getListener("errorScriptSyntax");
|
||||
this.testCaseAsync({
|
||||
name: "AutoCollection: errorScriptSyntax",
|
||||
stepDelay: delay,
|
||||
steps: [
|
||||
() => {
|
||||
this.loadErrorTest("errorScriptSyntax");
|
||||
}
|
||||
].concat(this.poll(() => {
|
||||
return this.verifyErrorMessages(this.errorSpy, [
|
||||
// IE specific error messages
|
||||
"Object doesn't support property or method 'unsupportedMethod'",
|
||||
"Expected '}'",
|
||||
"Unterminated string constant",
|
||||
|
||||
// Chrome specific error messages
|
||||
"undefined is not a function",
|
||||
"Unexpected end of input",
|
||||
"Unexpected token ILLEGAL",
|
||||
|
||||
// Firefox specific error messages
|
||||
"obj.unsupportedMethod is not a function",
|
||||
"missing } in compound statement",
|
||||
"unterminated string literal",
|
||||
"missing } after function body",
|
||||
|
||||
// Safari specific error messages
|
||||
"Expected token '}'",
|
||||
"Unexpected EOF"
|
||||
], 5);
|
||||
}))
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private getListener(address): SinonSpy {
|
||||
var listener = { onMessage: () => null };
|
||||
var spy = this.sandbox.spy(listener, "onMessage");
|
||||
|
||||
if (window.addEventListener) {
|
||||
addEventListener("message", listener.onMessage, false);
|
||||
} else {
|
||||
window["attachEvent"].call("onmessage", listener.onMessage);
|
||||
}
|
||||
|
||||
return spy;
|
||||
}
|
||||
|
||||
private loadErrorTest(path) {
|
||||
window["appInsights"] = undefined;
|
||||
var href = window.location.href.toLowerCase();
|
||||
var fullPath = href.split("e2etests")[0] + "e2etests/" + path + ".html";
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = fullPath;
|
||||
iframe.id = path;
|
||||
document.getElementsByTagName("body")[0].parentNode.appendChild(iframe);
|
||||
return iframe;
|
||||
}
|
||||
|
||||
private poll(func: () => boolean, count: number = 1) {
|
||||
var polling = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
polling.push(() => {
|
||||
if (func()) {
|
||||
Assert.ok(true, "validated, stopping poll cycle");
|
||||
this.testCleanup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return polling;
|
||||
}
|
||||
|
||||
private getTelemetryItemsFromMessage(args, telemetryType) {
|
||||
var items = [];
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var payload = args[i][0];
|
||||
try {
|
||||
var data = JSON.parse(payload.data);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var d = data[j].data;
|
||||
if (d && d.baseType === telemetryType) {
|
||||
items.push(d.baseData);
|
||||
}
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private getExceptionsFromMessage(args) {
|
||||
var exceptions = [];
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var payload = args[i][0];
|
||||
var data = JSON.parse(payload.data);
|
||||
for (var j = 0; j < data.length; j++) {
|
||||
var d = data[j].data;
|
||||
if (d && d.baseType === Microsoft.ApplicationInsights.Telemetry.Exception.dataType) {
|
||||
exceptions.push(d.baseData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
private verifyAjax(spy: SinonSpy, expectedItems) {
|
||||
if (spy.called) {
|
||||
var args = spy.args;
|
||||
var ajaxItems = this.getTelemetryItemsFromMessage(args, Microsoft.ApplicationInsights.Telemetry.RemoteDependencyData.dataType);
|
||||
|
||||
Assert.equal(expectedItems.length, ajaxItems.length, "Number of expected and actual ajax calls must match");
|
||||
|
||||
for (var i = 0; i < ajaxItems.length; ++i) {
|
||||
var actual = ajaxItems[i];
|
||||
var expected = expectedItems[i];
|
||||
|
||||
Assert.equal(expected.name, actual.name, "Name must match");
|
||||
Assert.equal(expected.commandName, actual.commandName, "CommandName must match");
|
||||
Assert.equal(expected.success, actual.success, "Success property must match");
|
||||
Assert.equal(expected.dependencyTypeName, actual.dependencyTypeName, "DependencyTypeName must match");
|
||||
Assert.equal(expected.dependencyKind, actual.dependencyKind, "DependencyKind must match");
|
||||
Assert.equal(expected.dependencySource, actual.dependencySource, "DependencySource must match");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private verifyErrorMessages(spy: SinonSpy, expectedMessages, numberOfTests) {
|
||||
var done = false;
|
||||
|
||||
if (spy.called) {
|
||||
var args = spy.args;
|
||||
var exceptions = this.getExceptionsFromMessage(args);
|
||||
var count = 0;
|
||||
for (var i = 0; i < exceptions.length; i++) {
|
||||
var exception = exceptions[i];
|
||||
var message = exception.exceptions[0].message;
|
||||
for (var j = 0; j < expectedMessages.length; j++) {
|
||||
if (message.indexOf(expectedMessages[j]) >= 0) {
|
||||
Assert.ok(true, "Message '" + expectedMessages[j] + "' is contained in: " + message);
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done = count >= numberOfTests;
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
}
|
||||
new AutoCollectionTests().registerTests();
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
class SnippetTests extends TestClass {
|
||||
private aiName = "appInsights";
|
||||
private instrumentationKey = "3e6a441c-b52b-4f39-8944-f81dd6c2dc46";
|
||||
private originalAppInsights;
|
||||
private queueSpy;
|
||||
|
||||
|
|
Двоичный файл не отображается.
Двоичный файл не отображается.
Двоичный файл не отображается.
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -97,12 +97,6 @@
|
|||
<Content Include="E2ETests\testSnippet.js">
|
||||
<DependentUpon>PostBuild.ps1</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="E2ETests\ajax.html">
|
||||
<DependentUpon>PostBuild.ps1</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="E2ETests\errorDom.html">
|
||||
<DependentUpon>PostBuild.ps1</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="E2ETests\errorScriptGlobal.html">
|
||||
<DependentUpon>PostBuild.ps1</DependentUpon>
|
||||
</Content>
|
||||
|
@ -123,8 +117,6 @@
|
|||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="E2ETests\autoCollectionTemplates\ajax.html" />
|
||||
<Content Include="E2ETests\autoCollectionTemplates\errorDom.html" />
|
||||
<Content Include="E2ETests\autoCollectionTemplates\errorScriptGlobal.html" />
|
||||
<Content Include="E2ETests\autoCollectionTemplates\errorScriptNested.html" />
|
||||
<Content Include="E2ETests\autoCollectionTemplates\errorScriptSyntax.html" />
|
||||
|
@ -170,20 +162,6 @@
|
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JavaScriptSDK.Interfaces\JavaScriptSDK.Interfaces.csproj">
|
||||
<Project>{fad54375-9834-4265-baac-77b64a6aeec1}</Project>
|
||||
<Name>JavaScriptSDK.Interfaces</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JavaScriptSDK.Module\JavaScriptSDK.Module.csproj">
|
||||
<Project>{9efeed47-7841-4356-8a6f-ad16ff9a28e4}</Project>
|
||||
<Name>JavaScriptSDK.Module</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JavaScriptSDK\JavaScriptSDK.csproj">
|
||||
<Project>{49ECFE69-8C92-4FA7-A7C3-CDB957C71654}</Project>
|
||||
<Name>JavaScriptSDK</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="External\qunit.d.ts" />
|
||||
<Content Include="External\sinon.d.ts" />
|
||||
|
@ -275,12 +253,6 @@
|
|||
<DependentUpon>DisableTelemetryTests.ts</DependentUpon>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
||||
<SeleniumAppInsightsSDK Include="Selenium\appInsightsSdk.ts" />
|
||||
<Content Include="Selenium\appInsightsSdk.js">
|
||||
<DependentUpon>appInsightsSdk.ts</DependentUpon>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<SeleniumCheckinTests Include="Selenium\checkinTests.ts" />
|
||||
<SeleniumPerformance Include="Selenium\performanceTests.ts" />
|
||||
<Content Include="Selenium\checkinTests.js">
|
||||
|
@ -309,7 +281,6 @@
|
|||
<Exec Command="$(TypeScriptCompilerPath) --target ES5 --module amd @(SnippetTests ->'"%(fullpath)"', ' ') --out E2ETests\snippet.tests.js" />
|
||||
<Exec Command="$(TypeScriptCompilerPath) --target ES5 --module amd @(DisableTelemetryTests ->'"%(fullpath)"', ' ') --out E2ETests\DisableTelemetryTests.js" />
|
||||
<Exec Command="$(TypeScriptCompilerPath) --target ES5 --module amd @(SenderTests ->'"%(fullpath)"', ' ') --out E2ETests\SenderE2E.tests.js" />
|
||||
|
||||
<Exec Command="Powershell.exe -ExecutionPolicy ByPass -File "$(ProjectDir)E2ETests\PostBuild.ps1" -projectDir $(ProjectDir) -outputDir $(OutputPath)" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -1,41 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Cache-control" content="no-Cache" />
|
||||
<title>Tests for Application Insights JavaScript API</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.18.0.css">
|
||||
<script src="http://code.jquery.com/qunit/qunit-1.18.0.js"></script>
|
||||
<script src="http://sinonjs.org/releases/sinon-1.17.2.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.AIResults = [];
|
||||
QUnit.testDone(function (result) {
|
||||
window.AIResults.push(result);
|
||||
});
|
||||
</script>
|
||||
<script src="../external/blanket-1.2.2.js" data-cover-reporter="../external/blanket-reporter.js" data-cover-flags="debug"></script>
|
||||
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
|
||||
<script src="http://sinonjs.org/releases/sinon-2.3.8.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>
|
||||
|
||||
<script src="appInsightsSdk.js" data-cover></script>
|
||||
<script src="checkinTests.js"></script>
|
||||
|
||||
<script>
|
||||
require.config({
|
||||
baseUrl: "../../"
|
||||
paths: {
|
||||
qunit: "../External/qunit-1.23.1",
|
||||
bridge: "../../../node_modules/grunt-contrib-qunit/phantomjs/bridge"
|
||||
}
|
||||
});
|
||||
|
||||
require(
|
||||
["JavaScriptSDK.Tests/Selenium/checkinTests"],
|
||||
function (t) {
|
||||
// register the tests.
|
||||
t.default();
|
||||
["qunit", "ai.tests"],
|
||||
function (QUnit, tests) {
|
||||
QUnit.start();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
<div id="error-message"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1 +0,0 @@
|
|||
/// <reference path="../../JavaScriptSDK/appInsights.ts" />
|
|
@ -1,4 +1,5 @@
|
|||
/// <reference path="../performance/api.perftests.ts" />
|
||||
/// <reference path="../performance/serializer.perftests.ts" />
|
||||
/// <reference path="../performance/pageload.perftests.ts" />
|
||||
// TODO: fix and enable
|
||||
// <reference path="../performance/api.perftests.ts" />
|
||||
// <reference path="../performance/serializer.perftests.ts" />
|
||||
// <reference path="../performance/pageload.perftests.ts" />
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
page = require('webpage').create();
|
||||
page.open('/JavaScript/JavaScriptSDK.Tests/Selenium/Tests.html?hidepassed', function () {
|
||||
debugger;
|
||||
page.evaluateAsync(function () {
|
||||
debugger; // wait here in the second web browser tab
|
||||
});
|
||||
});
|
|
@ -64,44 +64,9 @@
|
|||
<TypeScriptRemoveComments>true</TypeScriptRemoveComments>
|
||||
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<AjaxMinManifests Include="min\appInsights.ajaxmin.in">
|
||||
<SubType>Designer</SubType>
|
||||
</AjaxMinManifests>
|
||||
<Content Include="min\ai.min.js">
|
||||
<DependentUpon>appInsights.ajaxmin.in</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="min\snippet.min.js">
|
||||
<DependentUpon>appInsights.ajaxmin.in</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="min\ai.js">
|
||||
<DependentUpon>appInsights.ajaxmin.in</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="min\ai.d.ts">
|
||||
<DependentUpon>appInsights.ajaxmin.in</DependentUpon>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="min\snippet.ps1" />
|
||||
<Content Include="min\snippet.html">
|
||||
<DependentUpon>snippet.ps1</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="min\snippet_int.html">
|
||||
<DependentUpon>snippet.ps1</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="min\snippet_vsix.html">
|
||||
<DependentUpon>snippet.ps1</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="min\snippet_vsixint.html">
|
||||
<DependentUpon>snippet.ps1</DependentUpon>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="snippet.js" />
|
||||
<Content Include="web.config" />
|
||||
<Content Include="min\ai.min.js.map">
|
||||
<DependentUpon>ai.min.js</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="packages.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
|
@ -277,10 +242,6 @@
|
|||
<Error Condition="!Exists('..\..\..\packages\AjaxMin.5.14.5506.26202\tools\net40\AjaxMin.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." />
|
||||
<Error Condition="Exists('..\..\..\packages\AjaxMin.5.14.5506.26202\tools\net40\AjaxMin.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." />
|
||||
</Target>
|
||||
<Target Name="AfterBuild" DependsOnTargets="BuildAjaxMinManifests">
|
||||
<Message Text="Build snippet.html" />
|
||||
<Exec Command="Powershell.exe -ExecutionPolicy ByPass -File "$(ProjectDir)min\snippet.ps1" -projectDir $(ProjectDir)" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
<root>
|
||||
<output path="min\ai.min.js">
|
||||
<input path="min\ai.js"/>
|
||||
<!-- The TypeScript compiler generates unreferenced variables, so tell Ajax Minifier to not show these (or other) warnings. -->
|
||||
<arguments>-warn:0</arguments>
|
||||
</output>
|
||||
<output path="min\snippet.min.js">
|
||||
<input path="snippet.js"/>
|
||||
</output>
|
||||
</root>
|
|
@ -1,10 +0,0 @@
|
|||
<root>
|
||||
<output path="min\ai_tests.min.js">
|
||||
<input path="min\ai_tests.js"/>
|
||||
<!-- The TypeScript compiler generates unreferenced variables, so tell Ajax Minifier to not show these (or other) warnings. -->
|
||||
<arguments>-warn:0</arguments>
|
||||
</output>
|
||||
<output path="min\snippet.debug.m.js">
|
||||
<input path="snippet.js"/>
|
||||
</output>
|
||||
</root>
|
|
@ -1,4 +1,4 @@
|
|||
var appInsights = window.appInsights || (function(aiConfig) {
|
||||
var appInsights = window.appInsights || (function (aiConfig) {
|
||||
var appInsights = {
|
||||
config: aiConfig
|
||||
};
|
||||
|
@ -22,17 +22,17 @@
|
|||
// capture initial cookie
|
||||
try {
|
||||
appInsights.cookie = localDocument.cookie;
|
||||
} catch (e) {}
|
||||
} catch (e) { }
|
||||
|
||||
appInsights.queue = [];
|
||||
|
||||
function createLazyMethod(name) {
|
||||
// Define a temporary method that queues-up a the real method call
|
||||
appInsights[name] = function() {
|
||||
appInsights[name] = function () {
|
||||
// Capture the original arguments passed to the method
|
||||
var originalArguments = arguments;
|
||||
// Queue-up a call to the real method
|
||||
appInsights.queue.push(function() {
|
||||
appInsights.queue.push(function () {
|
||||
// Invoke the real method with the captured original arguments
|
||||
appInsights[name].apply(appInsights, originalArguments);
|
||||
});
|
||||
|
@ -60,7 +60,7 @@
|
|||
method = "onerror";
|
||||
createLazyMethod("_" + method);
|
||||
var originalOnError = localWindow[method];
|
||||
localWindow[method] = function(message, url, lineNumber, columnNumber, error) {
|
||||
localWindow[method] = function (message, url, lineNumber, columnNumber, error) {
|
||||
var handled = originalOnError && originalOnError(message, url, lineNumber, columnNumber, error);
|
||||
if (handled !== true) {
|
||||
appInsights["_" + method](message, url, lineNumber, columnNumber, error);
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.JavaScript", "NuGet.JavaScript\NuGet.JavaScript.csproj", "{7C2662E9-96D3-473A-B0DD-55A80343A237}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{49ECFE69-8C92-4FA7-A7C3-CDB957C71654} = {49ECFE69-8C92-4FA7-A7C3-CDB957C71654}
|
||||
{C6CA61F8-4855-4C77-B199-A56BAD047ADB} = {C6CA61F8-4855-4C77-B199-A56BAD047ADB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{59A3A3F8-A4CA-48B7-91BB-B3F1DE661EB9}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
|
@ -20,25 +16,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||
..\scripts\RunTestsInBrowser.ps1 = ..\scripts\RunTestsInBrowser.ps1
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptSDK", "JavaScriptSDK\JavaScriptSDK.csproj", "{49ECFE69-8C92-4FA7-A7C3-CDB957C71654}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptSDK.Tests", "JavaScriptSDK.Tests\JavaScriptSDK.Tests.csproj", "{C6CA61F8-4855-4C77-B199-A56BAD047ADB}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{49ECFE69-8C92-4FA7-A7C3-CDB957C71654} = {49ECFE69-8C92-4FA7-A7C3-CDB957C71654}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{6437E05C-5120-4E44-B696-61F19B0FD73A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.TypeScript", "NuGet.TypeScript\NuGet.TypeScript.csproj", "{314B90F5-0E04-456A-AF38-914F520C3BF3}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{7C2662E9-96D3-473A-B0DD-55A80343A237} = {7C2662E9-96D3-473A-B0DD-55A80343A237}
|
||||
{C6CA61F8-4855-4C77-B199-A56BAD047ADB} = {C6CA61F8-4855-4C77-B199-A56BAD047ADB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptSDK.Interfaces", "JavaScriptSDK.Interfaces\JavaScriptSDK.Interfaces.csproj", "{FAD54375-9834-4265-BAAC-77B64A6AEEC1}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JavaScriptSDK.Module", "JavaScriptSDK.Module\JavaScriptSDK.Module.csproj", "{9EFEED47-7841-4356-8A6F-AD16FF9A28E4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -48,26 +32,10 @@ Global
|
|||
{7C2662E9-96D3-473A-B0DD-55A80343A237}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7C2662E9-96D3-473A-B0DD-55A80343A237}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7C2662E9-96D3-473A-B0DD-55A80343A237}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{49ECFE69-8C92-4FA7-A7C3-CDB957C71654}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{49ECFE69-8C92-4FA7-A7C3-CDB957C71654}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{49ECFE69-8C92-4FA7-A7C3-CDB957C71654}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{49ECFE69-8C92-4FA7-A7C3-CDB957C71654}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C6CA61F8-4855-4C77-B199-A56BAD047ADB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C6CA61F8-4855-4C77-B199-A56BAD047ADB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C6CA61F8-4855-4C77-B199-A56BAD047ADB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C6CA61F8-4855-4C77-B199-A56BAD047ADB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{314B90F5-0E04-456A-AF38-914F520C3BF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{314B90F5-0E04-456A-AF38-914F520C3BF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{314B90F5-0E04-456A-AF38-914F520C3BF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{314B90F5-0E04-456A-AF38-914F520C3BF3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FAD54375-9834-4265-BAAC-77B64A6AEEC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FAD54375-9834-4265-BAAC-77B64A6AEEC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FAD54375-9834-4265-BAAC-77B64A6AEEC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FAD54375-9834-4265-BAAC-77B64A6AEEC1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9EFEED47-7841-4356-8A6F-AD16FF9A28E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9EFEED47-7841-4356-8A6F-AD16FF9A28E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9EFEED47-7841-4356-8A6F-AD16FF9A28E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9EFEED47-7841-4356-8A6F-AD16FF9A28E4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -23,26 +23,23 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
|
||||
<ItemGroup>
|
||||
<None Include="Package.nuspec" />
|
||||
<Content Include="..\JavaScriptSDK\min\ai.js">
|
||||
<Content Include="..\..\bundle\ai.js">
|
||||
<Link>ai.js</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\JavaScriptSDK\min\ai.min.js">
|
||||
<Content Include="..\..\bundle\ai.0.js">
|
||||
<Link>ai.min.js</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\JavaScriptSDK\min\snippet_vsix.html">
|
||||
<Content Include="..\..\bundle\ai.0.js.map">
|
||||
<Link>ai.min.js.map</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="..\..\snippet\snippet.html">
|
||||
<Link>snippet.html</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JavaScriptSDK\JavaScriptSDK.csproj">
|
||||
<Project>{49ECFE69-8C92-4FA7-A7C3-CDB957C71654}</Project>
|
||||
<Name>JavaScriptSDK</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\..\NuGet.targets" />
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'Package.targets'))\Package.targets" />
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<ProjectGuid>{314b90f5-0e04-456a-af38-914f520c3bf3}</ProjectGuid>
|
||||
<ProjectGuid>{314B90F5-0E04-456A-AF38-914F520C3BF3}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Microsoft.ApplicationInsights.TypeScript.NuGet</RootNamespace>
|
||||
<AssemblyName>Microsoft.ApplicationInsights.TypeScript.NuGet</AssemblyName>
|
||||
|
@ -23,17 +23,11 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
|
||||
<ItemGroup>
|
||||
<None Include="Package.nuspec" />
|
||||
<Content Include="..\JavaScriptSDK\min\ai.d.ts">
|
||||
<Content Include="..\..\bundle\ai.d.ts">
|
||||
<Link>ai.d.ts</Link>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JavaScriptSDK\JavaScriptSDK.csproj">
|
||||
<Project>{49ECFE69-8C92-4FA7-A7C3-CDB957C71654}</Project>
|
||||
<Name>JavaScriptSDK</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\..\NuGet.targets" />
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'Package.targets'))\Package.targets" />
|
||||
|
|
16
README.md
16
README.md
|
@ -95,15 +95,17 @@ See:
|
|||
## Build and run check-in tests:
|
||||
|
||||
* Build
|
||||
* Visual Studio 2013 Ultimate with Update 4 or later
|
||||
* Clone the Git repository
|
||||
* Open Visual Studio solution (devenv JavaScript\Microsoft.ApplicationInsights.JavaScript.sln)
|
||||
* Build solution in Visual Studio
|
||||
* `npm install -g grunt-cli`
|
||||
* `npm install`
|
||||
* `grunt` or Ctrl+Shift+B in VisualStudio Code
|
||||
* `grunt module` to build the npm module
|
||||
* compiled files are dropped into a `/bundle` folder
|
||||
|
||||
* Run check-in tests
|
||||
* `powershell "& .\scripts\RunTestsInBrowser.ps1"` to run `Tests.html` in a browser (you might need to call Set-ExecutionPolicy to be able to execute the script)
|
||||
* Don't forget to build the solution after changing TypeScript files
|
||||
* Refresh Tests.html in the browser to re-run tests
|
||||
* `grunt test` to build and run tests
|
||||
* You can also open `JavaScriptSDK.Tests/Selenium/Tests.html` directly in your browser to debug failing tests.
|
||||
|
||||
To debug tests in PhantomJS use a remote debugger: `phantomjs.exe --remote-debugger-port=9000 \JavaScript\JavaScriptSDK.Tests\phantomJS.debug.js`. If webkit console isn't working execute the following script in a browser's console: `function isEnterKey(event) { return (event.keyCode !== 229 && event.keyIdentifier === "Enter") || event.keyCode === 13; }`.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
module.exports = function (grunt) {
|
||||
grunt.initConfig({
|
||||
ts: {
|
||||
tsconfig: true,
|
||||
options: {
|
||||
comments: true
|
||||
},
|
||||
default: {
|
||||
src: [
|
||||
'JavaScript/JavaScriptSDK.Interfaces/*.ts',
|
||||
'JavaScript/JavaScriptSDK/*.ts',
|
||||
],
|
||||
out: 'bundle/ai.js',
|
||||
},
|
||||
module: {
|
||||
src: [
|
||||
'JavaScript/JavaScriptSDK.Interfaces/*.ts',
|
||||
'JavaScript/JavaScriptSDK.Module/*.ts',
|
||||
],
|
||||
out: 'bundle/ai.module.js'
|
||||
},
|
||||
types: {
|
||||
src: [
|
||||
'JavaScript/JavaScriptSDK.Tests/DefinitionTypes/*.ts'
|
||||
],
|
||||
out: 'bundle/test/ai.types.js'
|
||||
},
|
||||
test: {
|
||||
src: [
|
||||
'JavaScript/JavaScriptSDK.Tests/Selenium/*.ts'
|
||||
],
|
||||
out: 'JavaScript/JavaScriptSDK.Tests/Selenium/ai.tests.js'
|
||||
},
|
||||
testE2E: {
|
||||
files: [
|
||||
{
|
||||
src: 'JavaScript/JavaScriptSDK.Tests/E2ETests/DisableTelemetry.tests.ts',
|
||||
dest: 'bundle/test/e2e/DisableTelemetry.tests.js'
|
||||
},
|
||||
{
|
||||
src: 'JavaScript/JavaScriptSDK.Tests/E2ETests/PublicApi.tests.ts',
|
||||
dest: 'bundle/test/e2e/PublicApiTests.tests.js'
|
||||
},
|
||||
{
|
||||
src: 'JavaScript/JavaScriptSDK.Tests/E2ETests/SanitizerE2E.tests.ts',
|
||||
dest: 'bundle/test/e2e/SanitizerE2E.tests.js'
|
||||
},
|
||||
{
|
||||
src: 'JavaScript/JavaScriptSDK.Tests/E2ETests/SenderE2E.tests.ts',
|
||||
dest: 'bundle/test/e2e/SenderE2E.tests.js'
|
||||
},
|
||||
{
|
||||
src: 'JavaScript/JavaScriptSDK.Tests/E2ETests/Snippet.tests.ts',
|
||||
dest: 'bundle/test/e2e/Snippet.tests.js'
|
||||
},
|
||||
{
|
||||
src: 'JavaScript/JavaScriptSDK.Tests/E2ETests/ValidateApi.tests.ts',
|
||||
dest: 'bundle/test/e2e/ValidateApi.tests.js'
|
||||
}
|
||||
],
|
||||
outDir: 'bundle/test/e2e'
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
ai: {
|
||||
files: {
|
||||
'bundle/ai.0.js': ['bundle/ai.js'],
|
||||
},
|
||||
options: {
|
||||
sourceMap: true,
|
||||
sourceMapIncludeSources: true,
|
||||
sourceMapIn: 'bundle/ai.js.map'
|
||||
},
|
||||
},
|
||||
snippet: {
|
||||
files: {
|
||||
'bundle/snippet/snippet.min.js': ['JavaScript/JavaScriptSDK/snippet.js']
|
||||
}
|
||||
}
|
||||
},
|
||||
qunit: {
|
||||
all: {
|
||||
options: {
|
||||
urls: [
|
||||
'JavaScript/JavaScriptSDK.Tests/Selenium/Tests.html',
|
||||
'JavaScript/JavaScriptSDK.Tests/E2ETests/E2E.DisableTelemetry.tests.htm',
|
||||
'JavaScript/JavaScriptSDK.Tests/E2ETests/E2E.PublicApi.tests.htm',
|
||||
'JavaScript/JavaScriptSDK.Tests/E2ETests/E2E.SanitizerE2E.tests.htm',
|
||||
'JavaScript/JavaScriptSDK.Tests/E2ETests/E2E.Sender.tests.htm',
|
||||
'JavaScript/JavaScriptSDK.Tests/E2ETests/E2E.snippetTests.htm',
|
||||
'JavaScript/JavaScriptSDK.Tests/E2ETests/E2E.ValidateApi.tests.htm'
|
||||
],
|
||||
timeout: 300 * 1000, // 5 min
|
||||
console: false,
|
||||
summaryOnly: true,
|
||||
'--web-security': 'false' // we need this to allow CORS requests in PhantomJS
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.event.on('qunit.testStart', function (name) {
|
||||
grunt.log.ok('Running test: ' + name);
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks("grunt-ts");
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-qunit');
|
||||
|
||||
grunt.registerTask("default", ["ts:default", "uglify:ai", "uglify:snippet"]);
|
||||
grunt.registerTask("module", ["ts:module"]);
|
||||
grunt.registerTask("test", ["ts:default", "ts:test", "ts:testE2E", "ts:types", "qunit"]);
|
||||
};
|
55
package.json
55
package.json
|
@ -1,26 +1,33 @@
|
|||
{
|
||||
"name": "applicationinsights-js",
|
||||
"version": "1.0.11",
|
||||
"description": "Microsoft Application Insights JavaScript SDK",
|
||||
"main": "JavaScript/JavaScriptSDK.Module/AppInsightsModule.js",
|
||||
"keywords": [
|
||||
"browser performance monitoring",
|
||||
"script errors",
|
||||
"application insights",
|
||||
"microsoft",
|
||||
"azure"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Microsoft/ApplicationInsights-JS.git"
|
||||
},
|
||||
"author": "Microsoft Application Insights Team",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/ApplicationInsights-JS/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Microsoft/ApplicationInsights-JS#readme"
|
||||
"name": "applicationinsights-js",
|
||||
"version": "1.0.11",
|
||||
"description": "Microsoft Application Insights JavaScript SDK",
|
||||
"main": "bundle/ai.module.js",
|
||||
"keywords": [
|
||||
"browser performance monitoring",
|
||||
"script errors",
|
||||
"application insights",
|
||||
"microsoft",
|
||||
"azure"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Microsoft/ApplicationInsights-JS.git"
|
||||
},
|
||||
"author": "Microsoft Application Insights Team",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Microsoft/ApplicationInsights-JS/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Microsoft/ApplicationInsights-JS#readme",
|
||||
"devDependencies": {
|
||||
"grunt": "1.0.1",
|
||||
"grunt-contrib-qunit": "2.0.0",
|
||||
"grunt-contrib-uglify": "2.3.0",
|
||||
"grunt-ts": "^6.0.0-beta.15",
|
||||
"typescript": "2.4.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ $aiSize = (Get-Item $ai).Length;
|
|||
$aiMinSize = (Get-Item $aiMin).Length;
|
||||
$aiMinZipSize = (Get-Item $aiMinZip).Length;
|
||||
|
||||
Write-Host ==== JS SDK size ===
|
||||
Write-Host ai.js: $aiSize bytes
|
||||
Write-Host ai.min.js: $aiMinSize bytes
|
||||
Write-Host ai.min.zip: $aiMinZipSize bytes
|
||||
Write-Host "==== JS SDK size ==="
|
||||
Write-Host "ai.js: $aiSize bytes. Path: $ai"
|
||||
Write-Host "ai.min.js: $aiMinSize bytes. Path: $aiMin"
|
||||
Write-Host "ai.min.zip: $aiMinZipSize bytes. Path $aiMinZip"
|
||||
|
||||
$currentDir = Get-Location;
|
||||
$aiDll = Join-Path $currentDir -ChildPath "Microsoft.ApplicationInsights.dll";
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
# build snippet.html from minified javascript snippet
|
||||
Param(
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[parameter(Mandatory=$true, HelpMessage="The project directory.")]
|
||||
[string]$projectDir,
|
||||
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[parameter(Mandatory=$false, HelpMessage="The relative output path/format.")]
|
||||
[string]$outputPath="snippet.html",
|
||||
|
@ -37,7 +33,7 @@ Param(
|
|||
#>
|
||||
function Get-OutputPath($flavor) {
|
||||
$path = $outputPath -replace "\.", "$($flavor)."
|
||||
return "$($projectDir)\min\$($path)"
|
||||
return ".\snippet\$($path)"
|
||||
}
|
||||
|
||||
<#
|
||||
|
@ -51,7 +47,7 @@ function Get-OutputPath($flavor) {
|
|||
function Read-MinifiedSnippet()
|
||||
{
|
||||
# find the file path with preference for release build
|
||||
$snippetPath = "$($projectDir)\min\snippet.min.js"
|
||||
$snippetPath = ".\bundle\snippet\snippet.min.js"
|
||||
|
||||
# read the minified snippet
|
||||
$snippet = gc $snippetPath
|
|
@ -13,7 +13,7 @@ $packagesJson = (Get-Content $packageJsonPath -Raw) | ConvertFrom-Json
|
|||
$version = $packagesJson.version;
|
||||
|
||||
# check if the minified dir exists
|
||||
$jssdkMinDir = Join-Path $jssdkDir -ChildPath "JavaScript\JavaScriptSDK\min\";
|
||||
$jssdkMinDir = Join-Path $jssdkDir -ChildPath "bundle\";
|
||||
|
||||
if (-Not (Test-Path $jssdkMinDir)) {
|
||||
Write-Warning "'$jssdkMinDir' directory doesn't exist. Compile JSSDK first.";
|
||||
|
|
|
@ -3,7 +3,7 @@ $jsSdkDir = Split-Path (Split-Path $MyInvocation.MyCommand.Path) -Parent;
|
|||
Write-Host "Releasing a vnext from $jsSdkDir";
|
||||
|
||||
# check if the minified dir exists
|
||||
$jssdkMinDir = Join-Path $jssdkDir -ChildPath "JavaScript\JavaScriptSDK\min\";
|
||||
$jssdkMinDir = Join-Path $jssdkDir -ChildPath "bundle\";
|
||||
|
||||
if (-Not (Test-Path $jssdkMinDir)) {
|
||||
Write-Warning "'$jssdkMinDir' directory doesn't exist. Compile JSSDK first.";
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"sourceMap": true,
|
||||
"noImplicitAny": false,
|
||||
"module": "amd",
|
||||
"target": "es5",
|
||||
"alwaysStrict": true,
|
||||
"declaration": true
|
||||
},
|
||||
"files": [
|
||||
]
|
||||
}
|
Загрузка…
Ссылка в новой задаче