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.
- package/.claude/settings.local.json +3 -0
- package/.cursor/rules/guidelines.mdc +154 -0
- package/.github/workflows/ci.yml +4 -6
- package/CLAUDE.local.md +297 -0
- package/CLAUDE.md +201 -0
- package/CLAUDE.testrunner.md +470 -0
- package/Gruntfile.js +59 -16
- package/Makefile +3 -3
- package/SECURITY.md +5 -0
- package/babel.config.json +9 -0
- package/codex.md +148 -0
- package/dist/plugins/jquery.min.js +1 -1
- package/dist/rollbar.js +19332 -6596
- 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 +19332 -6596
- package/dist/rollbar.named-amd.js.map +1 -1
- package/dist/rollbar.named-amd.min.js +2 -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 +19319 -6581
- package/dist/rollbar.noconflict.umd.js.map +1 -1
- package/dist/rollbar.noconflict.umd.min.js +2 -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 +19333 -6597
- package/dist/rollbar.umd.js.map +1 -1
- package/dist/rollbar.umd.min.js +2 -1
- package/dist/rollbar.umd.min.js.LICENSE.txt +1 -0
- package/dist/rollbar.umd.min.js.map +1 -1
- package/eslint.config.mjs +33 -0
- package/karma.conf.js +5 -14
- package/package.json +19 -20
- package/src/api.js +57 -4
- package/src/apiUtility.js +2 -3
- package/src/browser/core.js +37 -9
- package/src/browser/replay/defaults.js +70 -0
- package/src/browser/replay/recorder.js +194 -0
- package/src/browser/replay/replayMap.js +195 -0
- package/src/browser/rollbar.js +11 -7
- package/src/browser/telemetry.js +3 -3
- package/src/browser/transport/fetch.js +17 -4
- package/src/browser/transport/xhr.js +17 -1
- package/src/browser/transport.js +11 -8
- package/src/defaults.js +1 -1
- package/src/queue.js +65 -4
- package/src/react-native/rollbar.js +1 -1
- package/src/rollbar.js +52 -10
- package/src/server/rollbar.js +3 -2
- package/src/telemetry.js +76 -11
- 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/utility.js +34 -0
- package/test/api.test.js +57 -12
- package/test/apiUtility.test.js +5 -6
- package/test/browser.core.test.js +1 -10
- package/test/browser.domUtility.test.js +1 -1
- package/test/browser.predicates.test.js +1 -1
- package/test/browser.replay.recorder.test.js +430 -0
- package/test/browser.rollbar.test.js +58 -12
- package/test/browser.telemetry.test.js +1 -1
- package/test/browser.transforms.test.js +20 -13
- package/test/browser.transport.test.js +5 -4
- package/test/browser.url.test.js +1 -1
- 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 +1 -1
- package/test/predicates.test.js +1 -1
- package/test/queue.test.js +1 -1
- package/test/rateLimiter.test.js +1 -1
- package/test/react-native.rollbar.test.js +1 -1
- package/test/react-native.transforms.test.js +2 -2
- package/test/react-native.transport.test.js +3 -3
- 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 +132 -1
- 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 +2 -2
- package/test/truncation.test.js +2 -2
- package/test/utility.test.js +44 -6
- package/webpack.config.js +6 -44
- package/.eslintignore +0 -7
- package/test/server.lambda.test.js +0 -194
- package/test/server.locals.test.js +0 -1068
- package/test/server.parser.test.js +0 -78
- package/test/server.predicates.test.js +0 -91
- package/test/server.rollbar.test.js +0 -728
- package/test/server.telemetry.test.js +0 -443
- package/test/server.transforms.test.js +0 -1193
- package/test/server.transport.test.js +0 -269
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synthetic rrweb events created from type definitions
|
|
3
|
+
* These events are NOT from real recordings but are created based on the
|
|
4
|
+
* type definitions in @rrweb/types to ensure complete test coverage.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
EventType,
|
|
9
|
+
IncrementalSource,
|
|
10
|
+
MouseInteractions,
|
|
11
|
+
MediaInteractions,
|
|
12
|
+
PointerTypes,
|
|
13
|
+
} from '@rrweb/types';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Synthetic events created from type definitions for testing
|
|
17
|
+
* These cover sources and interactions not in the real recordings
|
|
18
|
+
*/
|
|
19
|
+
export const syntheticEvents = {
|
|
20
|
+
domContentLoaded: {
|
|
21
|
+
type: EventType.DomContentLoaded,
|
|
22
|
+
data: {}, // Empty object confirmed in rrweb/src/record/index.ts
|
|
23
|
+
timestamp: 1744983335276,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
load: {
|
|
27
|
+
type: EventType.Load,
|
|
28
|
+
data: {}, // Empty object confirmed in rrweb/src/record/index.ts
|
|
29
|
+
timestamp: 1744983335277,
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
touchMove: {
|
|
33
|
+
type: EventType.IncrementalSnapshot,
|
|
34
|
+
data: {
|
|
35
|
+
source: IncrementalSource.TouchMove,
|
|
36
|
+
positions: [
|
|
37
|
+
{
|
|
38
|
+
x: 150,
|
|
39
|
+
y: 200,
|
|
40
|
+
id: 20,
|
|
41
|
+
timeOffset: 0,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
x: 160,
|
|
45
|
+
y: 210,
|
|
46
|
+
id: 20,
|
|
47
|
+
timeOffset: 100,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
timestamp: 1744983335300,
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
mediaInteractionPlay: {
|
|
55
|
+
type: EventType.IncrementalSnapshot,
|
|
56
|
+
data: {
|
|
57
|
+
source: IncrementalSource.MediaInteraction,
|
|
58
|
+
type: MediaInteractions.Play,
|
|
59
|
+
id: 45,
|
|
60
|
+
currentTime: 0,
|
|
61
|
+
},
|
|
62
|
+
timestamp: 1744983335310,
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
mediaInteractionPause: {
|
|
66
|
+
type: EventType.IncrementalSnapshot,
|
|
67
|
+
data: {
|
|
68
|
+
source: IncrementalSource.MediaInteraction,
|
|
69
|
+
type: MediaInteractions.Pause,
|
|
70
|
+
id: 45,
|
|
71
|
+
currentTime: 30.5,
|
|
72
|
+
},
|
|
73
|
+
timestamp: 1744983335320,
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
mediaInteractionSeeked: {
|
|
77
|
+
type: EventType.IncrementalSnapshot,
|
|
78
|
+
data: {
|
|
79
|
+
source: IncrementalSource.MediaInteraction,
|
|
80
|
+
type: MediaInteractions.Seeked,
|
|
81
|
+
id: 45,
|
|
82
|
+
currentTime: 60,
|
|
83
|
+
},
|
|
84
|
+
timestamp: 1744983335330,
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
mediaInteractionVolumeChange: {
|
|
88
|
+
type: EventType.IncrementalSnapshot,
|
|
89
|
+
data: {
|
|
90
|
+
source: IncrementalSource.MediaInteraction,
|
|
91
|
+
type: MediaInteractions.VolumeChange,
|
|
92
|
+
id: 45,
|
|
93
|
+
volume: 0.75,
|
|
94
|
+
muted: false,
|
|
95
|
+
},
|
|
96
|
+
timestamp: 1744983335340,
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
mediaInteractionRateChange: {
|
|
100
|
+
type: EventType.IncrementalSnapshot,
|
|
101
|
+
data: {
|
|
102
|
+
source: IncrementalSource.MediaInteraction,
|
|
103
|
+
type: MediaInteractions.RateChange,
|
|
104
|
+
id: 45,
|
|
105
|
+
playbackRate: 1.5,
|
|
106
|
+
},
|
|
107
|
+
timestamp: 1744983335350,
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
styleSheetRule: {
|
|
111
|
+
type: EventType.IncrementalSnapshot,
|
|
112
|
+
data: {
|
|
113
|
+
source: IncrementalSource.StyleSheetRule,
|
|
114
|
+
styleId: 3,
|
|
115
|
+
adds: [
|
|
116
|
+
{
|
|
117
|
+
rule: '.new-class { color: red; }',
|
|
118
|
+
index: 1,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
timestamp: 1744983335360,
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
canvasMutation: {
|
|
126
|
+
type: EventType.IncrementalSnapshot,
|
|
127
|
+
data: {
|
|
128
|
+
source: IncrementalSource.CanvasMutation,
|
|
129
|
+
id: 24,
|
|
130
|
+
type: 0, // 2D canvas mutation
|
|
131
|
+
commands: [
|
|
132
|
+
{
|
|
133
|
+
property: 'fillStyle',
|
|
134
|
+
args: ['#ff0000'],
|
|
135
|
+
setter: true,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
property: 'fillRect',
|
|
139
|
+
args: [10, 10, 100, 100],
|
|
140
|
+
setter: false,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
timestamp: 1744983335370,
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
font: {
|
|
148
|
+
type: EventType.IncrementalSnapshot,
|
|
149
|
+
data: {
|
|
150
|
+
source: IncrementalSource.Font,
|
|
151
|
+
family: 'CustomFont',
|
|
152
|
+
fontSource: "url('path/to/font.woff2')",
|
|
153
|
+
buffer: false,
|
|
154
|
+
descriptors: {
|
|
155
|
+
style: 'normal',
|
|
156
|
+
weight: '400',
|
|
157
|
+
display: 'swap',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
timestamp: 1744983335380,
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
log: {
|
|
164
|
+
type: EventType.IncrementalSnapshot,
|
|
165
|
+
data: {
|
|
166
|
+
source: IncrementalSource.Log,
|
|
167
|
+
level: 'info',
|
|
168
|
+
trace: [],
|
|
169
|
+
payload: ['Log message from application'],
|
|
170
|
+
},
|
|
171
|
+
timestamp: 1744983335390,
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
drag: {
|
|
175
|
+
type: EventType.IncrementalSnapshot,
|
|
176
|
+
data: {
|
|
177
|
+
source: IncrementalSource.Drag,
|
|
178
|
+
positions: [
|
|
179
|
+
{
|
|
180
|
+
x: 100,
|
|
181
|
+
y: 100,
|
|
182
|
+
id: 50,
|
|
183
|
+
timeOffset: 0,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
x: 120,
|
|
187
|
+
y: 120,
|
|
188
|
+
id: 50,
|
|
189
|
+
timeOffset: 100,
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
x: 140,
|
|
193
|
+
y: 140,
|
|
194
|
+
id: 50,
|
|
195
|
+
timeOffset: 200,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
timestamp: 1744983335400,
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
styleDeclaration: {
|
|
203
|
+
type: EventType.IncrementalSnapshot,
|
|
204
|
+
data: {
|
|
205
|
+
source: IncrementalSource.StyleDeclaration,
|
|
206
|
+
id: 64,
|
|
207
|
+
index: [0],
|
|
208
|
+
set: {
|
|
209
|
+
property: 'color',
|
|
210
|
+
value: 'blue',
|
|
211
|
+
priority: 'important',
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
timestamp: 1744983335410,
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
adoptedStyleSheet: {
|
|
218
|
+
type: EventType.IncrementalSnapshot,
|
|
219
|
+
data: {
|
|
220
|
+
source: IncrementalSource.AdoptedStyleSheet,
|
|
221
|
+
id: 1,
|
|
222
|
+
styles: [
|
|
223
|
+
{
|
|
224
|
+
id: 1,
|
|
225
|
+
rules: [
|
|
226
|
+
{
|
|
227
|
+
cssText: 'body { margin: 0; padding: 0; }',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
cssText: 'h1 { font-size: 24px; }',
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
timestamp: 1744983335420,
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
customElement: {
|
|
240
|
+
type: EventType.IncrementalSnapshot,
|
|
241
|
+
data: {
|
|
242
|
+
source: IncrementalSource.CustomElement,
|
|
243
|
+
id: 80,
|
|
244
|
+
mutations: [
|
|
245
|
+
{
|
|
246
|
+
type: 'attributes',
|
|
247
|
+
name: 'data-custom',
|
|
248
|
+
value: 'new-value',
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
},
|
|
252
|
+
timestamp: 1744983335430,
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
mouseInteractionDblClick: {
|
|
256
|
+
type: EventType.IncrementalSnapshot,
|
|
257
|
+
data: {
|
|
258
|
+
source: IncrementalSource.MouseInteraction,
|
|
259
|
+
type: MouseInteractions.DblClick,
|
|
260
|
+
id: 73,
|
|
261
|
+
x: 200,
|
|
262
|
+
y: 300,
|
|
263
|
+
pointerType: PointerTypes.Mouse,
|
|
264
|
+
},
|
|
265
|
+
timestamp: 1744983335440,
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
mouseInteractionContextMenu: {
|
|
269
|
+
type: EventType.IncrementalSnapshot,
|
|
270
|
+
data: {
|
|
271
|
+
source: IncrementalSource.MouseInteraction,
|
|
272
|
+
type: MouseInteractions.ContextMenu,
|
|
273
|
+
id: 73,
|
|
274
|
+
x: 200,
|
|
275
|
+
y: 300,
|
|
276
|
+
pointerType: PointerTypes.Mouse,
|
|
277
|
+
},
|
|
278
|
+
timestamp: 1744983335450,
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
mouseInteractionFocus: {
|
|
282
|
+
type: EventType.IncrementalSnapshot,
|
|
283
|
+
data: {
|
|
284
|
+
source: IncrementalSource.MouseInteraction,
|
|
285
|
+
type: MouseInteractions.Focus,
|
|
286
|
+
id: 73,
|
|
287
|
+
pointerType: PointerTypes.Mouse,
|
|
288
|
+
},
|
|
289
|
+
timestamp: 1744983335460,
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
mouseInteractionBlur: {
|
|
293
|
+
type: EventType.IncrementalSnapshot,
|
|
294
|
+
data: {
|
|
295
|
+
source: IncrementalSource.MouseInteraction,
|
|
296
|
+
type: MouseInteractions.Blur,
|
|
297
|
+
id: 73,
|
|
298
|
+
pointerType: PointerTypes.Mouse,
|
|
299
|
+
},
|
|
300
|
+
timestamp: 1744983335470,
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
mouseInteractionTouchStart: {
|
|
304
|
+
type: EventType.IncrementalSnapshot,
|
|
305
|
+
data: {
|
|
306
|
+
source: IncrementalSource.MouseInteraction,
|
|
307
|
+
type: MouseInteractions.TouchStart,
|
|
308
|
+
id: 73,
|
|
309
|
+
x: 200,
|
|
310
|
+
y: 300,
|
|
311
|
+
pointerType: PointerTypes.Touch,
|
|
312
|
+
},
|
|
313
|
+
timestamp: 1744983335480,
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
mouseInteractionTouchEnd: {
|
|
317
|
+
type: EventType.IncrementalSnapshot,
|
|
318
|
+
data: {
|
|
319
|
+
source: IncrementalSource.MouseInteraction,
|
|
320
|
+
type: MouseInteractions.TouchEnd,
|
|
321
|
+
id: 73,
|
|
322
|
+
x: 200,
|
|
323
|
+
y: 300,
|
|
324
|
+
pointerType: PointerTypes.Touch,
|
|
325
|
+
},
|
|
326
|
+
timestamp: 1744983335490,
|
|
327
|
+
},
|
|
328
|
+
};
|
package/test/notifier.test.js
CHANGED
package/test/predicates.test.js
CHANGED
package/test/queue.test.js
CHANGED
package/test/rateLimiter.test.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
/* globals it */
|
|
4
4
|
/* globals sinon */
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import Rollbar from '../src/react-native/rollbar.js';
|
|
7
|
+
import t from '../src/react-native/transforms.js';
|
|
8
8
|
|
|
9
9
|
function TestClientGen() {
|
|
10
10
|
var TestClient = function () {
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
/* globals it */
|
|
4
4
|
/* globals sinon */
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import truncation from '../src/truncation.js';
|
|
7
|
+
import Transport from '../src/react-native/transport.js';
|
|
8
8
|
var t = new Transport(truncation);
|
|
9
|
-
|
|
9
|
+
import utility from '../src/utility.js';
|
|
10
10
|
utility.setupJSON();
|
|
11
11
|
|
|
12
12
|
describe('post', function () {
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API integration tests for span transport
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/* globals describe */
|
|
6
|
+
/* globals it */
|
|
7
|
+
/* globals beforeEach */
|
|
8
|
+
/* globals afterEach */
|
|
9
|
+
|
|
10
|
+
import { expect } from 'chai';
|
|
11
|
+
import sinon from 'sinon';
|
|
12
|
+
|
|
13
|
+
import Api from '../../../src/api.js';
|
|
14
|
+
import {
|
|
15
|
+
standardPayload,
|
|
16
|
+
createPayloadWithReplayId,
|
|
17
|
+
} from '../../fixtures/replay/payloads.fixtures.js';
|
|
18
|
+
|
|
19
|
+
describe('API Span Transport', function () {
|
|
20
|
+
let api;
|
|
21
|
+
let transport;
|
|
22
|
+
let accessToken;
|
|
23
|
+
|
|
24
|
+
beforeEach(function () {
|
|
25
|
+
accessToken = 'test-token-12345';
|
|
26
|
+
|
|
27
|
+
transport = {
|
|
28
|
+
post: sinon
|
|
29
|
+
.stub()
|
|
30
|
+
.callsFake((accessToken, transportOptions, payload, callback) => {
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
callback(null, { err: 0, result: { id: '12345' } });
|
|
33
|
+
}, 10);
|
|
34
|
+
}),
|
|
35
|
+
postJsonPayload: sinon.stub(),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const urlMock = { parse: sinon.stub().returns({}) };
|
|
39
|
+
const truncationMock = {
|
|
40
|
+
truncate: sinon.stub().returns({ error: null, value: '{}' }),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
api = new Api({ accessToken }, transport, urlMock, truncationMock);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterEach(function () {
|
|
47
|
+
sinon.restore();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should use the session endpoint for spans', async function () {
|
|
51
|
+
const spans = standardPayload;
|
|
52
|
+
|
|
53
|
+
await api.postSpans(spans);
|
|
54
|
+
|
|
55
|
+
expect(transport.post.calledOnce).to.be.true;
|
|
56
|
+
|
|
57
|
+
const transportOptions = transport.post.firstCall.args[1];
|
|
58
|
+
expect(transportOptions.path).to.include('/api/1/session/');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should format spans payload correctly', async function () {
|
|
62
|
+
const testReplayId = 'test-replay-api-12345';
|
|
63
|
+
const spans = createPayloadWithReplayId(testReplayId);
|
|
64
|
+
|
|
65
|
+
await api.postSpans(spans);
|
|
66
|
+
|
|
67
|
+
const payload = transport.post.firstCall.args[2];
|
|
68
|
+
|
|
69
|
+
expect(payload).to.have.property('resourceSpans');
|
|
70
|
+
expect(payload).to.deep.equal(spans);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should handle transport errors', async function () {
|
|
74
|
+
const testError = new Error('Transport failure');
|
|
75
|
+
transport.post.callsFake(
|
|
76
|
+
(accessToken, transportOptions, payload, callback) => {
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
callback(testError);
|
|
79
|
+
}, 10);
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const spans = [{ id: 'error-span', name: 'error-recording' }];
|
|
84
|
+
|
|
85
|
+
try {
|
|
86
|
+
await api.postSpans(spans);
|
|
87
|
+
expect.fail('Expected error not thrown');
|
|
88
|
+
} catch (error) {
|
|
89
|
+
expect(error).to.equal(testError);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should handle API response errors', async function () {
|
|
94
|
+
transport.post.callsFake(
|
|
95
|
+
(accessToken, transportOptions, payload, callback) => {
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
callback(null, { err: 1, message: 'API Error' });
|
|
98
|
+
}, 10);
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const spans = [{ id: 'error-span', name: 'error-recording' }];
|
|
103
|
+
|
|
104
|
+
const response = await api.postSpans(spans);
|
|
105
|
+
|
|
106
|
+
expect(response).to.have.property('err', 1);
|
|
107
|
+
expect(response).to.have.property('message', 'API Error');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should merge options when reconfigured', function () {
|
|
111
|
+
const originalOptions = api.options;
|
|
112
|
+
|
|
113
|
+
api.configure({
|
|
114
|
+
endpoint: 'https://custom.rollbar.com/api/',
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
expect(api.options).to.not.equal(originalOptions);
|
|
118
|
+
expect(api.options).to.have.property(
|
|
119
|
+
'endpoint',
|
|
120
|
+
'https://custom.rollbar.com/api/',
|
|
121
|
+
);
|
|
122
|
+
expect(api.accessToken).to.equal(accessToken);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('should update sessionTransportOptions when reconfigured', function () {
|
|
126
|
+
const originalTransportOptions = api.OTLPTransportOptions;
|
|
127
|
+
|
|
128
|
+
api.configure({
|
|
129
|
+
tracing: {
|
|
130
|
+
endpoint: 'https://custom.rollbar.com/api/',
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
expect(api.OTLPTransportOptions).to.not.equal(originalTransportOptions);
|
|
135
|
+
});
|
|
136
|
+
});
|