squash_javascript 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +202 -0
- data/README.md +282 -0
- data/bin/upload_source_map +75 -0
- data/lib/squash/javascript/engine.rb +20 -0
- data/lib/squash/javascript/source_map.rb +181 -0
- data/lib/squash/javascript.rb +26 -0
- data/vendor/assets/javascripts/squash_javascript/client.coffee +219 -0
- data/vendor/assets/javascripts/squash_javascript/index.js +16 -0
- data/vendor/assets/javascripts/squash_javascript/tracekit.js +1132 -0
- data/vendor/assets/javascripts/squash_javascript.min.js +24 -0
- data/vendor/assets/javascripts/squash_javascript.orig.js +260 -0
- metadata +175 -0
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
Squash Client Library: JavaScript
|
|
2
|
+
=================================
|
|
3
|
+
|
|
4
|
+
This client library reports front-end JavaScript exceptions to Squash, the
|
|
5
|
+
Squarish exception reporting and management system.
|
|
6
|
+
|
|
7
|
+
Documentation
|
|
8
|
+
-------------
|
|
9
|
+
|
|
10
|
+
For an overview of the various components of Squash, see the website
|
|
11
|
+
documentation at https://github.com/SquareSquash/web.
|
|
12
|
+
|
|
13
|
+
### JavaScript client
|
|
14
|
+
|
|
15
|
+
Documentation is written in Codo format. HTML documentation can be generated by
|
|
16
|
+
running `rake doc:js`. Note that Codo is still a work in progress, and the
|
|
17
|
+
generated docs will have some formatting errors. The documentation is written to
|
|
18
|
+
the `doc/js` directory.
|
|
19
|
+
|
|
20
|
+
If you do not have Codo installed in your path, you can download a project-local
|
|
21
|
+
install with `rake setup`.
|
|
22
|
+
|
|
23
|
+
### Ruby library
|
|
24
|
+
|
|
25
|
+
Markdown-formatted YARD documentation is available by running 'rake doc:ruby`.
|
|
26
|
+
The documentation is written to the `doc/ruby` directory.
|
|
27
|
+
|
|
28
|
+
Compatibility
|
|
29
|
+
-------------
|
|
30
|
+
|
|
31
|
+
The JavaScript library is compatible with any modern JavaScript engine,
|
|
32
|
+
including any version of V8, Nitro, and Chakra.
|
|
33
|
+
|
|
34
|
+
The Rails engine (allowing the library to be easily used in a Rails app) is
|
|
35
|
+
compatible with Rails 3.1 and later.
|
|
36
|
+
|
|
37
|
+
Requirements
|
|
38
|
+
------------
|
|
39
|
+
|
|
40
|
+
The JavaScript library uses TraceKit for cross-platform stack trace extraction.
|
|
41
|
+
The library is included in this project. For Rails projects, a Sprockets include
|
|
42
|
+
file is provided. For non-Rails projects, the output of `rake minify` rolls in
|
|
43
|
+
the library.
|
|
44
|
+
|
|
45
|
+
Unfortunately, TraceKit was causing unexpected behavior on Chrome and Firefox,
|
|
46
|
+
and parts of it are commented out. (The jQuery hooks were disabled.)
|
|
47
|
+
|
|
48
|
+
Installation
|
|
49
|
+
-----
|
|
50
|
+
|
|
51
|
+
### Rails
|
|
52
|
+
|
|
53
|
+
For Rails applications, add the Squash client engine to your Gemfile with
|
|
54
|
+
`gem 'squash_javascript', require: 'squash/javascript'`, and then include the
|
|
55
|
+
JavaScript into your application.js file (or other JavaScript manifest):
|
|
56
|
+
|
|
57
|
+
```` javascript
|
|
58
|
+
//= require squash/javascript
|
|
59
|
+
````
|
|
60
|
+
|
|
61
|
+
### Other projects
|
|
62
|
+
|
|
63
|
+
For other projects, you may need to compile the CoffeeScript file first. If you
|
|
64
|
+
do not have the `coffee` binary installed in your path, you can download and
|
|
65
|
+
install a copy of CoffeeScript by running `rake setup`. This task uses npm (the
|
|
66
|
+
Node package manager) to perform the installation; you will need to install npm
|
|
67
|
+
first if you haven't already. CoffeeScript will be installed into a
|
|
68
|
+
project-local directory.
|
|
69
|
+
|
|
70
|
+
Once you have the `coffee` binary, you can run `rake minify` to generate a
|
|
71
|
+
JavaScript file that you can use in your project. If you would like a
|
|
72
|
+
non-minified JavaScript file without dependencies, run `rake compile`.
|
|
73
|
+
|
|
74
|
+
Place the compiled `squash_javascript.min.js` file in a Web-public directory and
|
|
75
|
+
include it using a `<script>` tag:
|
|
76
|
+
|
|
77
|
+
```` html
|
|
78
|
+
<script type="text/javascript" href="http://url.to.your/squash_javascript.min.js" />
|
|
79
|
+
````
|
|
80
|
+
|
|
81
|
+
The file defines a `SquashJavascript` singleton which is accessible using
|
|
82
|
+
`SquashJavascript.instance()`.
|
|
83
|
+
|
|
84
|
+
Usage
|
|
85
|
+
-----
|
|
86
|
+
|
|
87
|
+
Before you can use Squash, you must configure it (see **Configuration** below).
|
|
88
|
+
At a minimum, you must specify
|
|
89
|
+
|
|
90
|
+
* the host on which Squash is running,
|
|
91
|
+
* your project's API key,
|
|
92
|
+
* the environment, and
|
|
93
|
+
* the SHA of the Git revision currently deployed.
|
|
94
|
+
|
|
95
|
+
Use `SquashJavascript.instance().configure` to set up the Squash JavaScript client:
|
|
96
|
+
|
|
97
|
+
```` javascript
|
|
98
|
+
SquashJavascript.instance().configure({APIHost: 'YOUR_API_HOST',
|
|
99
|
+
APIKey: 'YOUR_API_KEY',
|
|
100
|
+
environment: 'production',
|
|
101
|
+
revision: '8718e4336990f9ea0198c2ff5668bbb673befd65'})
|
|
102
|
+
````
|
|
103
|
+
|
|
104
|
+
Squash will automatically install a listener that will trap exceptions, send
|
|
105
|
+
them to the server, and re-throw them. Note that the client will only notify for
|
|
106
|
+
instances of the `Error` class.
|
|
107
|
+
|
|
108
|
+
There are many additional features you can take advantage of; see **Additional
|
|
109
|
+
Features** below.
|
|
110
|
+
|
|
111
|
+
### Additional Features
|
|
112
|
+
|
|
113
|
+
There are a number of other features you can take advantage of to help you debug
|
|
114
|
+
your exceptions:
|
|
115
|
+
|
|
116
|
+
#### User Data
|
|
117
|
+
|
|
118
|
+
Exceptions can be annotated with freeform user data. This data can take any
|
|
119
|
+
format and have any meaning, typically being relevant to the exception at hand.
|
|
120
|
+
|
|
121
|
+
There are multiple ways to add user data to an exception. The most
|
|
122
|
+
straightforward way is to include the user data as the second argument to the
|
|
123
|
+
`notify` method:
|
|
124
|
+
|
|
125
|
+
```` javascript
|
|
126
|
+
SquashJavascript.instance().notify(error, {event: e, arguments: arguments});
|
|
127
|
+
````
|
|
128
|
+
|
|
129
|
+
You can apply user data to a block of code using the
|
|
130
|
+
`SquashJavascript.instance().addUserData` method:
|
|
131
|
+
|
|
132
|
+
```` javascript
|
|
133
|
+
$(window).resize(function(e) {
|
|
134
|
+
SquashJavascript.instance().addUserData({event: e}, function() {
|
|
135
|
+
// ... process event ...
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
````
|
|
139
|
+
|
|
140
|
+
If that's too verbose, there's additionally a curry function, `addingUserData`,
|
|
141
|
+
that takes a function, applies the `addUserData` behavior to it, and returns a
|
|
142
|
+
new function:
|
|
143
|
+
|
|
144
|
+
```` javascript
|
|
145
|
+
$(window).resize(SquashJavascript.instance().addingUserData({event: e}, function(e) {
|
|
146
|
+
// ... process event ...
|
|
147
|
+
});
|
|
148
|
+
````
|
|
149
|
+
|
|
150
|
+
And lastly, you can add user data directly to the exception:
|
|
151
|
+
|
|
152
|
+
```` javascript
|
|
153
|
+
function myFunction(value) {
|
|
154
|
+
if (value < 0) {
|
|
155
|
+
var err = new Error("value was less than 0");
|
|
156
|
+
err._squash_user_data = { value: value };
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ... do the thing ...
|
|
161
|
+
}
|
|
162
|
+
````
|
|
163
|
+
|
|
164
|
+
You can also add user data to exceptions you catch and re-throw:
|
|
165
|
+
|
|
166
|
+
```` javascript
|
|
167
|
+
try {
|
|
168
|
+
doSomethingWithInput(input);
|
|
169
|
+
} catch (err) {
|
|
170
|
+
if (!err._squash_user_data) err._squash_user_data = new Object();
|
|
171
|
+
err._squash_user_data.input = input;
|
|
172
|
+
throw err; // assumed that SquashJavascript.instance().notify is called somewhere further up in the stack
|
|
173
|
+
}
|
|
174
|
+
````
|
|
175
|
+
|
|
176
|
+
#### Ignoring Exceptions
|
|
177
|
+
|
|
178
|
+
You can ignore certain error classes within a block of code if those exceptions
|
|
179
|
+
are not worth sending to Squash. Use the
|
|
180
|
+
`SquashJavascript.instance().ignore_exceptions` method:
|
|
181
|
+
|
|
182
|
+
```` javascript
|
|
183
|
+
SquashJavascript.instance().ignoreExceptions(EvalError, SyntaxError, function() {
|
|
184
|
+
// ... some code ...
|
|
185
|
+
});
|
|
186
|
+
````
|
|
187
|
+
|
|
188
|
+
The curry-type syntax is also supported here:
|
|
189
|
+
|
|
190
|
+
```` javascript
|
|
191
|
+
$(window).resize(SquashJavascript.instance().ignoringExceptions(EvalError, SyntaxError, function(e) {
|
|
192
|
+
/// ... some code ...
|
|
193
|
+
});
|
|
194
|
+
````
|
|
195
|
+
|
|
196
|
+
The exceptions _will_ be raised (not eaten) but will _not_ be reported to
|
|
197
|
+
Squash.
|
|
198
|
+
|
|
199
|
+
You can also globally ignore exceptions using the `ignored_exceptions`
|
|
200
|
+
configuration; see **Configuration** below.
|
|
201
|
+
|
|
202
|
+
Configuration
|
|
203
|
+
-------------
|
|
204
|
+
|
|
205
|
+
You can configure the client with the `SquashJavascript.instance().configure`
|
|
206
|
+
method. Calling this method multiple times will merge new values in with the
|
|
207
|
+
existing configuration. The method takes a hash, which accepts the following
|
|
208
|
+
keys:
|
|
209
|
+
|
|
210
|
+
### General
|
|
211
|
+
|
|
212
|
+
* `disabled`: If `true`, the Squash client will not report any errors.
|
|
213
|
+
* `APIKey`: The API key of the project that exceptions will be associated with.
|
|
214
|
+
This configuration option is required. The value can be found by going to the
|
|
215
|
+
project's home page on Squash.
|
|
216
|
+
* `environment`: The environment that exceptions will be associated with. This
|
|
217
|
+
configuration option is required.
|
|
218
|
+
* `revision`: The SHA1 of the current Git revision. This is the revision of the
|
|
219
|
+
code that is currently running. This configuration option is required.
|
|
220
|
+
|
|
221
|
+
### Error Transmission
|
|
222
|
+
|
|
223
|
+
* `APIHost`: The host on which Squash is running. Required.
|
|
224
|
+
* `notifyPath`: The path to post new exception notifications to. By default
|
|
225
|
+
it's set to `/api/1.0/notify`.
|
|
226
|
+
* `transmitTimeout`: The amount of time to wait before giving up on trasmitting
|
|
227
|
+
an error. By default this is treated as both an open and a read timeout.
|
|
228
|
+
|
|
229
|
+
### Ignored Exceptions
|
|
230
|
+
|
|
231
|
+
* `ignoredExceptionClasses`: An array of exception class names that will not
|
|
232
|
+
be reported to Squash.
|
|
233
|
+
* `ignoredExceptionMessages`: A hash mapping an exception class name to an
|
|
234
|
+
array of regexes. Exceptions of that class whose messages match a regex in the
|
|
235
|
+
list will not be reported to Squash.
|
|
236
|
+
|
|
237
|
+
Error Transmission
|
|
238
|
+
------------------
|
|
239
|
+
|
|
240
|
+
Exceptions are transmitted to Squash using JSON-over-XMLHttpRequest. A default
|
|
241
|
+
API endpoint is pre-configured, though you can always set your own (see
|
|
242
|
+
**Configuration** above).
|
|
243
|
+
|
|
244
|
+
Failsafe Reporting
|
|
245
|
+
------------------
|
|
246
|
+
|
|
247
|
+
In the event that the Squash client itself raises an exception when processing
|
|
248
|
+
an exception, it will log that exception to the console. Both the original
|
|
249
|
+
exception and the failsafe error will be logged. The original exception will
|
|
250
|
+
still be re-raised, but the failsafe error will be "eaten."
|
|
251
|
+
|
|
252
|
+
Source Mapping
|
|
253
|
+
--------------
|
|
254
|
+
|
|
255
|
+
If you can generate a source map for your minified JavaScript files (Clojure
|
|
256
|
+
can), you can use this gem to upload that source map to Squash, where it will
|
|
257
|
+
be used to convert minified stack traces to their original format, which can
|
|
258
|
+
then benefit from Git-blaming, context, and other features of Squash.
|
|
259
|
+
|
|
260
|
+
To upload the source map to squash, run the `upload_source_map` binary included
|
|
261
|
+
with this gem, and pass it four arguments: 1) your API key, 2) the environment
|
|
262
|
+
name, 3) the path to the JSON source map, and 4) the URL where this file will be
|
|
263
|
+
hosted. Example:
|
|
264
|
+
|
|
265
|
+
````
|
|
266
|
+
upload_source_map abc-123-abc-123-abc-123 production artifacts/mapping.json https://my.application/assets/minified.js
|
|
267
|
+
````
|
|
268
|
+
|
|
269
|
+
Specs
|
|
270
|
+
-----
|
|
271
|
+
|
|
272
|
+
### JavaScript client
|
|
273
|
+
|
|
274
|
+
Jasmine unit and integration tests are implemented in the `spec/js` directory.
|
|
275
|
+
To run these tests, run `rake spec:js` (Mac OS X required), or simply compile
|
|
276
|
+
the CoffeeScript source and open the `SpecRunner.html` file in your favorite Web
|
|
277
|
+
browser.
|
|
278
|
+
|
|
279
|
+
### Ruby library
|
|
280
|
+
|
|
281
|
+
RSpec unit tests are implemented in the `spec/ruby` directory. To run these
|
|
282
|
+
tests, run `rake spec:ruby`.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Copyright 2012 Square Inc.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
require 'optparse'
|
|
18
|
+
require 'base64'
|
|
19
|
+
require 'zlib'
|
|
20
|
+
require 'yaml'
|
|
21
|
+
|
|
22
|
+
require 'rubygems'
|
|
23
|
+
require 'squash/uploader'
|
|
24
|
+
require 'squash/javascript'
|
|
25
|
+
|
|
26
|
+
def git_revision(dir)
|
|
27
|
+
head = File.read(File.join(dir, '.git', 'HEAD')).chomp
|
|
28
|
+
if head =~ /^ref: (.+)$/
|
|
29
|
+
File.read(File.join(dir, '.git', $1)).chomp
|
|
30
|
+
else
|
|
31
|
+
raise "Couldn't determine current revision from #{head.inspect}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
project_dir = Dir.getwd
|
|
36
|
+
ignore_root = false
|
|
37
|
+
revision = nil
|
|
38
|
+
options = {}
|
|
39
|
+
|
|
40
|
+
parser = OptionParser.new do |parser|
|
|
41
|
+
parser.banner = "Usage: upload_source_map [options] YOUR_SQUASH_HOST YOUR_API_KEY ENVIRONMENT /path/to/mapping.json https://url.for/minified/asset.js"
|
|
42
|
+
parser.on('-o', '--open-timeout N', Integer, "HTTP connection open timeout") { |ot| options[:open_timeout] = ot }
|
|
43
|
+
parser.on('-r', '--read-timeout N', Integer, "HTTP connection data received timeout") { |rt| options[:read_timeout] = rt }
|
|
44
|
+
parser.on('-k', '--[no-]skip-verification', "Do not perform SSL peer verification") { |sv| options[:skip_verification] = sv }
|
|
45
|
+
|
|
46
|
+
parser.on('-p', '--project-dir F', "Specify a custom project directory (default current directory)") { |pd| project_dir = pd }
|
|
47
|
+
parser.on('-i', '--[no]-ignore-root', "Ignore the sourceRoot field in the mapping file; always use --project-dir") { |ir| ignore_root = ir }
|
|
48
|
+
|
|
49
|
+
parser.on('-r', '--revision R', "Specify a code revision that was deployed (default current revision)") { |r| revision = r }
|
|
50
|
+
|
|
51
|
+
parser.on('-h', '--help', "Show this message") { puts parser; exit }
|
|
52
|
+
parser.on('--version', "Display version number of this program") { puts "1.0.0"; exit }
|
|
53
|
+
end
|
|
54
|
+
parser.parse!(ARGV)
|
|
55
|
+
|
|
56
|
+
if ARGV.size != 5
|
|
57
|
+
puts parser
|
|
58
|
+
exit 1
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
host = ARGV.shift
|
|
62
|
+
api_key = ARGV.shift
|
|
63
|
+
environment = ARGV.shift
|
|
64
|
+
map_file = ARGV.shift
|
|
65
|
+
route = ARGV.shift
|
|
66
|
+
revision = revision || git_revision(project_dir)
|
|
67
|
+
|
|
68
|
+
map = Squash::Javascript::SourceMap.from_sourcemap(map_file, route, root: ignore_root ? project_dir : nil)
|
|
69
|
+
Squash::Uploader.new(host, options).transmit '/api/1.0/sourcemap.json',
|
|
70
|
+
{
|
|
71
|
+
'api_key' => api_key,
|
|
72
|
+
'environment' => environment,
|
|
73
|
+
'revision' => revision,
|
|
74
|
+
'sourcemap' => Base64.encode64(Zlib::Deflate.deflate(map.to_yaml))
|
|
75
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Copyright 2012 Square Inc.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require 'rails/engine'
|
|
16
|
+
|
|
17
|
+
# Rails engine for the JavaScript client library assets.
|
|
18
|
+
|
|
19
|
+
class Squash::Javascript::Engine < Rails::Engine
|
|
20
|
+
end
|