You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In version 1.x, We've switched from a *synchronous* API to an *asynchronous* one using [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
4
+
because synchronous ajax calls are [deprecated](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests#Synchronous_request)
5
+
and frowned upon due to performance implications.
6
+
7
+
> **HEADS UP:** StackTrace.JS does *NOT* provide a Promises polyfill by default, but we do distribute a [version with polyfills](https://raw.githubusercontent.com/stacktracejs/stacktrace.js/master/dist/stacktrace-with-polyfills.min.js)!
8
+
> Check [the Promises page on caniuse.com](http://caniuse.com/#feat=promises) to determine if you need one.
9
+
10
+
All methods now return [stackframe](https://github.com/stacktracejs/stackframe)s.
11
+
This Object representation is modeled closely after StackFrame representations in Gecko and V8.
12
+
All you have to do to get stacktrace.js v0.x behavior is call `.toString()` on a stackframe.
13
+
14
+
### Use Case: Give me a trace from wherever I am right now
15
+
16
+
v0.x:
17
+
```js
18
+
printStackTrace();
19
+
=>Array[String]
20
+
```
21
+
22
+
v1.x:
23
+
```js
24
+
StackTrace.get().then(callback).catch(errback);
25
+
=>Promise(Array[StackFrame], Error)
26
+
```
27
+
28
+
`StackTrace.get()` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
If this is all you need, you don't even need the full stacktrace.js library! Just use [error-stack-parser](https://github.com/stacktracejs/error-stack-parser)!
48
+
```js
49
+
ErrorStackParser.parse(newError('boom'));
50
+
```
51
+
52
+
### Use Case: Give me a trace anytime this function is called
53
+
54
+
Instrumenting now takes `Function` references instead of `String`s.
A JavaScript tool that allows you to debug your JavaScript by giving you a [stack trace](http://en.wikipedia.org/wiki/Stack_trace) of function calls leading to an error (or any condition you specify).
5
+
Debug and profile your JavaScript with a [stack trace](http://en.wikipedia.org/wiki/Stack_trace) of function calls leading to an error (or any condition you specify).
6
6
7
-
The promises referenced below are [ES6-Promises](https://github.com/jakearchibald/es6-promise).
7
+
stacktrace.js uses browsers' `Error.stack` mechanism to generate stack traces, parses them, enhances them with
8
+
[source maps](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/) and uses
Generate a backtrace from invocation point, then parse and enhance it.
56
-
options:Object
57
-
***sourceCache:Object (StringURL=>String Source)**- Pre-populate source cache to avoid network requests
58
-
***offline:Boolean (default:false)**-Set to `true` to prevent all network requests
77
+
78
+
**(Optional) options: Object**
79
+
**filter: Function([StackFrame](https://github.com/stacktracejs/stackframe) => Boolean)* - Only include stack entries matching for which `filter` returns `true`
Given an Error object, use [error-stack-parser](https://github.com/stacktracejs/error-stack-parser)
62
-
to parse it and enhance location information with [stacktrace-gps](https://github.com/stacktracejs/stacktrace-gps).
63
-
***sourceCache:Object (StringURL=>String Source)**- Pre-populate source cache to avoid network requests
64
-
***offline:Boolean (default:false)**-Set to `true` to prevent all network requests
85
+
to parse it and enhance location information with [stacktrace-gps](https://github.com/stacktracejs/stacktrace-gps).
86
+
87
+
**error: Error**
88
+
89
+
**(Optional) options: Object**
90
+
**filter: Function([StackFrame](https://github.com/stacktracejs/stackframe) => Boolean)* - Only include stack entries matching for which `filter` returns `true`
Use [stack-generator](https://github.com/stacktracejs/stack-generator) to generate a backtrace by walking the `arguments.callee.caller` chain.
68
-
***sourceCache:Object (StringURL=>String Source)**- Pre-populate source cache to avoid network requests
69
-
***offline:Boolean (default:false)**-Set to `true` to prevent all network requests
96
+
97
+
**(Optional) options: Object**
98
+
**filter: Function([StackFrame](https://github.com/stacktracejs/stackframe) => Boolean)* - Only include stack entries matching for which `filter` returns `true`
0 commit comments