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
@@ -1,269 +0,0 @@
1
- 'use strict';
2
-
3
- var assert = require('assert');
4
- var util = require('util');
5
- var vows = require('vows');
6
- var Transport = require('../src/server/transport');
7
- var t = new Transport();
8
-
9
- vows
10
- .describe('transport')
11
- .addBatch({
12
- post: {
13
- 'base data': {
14
- topic: function () {
15
- return {
16
- accessToken: 'abc123',
17
- options: {},
18
- payload: {
19
- access_token: 'abc123',
20
- data: { a: 1 },
21
- },
22
- };
23
- },
24
- 'with no payload': {
25
- topic: function (data) {
26
- var factory = transportFactory(
27
- null,
28
- '{"err": null, "result":"all good"}',
29
- );
30
- t.post(
31
- data.accessToken,
32
- data.options,
33
- null,
34
- this.callback,
35
- factory,
36
- );
37
- },
38
- 'should have an error': function (err, resp) {
39
- assert.ok(err);
40
- },
41
- },
42
- 'with a payload and no error': {
43
- topic: function (data) {
44
- var factory = transportFactory(
45
- null,
46
- '{"err": null, "result":{"uuid":"42def", "message":"all good"}}',
47
- function () {
48
- assert.equal(
49
- this.options.headers['Content-Type'],
50
- 'application/json',
51
- );
52
- assert.isNumber(this.options.headers['Content-Length']);
53
- assert(this.options.headers['Content-Length'] > 0);
54
- assert.equal(
55
- this.options.headers['X-Rollbar-Access-Token'],
56
- data.accessToken,
57
- );
58
- },
59
- );
60
- t.post(
61
- data.accessToken,
62
- data.options,
63
- data.payload,
64
- this.callback,
65
- factory,
66
- );
67
- },
68
- 'should not error': function (err, resp) {
69
- assert.ifError(err);
70
- },
71
- 'should have the right response data': function (err, resp) {
72
- assert.equal(resp.message, 'all good');
73
- },
74
- },
75
- 'with a payload and an error in the response': {
76
- topic: function (data) {
77
- var factory = transportFactory(
78
- null,
79
- '{"err": "bork", "message":"things broke"}',
80
- function () {
81
- assert.equal(
82
- this.options.headers['Content-Type'],
83
- 'application/json',
84
- );
85
- assert.isNumber(this.options.headers['Content-Length']);
86
- assert(this.options.headers['Content-Length'] > 0);
87
- assert.equal(
88
- this.options.headers['X-Rollbar-Access-Token'],
89
- data.accessToken,
90
- );
91
- },
92
- );
93
- t.post(
94
- data.accessToken,
95
- data.options,
96
- data.payload,
97
- this.callback,
98
- factory,
99
- );
100
- },
101
- 'should error': function (err, resp) {
102
- assert.ok(err);
103
- },
104
- 'should have the message somewhere': function (err, resp) {
105
- assert.match(err.message, /things broke/);
106
- },
107
- 'should not have a response': function (err, resp) {
108
- assert.ifError(resp);
109
- },
110
- },
111
- 'with a payload and an error during sending': {
112
- topic: function (data) {
113
- var factory = transportFactory(
114
- new Error('bork'),
115
- null,
116
- function () {
117
- assert.equal(
118
- this.options.headers['Content-Type'],
119
- 'application/json',
120
- );
121
- assert.isNumber(this.options.headers['Content-Length']);
122
- assert(this.options.headers['Content-Length'] > 0);
123
- assert.equal(
124
- this.options.headers['X-Rollbar-Access-Token'],
125
- data.accessToken,
126
- );
127
- },
128
- );
129
- t.post(
130
- data.accessToken,
131
- data.options,
132
- data.payload,
133
- this.callback,
134
- factory,
135
- );
136
- },
137
- 'should error': function (err, resp) {
138
- assert.ok(err);
139
- },
140
- 'should have the message somewhere': function (err, resp) {
141
- assert.match(err.message, /bork/);
142
- },
143
- 'should not have a response': function (err, resp) {
144
- assert.ifError(resp);
145
- },
146
- },
147
- },
148
- 'with rate limiting': {
149
- topic: function () {
150
- return new Transport();
151
- },
152
- 'should transmit non-rate limited requests': function (t) {
153
- var response = new TestResponse({
154
- statusCode: 200,
155
- headers: {
156
- 'x-rate-limit-remaining': '1',
157
- 'x-rate-limit-remaining-seconds': '100',
158
- },
159
- });
160
- var error;
161
-
162
- assert.equal(t.rateLimitExpires, 0);
163
-
164
- t.handleResponse(response);
165
-
166
- var factory = transportFactory(
167
- null,
168
- '{"err": null, "result": "all good"}',
169
- );
170
- t.post(
171
- 'token',
172
- {},
173
- 'payload',
174
- function (err) {
175
- error = err;
176
- },
177
- factory,
178
- );
179
-
180
- assert.equal(error, null);
181
- assert.isTrue(Math.floor(Date.now() / 1000) >= t.rateLimitExpires);
182
- },
183
- 'should drop rate limited requests and set timeout': function (t) {
184
- var response = new TestResponse({
185
- statusCode: 429,
186
- headers: {
187
- 'x-rate-limit-remaining': '0',
188
- 'x-rate-limit-remaining-seconds': '100',
189
- },
190
- });
191
- var error;
192
-
193
- t.handleResponse(response);
194
-
195
- t.post('token', {}, 'payload', function (err) {
196
- error = err;
197
- });
198
-
199
- assert.match(error.message, /Exceeded rate limit/);
200
- assert.isTrue(Math.floor(Date.now() / 1000) < t.rateLimitExpires);
201
- },
202
- },
203
- },
204
- })
205
- .export(module, { error: false });
206
-
207
- var TestTransport = function (options, error, response, assertions) {
208
- this.options = options;
209
- this.error = error;
210
- this.response = response;
211
- this.requestOpts = null;
212
- this.requestCallback = null;
213
- this.assertions = assertions;
214
- };
215
- var TestRequest = function (error, response, transport) {
216
- this.error = error;
217
- this.responseData = response;
218
- this.data = [];
219
- this.events = {};
220
- this.transport = transport;
221
- this.response = null;
222
- };
223
- TestTransport.prototype.request = function (opts, cb) {
224
- this.requestOpts = opts;
225
- this.requestCallback = cb;
226
- return new TestRequest(this.error, this.response, this);
227
- };
228
- TestRequest.prototype.write = function (data) {
229
- this.data.push(data);
230
- };
231
- TestRequest.prototype.on = function (event, cb) {
232
- this.events[event] = cb;
233
- };
234
- TestRequest.prototype.end = function () {
235
- if (this.transport.assertions) {
236
- this.transport.assertions();
237
- }
238
- if (this.error) {
239
- if (this.events['error']) {
240
- this.events['error'](this.error);
241
- }
242
- } else {
243
- this.response = new TestResponse();
244
- this.transport.requestCallback(this.response);
245
- if (this.response.events['data']) {
246
- this.response.events['data'](this.responseData);
247
- }
248
- if (this.response.events['end']) {
249
- this.response.events['end']();
250
- }
251
- }
252
- };
253
- var TestResponse = function (options = {}) {
254
- this.encoding = null;
255
- this.events = {};
256
- this.headers = options.headers || {};
257
- this.statusCode = options.statusCode || 200;
258
- };
259
- TestResponse.prototype.setEncoding = function (s) {
260
- this.encoding = s;
261
- };
262
- TestResponse.prototype.on = function (event, cb) {
263
- this.events[event] = cb;
264
- };
265
- var transportFactory = function (error, response, assertions) {
266
- return function (options) {
267
- return new TestTransport(options, error, response, assertions);
268
- };
269
- };