rollbar 3.0.0-alpha.3 → 3.0.0-alpha.4
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/.claude/settings.local.json +11 -0
- package/CLAUDE.examples.md +291 -0
- package/CLAUDE.examples.validate.md +97 -0
- package/CLAUDE.grunt.md +320 -0
- package/CLAUDE.local.md +301 -0
- package/CLAUDE.testrunner.md +470 -0
- package/CLAUDE.tooling.bugsnag.md +208 -0
- package/CLAUDE.tooling.datadog.md +397 -0
- package/CLAUDE.tooling.newrelic.md +345 -0
- package/CLAUDE.tooling.sentry.md +337 -0
- package/CONTRIBUTING.md +112 -0
- package/Gruntfile.cjs +7 -0
- package/README.md +48 -20
- package/bower.json +0 -1
- package/dist/rollbar.js +53 -824
- package/dist/rollbar.js.map +1 -1
- package/dist/rollbar.min.js +1 -1
- package/dist/rollbar.min.js.map +1 -1
- package/dist/rollbar.named-amd.js +53 -824
- package/dist/rollbar.named-amd.js.map +1 -1
- package/dist/rollbar.named-amd.min.js +1 -1
- package/dist/rollbar.named-amd.min.js.map +1 -1
- package/dist/rollbar.noconflict.umd.js +53 -824
- package/dist/rollbar.noconflict.umd.js.map +1 -1
- package/dist/rollbar.noconflict.umd.min.js +1 -1
- package/dist/rollbar.noconflict.umd.min.js.map +1 -1
- package/dist/rollbar.snippet.js +1 -1
- package/dist/rollbar.umd.js +53 -824
- package/dist/rollbar.umd.js.map +1 -1
- package/dist/rollbar.umd.min.js +1 -1
- package/dist/rollbar.umd.min.js.map +1 -1
- package/index.d.ts +0 -2
- package/karma.conf.cjs +5 -21
- package/package.json +17 -59
- package/src/browser/bundles/defaults.js +5 -0
- package/src/browser/bundles/rollbar.snippet.js +2 -2
- package/src/browser/core.js +8 -10
- package/src/browser/defaults.js +51 -0
- package/src/browser/plugins/jquery.js +1 -2
- package/src/browser/replay/defaults.js +1 -1
- package/src/browser/rollbar.js +0 -2
- package/src/defaults.js +66 -7
- package/src/react-native/defaults.js +26 -0
- package/src/react-native/rollbar.js +8 -10
- package/src/server/defaults.js +19 -0
- package/src/server/rollbar.cjs +5 -0
- package/src/server/rollbar.js +7 -10
- package/src/utility.js +2 -34
- package/test/api.test.js +0 -2
- package/test/apiUtility.test.js +7 -32
- package/test/browser.core.test.js +1 -1
- package/test/browser.rollbar.test.js +2 -2
- package/test/browser.transport.test.js +1 -6
- package/test/fixtures/html/csp-errors.html +9 -0
- package/test/fixtures/html/error.html +61 -0
- package/test/react-native.transport.test.js +1 -6
- package/test/truncation.test.js +6 -33
- package/test/utility.test.js +19 -245
- package/webpack.config.cjs +7 -17
- package/defaults.cjs +0 -29
- package/src/browser/defaults/scrubFields.js +0 -59
- package/src/utility/polyfillJSON.d.ts +0 -5
- package/src/utility/polyfillJSON.js +0 -3
- package/vendor/JSON-js/README +0 -40
- package/vendor/JSON-js/cycle.js +0 -181
- package/vendor/JSON-js/json2.js +0 -499
- package/vendor/JSON-js/json3.js +0 -763
- package/vendor/JSON-js/json_parse.js +0 -356
- package/vendor/JSON-js/json_parse_state.js +0 -405
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# Rollbar.js Integration Compatibility Matrix
|
|
2
|
+
|
|
3
|
+
## Current Project Status
|
|
4
|
+
|
|
5
|
+
**Objective**: Ensure ALL examples work with the ESM-migrated Rollbar.js library.
|
|
6
|
+
|
|
7
|
+
**Status**: ESM migration complete, DefinePlugin removed, examples fixed, tests passing with workarounds
|
|
8
|
+
|
|
9
|
+
**Testing Progress**:
|
|
10
|
+
- ✅ All Category 1 examples (Node.js/NPM) tested and working
|
|
11
|
+
- ✅ All Category 2 examples tested and working
|
|
12
|
+
- ✅ All Category 3 examples (HTML) tested and working
|
|
13
|
+
- ✅ 3/5 Category 4 examples tested (requirejs, bower, extension-exceptions)
|
|
14
|
+
- ⏸️ Browser extensions v2/v3 testing PAUSED - moving to next project phase
|
|
15
|
+
|
|
16
|
+
**Decision**: Examples validation is sufficient to confirm ESM migration success. Moving to Phase 2: Modern Testing & TypeScript Foundation (starting with Karma → Web Test Runner migration)
|
|
17
|
+
|
|
18
|
+
**Latest Updates**:
|
|
19
|
+
|
|
20
|
+
- ✅ All source code migrated from CommonJS to ES modules
|
|
21
|
+
- ✅ DefinePlugin strategy eliminated - replaced with proper default modules
|
|
22
|
+
- ✅ All Category 1 examples (with npm dependencies) now build successfully
|
|
23
|
+
- ✅ Test suite issues resolved (API endpoints, timing issues)
|
|
24
|
+
- ⚠️ Bundle size issue identified: local packages produce 3x larger bundles due to webpack including entire UMD
|
|
25
|
+
- 🔧 Workaround: Tests continue using pre-built dist files until yalc or similar solution implemented
|
|
26
|
+
- ✅ Moved test fixtures (error.html, csp-errors.html) from examples/ to test/fixtures/html/ following PR #1241 pattern
|
|
27
|
+
- ✅ Updated karma configuration to include test/fixtures path for HTML files
|
|
28
|
+
- ✅ All browser tests passing after fixture relocation
|
|
29
|
+
- ✅ Fixed references to non-existent `rollbar.umd.nojson.js` → now use `rollbar.umd.js`
|
|
30
|
+
- ✅ Fixed RequireJS example reference to non-existent `rollbar.umd.nojson.min.js` → now uses `rollbar.umd.min.js`
|
|
31
|
+
- ✅ Tested and confirmed working: all Category 3 HTML examples + requirejs + extension-exceptions
|
|
32
|
+
|
|
33
|
+
**Next Steps**:
|
|
34
|
+
|
|
35
|
+
- [x] Test Category 3 examples (script.html, snippet.html, test.html, itemsPerMinute.html, include_custom_object.html) ✅ All working
|
|
36
|
+
- [x] Fix test.html reference to non-existent rollbar.umd.nojson.js file → Changed to rollbar.umd.js ✅
|
|
37
|
+
- [x] Fix requirejs/test.html to use rollbar.named-amd.js instead of UMD ✅
|
|
38
|
+
- [x] Test requirejs example ✅ Working
|
|
39
|
+
- [x] Test extension-exceptions example ✅ Working
|
|
40
|
+
- [x] Test bower example ✅ Working (installed via `npx bower install`)
|
|
41
|
+
- [ ] Test remaining Category 4 examples (browser extensions v2/v3) - **PAUSED: Moving to Phase 2**
|
|
42
|
+
- [ ] Implement proper solution for local package testing (yalc)
|
|
43
|
+
- [ ] Create automated integration tests for all examples
|
|
44
|
+
|
|
45
|
+
## Import/Usage Methods vs Environments
|
|
46
|
+
|
|
47
|
+
| Environment/Framework | Script Tag<br>`<script>` | CommonJS<br>`require('rollbar')` | CommonJS Absolute<br>`require('rollbar/src/...')` | ESM<br>`import from 'rollbar'` | ESM Absolute<br>`import from 'rollbar/src/...'` | TypeScript<br>`import` | Dynamic Import<br>`import()` | AMD<br>`require([])` |
|
|
48
|
+
| --------------------- | --------------------------- | -------------------------------- | ------------------------------------------------- | ------------------------------ | ----------------------------------------------- | ---------------------- | ---------------------------- | ----------------------- |
|
|
49
|
+
| **Browser (Vanilla)** | ✅ rollbar.min.js<br>✅ CDN | ❌ | ❌ | ✅ bundler | ✅ browser/rollbar.js | ✅ bundler | ✅ rollbar.umd.js | ✅ rollbar.named-amd.js |
|
|
50
|
+
| **Node.js** | ❌ | ✅ main | ✅ server/rollbar.js | ✅ main | ✅ server/rollbar.js | ✅ | ✅ main | ❌ |
|
|
51
|
+
| **React** | ✅ | ✅ bundler | ✅ browser/rollbar.js | ✅ bundler | ✅ browser/rollbar.js | ✅ bundler | ✅ bundler | ⚠️ |
|
|
52
|
+
| **Vue.js** | ✅ | ✅ bundler | ✅ browser/rollbar.js | ✅ bundler | ✅ browser/rollbar.js | ✅ bundler | ✅ bundler | ⚠️ |
|
|
53
|
+
| **Angular** | ❌ | ❌ | ❌ | ✅ | ✅ browser/rollbar.js | ✅ | ✅ | ❌ |
|
|
54
|
+
| **Next.js (SSR)** | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
55
|
+
| **Webpack** | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
56
|
+
| **React Native** | ❌ | ✅ | ⚠️ | ✅ | ⚠️ | ✅ | ❌ | ❌ |
|
|
57
|
+
| **Electron** | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
58
|
+
| **Browser Extension** | ✅ | ❌ | ❌ | ✅ bundler | ✅ browser/rollbar.js | ✅ bundler | ✅ | ❌ |
|
|
59
|
+
| **Web Workers** | ✅ | ❌ | ❌ | ✅ | ✅ browser/rollbar.js | ✅ | ✅ | ❌ |
|
|
60
|
+
| **RequireJS** | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ rollbar.named-amd.js |
|
|
61
|
+
| **Browserify** | ❌ | ⚠️ | ⚠️ | ⚠️ | ⚠️ | ⚠️ | ❌ | ❌ |
|
|
62
|
+
| **Bower** | ⚠️ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ⚠️ |
|
|
63
|
+
|
|
64
|
+
## Legend
|
|
65
|
+
|
|
66
|
+
- ✅ Supported and tested
|
|
67
|
+
- ⚠️ Technically possible but unsupported/not recommended
|
|
68
|
+
- ❌ Not possible/applicable
|
|
69
|
+
|
|
70
|
+
## Absolute Import Patterns
|
|
71
|
+
|
|
72
|
+
### CommonJS Absolute Imports
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
// Browser-side (with bundler)
|
|
76
|
+
const Rollbar = require('rollbar/src/browser/rollbar');
|
|
77
|
+
|
|
78
|
+
// Server-side
|
|
79
|
+
const Rollbar = require('rollbar/src/server/rollbar');
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### ESM Absolute Imports
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
// Browser-side
|
|
86
|
+
import Rollbar from 'rollbar/src/browser/rollbar';
|
|
87
|
+
|
|
88
|
+
// Server-side
|
|
89
|
+
import Rollbar from 'rollbar/src/server/rollbar';
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Note**: The `.default` is no longer required for CommonJS imports. The package.json conditional exports now handle module format resolution automatically.
|
|
93
|
+
|
|
94
|
+
## Package Entry Points
|
|
95
|
+
|
|
96
|
+
### Conditional Exports (Primary)
|
|
97
|
+
|
|
98
|
+
The package uses conditional exports to provide the correct module format based on the environment:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
"exports": {
|
|
102
|
+
".": {
|
|
103
|
+
"types": "./index.d.ts",
|
|
104
|
+
"node": {
|
|
105
|
+
"import": "./src/server/rollbar.js",
|
|
106
|
+
"require": "./src/server/rollbar.cjs"
|
|
107
|
+
},
|
|
108
|
+
"browser": {
|
|
109
|
+
"import": "./src/browser/rollbar.js",
|
|
110
|
+
"require": "./dist/rollbar.umd.min.js"
|
|
111
|
+
},
|
|
112
|
+
"default": "./dist/rollbar.umd.min.js"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
This means:
|
|
118
|
+
|
|
119
|
+
- **Node.js + ESM**: `import Rollbar from 'rollbar'` → `src/server/rollbar.js`
|
|
120
|
+
- **Node.js + CommonJS**: `require('rollbar')` → `src/server/rollbar.cjs`
|
|
121
|
+
- **Browser + ESM**: `import Rollbar from 'rollbar'` → `src/browser/rollbar.js`
|
|
122
|
+
- **Browser + CommonJS**: `require('rollbar')` → `dist/rollbar.umd.min.js`
|
|
123
|
+
- **TypeScript**: Uses `index.d.ts` for type definitions
|
|
124
|
+
- **Default/Other**: Falls back to `dist/rollbar.umd.min.js`
|
|
125
|
+
|
|
126
|
+
### Legacy Fields (Backward Compatibility)
|
|
127
|
+
|
|
128
|
+
The package still includes legacy fields for older bundlers:
|
|
129
|
+
|
|
130
|
+
- `"main": "src/server/rollbar.js"` - Node.js entry point
|
|
131
|
+
- `"browser": "dist/rollbar.umd.min.js"` - Browser entry point
|
|
132
|
+
- `"module": "src/browser/rollbar.js"` - ES module entry point
|
|
133
|
+
|
|
134
|
+
### Direct Import Paths
|
|
135
|
+
|
|
136
|
+
1. **Source files** (ES modules):
|
|
137
|
+
- `rollbar/src/server/rollbar.js` - Server-side source
|
|
138
|
+
- `rollbar/src/browser/rollbar.js` - Browser-side source
|
|
139
|
+
- `rollbar/src/react-native/rollbar.js` - React Native source
|
|
140
|
+
|
|
141
|
+
2. **Distribution files** (pre-built bundles):
|
|
142
|
+
- `rollbar/dist/rollbar.umd.js` - Universal (CommonJS/AMD/global)
|
|
143
|
+
- `rollbar/dist/rollbar.umd.min.js` - Universal minified
|
|
144
|
+
- `rollbar/dist/rollbar.js` - Vanilla (script tag only)
|
|
145
|
+
- `rollbar/dist/rollbar.min.js` - Vanilla minified
|
|
146
|
+
- `rollbar/dist/rollbar.snippet.js` - Async snippet loader
|
|
147
|
+
- `rollbar/dist/rollbar.named-amd.js` - AMD/RequireJS
|
|
148
|
+
- `rollbar/dist/rollbar.named-amd.min.js` - AMD/RequireJS minified
|
|
149
|
+
|
|
150
|
+
### CDN
|
|
151
|
+
|
|
152
|
+
`https://cdn.rollbar.com/rollbarjs/refs/tags/v{VERSION}/rollbar.min.js`
|
|
153
|
+
|
|
154
|
+
## Test Coverage Status
|
|
155
|
+
|
|
156
|
+
### Category 1: Node.js/NPM Examples with Rollbar Dependency
|
|
157
|
+
|
|
158
|
+
Priority - these use the library and can break with our changes.
|
|
159
|
+
|
|
160
|
+
| Example | Type | Build Cmd | Start Cmd | Rollbar Dep | Status |
|
|
161
|
+
| ----------------- | --------------- | --------------------------- | -------------------- | ------------- | ----------------------- |
|
|
162
|
+
| `angular/` | Angular SPA | `ng build` | `ng serve` | ✅ file:../.. | [✅] Build [✅] Start |
|
|
163
|
+
| `react/` | React SPA | `webpack --mode production` | `webpack-dev-server` | ✅ file:../.. | [✅] Build\* [✅] Start |
|
|
164
|
+
| `vuejs3/` | Vue.js 3 SPA | `vite build` | `vite dev` | ✅ file:../.. | [✅] Build [✅] Start |
|
|
165
|
+
| `webpack/` | Webpack bundler | `webpack` | - | ✅ file:../.. | [✅] Build\* |
|
|
166
|
+
| `no-conflict/` | noConflict mode | `webpack` | `node server.js` | ✅ file:../.. | [✅] Build [✅] Start |
|
|
167
|
+
| `universal-node/` | SSR Node | `webpack` | `node dist/server` | ✅ file:../.. | [✅] Build [✅] Start |
|
|
168
|
+
|
|
169
|
+
\*Note: React and webpack examples pass build/tests but produce larger bundles when using local package dependency.
|
|
170
|
+
|
|
171
|
+
### Category 2: Examples Without Rollbar in package.json
|
|
172
|
+
|
|
173
|
+
Need investigation - they might import rollbar differently.
|
|
174
|
+
|
|
175
|
+
| Example | Type | Build Cmd | Start Cmd | Notes | Status |
|
|
176
|
+
| -------------------- | --------------- | --------------- | ---------------- | ---------------------------------------------- | ------------ |
|
|
177
|
+
| `browserify/` | Bundler | `npm run build` | - | Updated to use `rollbar` package | [✅] Build |
|
|
178
|
+
| `universal-browser/` | Browser/Snippet | - | `node server.js` | Uses Rollbar snippet, loads `/dist/rollbar.js` | [✅] Working |
|
|
179
|
+
|
|
180
|
+
### Category 3: HTML Examples (No Build System)
|
|
181
|
+
|
|
182
|
+
Direct script tag usage - critical for CDN users.
|
|
183
|
+
|
|
184
|
+
| Example | Type | Status | Notes |
|
|
185
|
+
| ---------------------------- | -------------------- | ------------ | ---------------------------------------------- |
|
|
186
|
+
| `script.html` | Basic `<script>` tag | [✅] Working | Uses `rollbar.umd.js` |
|
|
187
|
+
| `snippet.html` | Async snippet | [✅] Working | Uses snippet to load `/dist/rollbar.js` |
|
|
188
|
+
| `test.html` | Test page | [✅] Working | Fixed: now uses `rollbar.umd.js` (was nojson) |
|
|
189
|
+
| `itemsPerMinute.html` | Rate limiting | [✅] Working | Tests rate limiting with `rollbar.umd.js` |
|
|
190
|
+
| `include_custom_object.html` | Custom data | [✅] Working | Tests transform function with `rollbar.umd.js` |
|
|
191
|
+
|
|
192
|
+
### Category 4: Special Cases (No package.json)
|
|
193
|
+
|
|
194
|
+
| Example | Type | Notes | Status |
|
|
195
|
+
| ----------------------- | -------------------- | --------------------------------------------------- | ------------ |
|
|
196
|
+
| `browser_extension_v2/` | Chrome ext v2 | Has manifest.json | [ ] Test |
|
|
197
|
+
| `browser_extension_v3/` | Chrome ext v3 | Has manifest.json | [ ] Test |
|
|
198
|
+
| `requirejs/` | AMD loader | Fixed nojson reference -> uses `rollbar.umd.min.js` | [✅] Working |
|
|
199
|
+
| `bower/` | Legacy pkg mgr | Uses `rollbar.snippet.js` via bower_components | [✅] Working |
|
|
200
|
+
| `extension-exceptions/` | Ad blocker detection | Disables Rollbar if ad blocker detected | [✅] Working |
|
|
201
|
+
|
|
202
|
+
### Critical Test Scenarios After ESM Migration
|
|
203
|
+
|
|
204
|
+
1. **CommonJS in Node.js**: `const Rollbar = require('rollbar')`
|
|
205
|
+
2. **ESM in Node.js**: `import Rollbar from 'rollbar'`
|
|
206
|
+
3. **Browser script tag**: `<script src="dist/rollbar.min.js"></script>`
|
|
207
|
+
4. **Browser with bundler**: Various import methods
|
|
208
|
+
5. **TypeScript**: Type definitions still work
|
|
209
|
+
6. **Framework integrations**: React, Angular, Vue still work
|
|
210
|
+
7. **SSR frameworks**: Next.js dual environment support
|
|
211
|
+
8. **Legacy support**: RequireJS, Bower, Browserify
|
|
212
|
+
|
|
213
|
+
## Examples Validation
|
|
214
|
+
|
|
215
|
+
The validation of examples is automated using the `examples/validate.js` script. See [CLAUDE.examples.validate.md](./CLAUDE.examples.validate.md) for implementation details and future automation plans.
|
|
216
|
+
|
|
217
|
+
## Key Changes Made During ESM Migration
|
|
218
|
+
|
|
219
|
+
### 1. Removed DefinePlugin Strategy
|
|
220
|
+
|
|
221
|
+
- Eliminated runtime `package.json` imports that were causing Angular SSR failures
|
|
222
|
+
- Created proper default modules for each platform (`src/defaults.js`, `src/browser/defaults.js`, `src/server/defaults.js`)
|
|
223
|
+
- Removed `defaults.cjs` and the webpack DefinePlugin configuration
|
|
224
|
+
|
|
225
|
+
### 2. Package.json Updates
|
|
226
|
+
|
|
227
|
+
- Added `"module": "src/browser/rollbar.js"` field for modern bundler ES module support
|
|
228
|
+
- Removed the entire `defaults` section that was used by DefinePlugin
|
|
229
|
+
- All examples now use `"rollbar": "file:../.."` to test against local package
|
|
230
|
+
|
|
231
|
+
### 3. Fixed Examples
|
|
232
|
+
|
|
233
|
+
- **Angular**: Added `"analytics": false` to angular.json to prevent CLI prompts during CI
|
|
234
|
+
- **Vue.js 3**:
|
|
235
|
+
- Created missing `src/assets/main.css` file
|
|
236
|
+
- Fixed syntax error in `src/rollbar.js`
|
|
237
|
+
- Added module field to package.json for Vite compatibility
|
|
238
|
+
- **no-conflict**: Excluded `dist` directory from babel transpilation to prevent babel preset errors
|
|
239
|
+
|
|
240
|
+
### 4. Known Issues
|
|
241
|
+
|
|
242
|
+
- **Bundle Size Issue**: Examples using `"rollbar": "file:../.."` produce significantly larger bundles (~3x) compared to npm package versions
|
|
243
|
+
- Root cause: When using local file dependencies, webpack includes source files that result in larger bundles
|
|
244
|
+
- Impact: React and webpack examples experienced test timeouts due to bundles growing from ~185KB to ~504KB
|
|
245
|
+
- Hypothesis: The size increase may be related to the introduction of rrweb for session replay features (not yet verified)
|
|
246
|
+
- Current workaround: Continue testing with local packages despite the size difference
|
|
247
|
+
|
|
248
|
+
### 5. Dynamic Example Discovery
|
|
249
|
+
|
|
250
|
+
- Created `validate-examples.js` script that dynamically finds examples with local rollbar dependency
|
|
251
|
+
- Updated CI workflow to validate all examples automatically
|
|
252
|
+
- `quick-build-test.sh` now dynamically discovers examples based on package.json content
|
|
253
|
+
|
|
254
|
+
### 6. CommonJS/ESM Interoperability Fix
|
|
255
|
+
|
|
256
|
+
- Created `src/server/rollbar.cjs` wrapper for CommonJS compatibility
|
|
257
|
+
- Updated package.json with conditional exports:
|
|
258
|
+
- `"types"` for TypeScript support
|
|
259
|
+
- `"node"` conditions for import/require
|
|
260
|
+
- `"browser"` conditions for bundlers
|
|
261
|
+
- `"default"` fallback to UMD
|
|
262
|
+
- All Category 1 examples now build and run successfully
|
|
263
|
+
|
|
264
|
+
## Test Fixtures vs Examples
|
|
265
|
+
|
|
266
|
+
Following the pattern established in [PR #1241](https://github.com/rollbar/rollbar.js/pull/1241), we distinguish between:
|
|
267
|
+
|
|
268
|
+
### Examples (in `examples/`)
|
|
269
|
+
|
|
270
|
+
- User-facing demonstrations of SDK integration
|
|
271
|
+
- Meant to be run and understood by developers
|
|
272
|
+
- Should have clear documentation and realistic use cases
|
|
273
|
+
- All files here should be functional examples
|
|
274
|
+
|
|
275
|
+
### Test Fixtures (in `test/fixtures/`)
|
|
276
|
+
|
|
277
|
+
- Files used only by the test suite
|
|
278
|
+
- Not meant as examples for users
|
|
279
|
+
- May contain minimal or specialized code for testing specific features
|
|
280
|
+
- Should be organized by type (e.g., `test/fixtures/html/`, `test/fixtures/sourcemaps/`)
|
|
281
|
+
|
|
282
|
+
**Relocated Files**:
|
|
283
|
+
|
|
284
|
+
- `error.html` → `test/fixtures/html/error.html` - Used by browser tests to generate errors
|
|
285
|
+
- `csp-errors.html` → `test/fixtures/html/csp-errors.html` - Used to test CSP violation reporting
|
|
286
|
+
|
|
287
|
+
**Implementation Notes**:
|
|
288
|
+
|
|
289
|
+
- Updated `Gruntfile.cjs` to include `test/fixtures/**/*.html` pattern for karma file loading
|
|
290
|
+
- Updated test files to reference new paths (`test/fixtures/html/` instead of `examples/`)
|
|
291
|
+
- Added `/test/` proxy in `karma.conf.cjs` for serving fixture files
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Rollbar.js Examples Validation Automation
|
|
2
|
+
|
|
3
|
+
## Project Goal
|
|
4
|
+
|
|
5
|
+
Automate the validation of all Rollbar.js examples to ensure they work correctly with the ESM-migrated library.
|
|
6
|
+
|
|
7
|
+
## Current Implementation: JavaScript-based Validation
|
|
8
|
+
|
|
9
|
+
The validation script (`examples/validate.js`) dynamically discovers and validates all examples that use the local Rollbar package.
|
|
10
|
+
|
|
11
|
+
### How It Works
|
|
12
|
+
|
|
13
|
+
1. **Dynamic Discovery**: Scans all subdirectories in `examples/` for `package.json` files
|
|
14
|
+
2. **Local Package Detection**: Identifies examples using `"rollbar": "file:../.."`
|
|
15
|
+
3. **Automated Validation**: For each example:
|
|
16
|
+
- Runs `npm install` to ensure dependencies are resolved
|
|
17
|
+
- Runs `npm run build` to verify the build process succeeds
|
|
18
|
+
4. **Error Reporting**: Provides clear feedback on which examples fail and why
|
|
19
|
+
|
|
20
|
+
### Key Features
|
|
21
|
+
|
|
22
|
+
- **Automatic Example Discovery**: No need to manually maintain a list of examples
|
|
23
|
+
- **Cross-platform Compatibility**: Works on all platforms supporting Node.js
|
|
24
|
+
- **CI/CD Ready**: Exit codes and error reporting suitable for automated workflows
|
|
25
|
+
- **Functional Programming Style**: Uses async/await with proper error handling
|
|
26
|
+
|
|
27
|
+
### Usage
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# From the project root
|
|
31
|
+
node examples/validate.js
|
|
32
|
+
|
|
33
|
+
# Or make it executable
|
|
34
|
+
chmod +x examples/validate.js
|
|
35
|
+
./examples/validate.js
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Definition of "Working"
|
|
39
|
+
|
|
40
|
+
An example passes validation when:
|
|
41
|
+
|
|
42
|
+
1. `npm install` succeeds (dependencies resolve correctly)
|
|
43
|
+
2. `npm run build` succeeds (no compilation/bundling errors)
|
|
44
|
+
|
|
45
|
+
## Future Enhancements
|
|
46
|
+
|
|
47
|
+
### Runtime Validation
|
|
48
|
+
|
|
49
|
+
Extend the script to also validate runtime behavior:
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
// Add after build validation
|
|
53
|
+
await npm(['test'], example, name); // If test script exists
|
|
54
|
+
// Or
|
|
55
|
+
await npm(['start'], example, name); // With timeout and health check
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Browser Example Validation
|
|
59
|
+
|
|
60
|
+
For HTML examples without build systems:
|
|
61
|
+
|
|
62
|
+
1. Start a local HTTP server
|
|
63
|
+
2. Use Puppeteer/Playwright to load the HTML
|
|
64
|
+
3. Verify Rollbar initializes without errors
|
|
65
|
+
4. Check console for error messages
|
|
66
|
+
|
|
67
|
+
### Enhanced Reporting
|
|
68
|
+
|
|
69
|
+
- Generate detailed validation reports
|
|
70
|
+
- Track bundle sizes
|
|
71
|
+
- Compare against baseline metrics
|
|
72
|
+
- Create compatibility matrix
|
|
73
|
+
|
|
74
|
+
### Parallel Execution
|
|
75
|
+
|
|
76
|
+
Run validations in parallel for faster CI/CD:
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
await Promise.all(examples.map(validateExample));
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Integration with CI/CD
|
|
83
|
+
|
|
84
|
+
The script is designed to work seamlessly in CI environments:
|
|
85
|
+
|
|
86
|
+
- Returns non-zero exit code on failure
|
|
87
|
+
- Provides clear console output
|
|
88
|
+
- Can be integrated into GitHub Actions workflows
|
|
89
|
+
- Supports filtering specific examples if needed
|
|
90
|
+
|
|
91
|
+
## Next Steps
|
|
92
|
+
|
|
93
|
+
1. Add runtime validation capabilities
|
|
94
|
+
2. Implement browser example testing
|
|
95
|
+
3. Add performance metrics collection
|
|
96
|
+
4. Create visual compatibility dashboard
|
|
97
|
+
5. Set up automated regression alerts
|