rollbar 2.26.4 → 3.0.0-alpha.2

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.
Files changed (140) hide show
  1. package/.claude/settings.local.json +3 -0
  2. package/.cursor/rules/guidelines.mdc +154 -0
  3. package/.github/workflows/ci.yml +4 -6
  4. package/CLAUDE.local.md +297 -0
  5. package/CLAUDE.md +201 -0
  6. package/CLAUDE.testrunner.md +470 -0
  7. package/Gruntfile.js +59 -16
  8. package/Makefile +3 -3
  9. package/SECURITY.md +5 -0
  10. package/babel.config.json +9 -0
  11. package/codex.md +148 -0
  12. package/dist/plugins/jquery.min.js +1 -1
  13. package/dist/rollbar.js +19332 -6596
  14. package/dist/rollbar.js.map +1 -1
  15. package/dist/rollbar.min.js +2 -1
  16. package/dist/rollbar.min.js.LICENSE.txt +1 -0
  17. package/dist/rollbar.min.js.map +1 -1
  18. package/dist/rollbar.named-amd.js +19332 -6596
  19. package/dist/rollbar.named-amd.js.map +1 -1
  20. package/dist/rollbar.named-amd.min.js +2 -1
  21. package/dist/rollbar.named-amd.min.js.LICENSE.txt +1 -0
  22. package/dist/rollbar.named-amd.min.js.map +1 -1
  23. package/dist/rollbar.noconflict.umd.js +19319 -6581
  24. package/dist/rollbar.noconflict.umd.js.map +1 -1
  25. package/dist/rollbar.noconflict.umd.min.js +2 -1
  26. package/dist/rollbar.noconflict.umd.min.js.LICENSE.txt +1 -0
  27. package/dist/rollbar.noconflict.umd.min.js.map +1 -1
  28. package/dist/rollbar.snippet.js +1 -1
  29. package/dist/rollbar.umd.js +19333 -6597
  30. package/dist/rollbar.umd.js.map +1 -1
  31. package/dist/rollbar.umd.min.js +2 -1
  32. package/dist/rollbar.umd.min.js.LICENSE.txt +1 -0
  33. package/dist/rollbar.umd.min.js.map +1 -1
  34. package/eslint.config.mjs +33 -0
  35. package/karma.conf.js +5 -14
  36. package/package.json +19 -20
  37. package/src/api.js +57 -4
  38. package/src/apiUtility.js +2 -3
  39. package/src/browser/core.js +37 -9
  40. package/src/browser/replay/defaults.js +70 -0
  41. package/src/browser/replay/recorder.js +194 -0
  42. package/src/browser/replay/replayMap.js +195 -0
  43. package/src/browser/rollbar.js +11 -7
  44. package/src/browser/telemetry.js +3 -3
  45. package/src/browser/transport/fetch.js +17 -4
  46. package/src/browser/transport/xhr.js +17 -1
  47. package/src/browser/transport.js +11 -8
  48. package/src/defaults.js +1 -1
  49. package/src/queue.js +65 -4
  50. package/src/react-native/rollbar.js +1 -1
  51. package/src/rollbar.js +52 -10
  52. package/src/server/rollbar.js +3 -2
  53. package/src/telemetry.js +76 -11
  54. package/src/tracing/context.js +24 -0
  55. package/src/tracing/contextManager.js +37 -0
  56. package/src/tracing/defaults.js +7 -0
  57. package/src/tracing/exporter.js +188 -0
  58. package/src/tracing/hrtime.js +98 -0
  59. package/src/tracing/id.js +24 -0
  60. package/src/tracing/session.js +55 -0
  61. package/src/tracing/span.js +92 -0
  62. package/src/tracing/spanProcessor.js +15 -0
  63. package/src/tracing/tracer.js +46 -0
  64. package/src/tracing/tracing.js +89 -0
  65. package/src/utility.js +34 -0
  66. package/test/api.test.js +57 -12
  67. package/test/apiUtility.test.js +5 -6
  68. package/test/browser.core.test.js +1 -10
  69. package/test/browser.domUtility.test.js +1 -1
  70. package/test/browser.predicates.test.js +1 -1
  71. package/test/browser.replay.recorder.test.js +430 -0
  72. package/test/browser.rollbar.test.js +58 -12
  73. package/test/browser.telemetry.test.js +1 -1
  74. package/test/browser.transforms.test.js +20 -13
  75. package/test/browser.transport.test.js +5 -4
  76. package/test/browser.url.test.js +1 -1
  77. package/test/fixtures/replay/index.js +20 -0
  78. package/test/fixtures/replay/payloads.fixtures.js +229 -0
  79. package/test/fixtures/replay/rrwebEvents.fixtures.js +251 -0
  80. package/test/fixtures/replay/rrwebSyntheticEvents.fixtures.js +328 -0
  81. package/test/notifier.test.js +1 -1
  82. package/test/predicates.test.js +1 -1
  83. package/test/queue.test.js +1 -1
  84. package/test/rateLimiter.test.js +1 -1
  85. package/test/react-native.rollbar.test.js +1 -1
  86. package/test/react-native.transforms.test.js +2 -2
  87. package/test/react-native.transport.test.js +3 -3
  88. package/test/replay/index.js +2 -0
  89. package/test/replay/integration/api.spans.test.js +136 -0
  90. package/test/replay/integration/e2e.test.js +228 -0
  91. package/test/replay/integration/index.js +9 -0
  92. package/test/replay/integration/queue.replayMap.test.js +332 -0
  93. package/test/replay/integration/replayMap.test.js +163 -0
  94. package/test/replay/integration/sessionRecording.test.js +390 -0
  95. package/test/replay/unit/api.postSpans.test.js +150 -0
  96. package/test/replay/unit/index.js +7 -0
  97. package/test/replay/unit/queue.replayMap.test.js +225 -0
  98. package/test/replay/unit/replayMap.test.js +348 -0
  99. package/test/replay/util/index.js +5 -0
  100. package/test/replay/util/mockRecordFn.js +80 -0
  101. package/test/server.lambda.mocha.test.mjs +172 -0
  102. package/test/server.locals.constructor.mocha.test.mjs +80 -0
  103. package/test/server.locals.error-handling.mocha.test.mjs +387 -0
  104. package/test/server.locals.merge.mocha.test.mjs +267 -0
  105. package/test/server.locals.test-utils.mjs +114 -0
  106. package/test/server.parser.mocha.test.mjs +87 -0
  107. package/test/server.predicates.mocha.test.mjs +63 -0
  108. package/test/server.rollbar.constructor.mocha.test.mjs +199 -0
  109. package/test/server.rollbar.handlers.mocha.test.mjs +253 -0
  110. package/test/server.rollbar.logging.mocha.test.mjs +326 -0
  111. package/test/server.rollbar.misc.mocha.test.mjs +44 -0
  112. package/test/server.rollbar.test-utils.mjs +57 -0
  113. package/test/server.telemetry.mocha.test.mjs +377 -0
  114. package/test/server.transforms.data.mocha.test.mjs +163 -0
  115. package/test/server.transforms.error.mocha.test.mjs +199 -0
  116. package/test/server.transforms.request.mocha.test.mjs +208 -0
  117. package/test/server.transforms.scrub.mocha.test.mjs +140 -0
  118. package/test/server.transforms.sourcemaps.mocha.test.mjs +122 -0
  119. package/test/server.transforms.test-utils.mjs +62 -0
  120. package/test/server.transport.mocha.test.mjs +269 -0
  121. package/test/telemetry.test.js +132 -1
  122. package/test/tracing/contextManager.test.js +28 -0
  123. package/test/tracing/exporter.toPayload.test.js +400 -0
  124. package/test/tracing/id.test.js +24 -0
  125. package/test/tracing/span.test.js +183 -0
  126. package/test/tracing/spanProcessor.test.js +73 -0
  127. package/test/tracing/tracing.test.js +105 -0
  128. package/test/transforms.test.js +2 -2
  129. package/test/truncation.test.js +2 -2
  130. package/test/utility.test.js +44 -6
  131. package/webpack.config.js +6 -44
  132. package/.eslintignore +0 -7
  133. package/test/server.lambda.test.js +0 -194
  134. package/test/server.locals.test.js +0 -1068
  135. package/test/server.parser.test.js +0 -78
  136. package/test/server.predicates.test.js +0 -91
  137. package/test/server.rollbar.test.js +0 -728
  138. package/test/server.telemetry.test.js +0 -443
  139. package/test/server.transforms.test.js +0 -1193
  140. package/test/server.transport.test.js +0 -269
package/codex.md ADDED
@@ -0,0 +1,148 @@
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
+ ## SDK Design Principles
72
+
73
+ - **User Problems Are SDK Improvement Opportunities**: When users encounter integration issues, treat these as SDK design improvements rather than user implementation mistakes.
74
+ - Focus on enhancing the SDK to be more robust, intuitive and resilient
75
+ - Implement automatic environment detection and appropriate behavior selection
76
+ - Design APIs that work correctly across all supported contexts without requiring special user handling
77
+ - Errors should be informative and suggest correct usage patterns
78
+ - The burden of complexity should rest with the SDK, not its users
79
+
80
+ ## Error Handling
81
+
82
+ - Prefer try/catch blocks around risky operations
83
+ - Log errors through Rollbar's own logger system
84
+ - Scrub sensitive fields in error payloads (see package.json defaults)
85
+ - The codebase uses a comprehensive error tracking approach with appropriate levels:
86
+ - Debug level for development info
87
+ - Warning level for non-critical issues
88
+ - Error level for uncaught exceptions
89
+
90
+ ## TypeScript Support
91
+
92
+ - Type definitions in index.d.ts
93
+ - Add JSDoc types to enable intellisense when needed
94
+
95
+ ## Common Patterns
96
+
97
+ When working with this codebase, be aware of these patterns:
98
+
99
+ - Error transformation and normalization before sending
100
+ - Telemetry collection for context
101
+ - Queue-based sending with retry logic
102
+ - Environment and context detection
103
+ - Scrubbing of sensitive data
104
+
105
+ ## Testing Philosophy
106
+
107
+ - **Analyze Test Failures Objectively**: When tests fail, evaluate both possibilities objectively:
108
+
109
+ - The test could be correctly identifying an actual code issue
110
+ - The test itself might contain errors or invalid expectations
111
+
112
+ - **Diagnostic Process**:
113
+
114
+ 1. Examine what the test is expecting vs. what the code actually does
115
+ 2. Consider the intended behavior and design of the system
116
+ 3. If the test is correct and identifying a legitimate bug, fix the code
117
+ 4. If the test contains misconceptions or errors, fix the test
118
+
119
+ - **Default to Code Quality**: When in doubt and both seem potentially valid, prioritize improving code quality over modifying tests to pass
120
+
121
+ ## Tracing & Session Replay
122
+
123
+ The `src/tracing/` directory contains an OpenTelemetry-inspired tracing implementation that powers both distributed tracing and session recording features:
124
+
125
+ ### Components
126
+
127
+ - **Context & ContextManager**: Manages propagation of tracing context through the application
128
+ - **Span**: Represents a unit of work or operation with timing information and attributes
129
+ - **Tracer**: Creates and manages spans for tracking operations
130
+ - **SpanProcessor & SpanExporter**: Processes and exports spans to their destination
131
+ - **Session**: Manages browser session data persistence and creation
132
+
133
+ ### Usage Patterns
134
+
135
+ - **Tracing initialization**: Initialize via the main Tracing class with appropriate configuration
136
+ - **Context propagation**: Use context to pass trace information between components
137
+ - **Span creation**: Create spans to measure operations with `startSpan()`
138
+ - **Attributes and events**: Add metadata to spans with `setAttribute()` and `addEvent()`
139
+ - **Session management**: Automatically manages user sessions via browser sessionStorage
140
+
141
+ ### Integration with Session Replay
142
+
143
+ The Session Replay feature utilizes this tracing infrastructure to:
144
+
145
+ - Track and record user sessions with unique identifiers
146
+ - Associate spans with specific user sessions for complete context
147
+ - Capture timing information for accurate playback
148
+ - Store interaction events as span attributes and events
@@ -1 +1 @@
1
- (()=>{"use strict";!function(r,t,n){var e=t.Rollbar;if(e){e.configure({payload:{notifier:{plugins:{jquery:{version:"0.0.8"}}}}});var a=function(r){if(e.error(r),t.console){var n="[reported to Rollbar]";e.options&&!e.options.enabled&&(n="[Rollbar not enabled]"),t.console.log(r.message+" "+n)}};r(n).ajaxError((function(r,t,n,a){var o=t.status,i=n.url,u=n.type;if(o){var s={status:o,url:i,type:u,isAjax:!0,data:n.data,jqXHR_responseText:t.responseText,jqXHR_statusText:t.statusText},d=a||"jQuery ajax error for "+u;e.warning(d,s)}}));var o=r.fn.ready;r.fn.ready=function(r){return o.call(this,(function(t){try{r(t)}catch(r){a(r)}}))};var i=r.event.add;r.event.add=function(t,n,e,o,u){var s,d=function(r){return function(){try{return r.apply(this,arguments)}catch(r){a(r)}}};return e.handler?(s=e.handler,e.handler=d(e.handler)):(s=e,e=d(e)),s.guid?e.guid=s.guid:e.guid=s.guid=r.guid++,i.call(this,t,n,e,o,u)}}}(jQuery,window,document)})();
1
+ !function(r,n,t){var a=n.Rollbar;if(a){a.configure({payload:{notifier:{plugins:{jquery:{version:"0.0.8"}}}}});var e=function(r){if(a.error(r),n.console){var t="[reported to Rollbar]";a.options&&!a.options.enabled&&(t="[Rollbar not enabled]"),n.console.log(r.message+" "+t)}};r(t).ajaxError((function(r,n,t,e){var o=n.status,i=t.url,u=t.type;if(o){var d={status:o,url:i,type:u,isAjax:!0,data:t.data,jqXHR_responseText:n.responseText,jqXHR_statusText:n.statusText},l=e||"jQuery ajax error for "+u;a.warning(l,d)}}));var o=r.fn.ready;r.fn.ready=function(r){return o.call(this,(function(n){try{r(n)}catch(r){e(r)}}))};var i=r.event.add;r.event.add=function(n,t,a,o,u){var d,l=function(r){return function(){try{return r.apply(this,arguments)}catch(r){e(r)}}};return a.handler?(d=a.handler,a.handler=l(a.handler)):(d=a,a=l(a)),d.guid?a.guid=d.guid:a.guid=d.guid=r.guid++,i.call(this,n,t,a,o,u)}}}(jQuery,window,document);