diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 601f5414a..635d56fd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,5 +42,14 @@ jobs: - name: npm install run: npm install + - name: Lint + uses: wearerequired/lint-action@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + prettier: true + eslint: true + eslint_args: '--max-warnings 0' + eslint_extensions: js + - name: Run tests run: npm run test_ci diff --git a/.lgtm.yml b/.lgtm.yml index 061c733f4..e72db1933 100644 --- a/.lgtm.yml +++ b/.lgtm.yml @@ -1,8 +1,8 @@ path_classifiers: - generated: - - release - - dist - docs: - - examples - test: - - test + generated: + - release + - dist + docs: + - examples + test: + - test diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..f5e7ca462 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,18 @@ +.github +.next +.yalc +build +bundles +coverage +dist +lib +node_modules +out +public +release +vendor + +# ignore prettifying examples for now due to +# 1. there being minified snippets all over the place and +# 2. some tests fail cause they depend on some sources being exactly as they are +examples diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..9c5e96fe7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,39 @@ +{ + "[github-actions-workflow]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "[javascriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "[json5]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "file", + "editor.tabSize": 2, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + }, + "files.trimTrailingWhitespace": true, + "prettier.useEditorConfig": false +} diff --git a/CHANGELOG.md b/CHANGELOG.md index d1b9e8f98..d716945f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,6 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co The boolean configuration options `captureEmail` and `captureUsername` can be used to change this behaviour. - ## v2.3.6 - Updates for React Native @@ -46,26 +45,26 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co ## v2.3.2 -- Be defensive about navigator not existing on window -[#514](https://github.com/rollbar/rollbar.js/pull/514) +- Be defensive about navigator not existing on window + [#514](https://github.com/rollbar/rollbar.js/pull/514) -- Proper scrubbing -[#510](https://github.com/rollbar/rollbar.js/pull/510) +- Proper scrubbing + [#510](https://github.com/rollbar/rollbar.js/pull/510) -- Be defensive when accessing event properties -[#503](https://github.com/rollbar/rollbar.js/pull/503) +- Be defensive when accessing event properties + [#503](https://github.com/rollbar/rollbar.js/pull/503) - Add environment to options type enhancement -[#499](https://github.com/rollbar/rollbar.js/pull/499) + [#499](https://github.com/rollbar/rollbar.js/pull/499) -- call the transform in the options on the server side too -[#498](https://github.com/rollbar/rollbar.js/pull/498) +- call the transform in the options on the server side too + [#498](https://github.com/rollbar/rollbar.js/pull/498) -- fixes errMsg.match is not a function error -[#492](https://github.com/rollbar/rollbar.js/pull/492) +- fixes errMsg.match is not a function error + [#492](https://github.com/rollbar/rollbar.js/pull/492) -- Call callback even if logging same as last error -[#490](https://github.com/rollbar/rollbar.js/pull/490) +- Call callback even if logging same as last error + [#490](https://github.com/rollbar/rollbar.js/pull/490) ## v2.3.1 @@ -105,16 +104,20 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co - Fix some typescript declaration issues ## v2.2.7 + - Ensure scrubbing has the right value for telemetry inputs if `scrubTelemetryInputs` is true. - Fix memory leak related to network requests ## v2.2.6 + - Fix blacklist issue ## v2.2.5 + - Revert `isNative` check for replacing JSON functions ## v2.2.4 + - Fix a "race" condition in how wait works - Add two options to control scrubbing of telemetry input events: `scrubTelemetryInputs` and `telemetryScrubber`. @@ -126,9 +129,11 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co rather than an integer. ## v2.2.3 + - Actually make collecting network telemetry on by default ## v2.2.2 + - Fix bug in network telemetry that was wrapping onreadystatechage in correctly - Enable collecting network telemetry by default - Fix stack overflow issue due to scrubbing of self-referential objects @@ -137,43 +142,48 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co - Make the typescript type declarations better ## v2.2.1 + - Disable collection of network telemetry data by default ## v2.2.0 + - Telemetry data is now collected by default in the browser. See [README.md](https://github.com/rollbar/rollbar.js#telemetry) for information and configuration details. - Fix some typos in the typescript declarations ## v2.1.3 + - Actually change version number in package.json and build all relevant files ## v2.1.2 + - Actually send the client-side UUID with the item - Fix typos in typescript declaration ## v2.1.1 -- Allow more flexibility of request objects -[#346](https://github.com/rollbar/rollbar.js/pull/346) -- Address issue with handleItemWithError possible not calling the callback -[#345](https://github.com/rollbar/rollbar.js/pull/345) -- Fixed a typo in README.md -[#343](https://github.com/rollbar/rollbar.js/pull/343) -- unify configuration options -[#341](https://github.com/rollbar/rollbar.js/pull/341) -- add some intervals to keep the event loop running when wait is called -[#338](https://github.com/rollbar/rollbar.js/pull/338) -- [Fixes #336] Propagate message -[#337](https://github.com/rollbar/rollbar.js/pull/337) -- [Fixes #269] get rid of rollbar wrapper stack frames -[#335](https://github.com/rollbar/rollbar.js/pull/335) -- first pass at a typescript declaration file -[#334](https://github.com/rollbar/rollbar.js/pull/334) -- Fix #331 Verbose logging was using the wrong key structure -[#332](https://github.com/rollbar/rollbar.js/pull/332) +- Allow more flexibility of request objects + [#346](https://github.com/rollbar/rollbar.js/pull/346) +- Address issue with handleItemWithError possible not calling the callback + [#345](https://github.com/rollbar/rollbar.js/pull/345) +- Fixed a typo in README.md + [#343](https://github.com/rollbar/rollbar.js/pull/343) +- unify configuration options + [#341](https://github.com/rollbar/rollbar.js/pull/341) +- add some intervals to keep the event loop running when wait is called + [#338](https://github.com/rollbar/rollbar.js/pull/338) +- [Fixes #336] Propagate message + [#337](https://github.com/rollbar/rollbar.js/pull/337) +- [Fixes #269] get rid of rollbar wrapper stack frames + [#335](https://github.com/rollbar/rollbar.js/pull/335) +- first pass at a typescript declaration file + [#334](https://github.com/rollbar/rollbar.js/pull/334) +- Fix #331 Verbose logging was using the wrong key structure + [#332](https://github.com/rollbar/rollbar.js/pull/332) ## v2.1.0 + - Use the upstream version of console-polyfill: [#306](https://github.com/rollbar/rollbar.js/pull/306) - The verbose option still existed but didn't do anything, this adds back the functionality to output some information to the console: [#311](https://github.com/rollbar/rollbar.js/pull/311) @@ -197,10 +207,12 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co match what we allow in the browser: [#329](https://github.com/rollbar/rollbar.js/pull/329) ## v2.0.4 + - Fixes a small typo in the unhandled rejection handler. (pr#303) -- Updated the no-conflict example to use the new noconflict bundle and updated docs. +- Updated the no-conflict example to use the new noconflict bundle and updated docs. ## v2.0.3 + - Decreased NPM package size by removing examples and coverage directories. (pr#276) - Handle unordered params on the server side. (pr#286) - Fixes a server-side bug which failed to report an error if the request did not contain a `headers` key. (pr#288) @@ -210,13 +222,16 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co - Added a no-conflict bundle for the browser. (pr#295) ## v2.0.2 + - Added/updated docs on how to use rollbar.js with React, Angular 1 & 2, Ember, Backbone.js - Fixed a bug which was not respecting the `enabled` flag. (pr#280) ## v2.0.1 + - Maintenance release - No new features or bugfixes ## v2.0.0 + This release is the first where the library supports both browser and node environments from the same package. We decided to deprecate the `rollbar-browser` npm package in favor of using the `rollbar` npm package for all javascript environments. This single codebase now handles both @@ -247,6 +262,7 @@ be noticable. However, there are a few cases where one might run in to trouble. the convenience instance located at `window.Rollbar` will be setup as this handler. **v1.9.4** + - Updated to the newest version of console-polyfill (pr#244) - Log functions now return an object with the uuid as one of the keys (pr#236) - Fix issue related to Object.assign which caused problems on IE8 (pr#246) @@ -255,16 +271,20 @@ be noticable. However, there are a few cases where one might run in to trouble. `[object Object]` (pr#249) **v1.9.3** + - Serve rollbar.js from CDNJS **v1.9.2** + - Fix bug which would break `Rollbar.wrap()` if a string was thrown. (pr#222) **v1.9.1** + - Re-add rollbar.snippet.js to the Bower distribution. (pr#196) - This re-adds `dist/rollbar.snippet.js` to be backwards compatible with v1.8.5 **v1.9.0** + - Added support for arrays as custom data. (pr#194) - Documentation added for disabling Rollbar in the presence of ad blockers. (pr#190) - Added support for unhandled rejections from Promises. (pr#192) @@ -278,21 +298,27 @@ be noticable. However, there are a few cases where one might run in to trouble. - `src` **v1.8.5** + - Support retrying after being in offline mode. (pr#186) **v1.8.4** + - Check messages body for ignored messages. (pr#180) **v1.8.3** + - Fix a bug introduced in 1.8.0 where payload options were being removed by calls to `configure()`. (pr#176) **v1.8.2** + - Using the latest error-stack-parser from NPM. (pr#171) **v1.8.1** + - Changed the error-stack-parser dependency to use git+https. (pr#168) **v1.8.0** + - Fixed a few bugs in IE9, IE8 which were not recognozing `Error` instances properly. (pr#164) - Changed the behavior of `.global()` to only store options that we know how to process. (pr#164) - Refactored the code to remove custom polyfills. (pr#164) @@ -300,24 +326,30 @@ be noticable. However, there are a few cases where one might run in to trouble. - Fixed a bug in the jQuery plugin which would cause an error to be thrown in the internal `checkIgnore()` function. (pr#161) **v1.7.5** + - Fix bug when checking window.onerror.belongsToShim. **v1.7.4** + - Don't save shim's onerror when we are building globalnotifier. This fixes tests using window.onerror on a browser console - Fix Default endpoint on docs/configuration.md **v1.7.3** + - Added a named AMD module to the list of build targets. (pr#151) **v1.7.2** + - Bumped version so that NPM lists 1.7.2 as the latest, (was pointing to 1.6.0) (issue#148) **v1.7.1** + - Integrated karma tests. (pr#130) - Added warning message for common issue with `loadFull()` **v1.7.0** + - Fixed a bug that was not recognizing custom Error subclasses as valid errors. (pr#142) - Added documentation for the `hostWhiteList` option. (pr#138) - Changed the default uncaught error level to "error" instead of "warning". @@ -326,14 +358,17 @@ be noticable. However, there are a few cases where one might run in to trouble. asynchronously. This option is set to `true` by default. **v1.6.1** + - Updated bower.json to contain only a single .js entry. (issue#126) **v1.6.0** + - Fixed a bug that caused IE 8 to not properly initialize `window.Rollbar`. (pr#129) - Fixed the `XDomainRequest` code to work properly in IE 8. - Updated error parsing to provide more useful information for IE 8 errors **v1.5.0** + - Published rollbar.js to npmjs.com as rollbar-browser. (pr#127) - Fixes a bug where thrown non-error objects were not properly handled. (pr#125) - Fixes a bug that was logging an incorrect message when the notifier was disabled. (pr#124) @@ -341,158 +376,204 @@ be noticable. However, there are a few cases where one might run in to trouble. - Lots of code cleanup and smaller minified file size. **v1.4.4** + - Remove the `window.onload` event handler from the snippet and just create the script tag for the full rollbar.js source directly. (pr#120) **v1.4.3** + - Fixed a bug that would cause the notifier to crash when run in a Selenium test. (pr#117) - Force the notifier to always use HTTPS when communicating with api.rollbar.com. (pr#116) **v1.4.2** + - Fixed a bug that occurred in FF when Rollbar logged an internal error or if verbose mode was turned on. (pr#105) **v1.4.1** + - Fixed a bug that would load the wrong AMD module if a custom "rollbar" module was already defined. - Customers should copy and paste the new snippet into their code. **v1.4.0** + - Fix a bug, (introduced in v1.3) that caused Rollbar to generate an error when used with RequireJS. - Customers should copy and paste the new snippet into their code. **v1.3.0** + - Add more strict JSHint options and fix errors/warnings. **v1.3.0-rc.4** + - Fixes IE8 bug where JSON was not defined. **v1.3.0-rc.3** + - Remove polyfill. **v1.3.0-rc.2** + - Fix main values in bower.json. **v1.3.0-rc.1** + - Fixes for IE8+ **v1.3.0-alpha.5** + - Fix rollbar.umd.min.js URL in the snippet - Remove sourceMappingURL comment due to browser bug concerns **v1.3.0-alpha.4** + - Update CHANGELOG.md. **v1.3.0-alpha.3** + - Remove repeated timer to send enqueued payloads. - Change argument name in Stack() to fix uglify bug. -- Change __DEFAULT_ROLLBARJS_URL__ to use https. -- Set window._globalRollbarOptions when calling .configure(). +- Change **DEFAULT_ROLLBARJS_URL** to use https. +- Set window.\_globalRollbarOptions when calling .configure(). **v1.3.0-alpha.2** + - Update missing dist/ files. **v1.3.0-alpha.1** + - Build the library using webpack. - Replace tracekit and use error-stack-parser. **1.2.2** + - Added `nojson` distribution, for use on sites with a Content Security Policy that disallows `unsafe-eval`. (The standard distributions ship with a built-in JSON implementation, since external libraries, such as MooTools, sometimes break the brower's built-in JSON.) If you know that the built-in JSON is not being modified in your application, or you are disallowing `unsafe-eval`, use this distribution. **1.2.1** + - Fixed bug where the global notifier not being used to atch event listener exceptions. (pr#70) **1.2.0** + - Fixed AMD build to now return the notifier instance from the `init()` method. **1.1.16 - EDIT: This version has been removed due to finding a bug that broke backward compatibility.** + - Optimized the AMD build to not create a Notifier instance until the `init()` method is called. **1.1.15** + - Fix a bug where custom context functions that returned `undefined` were causing `Rollbar.wrap()` to throw an error. **1.1.14** + - Fix a bug in IE8 where DOMException was being used even though it's not defined, (#62). **1.1.13** + - Add `responseText` and `statusText` to the data reported by the jQuery ajax plugin, (pr#61). **1.1.12** + - Fixes a bug where `DOMException` objects were not recognized as error objects. (#55). **1.1.11** + - Fixes a bug where wrapped functions were crashing when a `null` callback was given to `removeEventListener()`, (pr#50). **1.1.10** + - Pulls in the latest JSON-js changes that do not call `.toJSON()` if the method exists already. This was breaking because MooTools v1.2.4 sets `.toJSON()` to use a broken JSON stringify implementation. **1.1.9** + - Always use the custom JSON implementation since some users are initializing a library that will overwrite a working `JSON.stringify()` with a broken one after Rollbar has checked for `JSON.stringify()` correctness. **1.1.8** + - Added a callback function to `loadFull()` to support Segment.io's plugin model. **1.1.7** + - Added `verbose` and `logFunction` options, (pr#42). **1.1.6** + - Added a `_wrappedSource` key to exceptions caught by the `wrap()` method to record the source of the wrapped function. **1.1.5** + - Added a `context` parameter to `Rollbar.wrap()`, (#26). - Added a `transform` option to allow the user to read/modify the payload before we send it to Rollbar, (#41 #43). **1.1.4** + - Added the `enabled` flag to determine when we should enqueue payloads to be sent, (#28). **1.1.3** + - Fixed a bug that was causing a stack overflow error in IE8, (#38). - Shaved off a few bytes from the snippet's size. **1.1.2** + - Fixed a bug that was causing `Rollbar.configure()` to incorrectly handle overwriting array configuration. - Added in support for a `ignoredMessages` configuration option, (pr#35). - Fixed a bug that was causing some `EventListener` objects to not be unbound, (pr#33). - Updated the snippet with fixes. **1.1.1** + - Fixed a bug with default rate limits. The defaults were not applied unless Rollbar.global() was called. **1.1.0** + - Add support for AMD JS loaders and refactor rollbar.require.js into rollbar.amd.js and rollbar.commonjs.js. **1.0.0-rc.11** + - Add support for whitelisting host names/domains, (pr#31). **1.0.0-rc.10** + - Add support for using rollbar with Webpack/Browserify via `require("rollbar.require.min.js")` with examples. **1.0.0-rc.9** + - Fixed a bug that caused a wrapped async handler to break if there was no callback provided. **1.0.0-rc.8** + - Fixed a bug that created/used a global variable. **1.0.0-rc.7** + - Change default reportLevel to `debug`. Previously, calls to `Rollbar.info` and `Rollbar.debug` were filtered out under the default configuration; now they are let through. **1.0.0-rc.6** + - Fixed a bug where items were sent in reverse order when queued - Add `maxItems` global option. If defined, at most this many items per pageview will be sent. Default `0`, meaning "no limit". **1.0.0-rc.5** + - Fix invalid payload generated when a non-Error object is passed as the error (#20) - Pass correct window.onerror args to original onerror (#23) - jQuery plugin: ignore status 0 events (#22) - Fix issue where callbacks to `.debug()`, etc. were not called if reportLevel filters the item (#24) **1.0.0-rc.4** + - Fix snippet in IE8 (change `map` to a for loop) **1.0.0-rc.3** + - Remove source maps from build process (no user-facing changes) **1.0.0-rc.2** + - Send access token as a request header in browsers that support XMLHttpRequest **1.0.0-rc.1** + - Fix bug where we were attempting to wrap an object instead of a function. - https://github.com/rollbar/rollbar.js/pull/17 - Fix bug in jQuery plugin that wasn't passing along the jQuery object. @@ -501,17 +582,21 @@ be noticable. However, there are a few cases where one might run in to trouble. - https://github.com/rollbar/rollbar.js/blob/master/docs/migration_v0_to_v1.md **1.0.0-beta9** + - Fix api response JSON parsing on older browsers **1.0.0-beta8** + - Fix uncaught errors being ignored in some browsers - Default uncaught error level now `warning` instead of `error`, also configurable - Wrap `addEventListener` to get more rich stack trace info for uncaught exceptions **1.0.0-beta7** + - Use a custom JSON.stringify method if the existing one does not work properly. **1.0.0-beta4** + - Fix some documentation bugs - Changes made to the snippet to put `environment` in the `payload` key. - Remove the default `context` value and associated logic around it being either a string or a function. @@ -519,4 +604,5 @@ be noticable. However, there are a few cases where one might run in to trouble. ## Upgrade Instructions ### v1.0.x to v1.1.x + 1. Replace your rollbar snippet with the latest from the [rollbar.js quickstart docs](https://rollbar.com/docs/notifier/rollbar.js/) or from [the GitHub repo](https://github.com/rollbar/rollbar.js/blob/master/dist/rollbar.snippet.js). diff --git a/Gruntfile.js b/Gruntfile.js index d64ca5660..5a12cffa6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -2,7 +2,6 @@ * Build and test rollbar.js */ - 'use strict'; var glob = require('glob'); @@ -12,7 +11,6 @@ var fs = require('fs'); var webpackConfig = require('./webpack.config.js'); - function findTests(context) { if (context !== 'browser') { return {}; @@ -20,7 +18,7 @@ function findTests(context) { var files = glob.sync('test/**/!(server.)*.test.js'); var mapping = {}; - files.forEach(function(file) { + files.forEach(function (file) { var testName = path.basename(file, '.test.js'); mapping[testName] = file; }); @@ -39,19 +37,19 @@ function buildGruntKarmaConfig(singleRun, tests, reporters) { pattern: 'dist/**/*.js', included: false, served: true, - watched: false + watched: false, }, { pattern: 'src/**/*.js', included: false, served: true, - watched: false + watched: false, }, { pattern: 'examples/**/*.js', included: false, served: true, - watched: false + watched: false, }, // Examples HTML, set `included: true`, but they won't be executed or added @@ -60,9 +58,9 @@ function buildGruntKarmaConfig(singleRun, tests, reporters) { pattern: 'examples/**/*.html', included: true, served: true, - watched: false - } - ] + watched: false, + }, + ], }, }; @@ -72,20 +70,18 @@ function buildGruntKarmaConfig(singleRun, tests, reporters) { for (var testName in tests) { var testFile = tests[testName]; - var testConfig = config[testName] = {}; + var testConfig = (config[testName] = {}); // Special case for testing requirejs integration. // Include the requirejs module as a framework so // Karma will inclue it in the web page. if (testName === 'requirejs') { - testConfig.files = [ - {src: './dist/rollbar.umd.js', included: false} - ]; + testConfig.files = [{ src: './dist/rollbar.umd.js', included: false }]; // NOTE: requirejs should go first in case the subsequent libraries // check for the existence of `define()` testConfig.frameworks = ['requirejs', 'expect', 'mocha']; } else { - testConfig.files = [{src: [testFile]}]; + testConfig.files = [{ src: [testFile] }]; } // Special config for BrowserStack IE tests @@ -98,8 +94,7 @@ function buildGruntKarmaConfig(singleRun, tests, reporters) { return config; } - -module.exports = function(grunt) { +module.exports = function (grunt) { require('time-grunt')(grunt); var browserTests = findTests('browser'); @@ -119,7 +114,6 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-text-replace'); grunt.loadNpmTasks('grunt-vows'); - var rollbarJsSnippet = fs.readFileSync('dist/rollbar.snippet.js'); var rollbarjQuerySnippet = fs.readFileSync('dist/plugins/jquery.min.js'); @@ -129,46 +123,62 @@ module.exports = function(grunt) { vows: { all: { options: { - reporter: 'spec' + reporter: 'spec', }, - src: ['test/server.*.test.js'] - } + src: ['test/server.*.test.js'], + }, }, karma: buildGruntKarmaConfig(singleRun, browserTests, reporters), replace: { snippets: { - src: ['*.md', 'src/**/*.js', 'examples/*.+(html|js)', 'examples/*/*.+(html|js)', 'docs/**/*.md'], + src: [ + '*.md', + 'src/**/*.js', + 'examples/*.+(html|js)', + 'examples/*/*.+(html|js)', + 'docs/**/*.md', + ], overwrite: true, replacements: [ // Main rollbar snippet { - from: new RegExp('^(.*// Rollbar Snippet)[\n\r]+(.*[\n\r])*(.*// End Rollbar Snippet)', 'm'), // eslint-disable-line no-control-regex - to: function(match, index, fullText, captures) { + from: new RegExp( + /* eslint-disable-next-line no-control-regex */ + '^(.*// Rollbar Snippet)[\n\r]+(.*[\n\r])*(.*// End Rollbar Snippet)', + 'm', + ), + to: function (match, index, fullText, captures) { captures[1] = rollbarJsSnippet; return captures.join('\n'); - } + }, }, // jQuery rollbar plugin snippet { - from: new RegExp('^(.*// Rollbar jQuery Snippet)[\n\r]+(.*[\n\r])*(.*// End Rollbar jQuery Snippet)', 'm'), // eslint-disable-line no-control-regex - to: function(match, index, fullText, captures) { + from: new RegExp( + /* eslint-disable-next-line no-control-regex */ + '^(.*// Rollbar jQuery Snippet)[\n\r]+(.*[\n\r])*(.*// End Rollbar jQuery Snippet)', + 'm', + ), + to: function (match, index, fullText, captures) { captures[1] = rollbarjQuerySnippet; return captures.join('\n'); - } + }, }, // README CI link { - from: new RegExp('(https://github\\.com/rollbar/rollbar\\.js/workflows/Rollbar\\.js%20CI/badge\\.svg\\?branch=v)([0-9a-zA-Z.-]+)'), - to: function(match, index, fullText, captures) { + from: new RegExp( + '(https://github\\.com/rollbar/rollbar\\.js/workflows/Rollbar\\.js%20CI/badge\\.svg\\?branch=v)([0-9a-zA-Z.-]+)', + ), + to: function (match, index, fullText, captures) { captures[1] = pkg.version; return captures.join(''); - } - } - ] - } - } + }, + }, + ], + }, + }, }); grunt.registerTask('build', ['webpack', 'replace:snippets']); @@ -176,12 +186,12 @@ module.exports = function(grunt) { grunt.registerTask('test', ['test-server', 'test-browser']); grunt.registerTask('release', ['build', 'copyrelease']); - grunt.registerTask('test-server', function(_target) { + grunt.registerTask('test-server', function (_target) { var tasks = ['vows']; grunt.task.run.apply(grunt.task, tasks); }); - grunt.registerTask('test-browser', function(target) { + grunt.registerTask('test-browser', function (target) { var karmaTask = 'karma' + (target ? ':' + target : ''); var tasks = [karmaTask]; grunt.task.run.apply(grunt.task, tasks); @@ -196,11 +206,11 @@ module.exports = function(grunt) { var minJs = 'dist/rollbar' + buildName + '.min.js'; var releaseJs = 'release/rollbar' + buildName + '-' + version + '.js'; - var releaseMinJs = 'release/rollbar' + buildName + '-' + version + '.min.js'; + var releaseMinJs = + 'release/rollbar' + buildName + '-' + version + '.min.js'; grunt.file.copy(js, releaseJs); grunt.file.copy(minJs, releaseMinJs); }); }); - }; diff --git a/README.md b/README.md index 2240f407c..61ad7be64 100644 --- a/README.md +++ b/README.md @@ -12,21 +12,20 @@ [![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/context:javascript) [![Total Alerts](https://img.shields.io/lgtm/alerts/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/alerts) - --- ## Key benefits of using Rollbar.js are: + - **Cross platform:** Rollbar.js supports both server-side and client-side Javascript, including frameworks such as React, Angular, Express, Next.js and more. - **Telemetry:** The telemetry timeline provides a list of “breadcrumbs” events that can help developers understand and fix problems in their client-side javascript. Learn more about telemetry. - **Automatic error grouping:** Rollbar aggregates Occurrences caused by the same error into Items that represent application issues. Learn more about reducing log noise. - **Advanced search:** Filter items by many different properties. Learn more about search. - **Customizable notifications:** Rollbar supports several messaging and incident management tools where your team can get notified about errors and important events by real-time alerts. Learn more about Rollbar notifications. - ## Setup Instructions 1. [Sign up for a Rollbar account](https://rollbar.com/signup). -2. For client-side Javascript, follow the [Browser Quick Start](https://docs.rollbar.com/docs/javascript#section-quick-start-browser) instructions. For Node.js, follow the [Server Quick Start](https://docs.rollbar.com/docs/javascript#section-quick-start-server). +2. For client-side Javascript, follow the [Browser Quick Start](https://docs.rollbar.com/docs/javascript#section-quick-start-browser) instructions. For Node.js, follow the [Server Quick Start](https://docs.rollbar.com/docs/javascript#section-quick-start-server). ## Usage and Reference diff --git a/bower.json b/bower.json index 3277d005f..1dcfc3c43 100644 --- a/bower.json +++ b/bower.json @@ -1,9 +1,7 @@ { "name": "rollbar", "dependencies": {}, - "main": [ - "dist/rollbar.umd.js" - ], + "main": ["dist/rollbar.umd.js"], "ignore": [ "dist/*.nojson*", "dist/*.named-amd*", diff --git a/defaults.js b/defaults.js index 5b79ee295..c11950703 100644 --- a/defaults.js +++ b/defaults.js @@ -5,13 +5,25 @@ var version = pkg.version; module.exports = { __NOTIFIER_VERSION__: JSON.stringify(pkg.version), __JQUERY_PLUGIN_VERSION__: JSON.stringify(pkg.plugins.jquery.version), - __DEFAULT_SERVER_SCRUB_FIELDS__: JSON.stringify(pkg.defaults.server.scrubFields), - __DEFAULT_SERVER_SCRUB_HEADERS__: JSON.stringify(pkg.defaults.server.scrubHeaders), + __DEFAULT_SERVER_SCRUB_FIELDS__: JSON.stringify( + pkg.defaults.server.scrubFields, + ), + __DEFAULT_SERVER_SCRUB_HEADERS__: JSON.stringify( + pkg.defaults.server.scrubHeaders, + ), __DEFAULT_ENDPOINT__: JSON.stringify(pkg.defaults.endpoint), __DEFAULT_LOG_LEVEL__: JSON.stringify(pkg.defaults.logLevel), __DEFAULT_REPORT_LEVEL__: JSON.stringify(pkg.defaults.reportLevel), - __DEFAULT_UNCAUGHT_ERROR_LEVEL: JSON.stringify(pkg.defaults.uncaughtErrorLevel), - __DEFAULT_ROLLBARJS_URL__: JSON.stringify('https://' + pkg.cdn.host + '/rollbarjs/refs/tags/v' + version + '/rollbar.min.js'), + __DEFAULT_UNCAUGHT_ERROR_LEVEL: JSON.stringify( + pkg.defaults.uncaughtErrorLevel, + ), + __DEFAULT_ROLLBARJS_URL__: JSON.stringify( + 'https://' + + pkg.cdn.host + + '/rollbarjs/refs/tags/v' + + version + + '/rollbar.min.js', + ), __DEFAULT_MAX_ITEMS__: pkg.defaults.maxItems, - __DEFAULT_ITEMS_PER_MIN__: pkg.defaults.itemsPerMin + __DEFAULT_ITEMS_PER_MIN__: pkg.defaults.itemsPerMin, }; diff --git a/docs/extension-exceptions.md b/docs/extension-exceptions.md index 906bc16f8..9b7517870 100644 --- a/docs/extension-exceptions.md +++ b/docs/extension-exceptions.md @@ -7,7 +7,7 @@ For most websites, the path for dealing with browser extension originating excep ## Dealing with adblockers -The most common type of extension that can be problematic is adblockers. These extensions can disable loading +The most common type of extension that can be problematic is adblockers. These extensions can disable loading certain external scripts or remove elements from a page based on a simple set of heuristics. You can see a [full example](https://github.com/rollbar/rollbar.js/tree/master/examples/extension-exceptions/) @@ -24,7 +24,7 @@ Load Rollbar.js as normal. captureUncaught: true, payload: { environment: 'development', - } + }, }; ``` @@ -33,45 +33,50 @@ Add an html element with "bait" class names to be removed by adblockers. ```html -
+
``` Add functions to check for the presence and visibility of our bait div. ```js - function disableRollbar() { - Rollbar.configure({enabled: false}); - } - - function checkForAds() { - var bait = document.getElementById("blocker-bait"); +function disableRollbar() { + Rollbar.configure({ enabled: false }); +} - if (bait == null) { - disableRollbar(); - return; - } - - var baitStyles = window.getComputedStyle(bait); - if (baitStyles && ( - baitStyles.getPropertyValue('display') === 'none' || - baitStyles.getPropertyValue('visibility') === 'hidden')) { - disableRollbar(); - } - } +function checkForAds() { + var bait = document.getElementById('blocker-bait'); - function onLoadStartAdCheck() { - // Ad blockers generally execute just after load, let's delay ourselves to get behind it. - setTimeout(checkForAds, 1); + if (bait == null) { + disableRollbar(); + return; } - if (window.addEventListener !== undefined) { - window.addEventListener('load', onLoadStartAdCheck, false); - } else { - window.attachEvent('onload', onLoadStartAdCheck); + var baitStyles = window.getComputedStyle(bait); + if ( + baitStyles && + (baitStyles.getPropertyValue('display') === 'none' || + baitStyles.getPropertyValue('visibility') === 'hidden') + ) { + disableRollbar(); } +} + +function onLoadStartAdCheck() { + // Ad blockers generally execute just after load, let's delay ourselves to get behind it. + setTimeout(checkForAds, 1); +} + +if (window.addEventListener !== undefined) { + window.addEventListener('load', onLoadStartAdCheck, false); +} else { + window.attachEvent('onload', onLoadStartAdCheck); +} ``` -The above approach is likely to work in the majority of cases, *but it is not foolproof*. Extensions and their +The above approach is likely to work in the majority of cases, _but it is not foolproof_. Extensions and their behavior evolve over time and nothing stops a user from opening their console and modifying / executing code as well. A practical approach involves incrementally adjusting your detection as new exceptions occur in large numbers. diff --git a/docs/migration_v0_to_v1.md b/docs/migration_v0_to_v1.md index 2e4327123..48bb03c1a 100644 --- a/docs/migration_v0_to_v1.md +++ b/docs/migration_v0_to_v1.md @@ -7,19 +7,20 @@ ### Change the config object: ```js -var _rollbarParams = {"server.environment": "production"}; -_rollbarParams["notifier.snippet_version"] = "2"; var _rollbar=["POST_CLIENT_ITEM_ACCESS_TOKEN", _rollbarParams]; +var _rollbarParams = { 'server.environment': 'production' }; +_rollbarParams['notifier.snippet_version'] = '2'; +var _rollbar = ['POST_CLIENT_ITEM_ACCESS_TOKEN', _rollbarParams]; ``` -to +to ```js var _rollbarConfig = { - accessToken: "POST_CLIENT_ITEM_ACCESS_TOKEN", + accessToken: 'POST_CLIENT_ITEM_ACCESS_TOKEN', captureUncaught: true, payload: { - environment: "production" - } + environment: 'production', + }, }; ``` @@ -29,21 +30,21 @@ e.g. ```js var _rollbarParams = { - checkIgnore: function(msg, url, lineNo, colNo, error) { + checkIgnore: function (msg, url, lineNo, colNo, error) { // don't ignore anything (default) return false; }, - context: "home#index", + context: 'home#index', itemsPerMinute: 60, - level: "error", + level: 'error', person: { id: 12345, - username: "johndoe", - email: "johndoe@example.com" + username: 'johndoe', + email: 'johndoe@example.com', }, - "server.branch": "develop", - "server.environment": "staging", - "server.host": "web1" + 'server.branch': 'develop', + 'server.environment': 'staging', + 'server.host': 'web1', }; ``` @@ -51,28 +52,28 @@ should be changed to ```js var _rollbarConfig = { - accessToken: "POST_CLIENT_ITEM_ACCESS_TOKEN", + accessToken: 'POST_CLIENT_ITEM_ACCESS_TOKEN', captureUncaught: true, - checkIgnore: function(msg, url, lineNo, colNo, error) { + checkIgnore: function (msg, url, lineNo, colNo, error) { // don't ignore anything (default) return false; }, itemsPerMinute: 60, - logLevel: "error", + logLevel: 'error', payload: { - environment: "production", - context: "home#index", + environment: 'production', + context: 'home#index', person: { id: 12345, - username: "johndoe", - email: "johndoe@example.com" + username: 'johndoe', + email: 'johndoe@example.com', }, server: { - branch: "develop", - environment: "staging", - host: "web1" - } - } + branch: 'develop', + environment: 'staging', + host: 'web1', + }, + }, }; ``` @@ -80,7 +81,6 @@ var _rollbarConfig = { For the latest snippet, see the instructions here: [https://rollbar.com/docs/notifier/rollbar.js/](https://rollbar.com/docs/notifier/rollbar.js/). - ## Update references to `_rollbar.push()` The v1 notifier has a more intuitive interface for recording errors and generic logging. @@ -118,19 +118,18 @@ try { } ``` - ### Recording a log message From ```js -_rollbar.push("Some log message"); +_rollbar.push('Some log message'); ``` to ```js -Rollbar.info("Some log message"); +Rollbar.info('Some log message'); ``` #### Including custom data @@ -138,13 +137,17 @@ Rollbar.info("Some log message"); From ```js -_rollbar.push({level: "warning", msg: "Some warning message", point: {x: 5, y: 10}}); +_rollbar.push({ + level: 'warning', + msg: 'Some warning message', + point: { x: 5, y: 10 }, +}); ``` to ```js -Rollbar.warning("Some warning message", {point: {x: 5, y: 10}}); +Rollbar.warning('Some warning message', { point: { x: 5, y: 10 } }); ``` #### Using callbacks @@ -155,11 +158,11 @@ From try { doSomething(); } catch (e) { - _rollbar.push(e, function(err, uuid) { + _rollbar.push(e, function (err, uuid) { if (err !== null) { - console.error("Could not report an exception to Rollbar, error: " + err); + console.error('Could not report an exception to Rollbar, error: ' + err); } else { - console.log("Reported exception to Rollbar, uuid: " + uuid); + console.log('Reported exception to Rollbar, uuid: ' + uuid); } }); } @@ -171,11 +174,11 @@ to try { doSomething(); } catch (e) { - Rollbar.log(e, function(err, uuid) { + Rollbar.log(e, function (err, uuid) { if (err !== null) { - console.error("Could not report an exception to Rollbar, error: " + err); + console.error('Could not report an exception to Rollbar, error: ' + err); } else { - console.log("Reported exception to Rollbar, uuid: " + uuid); + console.log('Reported exception to Rollbar, uuid: ' + uuid); } }); } diff --git a/examples/angular2/angular.json b/examples/angular2/angular.json index 88b3a7c0d..3d993ee20 100644 --- a/examples/angular2/angular.json +++ b/examples/angular2/angular.json @@ -18,13 +18,8 @@ "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.app.json", - "assets": [ - "src/favicon.ico", - "src/assets" - ], - "styles": [ - "src/styles.css" - ], + "assets": ["src/favicon.ico", "src/assets"], + "styles": ["src/styles.css"], "scripts": [], "es5BrowserSupport": true }, @@ -79,26 +74,16 @@ "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.spec.json", "karmaConfig": "src/karma.conf.js", - "styles": [ - "src/styles.css" - ], + "styles": ["src/styles.css"], "scripts": [], - "assets": [ - "src/favicon.ico", - "src/assets" - ] + "assets": ["src/favicon.ico", "src/assets"] } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { - "tsConfig": [ - "src/tsconfig.app.json", - "src/tsconfig.spec.json" - ], - "exclude": [ - "**/node_modules/**" - ] + "tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"], + "exclude": ["**/node_modules/**"] } } } @@ -124,13 +109,11 @@ "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": "e2e/tsconfig.e2e.json", - "exclude": [ - "**/node_modules/**" - ] + "exclude": ["**/node_modules/**"] } } } } }, "defaultProject": "my-app" -} \ No newline at end of file +} diff --git a/examples/angular2/e2e/protractor.conf.js b/examples/angular2/e2e/protractor.conf.js index 86776a391..98bba7090 100644 --- a/examples/angular2/e2e/protractor.conf.js +++ b/examples/angular2/e2e/protractor.conf.js @@ -5,11 +5,9 @@ const { SpecReporter } = require('jasmine-spec-reporter'); exports.config = { allScriptsTimeout: 11000, - specs: [ - './src/**/*.e2e-spec.ts' - ], + specs: ['./src/**/*.e2e-spec.ts'], capabilities: { - 'browserName': 'chrome' + browserName: 'chrome', }, directConnect: true, baseUrl: 'http://localhost:4200/', @@ -17,12 +15,14 @@ exports.config = { jasmineNodeOpts: { showColors: true, defaultTimeoutInterval: 30000, - print: function() {} + print: function () {}, }, onPrepare() { require('ts-node').register({ - project: require('path').join(__dirname, './tsconfig.e2e.json') + project: require('path').join(__dirname, './tsconfig.e2e.json'), }); - jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); - } -}; \ No newline at end of file + jasmine + .getEnv() + .addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + }, +}; diff --git a/examples/angular2/e2e/src/app.e2e-spec.ts b/examples/angular2/e2e/src/app.e2e-spec.ts index 3b79f7c47..12ba22b16 100644 --- a/examples/angular2/e2e/src/app.e2e-spec.ts +++ b/examples/angular2/e2e/src/app.e2e-spec.ts @@ -16,8 +16,10 @@ describe('workspace-project App', () => { afterEach(async () => { // Assert that there are no errors emitted from the browser const logs = await browser.manage().logs().get(logging.Type.BROWSER); - expect(logs).not.toContain(jasmine.objectContaining({ - level: logging.Level.SEVERE, - } as logging.Entry)); + expect(logs).not.toContain( + jasmine.objectContaining({ + level: logging.Level.SEVERE, + } as logging.Entry), + ); }); }); diff --git a/examples/angular2/e2e/tsconfig.e2e.json b/examples/angular2/e2e/tsconfig.e2e.json index a6dd62202..22e04cb18 100644 --- a/examples/angular2/e2e/tsconfig.e2e.json +++ b/examples/angular2/e2e/tsconfig.e2e.json @@ -4,10 +4,6 @@ "outDir": "../out-tsc/app", "module": "commonjs", "target": "es5", - "types": [ - "jasmine", - "jasminewd2", - "node" - ] + "types": ["jasmine", "jasminewd2", "node"] } -} \ No newline at end of file +} diff --git a/examples/angular2/src/app/app-routing.module.ts b/examples/angular2/src/app/app-routing.module.ts index d425c6f56..11c2e8407 100644 --- a/examples/angular2/src/app/app-routing.module.ts +++ b/examples/angular2/src/app/app-routing.module.ts @@ -5,6 +5,6 @@ const routes: Routes = []; @NgModule({ imports: [RouterModule.forRoot(routes)], - exports: [RouterModule] + exports: [RouterModule], }) -export class AppRoutingModule { } +export class AppRoutingModule {} diff --git a/examples/angular2/src/app/app.component.html b/examples/angular2/src/app/app.component.html index b0c533d70..62e304ba1 100644 --- a/examples/angular2/src/app/app.component.html +++ b/examples/angular2/src/app/app.component.html @@ -1,8 +1,6 @@ -
-

- Rollbar example for Angular 2+ -

+
+

Rollbar example for Angular 2+

diff --git a/examples/angular2/src/app/app.component.spec.ts b/examples/angular2/src/app/app.component.spec.ts index 3fe58ce0f..b9031c734 100644 --- a/examples/angular2/src/app/app.component.spec.ts +++ b/examples/angular2/src/app/app.component.spec.ts @@ -5,12 +5,8 @@ import { AppComponent } from './app.component'; describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [ - RouterTestingModule - ], - declarations: [ - AppComponent - ], + imports: [RouterTestingModule], + declarations: [AppComponent], }).compileComponents(); })); @@ -30,6 +26,8 @@ describe('AppComponent', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to my-app!'); + expect(compiled.querySelector('h1').textContent).toContain( + 'Welcome to my-app!', + ); }); }); diff --git a/examples/angular2/src/app/app.component.ts b/examples/angular2/src/app/app.component.ts index 2fbc3e4f7..5fd4783e1 100644 --- a/examples/angular2/src/app/app.component.ts +++ b/examples/angular2/src/app/app.component.ts @@ -5,10 +5,13 @@ import * as Rollbar from 'rollbar'; @Component({ selector: 'app-root', templateUrl: './app.component.html', - styleUrls: ['./app.component.css'] + styleUrls: ['./app.component.css'], }) export class AppComponent { - constructor(@Inject(RollbarService) private rollbar: Rollbar, private ngZone: NgZone) { + constructor( + @Inject(RollbarService) private rollbar: Rollbar, + private ngZone: NgZone, + ) { // Used by rollbar.js tests window['angularAppComponent'] = this; } diff --git a/examples/angular2/src/app/app.module.ts b/examples/angular2/src/app/app.module.ts index 9b6427d67..dec95454c 100644 --- a/examples/angular2/src/app/app.module.ts +++ b/examples/angular2/src/app/app.module.ts @@ -5,19 +5,13 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { RollbarService, rollbarFactory, RollbarErrorHandler } from './rollbar'; - @NgModule({ - declarations: [ - AppComponent - ], - imports: [ - BrowserModule, - AppRoutingModule - ], + declarations: [AppComponent], + imports: [BrowserModule, AppRoutingModule], providers: [ { provide: ErrorHandler, useClass: RollbarErrorHandler }, - { provide: RollbarService, useFactory: rollbarFactory } + { provide: RollbarService, useFactory: rollbarFactory }, ], - bootstrap: [AppComponent] + bootstrap: [AppComponent], }) export class AppModule {} diff --git a/examples/angular2/src/app/rollbar.ts b/examples/angular2/src/app/rollbar.ts index 38e2f2a1d..9cabd196d 100644 --- a/examples/angular2/src/app/rollbar.ts +++ b/examples/angular2/src/app/rollbar.ts @@ -3,10 +3,10 @@ import { Injectable, Inject, InjectionToken, - ErrorHandler + ErrorHandler, } from '@angular/core'; -const rollbarConfig:Rollbar.Configuration = { +const rollbarConfig: Rollbar.Configuration = { accessToken: 'POST_CLIENT_ITEM_TOKEN', captureUncaught: true, captureUnhandledRejections: true, @@ -16,7 +16,7 @@ const rollbarConfig:Rollbar.Configuration = { wrapGlobalEventHandlers: false, scrubRequestBody: true, exitOnUncaughtException: false, - stackTraceLimit: 20 + stackTraceLimit: 20, }; export const RollbarService = new InjectionToken('rollbar'); @@ -25,7 +25,7 @@ export const RollbarService = new InjectionToken('rollbar'); export class RollbarErrorHandler implements ErrorHandler { constructor(@Inject(RollbarService) private rollbar: Rollbar) {} - handleError(err:any) : void { + handleError(err: any): void { this.rollbar.error(err.originalError || err); } } diff --git a/examples/angular2/src/environments/environment.prod.ts b/examples/angular2/src/environments/environment.prod.ts index 3612073bc..c9669790b 100644 --- a/examples/angular2/src/environments/environment.prod.ts +++ b/examples/angular2/src/environments/environment.prod.ts @@ -1,3 +1,3 @@ export const environment = { - production: true + production: true, }; diff --git a/examples/angular2/src/environments/environment.ts b/examples/angular2/src/environments/environment.ts index 7b4f817ad..99c3763ca 100644 --- a/examples/angular2/src/environments/environment.ts +++ b/examples/angular2/src/environments/environment.ts @@ -3,7 +3,7 @@ // The list of file replacements can be found in `angular.json`. export const environment = { - production: false + production: false, }; /* diff --git a/examples/angular2/src/index.html b/examples/angular2/src/index.html index 0450fa57c..06a1b03e7 100644 --- a/examples/angular2/src/index.html +++ b/examples/angular2/src/index.html @@ -1,14 +1,14 @@ - - - MyApp - + + + MyApp + - - - - - - + + + + + + diff --git a/examples/angular2/src/karma.conf.js b/examples/angular2/src/karma.conf.js index 5934e22d1..c5f0bfc23 100644 --- a/examples/angular2/src/karma.conf.js +++ b/examples/angular2/src/karma.conf.js @@ -10,15 +10,15 @@ module.exports = function (config) { require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'), - require('@angular-devkit/build-angular/plugins/karma') + require('@angular-devkit/build-angular/plugins/karma'), ], client: { - clearContext: false // leave Jasmine Spec Runner output visible in browser + clearContext: false, // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { dir: require('path').join(__dirname, '../coverage/my-app'), reports: ['html', 'lcovonly', 'text-summary'], - fixWebpackSourcePaths: true + fixWebpackSourcePaths: true, }, reporters: ['progress', 'kjhtml'], port: 9876, @@ -27,6 +27,6 @@ module.exports = function (config) { autoWatch: true, browsers: ['Chrome'], singleRun: false, - restartOnFileChange: true + restartOnFileChange: true, }); }; diff --git a/examples/angular2/src/main.ts b/examples/angular2/src/main.ts index c7b673cf4..d9a2e7e4a 100644 --- a/examples/angular2/src/main.ts +++ b/examples/angular2/src/main.ts @@ -8,5 +8,6 @@ if (environment.production) { enableProdMode(); } -platformBrowserDynamic().bootstrapModule(AppModule) - .catch(err => console.error(err)); +platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch((err) => console.error(err)); diff --git a/examples/angular2/src/polyfills.ts b/examples/angular2/src/polyfills.ts index 75d639398..d15a1152a 100644 --- a/examples/angular2/src/polyfills.ts +++ b/examples/angular2/src/polyfills.ts @@ -55,8 +55,7 @@ /*************************************************************************************************** * Zone JS is required by default for Angular itself. */ -import 'zone.js/dist/zone'; // Included with Angular CLI. - +import 'zone.js/dist/zone'; // Included with Angular CLI. /*************************************************************************************************** * APPLICATION IMPORTS diff --git a/examples/angular2/src/test.ts b/examples/angular2/src/test.ts index 16317897b..b6d614daa 100644 --- a/examples/angular2/src/test.ts +++ b/examples/angular2/src/test.ts @@ -4,7 +4,7 @@ import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; import { BrowserDynamicTestingModule, - platformBrowserDynamicTesting + platformBrowserDynamicTesting, } from '@angular/platform-browser-dynamic/testing'; declare const require: any; @@ -12,7 +12,7 @@ declare const require: any; // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( BrowserDynamicTestingModule, - platformBrowserDynamicTesting() + platformBrowserDynamicTesting(), ); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); diff --git a/examples/angular2/src/tsconfig.app.json b/examples/angular2/src/tsconfig.app.json index 190fd300b..fb7c566bc 100644 --- a/examples/angular2/src/tsconfig.app.json +++ b/examples/angular2/src/tsconfig.app.json @@ -4,8 +4,5 @@ "outDir": "../out-tsc/app", "types": [] }, - "exclude": [ - "test.ts", - "**/*.spec.ts" - ] + "exclude": ["test.ts", "**/*.spec.ts"] } diff --git a/examples/angular2/src/tsconfig.spec.json b/examples/angular2/src/tsconfig.spec.json index de7733630..70add2d52 100644 --- a/examples/angular2/src/tsconfig.spec.json +++ b/examples/angular2/src/tsconfig.spec.json @@ -2,17 +2,8 @@ "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/spec", - "types": [ - "jasmine", - "node" - ] + "types": ["jasmine", "node"] }, - "files": [ - "test.ts", - "polyfills.ts" - ], - "include": [ - "**/*.spec.ts", - "**/*.d.ts" - ] + "files": ["test.ts", "polyfills.ts"], + "include": ["**/*.spec.ts", "**/*.d.ts"] } diff --git a/examples/angular2/src/tslint.json b/examples/angular2/src/tslint.json index aa7c3eeb7..ca6ba8c9e 100644 --- a/examples/angular2/src/tslint.json +++ b/examples/angular2/src/tslint.json @@ -1,17 +1,7 @@ { "extends": "../tslint.json", "rules": { - "directive-selector": [ - true, - "attribute", - "app", - "camelCase" - ], - "component-selector": [ - true, - "element", - "app", - "kebab-case" - ] + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"] } } diff --git a/examples/angular2/tsconfig.json b/examples/angular2/tsconfig.json index 951c1748c..08df71159 100644 --- a/examples/angular2/tsconfig.json +++ b/examples/angular2/tsconfig.json @@ -12,12 +12,7 @@ "importHelpers": true, "strictNullChecks": true, "target": "es5", - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2018", - "dom" - ] + "typeRoots": ["node_modules/@types"], + "lib": ["es2018", "dom"] } } diff --git a/examples/angular2/tslint.json b/examples/angular2/tslint.json index 868ecba0d..5aadf5b50 100644 --- a/examples/angular2/tslint.json +++ b/examples/angular2/tslint.json @@ -1,24 +1,16 @@ { "extends": "tslint:recommended", - "rulesDirectory": [ - "codelyzer" - ], + "rulesDirectory": ["codelyzer"], "rules": { "array-type": false, "arrow-parens": false, "deprecation": { "severity": "warn" }, - "import-blacklist": [ - true, - "rxjs/Rx" - ], + "import-blacklist": [true, "rxjs/Rx"], "interface-name": false, "max-classes-per-file": false, - "max-line-length": [ - true, - 140 - ], + "max-line-length": [true, 140], "member-access": false, "member-ordering": [ true, @@ -32,34 +24,18 @@ } ], "no-consecutive-blank-lines": false, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], + "no-console": [true, "debug", "info", "time", "timeEnd", "trace"], "no-empty": false, - "no-inferrable-types": [ - true, - "ignore-params" - ], + "no-inferrable-types": [true, "ignore-params"], "no-non-null-assertion": true, "no-redundant-jsdoc": true, "no-switch-case-fall-through": true, "no-use-before-declare": true, "no-var-requires": false, - "object-literal-key-quotes": [ - true, - "as-needed" - ], + "object-literal-key-quotes": [true, "as-needed"], "object-literal-sort-keys": false, "ordered-imports": false, - "quotemark": [ - true, - "single" - ], + "quotemark": [true, "single"], "trailing-comma": false, "no-output-on-prefix": true, "use-input-property-decorator": true, diff --git a/examples/bower/README.md b/examples/bower/README.md index d4ad721f0..e50a59beb 100644 --- a/examples/bower/README.md +++ b/examples/bower/README.md @@ -1,33 +1,38 @@ # Using Rollbar with [Bower](http://bower.io/) - Install rollbar.js + ``` bower install rollbar --save ``` + - Add the `_rollbarConfig` configuration to the `` of your page. + ```html ``` + - Include the Rollbar snippet just below `_rollbarConfig`. + ```html diff --git a/examples/bower/index.html b/examples/bower/index.html index efa96fd43..259ddd053 100644 --- a/examples/bower/index.html +++ b/examples/bower/index.html @@ -2,24 +2,24 @@ diff --git a/examples/browser_extension_v2/README.md b/examples/browser_extension_v2/README.md index 85029aa29..dea1da339 100644 --- a/examples/browser_extension_v2/README.md +++ b/examples/browser_extension_v2/README.md @@ -5,9 +5,9 @@ and in the content script of a Chrome/Chromium or Firefox manifest v2 extension. To load and run this demo: -* Add your Rolllbar client token (config.js for client script, background.js for background script.) -* Enable developer mode for extensions in Chrome -* Click 'Load unpacked extension', and select this folder to load. +- Add your Rolllbar client token (config.js for client script, background.js for background script.) +- Enable developer mode for extensions in Chrome +- Click 'Load unpacked extension', and select this folder to load. The background script outputs to a separate console accessed from the extensions panel in Chrome. @@ -18,16 +18,19 @@ Firefox has slightly different manifest.json requirements. This example is writt so that the same manifest.json can be used across all browsers. ### content_security_policy + According to the browser extension spec, it should be OK to only set `default-src`. This won't work for Firefox, which requires setting both `script-src` and `object-src`. This example uses the Firefox compatible content security policy, since it also works fine on Chrome and Edge. ### background.persistent + Firefox emits a warning when the `background.persistent` key is set false. This example sets the key true, as this setting works across all browsers. ### Rollbar configuration + There are some limitations on Firefox in the content script. The background script is not affected by these limitations. diff --git a/examples/browser_extension_v2/background.js b/examples/browser_extension_v2/background.js index ebbfae367..a546f5ac5 100644 --- a/examples/browser_extension_v2/background.js +++ b/examples/browser_extension_v2/background.js @@ -7,7 +7,7 @@ console.log('Background extension is running.'); var _rollbarConfig = { accessToken: 'ROLLBAR_CLIENT_TOKEN', captureUncaught: true, - captureUnhandledRejections: true + captureUnhandledRejections: true, }; // Rollbar Snippet diff --git a/examples/browser_extension_v2/config.js b/examples/browser_extension_v2/config.js index 2aff73d83..b3015639b 100644 --- a/examples/browser_extension_v2/config.js +++ b/examples/browser_extension_v2/config.js @@ -1,11 +1,10 @@ - window._rollbarConfig = { accessToken: 'ROLLBAR_CLIENT_TOKEN', captureUncaught: false, // Only required for Firefox, other browser targets - // may set true. See README. + // may set true. See README. captureUnhandledRejections: true, autoInstrument: { - network: false // Only required for Firefox, other browser targets - // may set true. See README. - } + network: false, // Only required for Firefox, other browser targets + // may set true. See README. + }, }; diff --git a/examples/browser_extension_v2/manifest.json b/examples/browser_extension_v2/manifest.json index f4fb79e7c..de56b81fb 100644 --- a/examples/browser_extension_v2/manifest.json +++ b/examples/browser_extension_v2/manifest.json @@ -5,13 +5,13 @@ "permissions": ["storage", "activeTab", "https://api.rollbar.com/"], "content_security_policy": "script-src 'self' https://cdn.rollbar.com; object-src 'self' https://cdn.rollbar.com;", "background": { - "scripts": ["background.js"], - "persistent": true + "scripts": ["background.js"], + "persistent": true }, - "content_scripts": [ - { - "matches": ["*://*/*"], - "js": ["config.js", "rollbar.min.js", "content_script.js"] - } - ] + "content_scripts": [ + { + "matches": ["*://*/*"], + "js": ["config.js", "rollbar.min.js", "content_script.js"] + } + ] } diff --git a/examples/browser_extension_v3/README.md b/examples/browser_extension_v3/README.md index 732ad9250..4b135f5d7 100644 --- a/examples/browser_extension_v3/README.md +++ b/examples/browser_extension_v3/README.md @@ -5,9 +5,9 @@ and in the content script of a Chrome/Chromium manifest v3 extension. To load and run this demo: -* Add your Rolllbar client token (config.js for client script, service-worker.js for background script.) -* Enable developer mode for extensions in Chrome -* Click 'Load unpacked extension', and select this folder to load. +- Add your Rolllbar client token (config.js for client script, service-worker.js for background script.) +- Enable developer mode for extensions in Chrome +- Click 'Load unpacked extension', and select this folder to load. The background script outputs to a separate console accessed from the extensions panel in Chrome. diff --git a/examples/browser_extension_v3/config.js b/examples/browser_extension_v3/config.js index ab86240b1..8577ba900 100644 --- a/examples/browser_extension_v3/config.js +++ b/examples/browser_extension_v3/config.js @@ -1,6 +1,5 @@ - window._rollbarConfig = { accessToken: 'ROLLBAR_CLIENT_TOKEN', captureUncaught: true, - captureUnhandledRejections: true + captureUnhandledRejections: true, }; diff --git a/examples/browser_extension_v3/service-worker.js b/examples/browser_extension_v3/service-worker.js index 361b50b7d..b7352ff9f 100644 --- a/examples/browser_extension_v3/service-worker.js +++ b/examples/browser_extension_v3/service-worker.js @@ -3,7 +3,7 @@ console.log('Background extension is running.'); const _rollbarConfig = { accessToken: 'ROLLBAR_CLIENT_TOKEN', captureUncaught: true, - captureUnhandledRejections: true + captureUnhandledRejections: true, }; // When using es6 module @@ -17,12 +17,12 @@ rollbar.init(_rollbarConfig); // log a generic message and send to rollbar rollbar.info('Service worker message'); -self.addEventListener("install", (event) => { +self.addEventListener('install', (event) => { console.log('Chrome ext service worker install event', event); rollbar.info('Chrome ext service worker install event'); }); -self.addEventListener("activate", (event) => { +self.addEventListener('activate', (event) => { console.log('Chrome ext service worker activate event', event); rollbar.info('Chrome ext service worker activate event'); }); diff --git a/examples/browserify/README.md b/examples/browserify/README.md index a2a15e1eb..d3e1a0616 100644 --- a/examples/browserify/README.md +++ b/examples/browserify/README.md @@ -11,7 +11,7 @@ var rollbarConfig = { captureUncaught: true, payload: { environment: 'development', - } + }, }; var Rollbar = rollbar.init(rollbarConfig); window.Rollbar = Rollbar; @@ -29,9 +29,10 @@ try { ``` ## To build and test the example + 1. Edit index.js and add your Rollbar `POST_CLIENT_ITEM_ACCESS_TOKEN` - Sign up for a free account [here](https://rollbar.com/signup/) -2. ```browserify index.js > all.js``` +2. `browserify index.js > all.js` 3. Open test.html in your browser and click the button 4. Go to your project dashboard and see the error diff --git a/examples/browserify/index.js b/examples/browserify/index.js index 20e61c917..24afbd396 100644 --- a/examples/browserify/index.js +++ b/examples/browserify/index.js @@ -5,7 +5,7 @@ var rollbarConfig = { captureUncaught: true, payload: { environment: 'development', - } + }, }; var Rollbar = rollbar.init(rollbarConfig); diff --git a/examples/csp-errors.html b/examples/csp-errors.html index df17e531f..9c239cc60 100644 --- a/examples/csp-errors.html +++ b/examples/csp-errors.html @@ -1,10 +1,9 @@ - - - Generate CSP error for test automation - - - - + + + Generate CSP error for test automation + + + diff --git a/examples/error.html b/examples/error.html index 9202d68c6..4f7d9c324 100644 --- a/examples/error.html +++ b/examples/error.html @@ -1,49 +1,61 @@ - - - Generate errors for test automation - - - - -
-

- Generate errors for test automation -

-
- - - - + // set hash location + window.location.hash = 'test'; + }; + + + +
+

Generate errors for test automation

+
+ + + + + diff --git a/examples/extension-exceptions/test.html b/examples/extension-exceptions/test.html index ded6fa72c..155b4e727 100644 --- a/examples/extension-exceptions/test.html +++ b/examples/extension-exceptions/test.html @@ -1,53 +1,64 @@ - - - - -
- - - - - + + + + +
+ + + + + diff --git a/examples/functions.js b/examples/functions.js index 9dbba52ab..12a0788f5 100644 --- a/examples/functions.js +++ b/examples/functions.js @@ -3,7 +3,7 @@ function functionA() { try { var a = b; - } catch(e) { + } catch (e) { Rollbar.error(e); } diff --git a/examples/include_custom_object.html b/examples/include_custom_object.html index 1982723b0..6cd05d133 100644 --- a/examples/include_custom_object.html +++ b/examples/include_custom_object.html @@ -2,15 +2,15 @@ - -

- -

- See results: rollbar/rollbar.js#420 - + +

+ +

+ See results: + rollbar/rollbar.js#420 diff --git a/examples/itemsPerMinute.html b/examples/itemsPerMinute.html index a13184e6c..2974f848d 100644 --- a/examples/itemsPerMinute.html +++ b/examples/itemsPerMinute.html @@ -2,13 +2,13 @@ diff --git a/examples/no-conflict/README.md b/examples/no-conflict/README.md index a97c0e3bf..ecc66de1e 100644 --- a/examples/no-conflict/README.md +++ b/examples/no-conflict/README.md @@ -1,5 +1,5 @@ -* npm install -* npm start +- npm install +- npm start This only uses a server to get around CORS for loading the rollbar library from a local file via the snippet. diff --git a/examples/no-conflict/server.js b/examples/no-conflict/server.js index 9b342d384..982a0c7ed 100644 --- a/examples/no-conflict/server.js +++ b/examples/no-conflict/server.js @@ -27,5 +27,9 @@ app.listen(port, '0.0.0.0', function onStart(err) { if (err) { console.log(err); } - console.info('==> 🌎 Listening on port %s. Open up http://0.0.0.0:%s/ in your browser.', port, port); + console.info( + '==> 🌎 Listening on port %s. Open up http://0.0.0.0:%s/ in your browser.', + port, + port, + ); }); diff --git a/examples/no-conflict/test.html b/examples/no-conflict/test.html index 1f904e546..2dc6d71e9 100644 --- a/examples/no-conflict/test.html +++ b/examples/no-conflict/test.html @@ -1,15 +1,13 @@ @@ -39,7 +37,7 @@ !function(r){var e={};function o(n){if(e[n])return e[n].exports;var t=e[n]={i:n,l:!1,exports:{}};return r[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=r,o.c=e,o.d=function(r,e,n){o.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},o.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(r,e){if(1&e&&(r=o(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var t in r)o.d(n,t,function(e){return r[e]}.bind(null,t));return n},o.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(e,"a",e),e},o.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},o.p="",o(o.s=0)}([function(r,e,o){"use strict";var n=o(1),t=o(5);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdn.rollbar.com/rollbarjs/refs/tags/v2.26.3/rollbar.min.js",_rollbarConfig.async=void 0===_rollbarConfig.async||_rollbarConfig.async;var a=n.setupShim(window,_rollbarConfig),l=t(_rollbarConfig);window.rollbar=n.Rollbar,a.loadFull(window,document,!_rollbarConfig.async,_rollbarConfig,l)},function(r,e,o){"use strict";var n=o(2),t=o(3);function a(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}var l=0;function i(r,e){this.options=r,this._rollbarOldOnError=null;var o=l++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}var s=o(4),d=function(r,e){return new i(r,e)},c=function(r){return new s(d,r)};function u(r){return a((function(){var e=this,o=Array.prototype.slice.call(arguments,0),n={shim:e,method:r,args:o,ts:new Date};window._rollbarShims[this.shimId()].messages.push(n)}))}i.prototype.loadFull=function(r,e,o,n,t){var l=!1,i=e.createElement("script"),s=e.getElementsByTagName("script")[0],d=s.parentNode;i.crossOrigin="",i.src=n.rollbarJsUrl,o||(i.async=!0),i.onload=i.onreadystatechange=a((function(){if(!(l||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)){i.onload=i.onreadystatechange=null;try{d.removeChild(i)}catch(r){}l=!0,function(){var e;if(void 0===r._rollbarDidLoad){e=new Error("rollbar.js did not load");for(var o,n,a,l,i=0;o=r._rollbarShims[i++];)for(o=o.messages||[];n=o.shift();)for(a=n.args||[],i=0;i - + diff --git a/examples/no-conflict/tool.js b/examples/no-conflict/tool.js index 9ec6ebbc7..f1a706550 100644 --- a/examples/no-conflict/tool.js +++ b/examples/no-conflict/tool.js @@ -4,9 +4,9 @@ var Rollbar = require('rollbar/dist/rollbar.noconflict.umd'); const rollbar = new Rollbar({ accessToken: 'POST_CLIENT_ITEM_TOKEN', captureUncaught: true, - captureUnhandledRejections: true -}) + captureUnhandledRejections: true, +}); module.exports = function tool(x) { - rollbar.log('foobar got data', {x}) -} + rollbar.log('foobar got data', { x }); +}; diff --git a/examples/no-conflict/webpack.config.js b/examples/no-conflict/webpack.config.js index b365dcc93..217ed0611 100644 --- a/examples/no-conflict/webpack.config.js +++ b/examples/no-conflict/webpack.config.js @@ -3,31 +3,35 @@ const path = require('path'); const webpack = require('webpack'); -module.exports = [{ - name: 'frontend', - devtool: 'eval-source-map', - entry: path.join(__dirname, '/tool.js'), - output: { - path: path.join(__dirname, '/dist/'), - filename: 'tool.js', - libraryTarget: 'umd', - library: 'tool' +module.exports = [ + { + name: 'frontend', + devtool: 'eval-source-map', + entry: path.join(__dirname, '/tool.js'), + output: { + path: path.join(__dirname, '/dist/'), + filename: 'tool.js', + libraryTarget: 'umd', + library: 'tool', + }, + plugins: [ + new webpack.optimize.OccurrenceOrderPlugin(), + new webpack.NoErrorsPlugin(), + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('development'), + }), + ], + module: { + loaders: [ + { + test: /\.jsx?$/, + exclude: /node_modules/, + loader: 'babel', + query: { + presets: ['es2015', 'stage-0'], + }, + }, + ], + }, }, - plugins: [ - new webpack.optimize.OccurrenceOrderPlugin(), - new webpack.NoErrorsPlugin(), - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify('development') - }) - ], - module: { - loaders: [{ - test: /\.jsx?$/, - exclude: /node_modules/, - loader: 'babel', - query: { - "presets": ["es2015", "stage-0"] - } - }] - } -}]; +]; diff --git a/examples/node-typescript/dist/index.js b/examples/node-typescript/dist/index.js index f8159757b..f4acb4515 100644 --- a/examples/node-typescript/dist/index.js +++ b/examples/node-typescript/dist/index.js @@ -10,4 +10,4 @@ module.exports = function error() { var error = new CustomError('foo'); throw error; }; -//# sourceMappingURL=index.js.map \ No newline at end of file +//# sourceMappingURL=index.js.map diff --git a/examples/node-typescript/dist/index.js.map b/examples/node-typescript/dist/index.js.map index 2a9f2c2a9..1eaa2b459 100644 --- a/examples/node-typescript/dist/index.js.map +++ b/examples/node-typescript/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iBAAS,SAAS,KAAK;IAErB,MAAM,WAAY,SAAQ,KAAK;QAC7B,YAAY,OAAe;YACzB,KAAK,CAAC,UAAU,OAAO,gBAAgB,CAAC,CAAC;YACzC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC5B,CAAC;KACF;IACD,iDAAiD;IACjD,IAAI,KAAK,GAAW,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,KAAK,CAAC;AACd,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iBAAS,SAAS,KAAK;IAErB,MAAM,WAAY,SAAQ,KAAK;QAC7B,YAAY,OAAe;YACzB,KAAK,CAAC,UAAU,OAAO,gBAAgB,CAAC,CAAC;YACzC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC5B,CAAC;KACF;IACD,iDAAiD;IACjD,IAAI,KAAK,GAAW,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,KAAK,CAAC;AACd,CAAC,CAAA"} diff --git a/examples/node-typescript/tsconfig.json b/examples/node-typescript/tsconfig.json index 9eba31973..c8a924fce 100644 --- a/examples/node-typescript/tsconfig.json +++ b/examples/node-typescript/tsconfig.json @@ -5,10 +5,6 @@ "outDir": "dist", "sourceMap": true }, - "include": [ - "src/**/*.ts" - ], - "exclude": [ - "node_modules" - ] + "include": ["src/**/*.ts"], + "exclude": ["node_modules"] } diff --git a/examples/react/src/TestError.js b/examples/react/src/TestError.js index a1b1a9186..dea3f3b3d 100644 --- a/examples/react/src/TestError.js +++ b/examples/react/src/TestError.js @@ -23,7 +23,9 @@ class TestError extends React.Component { return (

Rollbar Example for React Child Component

- +
); } diff --git a/examples/react/src/index.html b/examples/react/src/index.html index e31c48889..dd446a8f9 100644 --- a/examples/react/src/index.html +++ b/examples/react/src/index.html @@ -1,12 +1,12 @@ - + - - - - - React Example - - -
- + + + + + React Example + + +
+ diff --git a/examples/react/src/index.js b/examples/react/src/index.js index 2654adc92..ed0f23707 100644 --- a/examples/react/src/index.js +++ b/examples/react/src/index.js @@ -1,6 +1,6 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import Rollbar from "rollbar"; +import React from 'react'; +import ReactDOM from 'react-dom'; +import Rollbar from 'rollbar'; import ErrorBoundary from './ErrorBoundary'; import TestError from './TestError'; @@ -14,7 +14,7 @@ class App extends React.Component { accessToken: 'POST_CLIENT_ITEM_TOKEN', captureUncaught: true, captureUnhandledRejections: true, - }) + }), }; this.logInfo = this.logInfo.bind(this); @@ -34,15 +34,19 @@ class App extends React.Component { render() { return ( -

Rollbar Example for React

- - - - +

Rollbar Example for React

+ + + +
); } } -ReactDOM.render(, document.getElementById("index")); +ReactDOM.render(, document.getElementById('index')); diff --git a/examples/react/webpack.config.js b/examples/react/webpack.config.js index caa6a091a..74db617d6 100644 --- a/examples/react/webpack.config.js +++ b/examples/react/webpack.config.js @@ -1,15 +1,15 @@ -const HtmlWebPackPlugin = require("html-webpack-plugin"); +const HtmlWebPackPlugin = require('html-webpack-plugin'); const htmlPlugin = new HtmlWebPackPlugin({ - template: "./src/index.html", - filename: "./index.html" + template: './src/index.html', + filename: './index.html', }); module.exports = (_env, argv) => ({ output: { // rollbar.js tests require modified asset path. // Detect whether running JIT or building the webpack bundle. - publicPath: (argv.build ? '/examples/react/dist/' : '') + publicPath: argv.build ? '/examples/react/dist/' : '', }, module: { rules: [ @@ -17,10 +17,10 @@ module.exports = (_env, argv) => ({ test: /\.js$/, exclude: /node_modules/, use: { - loader: "babel-loader" - } - } - ] + loader: 'babel-loader', + }, + }, + ], }, - plugins: [htmlPlugin] + plugins: [htmlPlugin], }); diff --git a/examples/requirejs/README.md b/examples/requirejs/README.md index 736fcdc4d..faa6e598f 100644 --- a/examples/requirejs/README.md +++ b/examples/requirejs/README.md @@ -2,35 +2,34 @@ 1. Require and initialize the Rollbar javascript module: - ```js - - // - // Download the latest rollbar.umd.nojson.min.js and place in current directory. - var rollbarConfig = { - accessToken: '...', - captureUncaught: true, - payload: { - environment: 'development', - } - }; - - // Require the Rollbar library - require(["rollbar.umd.nojson.min.js"], function(Rollbar) { - var rollbar = Rollbar.init(rollbarConfig); - rollbar.info('Hello world'); - }); - ``` +```js +// +// Download the latest rollbar.umd.nojson.min.js and place in current directory. +var rollbarConfig = { + accessToken: '...', + captureUncaught: true, + payload: { + environment: 'development', + }, +}; + +// Require the Rollbar library +require(['rollbar.umd.nojson.min.js'], function (Rollbar) { + var rollbar = Rollbar.init(rollbarConfig); + rollbar.info('Hello world'); +}); +``` 2. Report exceptions and messages in your code: - ```js - try { - foo(); - rollbar.debug('foo() called'); - } catch (e) { - rollbar.error('Problem calling foo()', e); - } - ``` +```js +try { + foo(); + rollbar.debug('foo() called'); +} catch (e) { + rollbar.error('Problem calling foo()', e); +} +``` ## Test the example diff --git a/examples/requirejs/test.html b/examples/requirejs/test.html index b749cd5fc..9b8eed9e8 100644 --- a/examples/requirejs/test.html +++ b/examples/requirejs/test.html @@ -9,7 +9,7 @@ captureUncaught: true, payload: { environment: 'development', - } + }, }; // You can either use the snippet or load asynchronously via requirejs @@ -18,21 +18,20 @@ // NOTE: you must use the name "rollbar" here. require.config({ paths: { - rollbar: '../../dist/rollbar.umd' - } + rollbar: '../../dist/rollbar.umd', + }, }); - require(['rollbar'], - // Note: clicking on the "Foo" button below before the Rollbar - // module is loaded and initialized will not Report the - // exception to Rollbar. - function(Rollbar) { + require([ + 'rollbar', + ], // Note: clicking on the "Foo" button below before the Rollbar + // module is loaded and initialized will not Report the + // exception to Rollbar. + function (Rollbar) { + var rollbar = new Rollbar(_rollbarConfig); - var rollbar = new Rollbar(_rollbarConfig); - - rollbar.info('Hello world'); - } - ); + rollbar.info('Hello world'); + }); diff --git a/examples/script.html b/examples/script.html index 4cec3f6eb..d7fafeb8b 100644 --- a/examples/script.html +++ b/examples/script.html @@ -3,11 +3,11 @@ diff --git a/examples/snippet.html b/examples/snippet.html index 5b351f930..af045ffc6 100644 --- a/examples/snippet.html +++ b/examples/snippet.html @@ -3,12 +3,12 @@ - + diff --git a/examples/test.html b/examples/test.html index d7fc037cd..7a6e8e3d7 100644 --- a/examples/test.html +++ b/examples/test.html @@ -1,15 +1,13 @@ @@ -38,7 +36,7 @@ !function(r){var e={};function o(n){if(e[n])return e[n].exports;var t=e[n]={i:n,l:!1,exports:{}};return r[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.m=r,o.c=e,o.d=function(r,e,n){o.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},o.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},o.t=function(r,e){if(1&e&&(r=o(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var t in r)o.d(n,t,function(e){return r[e]}.bind(null,t));return n},o.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return o.d(e,"a",e),e},o.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},o.p="",o(o.s=0)}([function(r,e,o){"use strict";var n=o(1),t=o(5);_rollbarConfig=_rollbarConfig||{},_rollbarConfig.rollbarJsUrl=_rollbarConfig.rollbarJsUrl||"https://cdn.rollbar.com/rollbarjs/refs/tags/v2.26.3/rollbar.min.js",_rollbarConfig.async=void 0===_rollbarConfig.async||_rollbarConfig.async;var a=n.setupShim(window,_rollbarConfig),l=t(_rollbarConfig);window.rollbar=n.Rollbar,a.loadFull(window,document,!_rollbarConfig.async,_rollbarConfig,l)},function(r,e,o){"use strict";var n=o(2),t=o(3);function a(r){return function(){try{return r.apply(this,arguments)}catch(r){try{console.error("[Rollbar]: Internal error",r)}catch(r){}}}}var l=0;function i(r,e){this.options=r,this._rollbarOldOnError=null;var o=l++;this.shimId=function(){return o},"undefined"!=typeof window&&window._rollbarShims&&(window._rollbarShims[o]={handler:e,messages:[]})}var s=o(4),d=function(r,e){return new i(r,e)},c=function(r){return new s(d,r)};function u(r){return a((function(){var e=this,o=Array.prototype.slice.call(arguments,0),n={shim:e,method:r,args:o,ts:new Date};window._rollbarShims[this.shimId()].messages.push(n)}))}i.prototype.loadFull=function(r,e,o,n,t){var l=!1,i=e.createElement("script"),s=e.getElementsByTagName("script")[0],d=s.parentNode;i.crossOrigin="",i.src=n.rollbarJsUrl,o||(i.async=!0),i.onload=i.onreadystatechange=a((function(){if(!(l||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState)){i.onload=i.onreadystatechange=null;try{d.removeChild(i)}catch(r){}l=!0,function(){var e;if(void 0===r._rollbarDidLoad){e=new Error("rollbar.js did not load");for(var o,n,a,l,i=0;o=r._rollbarShims[i++];)for(o=o.messages||[];n=o.shift();)for(a=n.args||[],i=0;i - + diff --git a/examples/universal-browser/README.md b/examples/universal-browser/README.md index a97c0e3bf..ecc66de1e 100644 --- a/examples/universal-browser/README.md +++ b/examples/universal-browser/README.md @@ -1,5 +1,5 @@ -* npm install -* npm start +- npm install +- npm start This only uses a server to get around CORS for loading the rollbar library from a local file via the snippet. diff --git a/examples/universal-browser/server.js b/examples/universal-browser/server.js index 3b38cf72e..8c2815b63 100644 --- a/examples/universal-browser/server.js +++ b/examples/universal-browser/server.js @@ -10,9 +10,9 @@ const app = express(); app.use(express.static(path.join(__dirname))); app.get('/rollbar.js', function response(req, res) { var t = (req.query.t || 0.01) * 100; - console.log("Waiting: ", t, "ms"); - setTimeout(function() { - res.sendFile(path.join(__dirname, '../../dist/rollbar.umd.js')) + console.log('Waiting: ', t, 'ms'); + setTimeout(function () { + res.sendFile(path.join(__dirname, '../../dist/rollbar.umd.js')); }, t); }); @@ -21,12 +21,16 @@ app.get('/test', function response(req, res) { }); app.get('/sample', function response(req, res) { - res.status(200).json({'hello': 'world'}); + res.status(200).json({ hello: 'world' }); }); app.listen(port, '0.0.0.0', function onStart(err) { if (err) { console.log(err); } - console.info('==> 🌎 Listening on port %s. Open up http://0.0.0.0:%s/ in your browser.', port, port); + console.info( + '==> 🌎 Listening on port %s. Open up http://0.0.0.0:%s/ in your browser.', + port, + port, + ); }); diff --git a/examples/universal-browser/test-with-non-default-options.html b/examples/universal-browser/test-with-non-default-options.html index 73f7fb9a5..fdeab5541 100644 --- a/examples/universal-browser/test-with-non-default-options.html +++ b/examples/universal-browser/test-with-non-default-options.html @@ -2,15 +2,15 @@ -

Test snippet with non-default options.

diff --git a/examples/universal-browser/test.html b/examples/universal-browser/test.html index 3b6ff5257..b6721693f 100644 --- a/examples/universal-browser/test.html +++ b/examples/universal-browser/test.html @@ -1,15 +1,13 @@ @@ -42,10 +40,10 @@ function callServer() { var xhr = new XMLHttpRequest(); xhr.open('GET', '/sample', true); - xhr.onload = function() { + xhr.onload = function () { console.log('Got: ', xhr.response); }; - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if (this.readyState === 4) { console.log('Done!'); } @@ -53,7 +51,7 @@ xhr.send(null); } - +
@@ -62,7 +60,12 @@
- +