Skip to content

Commit b7af8e1

Browse files
committed
Release v2.17.0
1 parent 086b30f commit b7af8e1

26 files changed

+526
-110
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rollbar.js
22

33

4-
[![Build Status](https://travis-ci.org/rollbar/rollbar.js.svg?branch=v2.16.2)](https://travis-ci.org/rollbar/rollbar.js)
4+
[![Build Status](https://travis-ci.org/rollbar/rollbar.js.svg?branch=v2.17.0)](https://travis-ci.org/rollbar/rollbar.js)
55
[![Code Quality: Javascript](https://img.shields.io/lgtm/grade/javascript/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/context:javascript)
66
[![Total Alerts](https://img.shields.io/lgtm/alerts/g/rollbar/rollbar.js.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/rollbar/rollbar.js/alerts)
77

dist/rollbar.js

+126-22
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,6 @@ function Rollbar(options, client) {
13331333
this.options._configuredOptions = options;
13341334
var api = new API(this.options, transport, urllib);
13351335
this.client = client || new Client(this.options, api, logger, 'browser');
1336-
13371336
var gWindow = _gWindow();
13381337
var gDocument = (typeof document != 'undefined') && document;
13391338
this.isChrome = gWindow.chrome && gWindow.chrome.runtime; // check .runtime to avoid Edge browsers
@@ -1841,7 +1840,7 @@ function _gWindow() {
18411840
/* global __DEFAULT_ENDPOINT__:false */
18421841

18431842
var defaultOptions = {
1844-
version: "2.16.2",
1843+
version: "2.17.0",
18451844
scrubFields: ["pw","pass","passwd","password","secret","confirm_password","confirmPassword","password_confirmation","passwordConfirmation","access_token","accessToken","X-Rollbar-Access-Token","secret_key","secretKey","secretToken","cc-number","card number","cardnumber","cardnum","ccnum","ccnumber","cc num","creditcardnumber","credit card number","newcreditcardnumber","new credit card","creditcardno","credit card no","card#","card #","cc-csc","cvc","cvc2","cvv2","ccv2","security code","card verification","name on credit card","name on card","nameoncard","cardholder","card holder","name des karteninhabers","ccname","card type","cardtype","cc type","cctype","payment type","expiration date","expirationdate","expdate","cc-exp","ccmonth","ccyear"],
18461845
logLevel: "debug",
18471846
reportLevel: "debug",
@@ -1888,6 +1887,18 @@ function Rollbar(options, api, logger, platform) {
18881887
Rollbar.rateLimiter.setPlatformOptions(platform, this.options);
18891888
this.api = api;
18901889
this.queue = new Queue(Rollbar.rateLimiter, api, logger, this.options);
1890+
1891+
// This must happen before the Notifier is created
1892+
var tracer = this.options.tracer || null;
1893+
if (validateTracer(tracer)) {
1894+
this.tracer = tracer;
1895+
// set to a string for api response serialization
1896+
this.options.tracer = 'opentracing-tracer-enabled';
1897+
this.options._configuredOptions.tracer = 'opentracing-tracer-enabled';
1898+
} else {
1899+
this.tracer = null;
1900+
}
1901+
18911902
this.notifier = new Notifier(this.queue, this.options);
18921903
this.telemeter = new Telemeter(this.options);
18931904
setStackTraceLimit(options);
@@ -1902,81 +1913,99 @@ var defaultOptions = {
19021913

19031914
Rollbar.rateLimiter = new RateLimiter(defaultOptions);
19041915

1905-
Rollbar.prototype.global = function(options) {
1916+
Rollbar.prototype.global = function (options) {
19061917
Rollbar.rateLimiter.configureGlobal(options);
19071918
return this;
19081919
};
19091920

1910-
Rollbar.prototype.configure = function(options, payloadData) {
1921+
Rollbar.prototype.configure = function (options, payloadData) {
19111922
var oldOptions = this.options;
19121923
var payload = {};
19131924
if (payloadData) {
1914-
payload = {payload: payloadData};
1925+
payload = { payload: payloadData };
19151926
}
1927+
19161928
this.options = _.merge(oldOptions, options, payload);
1929+
1930+
// This must happen before the Notifier is configured
1931+
var tracer = this.options.tracer || null;
1932+
if (validateTracer(tracer)) {
1933+
this.tracer = tracer;
1934+
// set to a string for api response serialization
1935+
this.options.tracer = 'opentracing-tracer-enabled';
1936+
this.options._configuredOptions.tracer = 'opentracing-tracer-enabled';
1937+
} else {
1938+
this.tracer = null;
1939+
}
1940+
19171941
this.notifier && this.notifier.configure(this.options);
19181942
this.telemeter && this.telemeter.configure(this.options);
19191943
setStackTraceLimit(options);
19201944
this.global(this.options);
1945+
1946+
if (validateTracer(options.tracer)) {
1947+
this.tracer = options.tracer
1948+
}
1949+
19211950
return this;
19221951
};
19231952

1924-
Rollbar.prototype.log = function(item) {
1953+
Rollbar.prototype.log = function (item) {
19251954
var level = this._defaultLogLevel();
19261955
return this._log(level, item);
19271956
};
19281957

1929-
Rollbar.prototype.debug = function(item) {
1958+
Rollbar.prototype.debug = function (item) {
19301959
this._log('debug', item);
19311960
};
19321961

1933-
Rollbar.prototype.info = function(item) {
1962+
Rollbar.prototype.info = function (item) {
19341963
this._log('info', item);
19351964
};
19361965

1937-
Rollbar.prototype.warn = function(item) {
1966+
Rollbar.prototype.warn = function (item) {
19381967
this._log('warning', item);
19391968
};
19401969

1941-
Rollbar.prototype.warning = function(item) {
1970+
Rollbar.prototype.warning = function (item) {
19421971
this._log('warning', item);
19431972
};
19441973

1945-
Rollbar.prototype.error = function(item) {
1974+
Rollbar.prototype.error = function (item) {
19461975
this._log('error', item);
19471976
};
19481977

1949-
Rollbar.prototype.critical = function(item) {
1978+
Rollbar.prototype.critical = function (item) {
19501979
this._log('critical', item);
19511980
};
19521981

1953-
Rollbar.prototype.wait = function(callback) {
1982+
Rollbar.prototype.wait = function (callback) {
19541983
this.queue.wait(callback);
19551984
};
19561985

1957-
Rollbar.prototype.captureEvent = function(type, metadata, level) {
1986+
Rollbar.prototype.captureEvent = function (type, metadata, level) {
19581987
return this.telemeter.captureEvent(type, metadata, level);
19591988
};
19601989

1961-
Rollbar.prototype.captureDomContentLoaded = function(ts) {
1990+
Rollbar.prototype.captureDomContentLoaded = function (ts) {
19621991
return this.telemeter.captureDomContentLoaded(ts);
19631992
};
19641993

1965-
Rollbar.prototype.captureLoad = function(ts) {
1994+
Rollbar.prototype.captureLoad = function (ts) {
19661995
return this.telemeter.captureLoad(ts);
19671996
};
19681997

1969-
Rollbar.prototype.buildJsonPayload = function(item) {
1998+
Rollbar.prototype.buildJsonPayload = function (item) {
19701999
return this.api.buildJsonPayload(item);
19712000
};
19722001

1973-
Rollbar.prototype.sendJsonPayload = function(jsonPayload) {
2002+
Rollbar.prototype.sendJsonPayload = function (jsonPayload) {
19742003
this.api.postJsonPayload(jsonPayload);
19752004
};
19762005

19772006
/* Internal */
19782007

1979-
Rollbar.prototype._log = function(defaultLevel, item) {
2008+
Rollbar.prototype._log = function (defaultLevel, item) {
19802009
var callback;
19812010
if (item.callback) {
19822011
callback = item.callback;
@@ -1991,6 +2020,7 @@ Rollbar.prototype._log = function(defaultLevel, item) {
19912020
return;
19922021
}
19932022
try {
2023+
this._addTracingInfo(item);
19942024
item.level = item.level || defaultLevel;
19952025
this.telemeter._captureRollbarItem(item);
19962026
item.telemetryEvents = this.telemeter.copyEvents();
@@ -2000,11 +2030,11 @@ Rollbar.prototype._log = function(defaultLevel, item) {
20002030
}
20012031
};
20022032

2003-
Rollbar.prototype._defaultLogLevel = function() {
2033+
Rollbar.prototype._defaultLogLevel = function () {
20042034
return this.options.logLevel || 'debug';
20052035
};
20062036

2007-
Rollbar.prototype._sameAsLastError = function(item) {
2037+
Rollbar.prototype._sameAsLastError = function (item) {
20082038
if (!item._isUncaught) {
20092039
return false;
20102040
}
@@ -2017,6 +2047,34 @@ Rollbar.prototype._sameAsLastError = function(item) {
20172047
return false;
20182048
};
20192049

2050+
Rollbar.prototype._addTracingInfo = function (item) {
2051+
// Tracer validation occurs in the constructor
2052+
// or in the Rollbar.prototype.configure methods
2053+
if (this.tracer) {
2054+
// add rollbar occurrence uuid to span
2055+
var span = this.tracer.scope().active();
2056+
2057+
if (validateSpan(span)) {
2058+
span.setTag('rollbar.error_uuid', item.uuid);
2059+
span.setTag('rollbar.has_error', true);
2060+
2061+
// add span ID & trace ID to occurrence
2062+
var opentracingSpanId = span.context().toSpanId();
2063+
var opentracingTraceId = span.context().toTraceId();
2064+
2065+
if (item.custom) {
2066+
item.custom.opentracing_span_id = opentracingSpanId;
2067+
item.custom.opentracing_trace_id = opentracingTraceId;
2068+
} else {
2069+
item.custom = {
2070+
opentracing_span_id: opentracingSpanId,
2071+
opentracing_trace_id: opentracingTraceId
2072+
};
2073+
}
2074+
}
2075+
}
2076+
}
2077+
20202078
function generateItemHash(item) {
20212079
var message = item.message || '';
20222080
var stack = (item.err || {}).stack || String(item.err);
@@ -2032,6 +2090,51 @@ function setStackTraceLimit(options) {
20322090
}
20332091
}
20342092

2093+
/**
2094+
* Validate the Tracer object provided to the Client
2095+
* is valid for our Opentracing use case.
2096+
* @param {opentracer.Tracer} tracer
2097+
*/
2098+
function validateTracer(tracer) {
2099+
if (!tracer) {
2100+
return false;
2101+
}
2102+
2103+
if (!tracer.scope || typeof tracer.scope !== 'function') {
2104+
return false;
2105+
}
2106+
2107+
const scope = tracer.scope();
2108+
2109+
if (!scope || !scope.active || typeof scope.active !== 'function') {
2110+
return false;
2111+
}
2112+
2113+
return true;
2114+
}
2115+
2116+
/**
2117+
* Validate the Span object provided
2118+
* @param {opentracer.Span} span
2119+
*/
2120+
function validateSpan(span) {
2121+
if (!span || !span.context || typeof span.context !== 'function') {
2122+
return false;
2123+
}
2124+
2125+
const spanContext = span.context();
2126+
2127+
if (!spanContext
2128+
|| !spanContext.toSpanId
2129+
|| !spanContext.toTraceId
2130+
|| typeof spanContext.toSpanId !== 'function'
2131+
|| typeof spanContext.toTraceId !== 'function') {
2132+
return false
2133+
}
2134+
2135+
return true;
2136+
}
2137+
20352138
module.exports = Rollbar;
20362139

20372140

@@ -4339,7 +4442,8 @@ function addBaseInfo(item, options, callback) {
43394442
notifier: {
43404443
name: 'rollbar-browser-js',
43414444
version: options.version
4342-
}
4445+
},
4446+
custom: item.custom
43434447
});
43444448
callback(null, item);
43454449
}

dist/rollbar.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rollbar.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rollbar.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)