Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 103 lines (70 sloc) 4.17 kb
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
1 TraceKit - Cross browser stack traces.
2 =====================================
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
3
9e7dba9 @niemyjski Update README.md
niemyjski authored
4 [![Build status](https://ci.appveyor.com/api/projects/status/jaj7yuc29nny4tre/branch/master?svg=true)](https://ci.appveyor.com/project/niemyjski/tracekit/branch/master)
396b277 @occ Add Travis-CI build status to README
occ authored
5
aea6fac @jaredly typo
jaredly authored
6 ### Supports all major browsers, from IE6 to Opera, the Andriod webview and everywhere in between.
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
7
6695410 @devinrhode2 Minor tweaks
devinrhode2 authored
8 Not all browsers support stack traces on error objects, but TraceKit squeezes
9 out as much useful information as possible and normalizes it. 3kB minified + gzipped
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
10
11
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
12 ## Install
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
13
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
14 ```
15 bower install tracekit
16 ```
17 This places TraceKit at `components/tracekit/tracekit.js`. Install [bower](http://twitter.github.com/bower/): `npm install bower -g`, download npm with Node: http://nodejs.org
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
18
6695410 @devinrhode2 Minor tweaks
devinrhode2 authored
19 Then include the `<script>` to your page
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
20
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
21 ## Usage
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
22
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
23 First, register a subscriber for error reports:
24 ```javascript
25 TraceKit.report.subscribe(function yourLogger(errorReport) {
26 //send via ajax to server, or use console.error in development
27 //to get you started see: https://gist.github.com/4491219
28 });
29 ```
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
30
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
31 Then, make sure all your code is in a try/catch block:
32 ```javascript
33 try {
34 /*
35 * your application code here
36 *
37 */
38 throw new Error('oops');
39 } catch (e) {
40 TraceKit.report(e); //error with stack trace gets normalized and sent to subscriber
41 }
42 ```
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
43
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
44 In order to get stack traces, you need to wrap your code in a try/catch block like above. Otherwise the error hits `window.onerror` handler and will only contain the error message, line number, and column number.
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
45
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
46 You also need to throw errors with `throw new Error('foo')` instead of `throw 'foo'`.
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
47
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
48 You can unsubscribe some subscriber function by doing `TraceKit.report.unsubscribe(someFunction)`
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
49
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
50 #### Eliminating (anonymous function)'s
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
51
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
52 ```javascript
6695410 @devinrhode2 Minor tweaks
devinrhode2 authored
53 Api.foo = function Api_foo() {
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
54 };
55 var bar = function barFn() { //'Fn' is to avoid errors in IE
56 };
57 ```
58
6695410 @devinrhode2 Minor tweaks
devinrhode2 authored
59 We recommend the above convention of function naming, `Api_foo` always corresponds to `Api.foo`, `barFn` corresponds to `bar` - just as long as the function name is not the same as the identifier. Otherwise, you can have bugs in IE.
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
60
61 ## Options
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
62
9634fff @devinrhode2 Documentation on setting TraceKit.remoteFetching to false
devinrhode2 authored
63 TraceKit will attempt to fetch an analyze source files, but you can turn this off using:
64
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
65 ```javascript
66 TraceKit.remoteFetching = false;
67 ```
253f2d4 @devinrhode2 Added note about api to ignore window errors
devinrhode2 authored
68
69 You can also tell TraceKit to ignore global window errors with:
70
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
71 ```javascript
72 TraceKit.collectWindowErrors = false;
73 ```
74
75 View the source for more details and examples.
76
77 ![Stacktrace or GTFO](http://i.imgur.com/jacoj.jpg)
9634fff @devinrhode2 Documentation on setting TraceKit.remoteFetching to false
devinrhode2 authored
78
8edcac6 @devinrhode2 Added note about grunt in readme
devinrhode2 authored
79 ## Contributing
80
1c5b9fb @rwhogg Add a very basic Jasmine test suite
rwhogg authored
81 All code must pass JSHint and tests.
02a3601 @niemyjski Updated tests to use npm (no bower packages).
niemyjski authored
82 Run `grunt` to compile and run JSHint and `grunt test` for the test suite.
3f3f496 @rwhogg Jasmine tests now can run in the browser too
rwhogg authored
83 New features need accompanying documentation in the README, changes to existing api's need updated documentation.
1c5b9fb @rwhogg Add a very basic Jasmine test suite
rwhogg authored
84 In general, open an issue for whatever it is you're thinking, get some quick feedback, make good stuff, and we'll accept the PR.
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
85
02a3601 @niemyjski Updated tests to use npm (no bower packages).
niemyjski authored
86 Before building (minifying) you will need to get the closure compiler jar:
87 ```
88 wget http://dl.google.com/closure-compiler/compiler-latest.zip
89 unzip compiler-latest.zip -d closure
90 ```
91
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
92 ## License
cad0b5a @paulirish adding descriptions and examples to readme.
paulirish authored
93
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
94 (The MIT License)
0ddebce @paulirish Stacktrace or GTFO
paulirish authored
95
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
96 Copyright (c) 2013 Onur Can Cakmak <onur.cakmak@gmail.com> and all TraceKit contributors.
0ddebce @paulirish Stacktrace or GTFO
paulirish authored
97
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
98 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
0ddebce @paulirish Stacktrace or GTFO
paulirish authored
99
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
100 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
0ddebce @paulirish Stacktrace or GTFO
paulirish authored
101
104ae8f @devinrhode2 Overhauled README, updated license, closes #22
devinrhode2 authored
102 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.