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
@@ -3,7 +3,7 @@
3
3
  /* globals it */
4
4
  /* globals sinon */
5
5
 
6
- var url = require('../src/browser/url');
6
+ import * as url from '../src/browser/url.js';
7
7
 
8
8
  describe('parse', function () {
9
9
  it('should return an object full of nulls for a blank url', function () {
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Export all rrweb fixture events and payloads in a single module
3
+ */
4
+
5
+ import { rrwebEvents } from './rrwebEvents.fixtures.js';
6
+ import { syntheticEvents } from './rrwebSyntheticEvents.fixtures.js';
7
+ import * as payloads from './payloads.fixtures.js';
8
+
9
+ // Event collections
10
+ export const realEvents = rrwebEvents;
11
+ export const allEvents = {
12
+ ...rrwebEvents,
13
+ ...syntheticEvents,
14
+ };
15
+
16
+ // Payload fixtures
17
+ export const standardPayload = payloads.standardPayload;
18
+ export const checkpointPayload = payloads.checkpointPayload;
19
+ export const singleCheckpointPayload = payloads.singleCheckpointPayload;
20
+ export const createPayloadWithReplayId = payloads.createPayloadWithReplayId;
@@ -0,0 +1,229 @@
1
+ /**
2
+ * Fixtures for OTLP-formatted payloads used in tests
3
+ */
4
+ import { EventType } from '@rrweb/types';
5
+
6
+ /**
7
+ * Standard payload with one event of each type (Meta and FullSnapshot)
8
+ */
9
+ export const standardPayload = {
10
+ resourceSpans: [
11
+ {
12
+ resource: {
13
+ attributes: [
14
+ {
15
+ key: 'service.name',
16
+ value: { stringValue: 'test_service' },
17
+ },
18
+ {
19
+ key: 'rollbar.environment',
20
+ value: { stringValue: 'testenv' },
21
+ },
22
+ ],
23
+ },
24
+ scopeSpans: [
25
+ {
26
+ scope: { name: 'rollbar.js', version: '1.0.0', attributes: [] },
27
+ spans: [
28
+ {
29
+ name: 'rrweb-replay-recording',
30
+ traceId: 'abcdef1234567890abcdef1234567890',
31
+ spanId: '1234567890abcdef',
32
+ parentSpanId: '',
33
+ kind: 1,
34
+ startTimeUnixNano: '1600000000000000000',
35
+ endTimeUnixNano: '1600000100000000000',
36
+ attributes: [
37
+ {
38
+ key: 'rollbar.replay.id',
39
+ value: { stringValue: 'test-replay-id' },
40
+ },
41
+ ],
42
+ events: [
43
+ {
44
+ name: 'rrweb-replay-events',
45
+ timeUnixNano: '1600000050000000000',
46
+ attributes: [
47
+ {
48
+ key: 'eventType',
49
+ value: { stringValue: String(EventType.Meta) },
50
+ },
51
+ { key: 'json', value: { stringValue: '{}' } },
52
+ ],
53
+ },
54
+ {
55
+ name: 'rrweb-replay-events',
56
+ timeUnixNano: '1600000060000000000',
57
+ attributes: [
58
+ {
59
+ key: 'eventType',
60
+ value: { stringValue: String(EventType.FullSnapshot) },
61
+ },
62
+ { key: 'json', value: { stringValue: '{}' } },
63
+ ],
64
+ },
65
+ ],
66
+ },
67
+ ],
68
+ },
69
+ ],
70
+ },
71
+ ],
72
+ };
73
+
74
+ /**
75
+ * Checkpoint payload with multiple Meta and FullSnapshot events
76
+ * representing checkpoints in the recording
77
+ */
78
+ export const checkpointPayload = {
79
+ resourceSpans: [
80
+ {
81
+ resource: { attributes: [] },
82
+ scopeSpans: [
83
+ {
84
+ scope: { name: 'rollbar.js', version: '1.0.0', attributes: [] },
85
+ spans: [
86
+ {
87
+ name: 'rrweb-replay-recording',
88
+ traceId: 'abcdef1234567890abcdef1234567890',
89
+ spanId: '1234567890abcdef',
90
+ parentSpanId: '',
91
+ kind: 1,
92
+ startTimeUnixNano: '1600000000000000000',
93
+ endTimeUnixNano: '1600000400000000000',
94
+ attributes: [
95
+ {
96
+ key: 'rollbar.replay.id',
97
+ value: { stringValue: 'test-replay-id' },
98
+ },
99
+ ],
100
+ events: [
101
+ {
102
+ name: 'rrweb-replay-events',
103
+ timeUnixNano: '1600000050000000000',
104
+ attributes: [
105
+ {
106
+ key: 'eventType',
107
+ value: { stringValue: String(EventType.Meta) },
108
+ },
109
+ { key: 'json', value: { stringValue: '{}' } },
110
+ ],
111
+ },
112
+ {
113
+ name: 'rrweb-replay-events',
114
+ timeUnixNano: '1600000060000000000',
115
+ attributes: [
116
+ {
117
+ key: 'eventType',
118
+ value: { stringValue: String(EventType.FullSnapshot) },
119
+ },
120
+ { key: 'json', value: { stringValue: '{}' } },
121
+ ],
122
+ },
123
+ {
124
+ name: 'rrweb-replay-events',
125
+ timeUnixNano: '1600000250000000000',
126
+ attributes: [
127
+ {
128
+ key: 'eventType',
129
+ value: { stringValue: String(EventType.Meta) },
130
+ },
131
+ { key: 'json', value: { stringValue: '{}' } },
132
+ ],
133
+ },
134
+ {
135
+ name: 'rrweb-replay-events',
136
+ timeUnixNano: '1600000260000000000',
137
+ attributes: [
138
+ {
139
+ key: 'eventType',
140
+ value: { stringValue: String(EventType.FullSnapshot) },
141
+ },
142
+ { key: 'json', value: { stringValue: '{}' } },
143
+ ],
144
+ },
145
+ ],
146
+ },
147
+ ],
148
+ },
149
+ ],
150
+ },
151
+ ],
152
+ };
153
+
154
+ /**
155
+ * Single checkpoint payload with just one set of Meta and FullSnapshot events
156
+ */
157
+ export const singleCheckpointPayload = {
158
+ resourceSpans: [
159
+ {
160
+ resource: { attributes: [] },
161
+ scopeSpans: [
162
+ {
163
+ scope: { name: 'rollbar.js', version: '1.0.0', attributes: [] },
164
+ spans: [
165
+ {
166
+ name: 'rrweb-replay-recording',
167
+ traceId: 'abcdef1234567890abcdef1234567890',
168
+ spanId: '1234567890abcdef',
169
+ parentSpanId: '',
170
+ kind: 1,
171
+ startTimeUnixNano: '1600000000000000000',
172
+ endTimeUnixNano: '1600000100000000000',
173
+ attributes: [
174
+ {
175
+ key: 'rollbar.replay.id',
176
+ value: { stringValue: 'test-replay-id' },
177
+ },
178
+ ],
179
+ events: [
180
+ {
181
+ name: 'rrweb-replay-events',
182
+ timeUnixNano: '1600000050000000000',
183
+ attributes: [
184
+ {
185
+ key: 'eventType',
186
+ value: { stringValue: String(EventType.Meta) },
187
+ },
188
+ { key: 'json', value: { stringValue: '{}' } },
189
+ ],
190
+ },
191
+ {
192
+ name: 'rrweb-replay-events',
193
+ timeUnixNano: '1600000060000000000',
194
+ attributes: [
195
+ {
196
+ key: 'eventType',
197
+ value: { stringValue: String(EventType.FullSnapshot) },
198
+ },
199
+ { key: 'json', value: { stringValue: '{}' } },
200
+ ],
201
+ },
202
+ ],
203
+ },
204
+ ],
205
+ },
206
+ ],
207
+ },
208
+ ],
209
+ };
210
+
211
+ /**
212
+ * Creates a deep clone of the standardPayload and updates the replay ID
213
+ * @param {string} replayId - The replay ID to set in the payload
214
+ * @returns {Object} A new payload object with the specified replay ID
215
+ */
216
+ export function createPayloadWithReplayId(replayId) {
217
+ const payload = JSON.parse(JSON.stringify(standardPayload));
218
+
219
+ const idAttr =
220
+ payload.resourceSpans[0].scopeSpans[0].spans[0].attributes.find(
221
+ (attr) => attr.key === 'rollbar.replay.id',
222
+ );
223
+
224
+ if (idAttr) {
225
+ idAttr.value.stringValue = replayId;
226
+ }
227
+
228
+ return payload;
229
+ }
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Fixture with a representative sample of rrweb events
3
+ * Extracted from real session recordings and categorized by type
4
+ */
5
+
6
+ import {
7
+ EventType,
8
+ IncrementalSource,
9
+ MouseInteractions,
10
+ NodeType,
11
+ PointerTypes,
12
+ } from '@rrweb/types';
13
+
14
+ /**
15
+ * A collection of unique rrweb events for testing
16
+ * Extracted from real recordings
17
+ */
18
+ export const rrwebEvents = {
19
+ fullSnapshot: {
20
+ type: EventType.FullSnapshot,
21
+ data: {
22
+ node: {
23
+ type: NodeType.Document,
24
+ childNodes: [
25
+ {
26
+ type: NodeType.DocumentType,
27
+ name: 'html',
28
+ publicId: '',
29
+ systemId: '',
30
+ id: 2,
31
+ },
32
+ {
33
+ type: NodeType.Element,
34
+ tagName: 'html',
35
+ attributes: { lang: 'en' },
36
+ childNodes: [
37
+ {
38
+ type: NodeType.Element,
39
+ tagName: 'head',
40
+ attributes: {},
41
+ childNodes: [],
42
+ id: 4,
43
+ },
44
+ {
45
+ type: NodeType.Element,
46
+ tagName: 'body',
47
+ attributes: {},
48
+ childNodes: [],
49
+ id: 5,
50
+ },
51
+ ],
52
+ id: 3,
53
+ },
54
+ ],
55
+ id: 1,
56
+ },
57
+ initialOffset: {
58
+ top: 0,
59
+ left: 0,
60
+ },
61
+ },
62
+ timestamp: 1744983335278,
63
+ },
64
+
65
+ mouseMove: {
66
+ type: EventType.IncrementalSnapshot,
67
+ data: {
68
+ source: IncrementalSource.MouseMove,
69
+ positions: [
70
+ {
71
+ x: 178,
72
+ y: 327,
73
+ id: 17,
74
+ timeOffset: 0,
75
+ },
76
+ {
77
+ x: 180,
78
+ y: 331,
79
+ id: 17,
80
+ timeOffset: 100,
81
+ },
82
+ ],
83
+ },
84
+ timestamp: 1744983335279,
85
+ },
86
+
87
+ mouseInteractionClick: {
88
+ type: EventType.IncrementalSnapshot,
89
+ data: {
90
+ source: IncrementalSource.MouseInteraction,
91
+ type: MouseInteractions.Click,
92
+ id: 17,
93
+ x: 180,
94
+ y: 331,
95
+ pointerType: PointerTypes.Mouse,
96
+ },
97
+ timestamp: 1744983335280,
98
+ },
99
+
100
+ mouseInteractionDown: {
101
+ type: EventType.IncrementalSnapshot,
102
+ data: {
103
+ source: IncrementalSource.MouseInteraction,
104
+ type: MouseInteractions.MouseDown,
105
+ id: 17,
106
+ x: 180,
107
+ y: 331,
108
+ pointerType: PointerTypes.Mouse,
109
+ },
110
+ timestamp: 1744983335281,
111
+ },
112
+
113
+ mouseInteractionUp: {
114
+ type: EventType.IncrementalSnapshot,
115
+ data: {
116
+ source: IncrementalSource.MouseInteraction,
117
+ type: MouseInteractions.MouseUp,
118
+ id: 17,
119
+ x: 180,
120
+ y: 331,
121
+ pointerType: PointerTypes.Mouse,
122
+ },
123
+ timestamp: 1744983335282,
124
+ },
125
+
126
+ scroll: {
127
+ type: EventType.IncrementalSnapshot,
128
+ data: {
129
+ source: IncrementalSource.Scroll,
130
+ id: 1,
131
+ x: 0,
132
+ y: 274,
133
+ },
134
+ timestamp: 1744983335283,
135
+ },
136
+
137
+ viewportResize: {
138
+ type: EventType.IncrementalSnapshot,
139
+ data: {
140
+ source: IncrementalSource.ViewportResize,
141
+ width: 1721,
142
+ height: 488,
143
+ },
144
+ timestamp: 1744983335284,
145
+ },
146
+
147
+ input: {
148
+ type: EventType.IncrementalSnapshot,
149
+ data: {
150
+ source: IncrementalSource.Input,
151
+ id: 100,
152
+ text: 'user input text',
153
+ isChecked: false,
154
+ userTriggered: true,
155
+ },
156
+ timestamp: 1744983335285,
157
+ },
158
+
159
+ mutation: {
160
+ type: EventType.IncrementalSnapshot,
161
+ data: {
162
+ source: IncrementalSource.Mutation,
163
+ texts: [],
164
+ attributes: [
165
+ {
166
+ id: 73,
167
+ attributes: {
168
+ class: 'active',
169
+ },
170
+ },
171
+ ],
172
+ removes: [],
173
+ adds: [
174
+ {
175
+ parentId: 5,
176
+ nextId: null,
177
+ node: {
178
+ type: NodeType.Element,
179
+ tagName: 'div',
180
+ attributes: {
181
+ id: 'new-element',
182
+ },
183
+ childNodes: [],
184
+ id: 101,
185
+ },
186
+ },
187
+ ],
188
+ },
189
+ timestamp: 1744983335286,
190
+ },
191
+
192
+ selection: {
193
+ type: EventType.IncrementalSnapshot,
194
+ data: {
195
+ source: IncrementalSource.Selection,
196
+ ranges: [
197
+ {
198
+ start: 20,
199
+ startOffset: 0,
200
+ end: 20,
201
+ endOffset: 4,
202
+ },
203
+ ],
204
+ },
205
+ timestamp: 1744983335287,
206
+ },
207
+
208
+ meta: {
209
+ type: EventType.Meta,
210
+ data: {
211
+ href: 'http://localhost:3001/',
212
+ width: 1721,
213
+ height: 470,
214
+ },
215
+ timestamp: 1744983335288,
216
+ },
217
+
218
+ custom: {
219
+ type: EventType.Custom,
220
+ data: {
221
+ tag: 'custom-event',
222
+ payload: {
223
+ key: 'value',
224
+ },
225
+ },
226
+ timestamp: 1744983335289,
227
+ },
228
+
229
+ plugin: {
230
+ type: EventType.Plugin,
231
+ data: {
232
+ plugin: 'rrweb/console@1',
233
+ payload: {
234
+ level: 'log',
235
+ args: ['Console log message'],
236
+ },
237
+ },
238
+ timestamp: 1744983335290,
239
+ },
240
+
241
+ invalid: {
242
+ type: 999,
243
+ data: {},
244
+ timestamp: 1744983335291,
245
+ },
246
+
247
+ incomplete: {
248
+ type: EventType.IncrementalSnapshot,
249
+ // Missing data and timestamp
250
+ },
251
+ };