Skip to content

Commit 7397093

Browse files
committed
Imported stacktrace.js 1.0
1 parent 0c87257 commit 7397093

File tree

5 files changed

+93
-10
lines changed

5 files changed

+93
-10
lines changed

src/StackTrace.d.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/// <reference path="typings/tsd.d.ts" />
2+
3+
declare module StackTrace {
4+
interface StackTraceOptions {
5+
filter: (stackFrame:StackFrame) => boolean;
6+
}
7+
8+
interface StackFrame {
9+
constructor(functionName:string, args:any, fileName:string, lineNumber:number, columnNumber:number);
10+
11+
getFunctionName():string;
12+
setFunctionName(value:string);
13+
14+
getArgs():any;
15+
setArgs(value:any);
16+
17+
getFileName():string;
18+
setFileName(value:string);
19+
20+
getLineNumber():number;
21+
setLineNumber(value:number);
22+
23+
getColumnNumber():number;
24+
setColumnNumber(value:number);
25+
26+
toString():string;
27+
}
28+
29+
/**
30+
* Get a backtrace from invocation point.
31+
* @param options Options Object
32+
* @return Array[StackFrame]
33+
*/
34+
function get(options: StackTraceOptions): Promise<StackFrame[]>;
35+
36+
/**
37+
* Given an error object, parse it.
38+
* @param error Error object
39+
* @param options Object for options
40+
* @return Array[StackFrame]
41+
*/
42+
function fromError(error:Error, options:StackTraceOptions): Promise<StackFrame[]>;
43+
44+
/**
45+
* Use StackGenerator to generate a backtrace.
46+
* @param options Object options
47+
* @returns Array[StackFrame]
48+
*/
49+
function generateArtificially(options: StackTraceOptions): Promise<StackFrame[]>;
50+
51+
/**
52+
* Given a function, wrap it such that invocations trigger a callback that
53+
* is called with a stack trace.
54+
*
55+
* @param {Function} fn to be instrumented
56+
* @param {Function} callback function to call with a stack trace on invocation
57+
* @param {Function} errorCallback optional function to call with error if unable to get stack trace.
58+
* @param {Object} thisArg optional context object (e.g. window)
59+
*/
60+
function instrument(fn:() => void, callback:(stackFrames:StackFrame[]) => void, errorCallback:() => void, thisArg:any): void;
61+
62+
/**
63+
* Given a function that has been instrumented,
64+
* revert the function to it's original (non-instrumented) state.
65+
*
66+
* @param fn {Function}
67+
*/
68+
function deinstrument(fn:() => void): void;
69+
}

src/exceptionless.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference path="typings/tsd.d.ts" />
2-
2+
/// <reference path="stacktrace.d.ts" />
33
// TODO: We'll need a poly fill for promises.
44
// TODO: Process Errors
55
// TODO: Handle Server Settings
@@ -952,8 +952,8 @@ module Exceptionless {
952952
}
953953

954954
private processStackFrames(context:Exceptionless.EventPluginContext, stackFrames: any[]) {
955-
//console.log(stackFrames);
956-
//context.event.data['@error'] = stackFrames;
955+
956+
context.event.data['@error'] = stackFrames;
957957
}
958958
}
959959

@@ -976,6 +976,4 @@ module Exceptionless {
976976
return Math.floor(Math.random() * 9007199254740992);
977977
}
978978
}
979-
980-
declare var StackTrace: any;
981979
}

src/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<title>Exceptionless Test</title>
66
</head>
77
<body>
8+
<script type="application/javascript" src="node_modules/es6-promise/dist/es6-promise.js"></script>
9+
<script type="application/javascript" src="node_modules/stackframe/dist/stackframe.js"></script>
10+
<script type="application/javascript" src="node_modules/error-stack-parser/dist/error-stack-parser.js"></script>
11+
<script type="application/javascript" src="node_modules/stack-generator/dist/stack-generator.js"></script>
12+
<script type="application/javascript" src="node_modules/stacktrace-gps/dist/stacktrace-gps.js"></script>
813
<script type="application/javascript" src="node_modules/stacktrace-js/dist/stacktrace.js"></script>
914
<script type="application/javascript" src="exceptionless.js"></script>
1015
<script type="application/javascript">

src/karma.conf.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ module.exports = function (config) {
44
config.set({
55
basePath: '.',
66
browserNoActivityTimeout: 100000,
7-
browsers: ['Chrome'], // PhantomJS
7+
browsers: ['Chrome'],
88
frameworks: ['jasmine'],
99
files: [
10-
'bower_components/es5-shim/es5-shim.js',
11-
'bower_components/es6-shim/es6-shim.js',
10+
'node_modules/es5-shim/es5-shim.js',
11+
'node_modules/es6-shim/es6-shim.js',
12+
'node_modules/es6-promise/dist/es6-promise.js',
13+
'node_modules/stackframe/dist/stackframe.js',
14+
'node_modules/error-stack-parser/dist/error-stack-parser.js',
15+
'node_modules/stack-generator/dist/stack-generator.js',
16+
'node_modules/stacktrace-gps/dist/stacktrace-gps.js',
17+
'node_modules/stacktrace-js/dist/stacktrace.js',
18+
1219
'**/*.ts'
1320
],
1421
exclude: [],

src/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
],
1616
"devDependencies": {
1717
"bower": "~1.4.1",
18+
"error-stack-parser": "^1.2.0",
1819
"es5-shim": "^4.1.0",
20+
"es6-promise": "^2.1.0",
1921
"es6-shim": "^0.27.1",
2022
"event-stream": "^3.3.0",
2123
"gulp": "^3.8.11",
@@ -27,10 +29,12 @@
2729
"karma-chrome-launcher": "^0.1.7",
2830
"karma-cli": "0.0.4",
2931
"karma-jasmine": "~0.3.5",
30-
"karma-phantomjs-launcher": "^0.1.4",
3132
"karma-typescript-preprocessor": "0.0.16",
3233
"rimraf": "^2.3.2",
33-
"stacktrace-js": "^0.6.4",
34+
"stack-generator": "^1.0.3",
35+
"stackframe": "^0.2.2",
36+
"stacktrace-gps": "^2.1.2",
37+
"stacktrace-js": "git://github.com/stacktracejs/stacktrace.js.git",
3438
"typescript": "1.5.0-alpha"
3539
},
3640
"dependencies": {}

0 commit comments

Comments
 (0)