Skip to content

Commit 973bdea

Browse files
authored
Eliminate runtime package.json imports and reorganize defaults (#1246)
1 parent 68ca35f commit 973bdea

File tree

15 files changed

+206
-202
lines changed

15 files changed

+206
-202
lines changed

defaults.cjs

Lines changed: 0 additions & 29 deletions
This file was deleted.

karma.conf.cjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
const path = require('path');
22
const webpack = require('webpack');
3-
const defaults = require('./defaults.cjs');
4-
5-
const defaultsPlugin = new webpack.DefinePlugin(defaults);
63

74
module.exports = function (config) {
85
config.set({
@@ -60,7 +57,6 @@ module.exports = function (config) {
6057
forceJSONP: true,
6158

6259
webpack: {
63-
plugins: [defaultsPlugin],
6460
devtool: 'inline-source-map',
6561
performance: { hints: false },
6662
module: {

package.json

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -100,63 +100,6 @@
100100
"cdn": {
101101
"host": "cdn.rollbar.com"
102102
},
103-
"defaults": {
104-
"endpoint": "api.rollbar.com/api/1/item/",
105-
"server": {
106-
"scrubHeaders": [
107-
"authorization",
108-
"www-authorization",
109-
"http_authorization",
110-
"omniauth.auth",
111-
"cookie",
112-
"oauth-access-token",
113-
"x-access-token",
114-
"x_csrf_token",
115-
"http_x_csrf_token",
116-
"x-csrf-token"
117-
],
118-
"scrubFields": [
119-
"pw",
120-
"pass",
121-
"passwd",
122-
"password",
123-
"password_confirmation",
124-
"passwordConfirmation",
125-
"confirm_password",
126-
"confirmPassword",
127-
"secret",
128-
"secret_token",
129-
"secretToken",
130-
"secret_key",
131-
"secretKey",
132-
"api_key",
133-
"access_token",
134-
"accessToken",
135-
"authenticity_token",
136-
"oauth_token",
137-
"token",
138-
"user_session_secret",
139-
"request.session.csrf",
140-
"request.session._csrf",
141-
"request.params._csrf",
142-
"request.cookie",
143-
"request.cookies"
144-
]
145-
},
146-
"reactNative": {
147-
"rewriteFilenamePatterns": [
148-
"^.*/[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/[^/]*.app/(.*)$",
149-
"^.*/[0-9A-Fa-f]{64}/codepush_ios/(.*)$",
150-
"^.*/[0-9A-Fa-f]{64}/codepush_android/(.*)$",
151-
"^.*/[0-9A-Fa-f]{64}/CodePush/(.*)$"
152-
]
153-
},
154-
"logLevel": "debug",
155-
"reportLevel": "debug",
156-
"uncaughtErrorLevel": "error",
157-
"maxItems": 0,
158-
"itemsPerMin": 60
159-
},
160103
"plugins": {
161104
"jquery": {
162105
"version": "0.0.8"

src/browser/bundles/rollbar.snippet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/* global __DEFAULT_ROLLBARJS_URL__:false */
21
/* global _rollbarConfig:true */
32

43
import * as Shim from '../shim.js';
54
import snippetCallback from '../snippet_callback.js';
5+
import { defaultRollbarJsUrl } from '../defaults.js';
66

77
_rollbarConfig = _rollbarConfig || {};
8-
_rollbarConfig.rollbarJsUrl = _rollbarConfig.rollbarJsUrl || __DEFAULT_ROLLBARJS_URL__;
8+
_rollbarConfig.rollbarJsUrl = _rollbarConfig.rollbarJsUrl || defaultRollbarJsUrl;
99
_rollbarConfig.async = _rollbarConfig.async === undefined || _rollbarConfig.async;
1010

1111
var shim = Shim.setupShim(window, _rollbarConfig);

src/browser/core.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -616,16 +616,16 @@ function _gWindow() {
616616
);
617617
}
618618

619-
import defaults from '../defaults.js';
620-
import scrubFields from './defaults/scrubFields.js';
619+
import { version, logLevel, reportLevel, uncaughtErrorLevel, endpoint } from '../defaults.js';
620+
import browserDefaults from './defaults.js';
621621

622622
var defaultOptions = {
623-
version: defaults.version,
624-
scrubFields: scrubFields.scrubFields,
625-
logLevel: defaults.logLevel,
626-
reportLevel: defaults.reportLevel,
627-
uncaughtErrorLevel: defaults.uncaughtErrorLevel,
628-
endpoint: defaults.endpoint,
623+
version: version,
624+
scrubFields: browserDefaults.scrubFields,
625+
logLevel: logLevel,
626+
reportLevel: reportLevel,
627+
uncaughtErrorLevel: uncaughtErrorLevel,
628+
endpoint: endpoint,
629629
verbose: false,
630630
enabled: true,
631631
transmit: true,

src/browser/defaults.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Default browser options
3+
*/
4+
import { version, commonScrubFields } from '../defaults.js';
5+
6+
export const scrubFields = [
7+
...commonScrubFields,
8+
'cc-number',
9+
'card number',
10+
'cardnumber',
11+
'cardnum',
12+
'ccnum',
13+
'ccnumber',
14+
'cc num',
15+
'creditcardnumber',
16+
'credit card number',
17+
'newcreditcardnumber',
18+
'new credit card',
19+
'creditcardno',
20+
'credit card no',
21+
'card#',
22+
'card #',
23+
'cc-csc',
24+
'cvc',
25+
'cvc2',
26+
'cvv2',
27+
'ccv2',
28+
'security code',
29+
'card verification',
30+
'name on credit card',
31+
'name on card',
32+
'nameoncard',
33+
'cardholder',
34+
'card holder',
35+
'name des karteninhabers',
36+
'ccname',
37+
'card type',
38+
'cardtype',
39+
'cc type',
40+
'cctype',
41+
'payment type',
42+
'expiration date',
43+
'expirationdate',
44+
'expdate',
45+
'cc-exp',
46+
'ccmonth',
47+
'ccyear',
48+
];
49+
50+
// CDN configuration for the snippet
51+
export const cdnHost = 'cdn.rollbar.com';
52+
export const defaultRollbarJsUrl = `https://${cdnHost}/rollbarjs/refs/tags/v${version}/rollbar.min.js`;
53+
54+
export const jqueryPluginVersion = '0.0.8';
55+
56+
// For compatibility with existing code that expects default export with scrubFields property
57+
export default {
58+
scrubFields,
59+
};

src/browser/defaults/scrubFields.js

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/browser/plugins/jquery.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/* globals jQuery */
2-
/* globals __JQUERY_PLUGIN_VERSION__ */
2+
3+
import { jqueryPluginVersion } from '../defaults.js';
34

45
(function (jQuery, window, document) {
56
var rb = window.Rollbar;
67
if (!rb) {
78
return;
89
}
910

10-
var JQUERY_PLUGIN_VERSION = __JQUERY_PLUGIN_VERSION__;
11+
var JQUERY_PLUGIN_VERSION = jqueryPluginVersion;
1112

1213
rb.configure({
1314
payload: {

src/browser/replay/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Default options for the rrweb recorder
2+
* Default session replay recording options
33
* See https://github.com/rrweb-io/rrweb/blob/master/guide.md#options for details
44
*/
55
export default {

src/defaults.js

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,68 @@
1+
/**
2+
* Default options shared across platforms
3+
*/
4+
export const version = '3.0.0-alpha.3';
5+
export const endpoint = 'api.rollbar.com/api/1/item/';
6+
export const logLevel = 'debug';
7+
export const reportLevel = 'debug';
8+
export const uncaughtErrorLevel = 'error';
9+
export const maxItems = 0;
10+
export const itemsPerMin = 60;
11+
12+
export const commonScrubFields = [
13+
'pw',
14+
'pass',
15+
'passwd',
16+
'password',
17+
'secret',
18+
'confirm_password',
19+
'confirmPassword',
20+
'password_confirmation',
21+
'passwordConfirmation',
22+
'access_token',
23+
'accessToken',
24+
'X-Rollbar-Access-Token',
25+
'secret_key',
26+
'secretKey',
27+
'secretToken',
28+
];
29+
30+
export const apiScrubFields = [
31+
'api_key',
32+
'authenticity_token',
33+
'oauth_token',
34+
'token',
35+
'user_session_secret',
36+
];
37+
38+
export const requestScrubFields = [
39+
'request.session.csrf',
40+
'request.session._csrf',
41+
'request.params._csrf',
42+
'request.cookie',
43+
'request.cookies',
44+
];
45+
46+
export const commonScrubHeaders = [
47+
'authorization',
48+
'www-authorization',
49+
'http_authorization',
50+
'omniauth.auth',
51+
'cookie',
52+
'oauth-access-token',
53+
'x-access-token',
54+
'x_csrf_token',
55+
'http_x_csrf_token',
56+
'x-csrf-token',
57+
];
58+
59+
// For backward compatibility with default export
160
export default {
2-
version: '3.0.0-alpha.3',
3-
endpoint: 'api.rollbar.com/api/1/item/',
4-
logLevel: 'debug',
5-
reportLevel: 'debug',
6-
uncaughtErrorLevel: 'error',
7-
maxItems: 0,
8-
itemsPerMin: 60,
61+
version,
62+
endpoint,
63+
logLevel,
64+
reportLevel,
65+
uncaughtErrorLevel,
66+
maxItems,
67+
itemsPerMin,
968
};

0 commit comments

Comments
 (0)