Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Migrate to grunt build #498

Merged
merged 23 commits into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,10 @@ $RECYCLE.BIN/

# Visual studio 2015 user specific files
JavaScript/.vs

# Temp directories
bundle/
node_modules/

# Grunt
.tscache
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
// Use Typescript from node_modules instead of builtin to VSCode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments aren't usually valid JSON. Is vscode okay with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

"typescript.tsdk": "./node_modules/typescript/lib",
"files.exclude": {
"**/dist": true,
"**/.tscache": true
}
}
30 changes: 30 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"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"
]
}
]
}
1 change: 1 addition & 0 deletions JavaScript/.baseDir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Ignore this file. See https://github.com/grunt-ts/grunt-ts/issues/77
9 changes: 6 additions & 3 deletions JavaScript/JavaScriptSDK.Interfaces/ITelemetryContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion JavaScript/JavaScriptSDK.Interfaces/Telemetry/IEnvelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ module Microsoft.ApplicationInsights {
tags: { [name: string]: any };
data: any;
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
36 changes: 5 additions & 31 deletions JavaScript/JavaScriptSDK.Tests/CheckinTests/Context/User.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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



}
});

Expand Down Expand Up @@ -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



}
});

Expand All @@ -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");

}
});

Expand All @@ -142,7 +131,6 @@ class UserContextTests extends TestClass {

// verify
Assert.equal(authId, user.authenticatedId, "user auth id was set from cookie");

}
});

Expand All @@ -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");

}
});

Expand All @@ -176,7 +163,6 @@ class UserContextTests extends TestClass {

// verify
Assert.equal(config.accountId(), user.accountId, "user account id was set from back compat");

}
});

Expand All @@ -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");

}
});

Expand All @@ -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");

}
});

Expand All @@ -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");

}
});

Expand All @@ -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);
Expand All @@ -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");


}
});

Expand All @@ -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);
Expand All @@ -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");


}
});

Expand All @@ -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');
Expand All @@ -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");


}
});

Expand All @@ -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");


}
});

Expand All @@ -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");


}
});

Expand All @@ -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");


}
});

Expand All @@ -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");

}
});

Expand All @@ -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");

}
});
}
Expand Down
8 changes: 8 additions & 0 deletions JavaScript/JavaScriptSDK.Tests/CheckinTests/Sender.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,10 @@ class SenderTests extends TestClass {
this.testCase({
name: "SenderTests: send() is using BeaconAPI sender if the BeaconAPI is enabled",
test: () => {
if (!(<any>navigator).sendBeacon) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there types we can update rather than cast to any?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I added that when I was fixing unit tests and forgot to remove it. It's gone now.

(<any>navigator)['sendBeacon'] = (url: any, data: any) => {};
}

// enable beacon API and mock sender
var config = this.getDefaultConfig();
config.isBeaconApiDisabled = () => false;
Expand All @@ -1134,6 +1138,10 @@ class SenderTests extends TestClass {
this.testCase({
name: "SenderTests: send() is not using BeaconAPI sender if the BeaconAPI is disabled",
test: () => {
if (!(<any>navigator).sendBeacon) {
(<any>navigator)['sendBeacon'] = (url: any, data: any) => {};
}

// enable beacon API and mock sender
var config = this.getDefaultConfig();
config.isBeaconApiDisabled = () => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,28 @@ 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;

// Act
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);
}

}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down
Loading