Repository: microsoft/ApplicationInsights-node.js (ts)

Issue:
Application Context is not being passed the packageJsonPath from Context Constructor
The Context Constructor accepts a path to the `package.json` file but it is being dropped and not passed to the function which uses it.

https://github.com/microsoft/ApplicationInsights-node.js/blob/c8f3326447c97c4ffbedbf97fb59cc558a9126fc/Library/Context.ts#L21

This leaves the user forced to call the `_loadApplicationContext` manually, which feels off.

Pull request description:
Fixing issue with packageJsonPath ignored for App version context
Fixes #709

Patch:
diff --git a/Library/Context.ts b/Library/Context.ts
index e5b93fb..0f8cd44 100644
--- a/Library/Context.ts
+++ b/Library/Context.ts
@@ -18,7 +18,7 @@ class Context {
         this.keys = new Contracts.ContextTagKeys();
         this.tags = <{ [key: string]: string}>{};
 
-        this._loadApplicationContext();
+        this._loadApplicationContext(packageJsonPath);
         this._loadDeviceContext();
         this._loadInternalContext();
     }


Test patch:
diff --git a/Tests/Library/Context.tests.ts b/Tests/Library/Context.tests.ts
index ce6c4a5..f81c879 100644
--- a/Tests/Library/Context.tests.ts
+++ b/Tests/Library/Context.tests.ts
@@ -1,13 +1,27 @@
 import assert = require("assert");
 import sinon = require("sinon");
-import http = require("http");
+import fs = require("fs");
 import os = require("os");
+import path = require("path");
 
 import Context = require("../../Library/Context");
 
 describe("Library/Context", () => {
     describe("#constructor()", () => {
         var stubs: Array<any> = [];
+
+        before(() => {
+            // Create custom package json
+            var jsonContent = JSON.stringify({ "version": "testVersion" });
+            var testFilePath = path.resolve(__dirname, "testpackage.json");
+            fs.writeFile(testFilePath, jsonContent, () => { });
+        });
+
+        after(() => {
+            var testFilePath = path.resolve(__dirname, "testpackage.json")
+            fs.unlink(testFilePath, (err) => { });
+        });
+
         beforeEach(() => {
             stubs = [
                 sinon.stub(os, "hostname", () => "host"),
@@ -28,7 +42,8 @@ describe("Library/Context", () => {
                 context.keys.cloudRoleInstance,
                 context.keys.deviceOSVersion,
                 context.keys.internalSdkVersion,
-                context.keys.cloudRole
+                context.keys.cloudRole,
+                context.keys.applicationVersion
             ];
 
             for (var i = 0; i < defaultkeys.length; i++) {
@@ -52,5 +67,13 @@ describe("Library/Context", () => {
             assert.equal(context.tags["ai.device.osArchitecture"], "arch");
             assert.equal(context.tags["ai.device.osPlatform"], "platform");
         });
+
+        it("should correctly set application version", () => {
+            var context = new Context();
+            assert.equal(context.tags[context.keys.applicationVersion], "unknown");
+            var testFilePath = path.resolve(__dirname, "testpackage.json")
+            context = new Context(testFilePath);
+            assert.equal(context.tags[context.keys.applicationVersion], "testVersion");
+        });
     });
 });