rollbar 2.26.3 → 3.0.0-alpha.1
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.
- package/.cursor/rules/guidelines.mdc +154 -0
- package/.github/workflows/ci.yml +32 -12
- package/.lgtm.yml +7 -7
- package/.prettierignore +18 -0
- package/.vscode/settings.json +39 -0
- package/CHANGELOG.md +121 -35
- package/CLAUDE.md +201 -0
- package/Gruntfile.js +101 -48
- package/Makefile +3 -3
- package/README.md +2 -4
- package/SECURITY.md +5 -0
- package/babel.config.json +9 -0
- package/bower.json +1 -3
- package/codex.md +148 -0
- package/defaults.js +17 -5
- package/dist/plugins/jquery.min.js +1 -1
- package/dist/rollbar.js +18748 -5375
- package/dist/rollbar.js.map +1 -1
- package/dist/rollbar.min.js +2 -1
- package/dist/rollbar.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.min.js.map +1 -1
- package/dist/rollbar.named-amd.js +19368 -6000
- package/dist/rollbar.named-amd.js.map +1 -1
- package/dist/rollbar.named-amd.min.js +3 -1
- package/dist/rollbar.named-amd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.named-amd.min.js.map +1 -1
- package/dist/rollbar.noconflict.umd.js +18749 -5380
- package/dist/rollbar.noconflict.umd.js.map +1 -1
- package/dist/rollbar.noconflict.umd.min.js +3 -1
- package/dist/rollbar.noconflict.umd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.noconflict.umd.min.js.map +1 -1
- package/dist/rollbar.snippet.js +1 -1
- package/dist/rollbar.umd.js +19367 -6000
- package/dist/rollbar.umd.js.map +1 -1
- package/dist/rollbar.umd.min.js +3 -1
- package/dist/rollbar.umd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.umd.min.js.map +1 -1
- package/docs/extension-exceptions.md +35 -30
- package/docs/migration_v0_to_v1.md +41 -38
- package/eslint.config.mjs +33 -0
- package/get_versions.js +33 -0
- package/index.d.ts +270 -231
- package/karma.conf.js +18 -27
- package/package.json +21 -21
- package/prettier.config.js +7 -0
- package/src/api.js +78 -14
- package/src/apiUtility.js +14 -11
- package/src/browser/core.js +138 -72
- package/src/browser/defaults/scrubFields.js +3 -3
- package/src/browser/detection.js +7 -8
- package/src/browser/domUtility.js +18 -8
- package/src/browser/globalSetup.js +12 -6
- package/src/browser/logger.js +1 -1
- package/src/browser/plugins/jquery.js +35 -35
- package/src/browser/predicates.js +1 -1
- package/src/browser/replay/defaults.js +71 -0
- package/src/browser/replay/recorder.js +193 -0
- package/src/browser/replay/replayMap.js +195 -0
- package/src/browser/rollbar.js +12 -8
- package/src/browser/rollbarWrapper.js +8 -5
- package/src/browser/shim.js +43 -19
- package/src/browser/snippet_callback.js +6 -4
- package/src/browser/telemetry.js +573 -361
- package/src/browser/transforms.js +46 -27
- package/src/browser/transport/fetch.js +26 -14
- package/src/browser/transport/xhr.js +41 -14
- package/src/browser/transport.js +93 -33
- package/src/browser/url.js +16 -8
- package/src/browser/wrapGlobals.js +27 -8
- package/src/defaults.js +3 -3
- package/src/errorParser.js +14 -11
- package/src/merge.js +32 -23
- package/src/notifier.js +16 -13
- package/src/predicates.js +43 -23
- package/src/queue.js +133 -40
- package/src/rateLimiter.js +59 -18
- package/src/react-native/logger.js +1 -1
- package/src/react-native/rollbar.js +59 -55
- package/src/react-native/transforms.js +13 -9
- package/src/react-native/transport.js +44 -34
- package/src/rollbar.js +72 -21
- package/src/scrub.js +0 -1
- package/src/server/locals.js +69 -39
- package/src/server/logger.js +4 -4
- package/src/server/parser.js +72 -47
- package/src/server/rollbar.js +135 -56
- package/src/server/sourceMap/stackTrace.js +33 -18
- package/src/server/telemetry/urlHelpers.js +9 -11
- package/src/server/telemetry.js +68 -45
- package/src/server/transforms.js +37 -21
- package/src/server/transport.js +62 -32
- package/src/telemetry.js +162 -33
- package/src/tracing/context.js +24 -0
- package/src/tracing/contextManager.js +37 -0
- package/src/tracing/defaults.js +7 -0
- package/src/tracing/exporter.js +188 -0
- package/src/tracing/hrtime.js +98 -0
- package/src/tracing/id.js +24 -0
- package/src/tracing/session.js +55 -0
- package/src/tracing/span.js +92 -0
- package/src/tracing/spanProcessor.js +15 -0
- package/src/tracing/tracer.js +46 -0
- package/src/tracing/tracing.js +89 -0
- package/src/transforms.js +33 -21
- package/src/truncation.js +8 -5
- package/src/utility/headers.js +43 -43
- package/src/utility/replace.js +9 -0
- package/src/utility/traverse.js +1 -1
- package/src/utility.js +123 -52
- package/test/api.test.js +88 -41
- package/test/apiUtility.test.js +48 -50
- package/test/browser.core.test.js +142 -141
- package/test/browser.domUtility.test.js +53 -36
- package/test/browser.predicates.test.js +14 -14
- package/test/browser.replay.recorder.test.js +416 -0
- package/test/browser.rollbar.test.js +655 -515
- package/test/browser.telemetry.test.js +46 -39
- package/test/browser.transforms.test.js +164 -139
- package/test/browser.transport.test.js +59 -50
- package/test/browser.url.test.js +13 -12
- package/test/fixtures/locals.fixtures.js +245 -126
- package/test/fixtures/replay/index.js +20 -0
- package/test/fixtures/replay/payloads.fixtures.js +229 -0
- package/test/fixtures/replay/rrwebEvents.fixtures.js +251 -0
- package/test/fixtures/replay/rrwebSyntheticEvents.fixtures.js +328 -0
- package/test/notifier.test.js +91 -79
- package/test/predicates.test.js +261 -215
- package/test/queue.test.js +231 -215
- package/test/rateLimiter.test.js +51 -43
- package/test/react-native.rollbar.test.js +150 -116
- package/test/react-native.transforms.test.js +23 -25
- package/test/react-native.transport.test.js +26 -14
- package/test/replay/index.js +2 -0
- package/test/replay/integration/api.spans.test.js +136 -0
- package/test/replay/integration/e2e.test.js +228 -0
- package/test/replay/integration/index.js +9 -0
- package/test/replay/integration/queue.replayMap.test.js +332 -0
- package/test/replay/integration/replayMap.test.js +163 -0
- package/test/replay/integration/sessionRecording.test.js +390 -0
- package/test/replay/unit/api.postSpans.test.js +150 -0
- package/test/replay/unit/index.js +7 -0
- package/test/replay/unit/queue.replayMap.test.js +225 -0
- package/test/replay/unit/replayMap.test.js +348 -0
- package/test/replay/util/index.js +5 -0
- package/test/replay/util/mockRecordFn.js +80 -0
- package/test/server.lambda.mocha.test.mjs +172 -0
- package/test/server.locals.constructor.mocha.test.mjs +80 -0
- package/test/server.locals.error-handling.mocha.test.mjs +387 -0
- package/test/server.locals.merge.mocha.test.mjs +267 -0
- package/test/server.locals.test-utils.mjs +114 -0
- package/test/server.parser.mocha.test.mjs +87 -0
- package/test/server.predicates.mocha.test.mjs +63 -0
- package/test/server.rollbar.constructor.mocha.test.mjs +199 -0
- package/test/server.rollbar.handlers.mocha.test.mjs +253 -0
- package/test/server.rollbar.logging.mocha.test.mjs +326 -0
- package/test/server.rollbar.misc.mocha.test.mjs +44 -0
- package/test/server.rollbar.test-utils.mjs +57 -0
- package/test/server.telemetry.mocha.test.mjs +377 -0
- package/test/server.transforms.data.mocha.test.mjs +163 -0
- package/test/server.transforms.error.mocha.test.mjs +199 -0
- package/test/server.transforms.request.mocha.test.mjs +208 -0
- package/test/server.transforms.scrub.mocha.test.mjs +140 -0
- package/test/server.transforms.sourcemaps.mocha.test.mjs +122 -0
- package/test/server.transforms.test-utils.mjs +62 -0
- package/test/server.transport.mocha.test.mjs +269 -0
- package/test/telemetry.test.js +178 -38
- package/test/tracing/contextManager.test.js +28 -0
- package/test/tracing/exporter.toPayload.test.js +400 -0
- package/test/tracing/id.test.js +24 -0
- package/test/tracing/span.test.js +183 -0
- package/test/tracing/spanProcessor.test.js +73 -0
- package/test/tracing/tracing.test.js +105 -0
- package/test/transforms.test.js +70 -68
- package/test/truncation.test.js +57 -55
- package/test/utility.test.js +310 -228
- package/webpack.config.js +36 -70
- package/.eslintignore +0 -7
- package/.gitmodules +0 -3
- package/test/server.lambda.test.js +0 -177
- package/test/server.locals.test.js +0 -841
- package/test/server.parser.test.js +0 -72
- package/test/server.predicates.test.js +0 -89
- package/test/server.rollbar.test.js +0 -676
- package/test/server.telemetry.test.js +0 -318
- package/test/server.transforms.test.js +0 -1099
- package/test/server.transport.test.js +0 -201
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
## About Rollbar.js
|
|
2
|
+
|
|
3
|
+
Rollbar.js is the official JavaScript SDK for the Rollbar error monitoring service. This library is not standalone - it works in tandem with the Rollbar platform to help developers detect, diagnose, and fix errors in real-time. The SDK sends error data to Rollbar's cloud service where errors are processed, grouped, and notifications are triggered.
|
|
4
|
+
|
|
5
|
+
The library works across platforms, supporting both browser and server-side JavaScript including frameworks like React, Angular, Express, and Next.js. Key features include:
|
|
6
|
+
|
|
7
|
+
- Cross-platform error tracking for client and server-side code
|
|
8
|
+
- Telemetry to provide context around errors (breadcrumbs of events)
|
|
9
|
+
- Automatic error grouping to reduce noise
|
|
10
|
+
- Real-time notifications for critical issues
|
|
11
|
+
- Detailed stack traces with source maps support
|
|
12
|
+
- Distributed tracing and session management
|
|
13
|
+
- Session replay capabilities for reproducing user actions
|
|
14
|
+
|
|
15
|
+
## Project Structure
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
src/
|
|
19
|
+
├── browser/ # Browser-specific implementation
|
|
20
|
+
├── server/ # Node.js-specific implementation
|
|
21
|
+
├── react-native/ # React Native implementation
|
|
22
|
+
├── tracing/ # Distributed tracing support
|
|
23
|
+
└── utility/ # Shared utility functions
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Build & Test Commands
|
|
27
|
+
|
|
28
|
+
- Build: `npm run build` (runs Grunt)
|
|
29
|
+
- Lint: `npm run lint` (ESLint)
|
|
30
|
+
- Test all: `npm run test` (runs both server and browser tests)
|
|
31
|
+
- Test browser only: `npm run test-browser`
|
|
32
|
+
- Test server only: `npm run test-server`
|
|
33
|
+
- Test specific browser test: `grunt test-browser:specificTestName`
|
|
34
|
+
- Example: `grunt test-browser:transforms`
|
|
35
|
+
- Single test: `./node_modules/.bin/karma start --single-run --files={path/to/test}`
|
|
36
|
+
|
|
37
|
+
## Modern Development Environment
|
|
38
|
+
|
|
39
|
+
As of version 3.0.0, the SDK has been updated to use modern JavaScript features with appropriate transpilation:
|
|
40
|
+
|
|
41
|
+
- **ES Modules**: The codebase supports ES modules (`import/export`) syntax
|
|
42
|
+
- **Target Compatibility**:
|
|
43
|
+
- Source code uses ECMAScript 2021 features
|
|
44
|
+
- Builds target ES5 for broad browser compatibility
|
|
45
|
+
- Lower versions can use the ES5/CommonJS compatible bundles
|
|
46
|
+
- **Build System**:
|
|
47
|
+
- Webpack 5 with Babel for transpilation
|
|
48
|
+
- ESLint for code quality
|
|
49
|
+
- Configurable output formats (UMD, AMD, vanilla)
|
|
50
|
+
- **Minimum Node.js**: Version 18+ for absolute imports
|
|
51
|
+
- **Toolchain Configuration**:
|
|
52
|
+
- `babel.config.json`: Controls transpilation options
|
|
53
|
+
- `eslint.config.mjs`: Modern ESLint flat config format
|
|
54
|
+
- `webpack.config.js`: Manages bundling and output formats
|
|
55
|
+
|
|
56
|
+
## Code Style Guidelines
|
|
57
|
+
|
|
58
|
+
- Use single quotes for strings
|
|
59
|
+
- Use camelCase for variables (underscore prefix for private)
|
|
60
|
+
- Indentation: 2 spaces
|
|
61
|
+
- Include trailing commas in multiline objects/arrays
|
|
62
|
+
- Max function complexity: 35
|
|
63
|
+
- Unused parameters prefixed with underscore: `function(a, _unused) {}`
|
|
64
|
+
- No whitespace in empty lines
|
|
65
|
+
- Files should end with exactly one newline
|
|
66
|
+
- Control statements (if, for, while, etc.) MUST use braces and newlines, even for single statements
|
|
67
|
+
- Opening braces should be on the same line as the control statement
|
|
68
|
+
- ESLint is used for enforcing code style
|
|
69
|
+
- Prettier for code formatting
|
|
70
|
+
|
|
71
|
+
### Documentation vs. Comments
|
|
72
|
+
|
|
73
|
+
- **Function Documentation (JSDoc/TSDoc)**: Always include comprehensive documentation for functions, classes, and methods using JSDoc/TSDoc format (`/** ... */`). These serve as API documentation, appear in IDE tooltips, and help developers understand purpose, parameters, and return values.
|
|
74
|
+
|
|
75
|
+
- **Inline Code Comments**: Avoid redundant comments that merely restate what the code is doing. Only add comments to explain:
|
|
76
|
+
- Why the code works a certain way (decisions and reasoning)
|
|
77
|
+
- Non-obvious behavior or edge cases
|
|
78
|
+
- Complex algorithms or business logic
|
|
79
|
+
- Workarounds for bugs or limitations
|
|
80
|
+
|
|
81
|
+
- **Self-documenting Code**: Write clear, readable code that explains itself through descriptive variable/function names and straightforward logic. Well-written code rarely needs explanatory comments.
|
|
82
|
+
|
|
83
|
+
- **Examples**:
|
|
84
|
+
```javascript
|
|
85
|
+
// BAD - Redundant comment
|
|
86
|
+
// Add one to x
|
|
87
|
+
x += 1;
|
|
88
|
+
|
|
89
|
+
// GOOD - Explains the non-obvious "why"
|
|
90
|
+
// Increment before sending to API to account for zero-indexing
|
|
91
|
+
x += 1;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## SDK Design Principles
|
|
95
|
+
|
|
96
|
+
- **User Problems Are SDK Improvement Opportunities**: When users encounter integration issues, treat these as SDK design improvements rather than user implementation mistakes.
|
|
97
|
+
- Focus on enhancing the SDK to be more robust, intuitive and resilient
|
|
98
|
+
- Implement automatic environment detection and appropriate behavior selection
|
|
99
|
+
- Design APIs that work correctly across all supported contexts without requiring special user handling
|
|
100
|
+
- Errors should be informative and suggest correct usage patterns
|
|
101
|
+
- The burden of complexity should rest with the SDK, not its users
|
|
102
|
+
|
|
103
|
+
## Error Handling
|
|
104
|
+
|
|
105
|
+
- Prefer try/catch blocks around risky operations
|
|
106
|
+
- Log errors through Rollbar's own logger system
|
|
107
|
+
- Scrub sensitive fields in error payloads (see package.json defaults)
|
|
108
|
+
- The codebase uses a comprehensive error tracking approach with appropriate levels:
|
|
109
|
+
- Debug level for development info
|
|
110
|
+
- Warning level for non-critical issues
|
|
111
|
+
- Error level for uncaught exceptions
|
|
112
|
+
|
|
113
|
+
## TypeScript Support
|
|
114
|
+
|
|
115
|
+
- Type definitions in index.d.ts
|
|
116
|
+
- Add JSDoc types to enable intellisense when needed
|
|
117
|
+
|
|
118
|
+
## Common Patterns
|
|
119
|
+
|
|
120
|
+
When working with this codebase, be aware of these patterns:
|
|
121
|
+
|
|
122
|
+
- Error transformation and normalization before sending
|
|
123
|
+
- Telemetry collection for context
|
|
124
|
+
- Queue-based sending with retry logic
|
|
125
|
+
- Environment and context detection
|
|
126
|
+
- Scrubbing of sensitive data
|
|
127
|
+
|
|
128
|
+
## Testing Philosophy
|
|
129
|
+
|
|
130
|
+
- **Analyze Test Failures Objectively**: When tests fail, evaluate both possibilities objectively:
|
|
131
|
+
|
|
132
|
+
- The test could be correctly identifying an actual code issue
|
|
133
|
+
- The test itself might contain errors or invalid expectations
|
|
134
|
+
|
|
135
|
+
- **Diagnostic Process**:
|
|
136
|
+
|
|
137
|
+
1. Examine what the test is expecting vs. what the code actually does
|
|
138
|
+
2. Consider the intended behavior and design of the system
|
|
139
|
+
3. If the test is correct and identifying a legitimate bug, fix the code
|
|
140
|
+
4. If the test contains misconceptions or errors, fix the test
|
|
141
|
+
|
|
142
|
+
- **Default to Code Quality**: When in doubt and both seem potentially valid, prioritize improving code quality over modifying tests to pass
|
|
143
|
+
|
|
144
|
+
## Tracing & Session Replay
|
|
145
|
+
|
|
146
|
+
The `src/tracing/` directory contains an OpenTelemetry-inspired tracing implementation that powers both distributed tracing and session recording features:
|
|
147
|
+
|
|
148
|
+
### Components
|
|
149
|
+
|
|
150
|
+
- **Context & ContextManager**: Manages propagation of tracing context through the application
|
|
151
|
+
- **Span**: Represents a unit of work or operation with timing information and attributes
|
|
152
|
+
- **Tracer**: Creates and manages spans for tracking operations
|
|
153
|
+
- **SpanProcessor & SpanExporter**: Processes and exports spans to their destination
|
|
154
|
+
- **Session**: Manages browser session data persistence and creation
|
|
155
|
+
|
|
156
|
+
### Usage Patterns
|
|
157
|
+
|
|
158
|
+
- **Tracing initialization**: Initialize via the main Tracing class with appropriate configuration
|
|
159
|
+
- **Context propagation**: Use context to pass trace information between components
|
|
160
|
+
- **Span creation**: Create spans to measure operations with `startSpan()`
|
|
161
|
+
- **Attributes and events**: Add metadata to spans with `setAttribute()` and `addEvent()`
|
|
162
|
+
- **Session management**: Automatically manages user sessions via browser sessionStorage
|
|
163
|
+
|
|
164
|
+
### Session Replay Implementation
|
|
165
|
+
|
|
166
|
+
The `src/browser/replay` directory contains the implementation of the Session Replay feature:
|
|
167
|
+
|
|
168
|
+
- **Recorder**: Core class that integrates with rrweb to record DOM events
|
|
169
|
+
- **ReplayMap**: Manages the mapping between error occurrences and session recordings
|
|
170
|
+
- **Configuration**: Configurable options in `defaults.js` for replay behavior
|
|
171
|
+
|
|
172
|
+
The Session Replay feature utilizes our tracing infrastructure to:
|
|
173
|
+
|
|
174
|
+
- Record user interactions using rrweb in a memory-efficient way
|
|
175
|
+
- Store recordings with checkpoints for better performance
|
|
176
|
+
- Generate spans that contain replay events with proper timing
|
|
177
|
+
- Associate recordings with user sessions for complete context
|
|
178
|
+
- Transport recordings to Rollbar servers via the API
|
|
179
|
+
|
|
180
|
+
### Session Replay Flow
|
|
181
|
+
|
|
182
|
+
1. **Recording**: The Recorder class continuously records DOM events using rrweb
|
|
183
|
+
2. **Error Occurrence**: When an error occurs, Queue.addItem() calls ReplayMap.add()
|
|
184
|
+
3. **Correlation**: ReplayMap generates a replayId and attaches it to the error
|
|
185
|
+
4. **Coordination**: After successful error submission, Queue triggers ReplayMap.send()
|
|
186
|
+
5. **Transport**: ReplayMap retrieves stored replay data and sends via api.postSpans()
|
|
187
|
+
|
|
188
|
+
### Testing Infrastructure
|
|
189
|
+
|
|
190
|
+
- **Unit Tests**: Component-focused tests in `test/replay/unit/`
|
|
191
|
+
- **Integration Tests**: Test component interactions in `test/replay/integration/`
|
|
192
|
+
- **End-to-End Tests**: Full flow verification in `test/replay/integration/e2e.test.js`
|
|
193
|
+
- **Mock Implementation**: `test/replay/util/mockRecordFn.js` provides a deterministic mock of rrweb
|
|
194
|
+
- **Fixtures**: Realistic rrweb events in `test/fixtures/replay/` for testing
|
|
195
|
+
- **Test Tasks**: Custom Grunt tasks for testing replay code specifically
|
|
196
|
+
|
|
197
|
+
## File Creation Guidelines
|
|
198
|
+
|
|
199
|
+
- **Newlines**: All new files MUST end with exactly one newline character
|
|
200
|
+
- **Encoding**: Use UTF-8 encoding for all text files
|
|
201
|
+
- **Line Endings**: Use LF (Unix-style) line endings, not CRLF
|
package/Gruntfile.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Build and test rollbar.js
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
'use strict';
|
|
7
6
|
|
|
8
7
|
var glob = require('glob');
|
|
@@ -12,7 +11,6 @@ var fs = require('fs');
|
|
|
12
11
|
|
|
13
12
|
var webpackConfig = require('./webpack.config.js');
|
|
14
13
|
|
|
15
|
-
|
|
16
14
|
function findTests(context) {
|
|
17
15
|
if (context !== 'browser') {
|
|
18
16
|
return {};
|
|
@@ -20,7 +18,7 @@ function findTests(context) {
|
|
|
20
18
|
var files = glob.sync('test/**/!(server.)*.test.js');
|
|
21
19
|
var mapping = {};
|
|
22
20
|
|
|
23
|
-
files.forEach(function(file) {
|
|
21
|
+
files.forEach(function (file) {
|
|
24
22
|
var testName = path.basename(file, '.test.js');
|
|
25
23
|
mapping[testName] = file;
|
|
26
24
|
});
|
|
@@ -39,19 +37,19 @@ function buildGruntKarmaConfig(singleRun, tests, reporters) {
|
|
|
39
37
|
pattern: 'dist/**/*.js',
|
|
40
38
|
included: false,
|
|
41
39
|
served: true,
|
|
42
|
-
watched: false
|
|
40
|
+
watched: false,
|
|
43
41
|
},
|
|
44
42
|
{
|
|
45
43
|
pattern: 'src/**/*.js',
|
|
46
44
|
included: false,
|
|
47
45
|
served: true,
|
|
48
|
-
watched: false
|
|
46
|
+
watched: false,
|
|
49
47
|
},
|
|
50
48
|
{
|
|
51
49
|
pattern: 'examples/**/*.js',
|
|
52
50
|
included: false,
|
|
53
51
|
served: true,
|
|
54
|
-
watched: false
|
|
52
|
+
watched: false,
|
|
55
53
|
},
|
|
56
54
|
|
|
57
55
|
// Examples HTML, set `included: true`, but they won't be executed or added
|
|
@@ -60,9 +58,9 @@ function buildGruntKarmaConfig(singleRun, tests, reporters) {
|
|
|
60
58
|
pattern: 'examples/**/*.html',
|
|
61
59
|
included: true,
|
|
62
60
|
served: true,
|
|
63
|
-
watched: false
|
|
64
|
-
}
|
|
65
|
-
]
|
|
61
|
+
watched: false,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
66
64
|
},
|
|
67
65
|
};
|
|
68
66
|
|
|
@@ -72,20 +70,18 @@ function buildGruntKarmaConfig(singleRun, tests, reporters) {
|
|
|
72
70
|
|
|
73
71
|
for (var testName in tests) {
|
|
74
72
|
var testFile = tests[testName];
|
|
75
|
-
var testConfig = config[testName] = {};
|
|
73
|
+
var testConfig = (config[testName] = {});
|
|
76
74
|
|
|
77
75
|
// Special case for testing requirejs integration.
|
|
78
76
|
// Include the requirejs module as a framework so
|
|
79
77
|
// Karma will inclue it in the web page.
|
|
80
78
|
if (testName === 'requirejs') {
|
|
81
|
-
testConfig.files = [
|
|
82
|
-
{src: './dist/rollbar.umd.js', included: false}
|
|
83
|
-
];
|
|
79
|
+
testConfig.files = [{ src: './dist/rollbar.umd.js', included: false }];
|
|
84
80
|
// NOTE: requirejs should go first in case the subsequent libraries
|
|
85
81
|
// check for the existence of `define()`
|
|
86
82
|
testConfig.frameworks = ['requirejs', 'expect', 'mocha'];
|
|
87
83
|
} else {
|
|
88
|
-
testConfig.files = [{src: [testFile]}];
|
|
84
|
+
testConfig.files = [{ src: [testFile] }];
|
|
89
85
|
}
|
|
90
86
|
|
|
91
87
|
// Special config for BrowserStack IE tests
|
|
@@ -98,8 +94,7 @@ function buildGruntKarmaConfig(singleRun, tests, reporters) {
|
|
|
98
94
|
return config;
|
|
99
95
|
}
|
|
100
96
|
|
|
101
|
-
|
|
102
|
-
module.exports = function(grunt) {
|
|
97
|
+
module.exports = function (grunt) {
|
|
103
98
|
require('time-grunt')(grunt);
|
|
104
99
|
|
|
105
100
|
var browserTests = findTests('browser');
|
|
@@ -117,8 +112,6 @@ module.exports = function(grunt) {
|
|
|
117
112
|
grunt.loadNpmTasks('grunt-karma');
|
|
118
113
|
grunt.loadNpmTasks('grunt-webpack');
|
|
119
114
|
grunt.loadNpmTasks('grunt-text-replace');
|
|
120
|
-
grunt.loadNpmTasks('grunt-vows');
|
|
121
|
-
|
|
122
115
|
|
|
123
116
|
var rollbarJsSnippet = fs.readFileSync('dist/rollbar.snippet.js');
|
|
124
117
|
var rollbarjQuerySnippet = fs.readFileSync('dist/plugins/jquery.min.js');
|
|
@@ -126,67 +119,127 @@ module.exports = function(grunt) {
|
|
|
126
119
|
grunt.initConfig({
|
|
127
120
|
pkg: pkg,
|
|
128
121
|
webpack: webpackConfig,
|
|
129
|
-
vows: {
|
|
130
|
-
all: {
|
|
131
|
-
options: {
|
|
132
|
-
reporter: 'spec'
|
|
133
|
-
},
|
|
134
|
-
src: ['test/server.*.test.js']
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
122
|
|
|
138
123
|
karma: buildGruntKarmaConfig(singleRun, browserTests, reporters),
|
|
139
124
|
|
|
140
125
|
replace: {
|
|
141
126
|
snippets: {
|
|
142
|
-
src: [
|
|
127
|
+
src: [
|
|
128
|
+
'*.md',
|
|
129
|
+
'src/**/*.js',
|
|
130
|
+
'examples/*.+(html|js)',
|
|
131
|
+
'examples/*/*.+(html|js)',
|
|
132
|
+
'docs/**/*.md',
|
|
133
|
+
],
|
|
143
134
|
overwrite: true,
|
|
144
135
|
replacements: [
|
|
145
136
|
// Main rollbar snippet
|
|
146
137
|
{
|
|
147
|
-
from: new RegExp(
|
|
148
|
-
|
|
138
|
+
from: new RegExp(
|
|
139
|
+
'^(.*// Rollbar Snippet)[\n\r]+(.*[\n\r])*(.*// End Rollbar Snippet)',
|
|
140
|
+
'm',
|
|
141
|
+
),
|
|
142
|
+
to: function (match, index, fullText, captures) {
|
|
149
143
|
captures[1] = rollbarJsSnippet;
|
|
150
144
|
return captures.join('\n');
|
|
151
|
-
}
|
|
145
|
+
},
|
|
152
146
|
},
|
|
153
147
|
// jQuery rollbar plugin snippet
|
|
154
148
|
{
|
|
155
|
-
from: new RegExp(
|
|
156
|
-
|
|
149
|
+
from: new RegExp(
|
|
150
|
+
'^(.*// Rollbar jQuery Snippet)[\n\r]+(.*[\n\r])*(.*// End Rollbar jQuery Snippet)',
|
|
151
|
+
'm',
|
|
152
|
+
),
|
|
153
|
+
to: function (match, index, fullText, captures) {
|
|
157
154
|
captures[1] = rollbarjQuerySnippet;
|
|
158
155
|
return captures.join('\n');
|
|
159
|
-
}
|
|
156
|
+
},
|
|
160
157
|
},
|
|
161
158
|
// README CI link
|
|
162
159
|
{
|
|
163
|
-
from: new RegExp(
|
|
164
|
-
|
|
160
|
+
from: new RegExp(
|
|
161
|
+
'(https://github\\.com/rollbar/rollbar\\.js/workflows/Rollbar\\.js%20CI/badge\\.svg\\?branch=v)([0-9a-zA-Z.-]+)',
|
|
162
|
+
),
|
|
163
|
+
to: function (match, index, fullText, captures) {
|
|
165
164
|
captures[1] = pkg.version;
|
|
166
165
|
return captures.join('');
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
}
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
172
171
|
});
|
|
173
172
|
|
|
174
173
|
grunt.registerTask('build', ['webpack', 'replace:snippets']);
|
|
175
174
|
grunt.registerTask('default', ['build']);
|
|
176
|
-
grunt.registerTask('test', [
|
|
175
|
+
grunt.registerTask('test', [
|
|
176
|
+
'test-browser',
|
|
177
|
+
]);
|
|
177
178
|
grunt.registerTask('release', ['build', 'copyrelease']);
|
|
178
179
|
|
|
179
|
-
grunt.registerTask('test-server', function(_target) {
|
|
180
|
-
var tasks = ['vows'];
|
|
181
|
-
grunt.task.run.apply(grunt.task, tasks);
|
|
182
|
-
});
|
|
183
180
|
|
|
184
|
-
grunt.registerTask('test-browser', function(target) {
|
|
181
|
+
grunt.registerTask('test-browser', function (target) {
|
|
185
182
|
var karmaTask = 'karma' + (target ? ':' + target : '');
|
|
186
183
|
var tasks = [karmaTask];
|
|
187
184
|
grunt.task.run.apply(grunt.task, tasks);
|
|
188
185
|
});
|
|
189
186
|
|
|
187
|
+
function findReplayTests() {
|
|
188
|
+
return Object.keys(browserTests).filter(function (testName) {
|
|
189
|
+
var testPath = browserTests[testName];
|
|
190
|
+
return (
|
|
191
|
+
testPath.includes('test/replay/') ||
|
|
192
|
+
testPath.includes('test/tracing/') ||
|
|
193
|
+
testPath.match(/test\/browser\.replay\..*\.test\.js/)
|
|
194
|
+
);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
grunt.registerTask('test-replay', function () {
|
|
199
|
+
var replayTests = findReplayTests();
|
|
200
|
+
|
|
201
|
+
grunt.log.writeln('Running all replay-related tests:');
|
|
202
|
+
replayTests.forEach(function (testName) {
|
|
203
|
+
grunt.log.writeln('- ' + testName + ' (' + browserTests[testName] + ')');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
replayTests.forEach(function (testName) {
|
|
207
|
+
grunt.task.run('karma:' + testName);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
grunt.registerTask('test-replay-unit', function () {
|
|
212
|
+
var unitTests = findReplayTests().filter(function (testName) {
|
|
213
|
+
var testPath = browserTests[testName];
|
|
214
|
+
return testPath.includes('/replay/unit/');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
grunt.log.writeln('Running replay unit tests:');
|
|
218
|
+
unitTests.forEach(function (testName) {
|
|
219
|
+
grunt.log.writeln('- ' + testName + ' (' + browserTests[testName] + ')');
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
unitTests.forEach(function (testName) {
|
|
223
|
+
grunt.task.run('karma:' + testName);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
grunt.registerTask('test-replay-integration', function () {
|
|
228
|
+
var integrationTests = findReplayTests().filter(function (testName) {
|
|
229
|
+
var testPath = browserTests[testName];
|
|
230
|
+
return testPath.includes('/replay/integration/');
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
grunt.log.writeln('Running replay integration tests:');
|
|
234
|
+
integrationTests.forEach(function (testName) {
|
|
235
|
+
grunt.log.writeln('- ' + testName + ' (' + browserTests[testName] + ')');
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
integrationTests.forEach(function (testName) {
|
|
239
|
+
grunt.task.run('karma:' + testName);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
190
243
|
grunt.registerTask('copyrelease', function createRelease() {
|
|
191
244
|
var version = pkg.version;
|
|
192
245
|
var builds = ['', '.umd'];
|
|
@@ -196,11 +249,11 @@ module.exports = function(grunt) {
|
|
|
196
249
|
var minJs = 'dist/rollbar' + buildName + '.min.js';
|
|
197
250
|
|
|
198
251
|
var releaseJs = 'release/rollbar' + buildName + '-' + version + '.js';
|
|
199
|
-
var releaseMinJs =
|
|
252
|
+
var releaseMinJs =
|
|
253
|
+
'release/rollbar' + buildName + '-' + version + '.min.js';
|
|
200
254
|
|
|
201
255
|
grunt.file.copy(js, releaseJs);
|
|
202
256
|
grunt.file.copy(minJs, releaseMinJs);
|
|
203
257
|
});
|
|
204
258
|
});
|
|
205
|
-
|
|
206
259
|
};
|
package/Makefile
CHANGED
package/README.md
CHANGED
|
@@ -12,21 +12,20 @@
|
|
|
12
12
|
[](https://lgtm.com/projects/g/rollbar/rollbar.js/context:javascript)
|
|
13
13
|
[](https://lgtm.com/projects/g/rollbar/rollbar.js/alerts)
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
---
|
|
17
16
|
|
|
18
17
|
## Key benefits of using Rollbar.js are:
|
|
18
|
+
|
|
19
19
|
- **Cross platform:** Rollbar.js supports both server-side and client-side Javascript, including frameworks such as <a href="https://docs.rollbar.com/docs/react-ts">React</a>, <a href="https://docs.rollbar.com/docs/angular">Angular</a>, <a href="https://docs.rollbar.com/docs/nodejs#using-express">Express</a>, <a href="https://docs.rollbar.com/docs/nextjs">Next.js</a> and more.
|
|
20
20
|
- **Telemetry:** The telemetry timeline provides a list of “breadcrumbs” events that can help developers understand and fix problems in their client-side javascript. <a href="https://docs.rollbar.com/docs/rollbarjs-telemetry">Learn more about telemetry</a>.
|
|
21
21
|
- **Automatic error grouping:** Rollbar aggregates Occurrences caused by the same error into Items that represent application issues. <a href="https://docs.rollbar.com/docs/grouping-occurrences">Learn more about reducing log noise</a>.
|
|
22
22
|
- **Advanced search:** Filter items by many different properties. <a href="https://docs.rollbar.com/docs/search-items">Learn more about search</a>.
|
|
23
23
|
- **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. <a href="https://docs.rollbar.com/docs/notifications">Learn more about Rollbar notifications</a>.
|
|
24
24
|
|
|
25
|
-
|
|
26
25
|
## Setup Instructions
|
|
27
26
|
|
|
28
27
|
1. [Sign up for a Rollbar account](https://rollbar.com/signup).
|
|
29
|
-
2. For client-side Javascript, follow the [Browser Quick Start](https://docs.rollbar.com/docs/javascript#section-quick-start-browser) instructions.
|
|
28
|
+
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).
|
|
30
29
|
|
|
31
30
|
## Usage and Reference
|
|
32
31
|
|
|
@@ -46,7 +45,6 @@ For bug reports, please [open an issue on GitHub](https://github.com/rollbar/rol
|
|
|
46
45
|
|
|
47
46
|
To set up a development environment, you'll need Node.js and npm.
|
|
48
47
|
|
|
49
|
-
1. `git submodule update --init`
|
|
50
48
|
2. `npm install -D`
|
|
51
49
|
3. `make`
|
|
52
50
|
|
package/SECURITY.md
ADDED