在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:SquareSquash/javascript开源软件地址:https://github.com/SquareSquash/javascript开源编程语言:JavaScript 76.6%开源软件介绍:Squash Client Library: JavaScriptThis client library reports front-end JavaScript exceptions to Squash, the Squarish exception reporting and management system. DocumentationFor an overview of the various components of Squash, see the website documentation at https://github.com/SquareSquash/web. JavaScript clientDocumentation is written in Codo format. HTML documentation can be generated by
running If you do not have Codo installed in your path, you can download a project-local
install with Ruby libraryMarkdown-formatted YARD documentation is available by running CompatibilityThe JavaScript library is compatible with any modern JavaScript engine, including any version of V8, Nitro, and Chakra. The Rails engine (allowing the library to be easily used in a Rails app) is compatible with Rails 3.1 and later. RequirementsThe JavaScript library uses TraceKit for cross-platform stack trace extraction.
The library is included in this project. For Rails projects, a Sprockets include
file is provided. For non-Rails projects, the output of The included version of TraceKit has been modified somewhat:
InstallationRailsFor Rails applications, add the Squash client engine to your Gemfile with
//= require squash_javascript Other projectsFor other projects, you may need to compile the CoffeeScript file first. If you
do not have the Once you have the Place the compiled <script type="text/javascript" href="http://url.to.your/squash_javascript.min.js" /> The file defines a Configuring CORSIn order for applications to report their JavaScript errors to Squash, your
Squash instance must be configured to accept cross-origin requests from your
other website. In your Squash web code, update the UsageBefore you can use Squash, you must configure it (see Configuration below). At a minimum, you must specify
Use SquashJavascript.instance().configure({APIHost: 'YOUR_API_HOST',
APIKey: 'YOUR_API_KEY',
environment: 'production',
revision: '8718e4336990f9ea0198c2ff5668bbb673befd65'}) Squash will automatically install a listener that will trap exceptions, send
them to the server, and re-throw them. Note that the client will only notify for
instances of the There are many additional features you can take advantage of; see Additional Features below. Additional FeaturesThere are a number of other features you can take advantage of to help you debug your exceptions: User DataExceptions can be annotated with freeform user data. This data can take any format and have any meaning, typically being relevant to the exception at hand. There are multiple ways to add user data to an exception. The most
straightforward way is to include the user data as the second argument to the
SquashJavascript.instance().notify(error, {event: e, arguments: arguments}); You can apply user data to a block of code using the
$(window).resize(function(e) {
SquashJavascript.instance().addUserData({event: e}, function() {
// ... process event ...
});
}); If that's too verbose, there's additionally a curry function, $(window).resize(SquashJavascript.instance().addingUserData({event: e}, function(e) {
// ... process event ...
}); And lastly, you can add user data directly to the exception: function myFunction(value) {
if (value < 0) {
var err = new Error("value was less than 0");
err._squash_user_data = { value: value };
throw err;
}
// ... do the thing ...
} You can also add user data to exceptions you catch and re-throw: try {
doSomethingWithInput(input);
} catch (err) {
if (!err._squash_user_data) err._squash_user_data = new Object();
err._squash_user_data.input = input;
throw err; // assumed that SquashJavascript.instance().notify is called somewhere further up in the stack
} Ignoring ExceptionsYou can ignore certain error classes within a block of code if those exceptions
are not worth sending to Squash. Use the
SquashJavascript.instance().ignoreExceptions(EvalError, SyntaxError, function() {
// ... some code ...
}); The curry-type syntax is also supported here: $(window).resize(SquashJavascript.instance().ignoringExceptions(EvalError, SyntaxError, function(e) {
/// ... some code ...
}); The exceptions will be raised (not eaten) but will not be reported to Squash. You can also globally ignore exceptions using the ConfigurationYou can configure the client with the General
Error Transmission
Ignored Exceptions
Error TransmissionExceptions are transmitted to Squash using JSON-over-XMLHttpRequest. A default API endpoint is pre-configured, though you can always set your own (see Configuration above). Failsafe ReportingIn the event that the Squash client itself raises an exception when processing an exception, it will log that exception to the console. Both the original exception and the failsafe error will be logged. The original exception will still be re-raised, but the failsafe error will be "eaten." Source MappingRails and SprocketsSquash JavaScript can integrate with Sprockets to automatically generate source maps for each stage of the asset compilation pipeline, then integrate with Capistrano to upload the source maps to Squash. To use this feature, configure your project like so:
Other ProjectsIf you can generate a source map for your minified JavaScript files (Closure can), you can use this gem to upload that source map to Squash, where it will be used to convert minified stack traces to their original format, which can then benefit from Git-blaming, context, and other features of Squash. To upload the source map to squash, run the
Use SpecsJavaScript clientJasmine unit and integration tests are implemented in the Ruby libraryRSpec unit tests are implemented in the |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论