Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

applicationinsights-js

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

applicationinsights-js - npm Package Compare versions

Comparing version 0.22.8 to 0.22.9

2

bower.json
{
"name": "applicationinsights-js",
"main": "dist/ai.0.js",
"version": "0.22.8",
"version": "0.22.9",
"homepage": "https://github.com/Microsoft/ApplicationInsights-JS",

@@ -6,0 +6,0 @@ "authors": [

@@ -35,4 +35,4 @@ /// <reference path="../../../JavaScriptSDK/context/session.ts" />

var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, () => { });
Assert.ok(!sessionManager.automaticSession.isFirst, "isFirst");
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
Assert.ok(!sessionManager.automaticSession.isFirst, "isFirst");
Assert.ok(!sessionManager.automaticSession.id, "id");

@@ -47,24 +47,24 @@ Assert.ok(!sessionManager.automaticSession.acquisitionDate, "acquisitionDate");

test: () => {
// no cookie, isNew should be true
Microsoft.ApplicationInsights.Util["document"] = <any>{
cookie: ""
};
// no cookie, isNew should be true
Microsoft.ApplicationInsights.Util["document"] = <any>{
cookie: ""
};
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, () => { });
// after first update, should be true
this.clock.tick(10);
sessionManager.update();
Assert.ok(sessionManager.automaticSession.isFirst, "isFirst should be true after 1st update");
// after first update, should be true
this.clock.tick(10);
sessionManager.update();
Assert.ok(sessionManager.automaticSession.isFirst, "isFirst should be true after 1st update");
// after second update also true
sessionManager.update();
Assert.ok(sessionManager.automaticSession.isFirst, "isFirst should be true after 2st update");
// after second update also true
sessionManager.update();
Assert.ok(sessionManager.automaticSession.isFirst, "isFirst should be true after 2st update");
// after renewal, should be false
this.clock.tick(Microsoft.ApplicationInsights.Context._SessionManager.renewalSpan + 1);
sessionManager.update();
Assert.ok(!sessionManager.automaticSession.isFirst, "isFirst should be false after renewal");
}
});
// after renewal, should be false
this.clock.tick(Microsoft.ApplicationInsights.Context._SessionManager.renewalSpan + 1);
sessionManager.update();
Assert.ok(!sessionManager.automaticSession.isFirst, "isFirst should be false after renewal");
}
});

@@ -80,3 +80,3 @@ this.testCase({

this.clock.tick(10);
var sessionManager1 = new Microsoft.ApplicationInsights.Context._SessionManager(null, () => { });
var sessionManager1 = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager1.update();

@@ -86,3 +86,3 @@ this.clock.tick(Microsoft.ApplicationInsights.Context._SessionManager.renewalSpan + 1);

// Creating one more instance immulate that browser was closed
var sessionManager2 = new Microsoft.ApplicationInsights.Context._SessionManager(null, () => { });
var sessionManager2 = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager2.update();

@@ -108,3 +108,3 @@ Assert.ok(!sessionManager2.automaticSession.isFirst, "isFirst should be false because it is same browser/user");

// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, () => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -145,3 +145,3 @@

// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null,() => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -190,3 +190,3 @@ sessionManager.backup();

new Microsoft.ApplicationInsights.Context.User(this.getEmptyConfig());
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null,() => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -228,3 +228,3 @@ sessionManager.backup();

new Microsoft.ApplicationInsights.Context.User(this.getEmptyConfig());
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null,() => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -270,3 +270,3 @@ sessionManager.backup();

new Microsoft.ApplicationInsights.Context.User(this.getEmptyConfig());
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null,() => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -310,3 +310,3 @@

new Microsoft.ApplicationInsights.Context.User(this.getEmptyConfig());
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null,() => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -318,3 +318,3 @@ sessionManager.backup();

new Microsoft.ApplicationInsights.Context.User(this.getEmptyConfig());
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null,() => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -349,3 +349,3 @@ sessionManager.backup();

var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, () => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -357,65 +357,2 @@ Assert.ok(!sessionManager.automaticSession.isFirst, "isFirst is false when an existing session was set");

this.testCase({
name: "SessionContext: session start is generated without cookies",
test: () => {
// no cookie, isNew should be true
Microsoft.ApplicationInsights.Util["document"] = <any>{
cookie: ""
};
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, (t) => { this.results.push(t); });
sessionManager.update();
Assert.equal(AI.SessionState.Start, this.results[0], "session start generated");
}
});
this.testCase({
name: "SessionContext: session start and end are generated after timeout expired",
test: () => {
// setup
var testGuid = "00000000-0000-0000-0000-000000000000";
var delta = (Microsoft.ApplicationInsights.Context._SessionManager.renewalSpan + 1);
this.clock.tick(delta); // safari crashes without this
var cookieTime = +new Date - delta;
var acquisitionDate = +new Date(cookieTime);
var renewalDate = +new Date(cookieTime);
this.setFakeCookie(testGuid, acquisitionDate, renewalDate);
// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, (t) => { this.results.push(t); });
sessionManager.update();
// verify
Assert.equal(2, this.results.length);
Assert.equal(AI.SessionState.End, this.results[0], "session end generated");
Assert.equal(AI.SessionState.Start, this.results[1], "session start generated");
}
});
this.testCase({
name: "SessionContext: session manager renews when acquisition date has expired",
test: () => {
// setup
var testGuid = "00000000-0000-0000-0000-000000000000";
var delta = (Microsoft.ApplicationInsights.Context._SessionManager.acquisitionSpan + 1);
this.clock.tick(delta); // safari crashes without this
var cookieTime = +new Date - delta;
var acquisitionDate = +new Date(cookieTime);
var renewalDate = +new Date();
this.setFakeCookie(testGuid, acquisitionDate, renewalDate);
// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, (t) => { this.results.push(t); });
sessionManager.update();
// verify
Assert.equal(2, this.results.length);
Assert.equal(AI.SessionState.End, this.results[0], "session end generated");
Assert.equal(AI.SessionState.Start, this.results[1], "session start generated");
}
});
this.testCase({
name: "SessionContext: session manager honors session from the cookie",

@@ -431,3 +368,3 @@ test: () => {

// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, () => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -456,3 +393,3 @@

// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, (t) => { this.results.push(t); });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -464,5 +401,2 @@

Assert.equal(delta, sessionManager.automaticSession.renewalDate, "cookie renewalDate was updated");
Assert.equal(2, this.results.length);
Assert.equal(AI.SessionState.End, this.results[0], "session end generated");
Assert.equal(AI.SessionState.Start, this.results[1], "session start generated");
}

@@ -485,3 +419,3 @@ });

// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, () => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
sessionManager.update();

@@ -507,3 +441,3 @@

// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null, () => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null);
this.clock.tick(10);

@@ -532,3 +466,3 @@ sessionManager.update();

// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(config, () => { });
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(config);

@@ -548,27 +482,2 @@ // verify

});
/* Temporarily disabled until we figure out sinon js behavior with Date.
* Problems:
* - new Date normally gives the current date, with sinon - 1970
* - new Date(NaN) normally throws an exception, with sinon - return undefined
this.testCase({
name: "SessionContext: renewal and aquisition dates from cookie are treated as numbers",
test: () => {
// setup
var testGuid = "00000000-0000-0000-0000-000000000000";
var acquisitionDate = Microsoft.ApplicationInsights.Util.toISOStringForIE8(new Date());
var renewalDate = Microsoft.ApplicationInsights.Util.toISOStringForIE8(new Date());
this.setFakeCookie(testGuid, acquisitionDate, renewalDate);
// act
var sessionManager = new Microsoft.ApplicationInsights.Context._SessionManager(null,(t) => { this.results.push(t); });
sessionManager.update();
// TODO: CHECK THAT A PARSING ERROR OCCURRED AND WE SENT A DIAGNOSTIC TRACE
}
});
*/
}

@@ -575,0 +484,0 @@

@@ -34,2 +34,3 @@

disableCorrelationHeaders: false,
disableFlushOnBeforeUnload: false,
cookieDomain: undefined

@@ -263,2 +264,24 @@ };

});
this.testCase({
name: "InitializationTests: disableFlushOnBeforeUnload switch works",
test: () => {
// Assemble
var userConfig = this.getAppInsightsSnippet();
userConfig.disableFlushOnBeforeUnload = true;
var snippet = <Microsoft.ApplicationInsights.Snippet>{
config: userConfig,
queue: []
};
var addEventHandlerStub = this.sandbox.stub(Microsoft.ApplicationInsights.Util, 'addEventHandler').returns(true);
var init = new Microsoft.ApplicationInsights.Initialization(snippet);
var appInsightsLocal = init.loadAppInsights();
// Act
init.addHousekeepingBeforeUnload(appInsightsLocal);
// Assert
Assert.ok(addEventHandlerStub.notCalled);
}
});
}

@@ -265,0 +288,0 @@ }

@@ -187,4 +187,15 @@ /// <reference path="../../testframework/common.ts" />

});
this.testCase({
name: "Stack trace with no method serializes as <no_method>",
test: () => {
// Act
var sut = new Microsoft.ApplicationInsights.Telemetry._StackFrame(" at http://myScript.js:40:50", 1);
// Verify
Assert.equal("<no_method>", sut.method);
}
});
}
}
new ExceptionTelemetryTests().registerTests();

@@ -187,22 +187,2 @@ /// <reference path="../testframework/common.ts" />

this.testCase({
name: "TelemetryContext: sessions do NOT get sampled",
test: () => {
var stub = this.getStub(Microsoft.ApplicationInsights.Telemetry.SessionTelemetry.envelopeType, this._telemetryContext);
var envelope = getEnvelope<Microsoft.ApplicationInsights.Telemetry.SessionTelemetry>(
new Microsoft.ApplicationInsights.Telemetry.SessionTelemetry(AI.SessionState.Start),
Microsoft.ApplicationInsights.Telemetry.SessionTelemetry.dataType,
Microsoft.ApplicationInsights.Telemetry.SessionTelemetry.envelopeType);
// act
this._telemetryContext.track(envelope);
// assert
Assert.equal(0, stub.isSampledInCallsCount);
// tear down
}
});
this.testCase({
name: "TelemetryContext: traces get sampled",

@@ -209,0 +189,0 @@ test: () => {

@@ -35,5 +35,3 @@ /// <reference path="..\TestFramework\Common.ts" />

var delay = config.maxBatchInterval + 100;
var testAi = new Microsoft.ApplicationInsights.AppInsights(config);
// disable session state event:
testAi.context._sessionManager._sessionHandler = null;
var testAi = new Microsoft.ApplicationInsights.AppInsights(config);

@@ -40,0 +38,0 @@ var boilerPlateAsserts = () => {

@@ -16,3 +16,3 @@ /// <reference path="telemetrycontext.ts" />

export var Version = "0.22.8";
export var Version = "0.22.9";

@@ -40,2 +40,3 @@ export interface IConfig {

disableCorrelationHeaders: boolean;
disableFlushOnBeforeUnload: boolean;
cookieDomain: string;

@@ -417,3 +418,3 @@ }

{ exception: Util.dump(e) }));
}
}
}

@@ -420,0 +421,0 @@

@@ -44,7 +44,5 @@ /// <reference path="../util.ts" />

public config: ISessionConfig;
constructor(config: ISessionConfig) {
public _sessionHandler: (sessionState: AI.SessionState, timestamp: number) => void;
constructor(config: ISessionConfig, sessionHandler: (sessionState: AI.SessionState, timestamp: number) => void) {
if (!config) {

@@ -64,3 +62,2 @@ config = <any>{};

this._sessionHandler = sessionHandler;
this.automaticSession = new Session();

@@ -81,6 +78,3 @@ }

if (acquisitionExpired || renewalExpired) {
// first send session end than update automaticSession so session state has correct id
if (typeof this._sessionHandler === "function") {
this._sessionHandler(AI.SessionState.End, this.automaticSession.renewalDate);
}
// update automaticSession so session state has correct id
this.automaticSession.isFirst = undefined;

@@ -175,6 +169,2 @@ this.renew();

this.setCookie(this.automaticSession.id, this.automaticSession.acquisitionDate, this.automaticSession.renewalDate);
// first we updated automaticSession than we send session start so it has correct id
if (typeof this._sessionHandler === "function") {
this._sessionHandler(AI.SessionState.Start, now);
}

@@ -181,0 +171,0 @@ // If this browser does not support local storage, fire an internal log to keep track of it at this point

@@ -117,3 +117,3 @@ /// <reference path="appinsights.ts" />

if ('onbeforeunload' in window) {
if (!appInsightsInstance.config.disableFlushOnBeforeUnload && ('onbeforeunload' in window)) {
var performHousekeeping = function () {

@@ -173,2 +173,6 @@ // Adds the ability to flush all data before the page unloads.

true;
config.disableFlushOnBeforeUnload = (config.disableFlushOnBeforeUnload !== undefined && config.disableFlushOnBeforeUnload !== null) ?
Util.stringToBoolOrDefault(config.disableFlushOnBeforeUnload) :
false;

@@ -175,0 +179,0 @@ return config;

@@ -1,7 +0,7 @@

e:\ai-gh-js\JavaScript\JavaScriptSDK\bin\JavaScriptSDK.dll
e:\ai-gh-js\JavaScript\JavaScriptSDK\bin\JavaScriptSDK.pdb
e:\ai-gh-js\JavaScript\JavaScriptSDK\bin\AjaxMin.dll
e:\ai-gh-js\JavaScript\JavaScriptSDK\obj\Debug\JavaScriptSDK.dll
e:\ai-gh-js\JavaScript\JavaScriptSDK\obj\Debug\JavaScriptSDK.pdb
e:\ai-gh-js\JavaScript\JavaScriptSDK\bin\JavaScriptSDK.dll.config
E:\ai-gh-js\JavaScript\JavaScriptSDK\obj\Debug\JavaScriptSDK.csprojResolveAssemblyReference.cache
c:\src\ApplicationInsights-JS-1\JavaScript\JavaScriptSDK\bin\JavaScriptSDK.dll.config
c:\src\ApplicationInsights-JS-1\JavaScript\JavaScriptSDK\bin\JavaScriptSDK.dll
c:\src\ApplicationInsights-JS-1\JavaScript\JavaScriptSDK\bin\JavaScriptSDK.pdb
c:\src\ApplicationInsights-JS-1\JavaScript\JavaScriptSDK\bin\AjaxMin.dll
c:\src\ApplicationInsights-JS-1\JavaScript\JavaScriptSDK\obj\Debug\JavaScriptSDK.dll
c:\src\ApplicationInsights-JS-1\JavaScript\JavaScriptSDK\obj\Debug\JavaScriptSDK.pdb
c:\src\ApplicationInsights-JS-1\JavaScript\JavaScriptSDK\obj\Debug\JavaScriptSDK.csprojResolveAssemblyReference.cache

@@ -143,3 +143,3 @@ /// <reference path="../Contracts/Generated/ExceptionData.ts" />

class _StackFrame extends AI.StackFrame implements ISerializable {
export class _StackFrame extends AI.StackFrame implements ISerializable {

@@ -163,7 +163,7 @@ // regex to match stack frames from ie/chrome/ff

this.level = level;
this.method = "unavailable";
this.method = "<no_method>";
this.assembly = Util.trim(frame);
var matches = frame.match(_StackFrame.regex);
if (matches && matches.length >= 5) {
this.method = Util.trim(matches[2]);
this.method = Util.trim(matches[2]) || this.method;
this.fileName = Util.trim(matches[4]);

@@ -170,0 +170,0 @@ this.line = parseInt(matches[5]) || 0;

@@ -8,3 +8,2 @@ /// <reference path="sender.ts"/>

/// <reference path="telemetry/pageviewperformance.ts" />
/// <reference path="telemetry/SessionTelemetry.ts" />
/// <reference path="./Util.ts"/>

@@ -87,5 +86,3 @@ /// <reference path="./Contracts/Generated/SessionState.ts"/>

if (typeof window !== 'undefined') {
this._sessionManager = new ApplicationInsights.Context._SessionManager(
config,
(sessionState, timestamp) => TelemetryContext._sessionHandler(this, sessionState, timestamp));
this._sessionManager = new ApplicationInsights.Context._SessionManager(config);
this.application = new Context.Application();

@@ -157,3 +154,3 @@ this.device = new Context.Device();

var doNotSendItem = false;
var doNotSendItem = false;
try {

@@ -179,8 +176,7 @@ this.telemetryInitializers = this.telemetryInitializers || [];

if (!doNotSendItem) {
if (envelope.name === Telemetry.SessionTelemetry.envelopeType ||
envelope.name === Telemetry.Metric.envelopeType ||
if (envelope.name === Telemetry.Metric.envelopeType ||
this.sample.isSampledIn(envelope)) {
var iKeyNoDashes = this._config.instrumentationKey().replace(/-/g, "");
envelope.name = envelope.name.replace("{0}", iKeyNoDashes);
this._sender.send(envelope);
var iKeyNoDashes = this._config.instrumentationKey().replace(/-/g, "");
envelope.name = envelope.name.replace("{0}", iKeyNoDashes);
this._sender.send(envelope);
} else {

@@ -195,13 +191,2 @@ _InternalLogging.throwInternalUserActionable(LoggingSeverity.WARNING, new _InternalLogMessage(_InternalMessageId.NONUSRACT_TelemetrySampledAndNotSent,

private static _sessionHandler(tc: TelemetryContext, sessionState: AI.SessionState, timestamp: number) {
var sessionStateTelemetry = new Telemetry.SessionTelemetry(sessionState);
var sessionStateData = new ApplicationInsights.Telemetry.Common.Data<ApplicationInsights.Telemetry.SessionTelemetry>(Telemetry.SessionTelemetry.dataType, sessionStateTelemetry);
var sessionStateEnvelope = new Telemetry.Common.Envelope(sessionStateData, Telemetry.SessionTelemetry.envelopeType);
sessionStateEnvelope.time = Util.toISOStringForIE8(new Date(timestamp));
tc._track(sessionStateEnvelope);
}
private _applyApplicationContext(envelope: Microsoft.Telemetry.Envelope, appContext: Microsoft.ApplicationInsights.Context.Application) {

@@ -304,3 +289,3 @@ if (appContext) {

if (sampleContext) {
envelope.sampleRate = sampleContext.sampleRate;
envelope.sampleRate = sampleContext.sampleRate;
}

@@ -307,0 +292,0 @@ }

{
"name": "applicationinsights-js",
"version": "0.22.8",
"version": "0.22.9",
"description": "[Application Insights](https://azure.microsoft.com/services/application-insights/) tells you about your app's performance and usage. By adding a few lines of code to your web pages, you get data about how many users you have, which pages are most popular, how fast pages load, whether they throw exceptions, and more. And you can add code to track more detailed user activity.",

@@ -5,0 +5,0 @@ "main": "dist/ai.0.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc