Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Library/EnvelopeFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class _StackFrame {

// regex to match stack frames from ie/chrome/ff
// methodName=$2, fileName=$4, lineNo=$5, column=$6
public static regex = /^([\s]+at)?(.*?)(\@|\s\(|\s)([^\(\@\n]+):([0-9]+):([0-9]+)(\)?)$/;
public static regex = /^(\s+at)?(.*?)(\@|\s\(|\s)([^\(\n]+):(\d+):(\d+)(\)?)$/;
public static baseSize = 58; //'{"method":"","level":,"assembly":"","fileName":"","line":}'.length
public sizeInBytes = 0;
public level: number;
Expand Down
36 changes: 36 additions & 0 deletions Tests/Library/EnvelopeFactoryTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,42 @@ describe("Library/EnvelopeFactory", () => {

assert.deepEqual(actual, expected);
});

it("fills stack when provided a scoped package", () => {
simpleError.stack = " at Context.foo (C:/@foo/bar/example.js:123:45)\n" + simpleError.stack;

var envelope = EnvelopeFactory.createEnvelope(<Contracts.ExceptionTelemetry>{ exception: simpleError }, Contracts.TelemetryType.Exception);
var exceptionData = <Contracts.Data<Contracts.ExceptionData>>envelope.data;

var actual = exceptionData.baseData.exceptions[0].parsedStack[0];

assert.deepEqual(actual, {
fileName: "C:/@foo/bar/example.js",
line: 123,
level: 0,
sizeInBytes: 141,
assembly: "at Context.foo (C:/@foo/bar/example.js:123:45)",
method: "Context.foo"
});
});

it("fills stack when provided a scoped package", () => {
simpleError.stack = " at C:/@foo/bar/example.js:123:45\n" + simpleError.stack;

var envelope = EnvelopeFactory.createEnvelope(<Contracts.ExceptionTelemetry>{ exception: simpleError }, Contracts.TelemetryType.Exception);
var exceptionData = <Contracts.Data<Contracts.ExceptionData>>envelope.data;

var actual = exceptionData.baseData.exceptions[0].parsedStack[0];

assert.deepEqual(actual, {
fileName: "C:/@foo/bar/example.js",
line: 123,
level: 0,
sizeInBytes: 127,
assembly: "at C:/@foo/bar/example.js:123:45",
method: "<no_method>"
});
});

it("fills 'severityLevel' with Error when not specified", () => {
var envelope = EnvelopeFactory.createEnvelope(<Contracts.ExceptionTelemetry>{ exception: simpleError }, Contracts.TelemetryType.Exception);
Expand Down