@rollbar/react
Advanced tools
Comparing version 0.10.0 to 0.11.0
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Rollbar = global.Rollbar || {}, global.Rollbar.react = {}), global.Rollbar, global.React, global.PropTypes)); | ||
}(this, (function (exports, Rollbar, React, PropTypes) { 'use strict'; | ||
})(this, (function (exports, Rollbar, React, PropTypes) { 'use strict'; | ||
@@ -14,18 +14,38 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
enumerableOnly && (symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
})), keys.push.apply(keys, symbols); | ||
} | ||
return _typeof(obj); | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = null != arguments[i] ? arguments[i] : {}; | ||
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { | ||
return typeof obj; | ||
} : function (obj) { | ||
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}, _typeof(obj); | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
@@ -50,2 +70,5 @@ if (!(instance instanceof Constructor)) { | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
@@ -69,36 +92,2 @@ } | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
} | ||
return target; | ||
} | ||
function _inherits(subClass, superClass) { | ||
@@ -116,2 +105,5 @@ if (typeof superClass !== "function" && superClass !== null) { | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
@@ -160,2 +152,4 @@ } | ||
return call; | ||
} else if (call !== void 0) { | ||
throw new TypeError("Derived constructors may only return object or undefined"); | ||
} | ||
@@ -203,3 +197,5 @@ | ||
} | ||
throw new Error(prefix + ": " + (message || '')); | ||
var provided = typeof message === 'function' ? message() : message; | ||
var value = provided ? prefix + ": " + provided : prefix; | ||
throw new Error(value); | ||
} | ||
@@ -212,3 +208,3 @@ | ||
invariant(rollbar instanceof Rollbar__default['default'], 'historyContext must have an instance of Rollbar'); | ||
invariant(rollbar instanceof Rollbar__default["default"], 'historyContext must have an instance of Rollbar'); | ||
invariant(formatter == null || typeof formatter === 'function', "formatter option must be a function, received ".concat(_typeof(formatter), " instead")); | ||
@@ -257,3 +253,8 @@ invariant(filter == null || typeof filter === 'function', "filter option must be a function, received ".concat(_typeof(filter), " instead")); // v4 of history.listen callback signature is (location, action) | ||
} | ||
function isRollbarInstance(instance) { | ||
var _instance$options; | ||
return !!(instance !== null && instance !== void 0 && (_instance$options = instance.options) !== null && _instance$options !== void 0 && _instance$options.accessToken); | ||
} | ||
var Context = /*#__PURE__*/React.createContext(); | ||
@@ -282,5 +283,5 @@ Context.displayName = 'Rollbar'; | ||
_this$props$Rollbar = _this$props.Rollbar, | ||
ctor = _this$props$Rollbar === void 0 ? Rollbar__default['default'] : _this$props$Rollbar, | ||
ctor = _this$props$Rollbar === void 0 ? Rollbar__default["default"] : _this$props$Rollbar, | ||
instance = _this$props.instance; | ||
invariant(!instance || instance instanceof Rollbar__default['default'], 'providing `instance` must be of type Rollbar'); | ||
invariant(!instance || isRollbarInstance(instance), '`instance` must be a configured instance of Rollbar'); | ||
var options = typeof config === 'function' ? config() : config; | ||
@@ -306,7 +307,7 @@ var rollbar = instance || new ctor(options); // TODO: use isUncaught to filter if this is 2nd Provider added | ||
_this$props2$Rollbar = _this$props2.Rollbar, | ||
ctor = _this$props2$Rollbar === void 0 ? Rollbar__default['default'] : _this$props2$Rollbar; | ||
ctor = _this$props2$Rollbar === void 0 ? Rollbar__default["default"] : _this$props2$Rollbar; | ||
var _this$state = this.state, | ||
rollbar = _this$state.rollbar, | ||
options = _this$state.options; | ||
return /*#__PURE__*/React__default['default'].createElement(Context.Provider, { | ||
return /*#__PURE__*/React__default["default"].createElement(Context.Provider, { | ||
value: (_ref = {}, _defineProperty(_ref, RollbarInstance, rollbar), _defineProperty(_ref, BaseOptions, options), _defineProperty(_ref, RollbarCtor, ctor), _ref) | ||
@@ -321,3 +322,3 @@ }, children); | ||
_defineProperty(Provider, "propTypes", { | ||
Rollbar: PropTypes__default['default'].func, | ||
Rollbar: PropTypes__default["default"].func, | ||
config: function config(props, propName, componentName) { | ||
@@ -343,4 +344,4 @@ if (!props.config && !props.instance) { | ||
if (props.instance && !(props.instance instanceof Rollbar__default['default'])) { | ||
return new Error("".concat(propName, " must be an instance of Rollbar")); | ||
if (props.instance && !isRollbarInstance(props.instance)) { | ||
return new Error("".concat(propName, " must be a configured instance of Rollbar")); | ||
} | ||
@@ -415,3 +416,3 @@ } | ||
return /*#__PURE__*/React__default['default'].createElement(FallbackUI, { | ||
return /*#__PURE__*/React__default["default"].createElement(FallbackUI, { | ||
error: error, | ||
@@ -437,7 +438,7 @@ resetError: this.resetError | ||
_defineProperty(ErrorBoundary, "propTypes", { | ||
fallbackUI: PropTypes__default['default'].oneOfType([PropTypes__default['default'].node, PropTypes__default['default'].func]), | ||
errorMessage: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].func]), | ||
extra: PropTypes__default['default'].oneOfType([PropTypes__default['default'].object, PropTypes__default['default'].func]), | ||
level: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].func]), | ||
callback: PropTypes__default['default'].func | ||
fallbackUI: PropTypes__default["default"].oneOfType([PropTypes__default["default"].node, PropTypes__default["default"].func]), | ||
errorMessage: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]), | ||
extra: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].func]), | ||
level: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]), | ||
callback: PropTypes__default["default"].func | ||
}); | ||
@@ -535,4 +536,4 @@ | ||
_defineProperty(RollbarContext, "propTypes", { | ||
context: PropTypes__default['default'].string.isRequired, | ||
onRender: PropTypes__default['default'].bool | ||
context: PropTypes__default["default"].string.isRequired, | ||
onRender: PropTypes__default["default"].bool | ||
}); | ||
@@ -600,2 +601,3 @@ | ||
exports.Context = Context; | ||
exports.ErrorBoundary = ErrorBoundary; | ||
@@ -609,2 +611,3 @@ exports.LEVEL_CRITICAL = LEVEL_CRITICAL; | ||
exports.RollbarContext = RollbarContext; | ||
exports.getRollbarFromContext = getRollbarFromContext; | ||
exports.historyContext = historyContext; | ||
@@ -620,3 +623,3 @@ exports.isValidLevel = isValidLevel; | ||
}))); | ||
})); | ||
//# sourceMappingURL=browser.umd.js.map |
@@ -1,2 +0,2 @@ | ||
import { _ as _defineProperty } from './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import { _ as _defineProperty } from './_rollupPluginBabelHelpers-b1794394.js'; | ||
@@ -12,4 +12,3 @@ var _LEVEL_DEBUG$LEVEL_IN; | ||
export default constants; | ||
export { LEVEL_CRITICAL, LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO, LEVEL_WARN }; | ||
export { LEVEL_CRITICAL, LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO, LEVEL_WARN, constants as default }; | ||
//# sourceMappingURL=constant.js.map |
@@ -1,8 +0,7 @@ | ||
import { b as _inherits, c as _createSuper, e as _classCallCheck, _ as _defineProperty, f as _assertThisInitialized, g as _objectSpread2, d as _createClass } from './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import { _ as _defineProperty, b as _inherits, c as _createSuper, e as _classCallCheck, f as _assertThisInitialized, g as _objectSpread2, d as _createClass } from './_rollupPluginBabelHelpers-b1794394.js'; | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { i as invariant } from './tiny-invariant.esm-a43f84cc.js'; | ||
import { i as invariant } from './tiny-invariant.esm-c1395f98.js'; | ||
import { LEVEL_ERROR } from './constant.js'; | ||
import { Context, getRollbarFromContext } from './Provider.js'; | ||
import { i as isValidLevel, v as value } from './utils-b8accee6.js'; | ||
import { i as isValidLevel, C as Context, v as value, g as getRollbarFromContext } from './provider-49173b4f.js'; | ||
import 'rollbar'; | ||
@@ -9,0 +8,0 @@ |
@@ -1,4 +0,4 @@ | ||
import { a as _typeof } from './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import { a as _typeof } from './_rollupPluginBabelHelpers-b1794394.js'; | ||
import Rollbar from 'rollbar'; | ||
import { i as invariant } from './tiny-invariant.esm-a43f84cc.js'; | ||
import { i as invariant } from './tiny-invariant.esm-c1395f98.js'; | ||
@@ -5,0 +5,0 @@ function historyContext(rollbar) { |
export { LEVEL_CRITICAL, LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO, LEVEL_WARN } from './constant.js'; | ||
export { historyContext } from './historyContext.js'; | ||
export { Provider } from './Provider.js'; | ||
export { C as Context, P as Provider, g as getRollbarFromContext, i as isValidLevel } from './provider-49173b4f.js'; | ||
export { ErrorBoundary } from './ErrorBoundary.js'; | ||
export { RollbarContext } from './RollbarContext.js'; | ||
export { i as isValidLevel } from './utils-b8accee6.js'; | ||
export { useRollbar } from './useRollbar.js'; | ||
@@ -12,7 +11,7 @@ export { useRollbarConfiguration } from './useRollbarConfiguration.js'; | ||
export { useRollbarCaptureEvent } from './useRollbarCaptureEvent.js'; | ||
import './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import './_rollupPluginBabelHelpers-b1794394.js'; | ||
import 'rollbar'; | ||
import './tiny-invariant.esm-a43f84cc.js'; | ||
import './tiny-invariant.esm-c1395f98.js'; | ||
import 'react'; | ||
import 'prop-types'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,99 +0,8 @@ | ||
import { b as _inherits, c as _createSuper, d as _createClass, _ as _defineProperty, a as _typeof, e as _classCallCheck } from './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import React, { createContext, Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Rollbar from 'rollbar'; | ||
import { i as invariant } from './tiny-invariant.esm-a43f84cc.js'; | ||
var Context = /*#__PURE__*/createContext(); | ||
Context.displayName = 'Rollbar'; | ||
var RollbarInstance = Symbol('RollbarInstance'); | ||
var BaseOptions = Symbol('BaseOptions'); | ||
var RollbarCtor = Symbol('RollbarCtor'); | ||
function getRollbarFromContext(context) { | ||
var rollbar = context[RollbarInstance]; | ||
return rollbar; | ||
} | ||
function getRollbarConstructorFromContext(context) { | ||
var ctor = context[RollbarCtor]; | ||
return ctor; | ||
} | ||
var Provider = /*#__PURE__*/function (_Component) { | ||
_inherits(Provider, _Component); | ||
var _super = _createSuper(Provider); | ||
function Provider(props) { | ||
var _this; | ||
_classCallCheck(this, Provider); | ||
_this = _super.call(this, props); | ||
var _this$props = _this.props, | ||
config = _this$props.config, | ||
_this$props$Rollbar = _this$props.Rollbar, | ||
ctor = _this$props$Rollbar === void 0 ? Rollbar : _this$props$Rollbar, | ||
instance = _this$props.instance; | ||
invariant(!instance || instance instanceof Rollbar, 'providing `instance` must be of type Rollbar'); | ||
var options = typeof config === 'function' ? config() : config; | ||
var rollbar = instance || new ctor(options); // TODO: use isUncaught to filter if this is 2nd Provider added | ||
// unless customer wants that | ||
_this.state = { | ||
rollbar: rollbar, | ||
options: options | ||
}; | ||
return _this; | ||
} // componentDidUpdate() | ||
_createClass(Provider, [{ | ||
key: "render", | ||
value: function render() { | ||
var _ref; | ||
var _this$props2 = this.props, | ||
children = _this$props2.children, | ||
_this$props2$Rollbar = _this$props2.Rollbar, | ||
ctor = _this$props2$Rollbar === void 0 ? Rollbar : _this$props2$Rollbar; | ||
var _this$state = this.state, | ||
rollbar = _this$state.rollbar, | ||
options = _this$state.options; | ||
return /*#__PURE__*/React.createElement(Context.Provider, { | ||
value: (_ref = {}, _defineProperty(_ref, RollbarInstance, rollbar), _defineProperty(_ref, BaseOptions, options), _defineProperty(_ref, RollbarCtor, ctor), _ref) | ||
}, children); | ||
} | ||
}]); | ||
return Provider; | ||
}(Component); | ||
_defineProperty(Provider, "propTypes", { | ||
Rollbar: PropTypes.func, | ||
config: function config(props, propName, componentName) { | ||
if (!props.config && !props.instance) { | ||
return new Error("One of the required props 'config' or 'instance' must be set for ".concat(componentName, ".")); | ||
} | ||
if (props.config) { | ||
var configType = _typeof(props.config); | ||
if (configType === 'function' || configType === 'object' && !Array.isArray(configType)) { | ||
return; | ||
} | ||
return new Error("".concat(propName, " must be either an Object or a Function")); | ||
} | ||
}, | ||
instance: function instance(props, propName, componentName) { | ||
if (!props.config && !props.instance) { | ||
return new Error("One of the required props 'config' or 'instance' must be set for ".concat(componentName, ".")); | ||
} | ||
if (props.instance && !(props.instance instanceof Rollbar)) { | ||
return new Error("".concat(propName, " must be an instance of Rollbar")); | ||
} | ||
} | ||
}); | ||
export { Context, Provider, getRollbarConstructorFromContext, getRollbarFromContext }; | ||
import './_rollupPluginBabelHelpers-b1794394.js'; | ||
import 'react'; | ||
import 'prop-types'; | ||
import 'rollbar'; | ||
import './tiny-invariant.esm-c1395f98.js'; | ||
export { B as BaseOptions, C as Context, P as Provider, a as RollbarCtor, R as RollbarInstance, b as getRollbarConstructorFromContext, g as getRollbarFromContext } from './provider-49173b4f.js'; | ||
import './constant.js'; | ||
//# sourceMappingURL=Provider.js.map |
@@ -1,7 +0,8 @@ | ||
import { b as _inherits, c as _createSuper, e as _classCallCheck, _ as _defineProperty, f as _assertThisInitialized, d as _createClass } from './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import { _ as _defineProperty, b as _inherits, c as _createSuper, e as _classCallCheck, f as _assertThisInitialized, d as _createClass } from './_rollupPluginBabelHelpers-b1794394.js'; | ||
import { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { getRollbarFromContext, Context } from './Provider.js'; | ||
import { g as getRollbarFromContext, C as Context } from './provider-49173b4f.js'; | ||
import 'rollbar'; | ||
import './tiny-invariant.esm-a43f84cc.js'; | ||
import './tiny-invariant.esm-c1395f98.js'; | ||
import './constant.js'; | ||
@@ -8,0 +9,0 @@ var RollbarContext = /*#__PURE__*/function (_Component) { |
import { useContext } from 'react'; | ||
import { Context, getRollbarFromContext } from './Provider.js'; | ||
import './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import { C as Context, g as getRollbarFromContext } from './provider-49173b4f.js'; | ||
import './_rollupPluginBabelHelpers-b1794394.js'; | ||
import 'prop-types'; | ||
import 'rollbar'; | ||
import './tiny-invariant.esm-a43f84cc.js'; | ||
import './tiny-invariant.esm-c1395f98.js'; | ||
import './constant.js'; | ||
@@ -8,0 +9,0 @@ function useRollbar() { |
@@ -1,8 +0,7 @@ | ||
import { i as invariant } from './tiny-invariant.esm-a43f84cc.js'; | ||
import { i as invariant } from './tiny-invariant.esm-c1395f98.js'; | ||
import { LEVEL_INFO } from './constant.js'; | ||
import { useRollbar } from './useRollbar.js'; | ||
import { i as isValidLevel } from './utils-b8accee6.js'; | ||
import './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import { i as isValidLevel } from './provider-49173b4f.js'; | ||
import './_rollupPluginBabelHelpers-b1794394.js'; | ||
import 'react'; | ||
import './Provider.js'; | ||
import 'prop-types'; | ||
@@ -9,0 +8,0 @@ import 'rollbar'; |
import { useRollbar } from './useRollbar.js'; | ||
import 'react'; | ||
import './Provider.js'; | ||
import './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import './provider-49173b4f.js'; | ||
import './_rollupPluginBabelHelpers-b1794394.js'; | ||
import 'prop-types'; | ||
import 'rollbar'; | ||
import './tiny-invariant.esm-a43f84cc.js'; | ||
import './tiny-invariant.esm-c1395f98.js'; | ||
import './constant.js'; | ||
@@ -9,0 +10,0 @@ function useRollbarConfiguration(config) { |
@@ -1,8 +0,9 @@ | ||
import { i as invariant } from './tiny-invariant.esm-a43f84cc.js'; | ||
import { i as invariant } from './tiny-invariant.esm-c1395f98.js'; | ||
import { useLayoutEffect, useEffect } from 'react'; | ||
import { useRollbar } from './useRollbar.js'; | ||
import './Provider.js'; | ||
import './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import './provider-49173b4f.js'; | ||
import './_rollupPluginBabelHelpers-b1794394.js'; | ||
import 'prop-types'; | ||
import 'rollbar'; | ||
import './constant.js'; | ||
@@ -9,0 +10,0 @@ // export function useRollbarContext(context) { |
import { useRollbarConfiguration } from './useRollbarConfiguration.js'; | ||
import './useRollbar.js'; | ||
import 'react'; | ||
import './Provider.js'; | ||
import './_rollupPluginBabelHelpers-e84dd01a.js'; | ||
import './provider-49173b4f.js'; | ||
import './_rollupPluginBabelHelpers-b1794394.js'; | ||
import 'prop-types'; | ||
import 'rollbar'; | ||
import './tiny-invariant.esm-a43f84cc.js'; | ||
import './tiny-invariant.esm-c1395f98.js'; | ||
import './constant.js'; | ||
@@ -10,0 +11,0 @@ function useRollbarPerson(person) { |
@@ -1,3 +0,4 @@ | ||
import { Component, ReactNode } from "react"; | ||
import { Component, Context as ReactContext, ReactNode } from "react"; | ||
import Rollbar, { Callback, Configuration } from "rollbar"; | ||
import { RollbarInstance, BaseOptions, RollbarCtor } from "./src/provider"; | ||
@@ -56,2 +57,11 @@ export const LEVEL_DEBUG = "debug"; | ||
interface ContextInterface { | ||
[RollbarInstance]: Rollbar; | ||
[BaseOptions]: Configuration; | ||
[RollbarCtor]: new (options: Configuration) => Rollbar; | ||
} | ||
export const Context: ReactContext<ContextInterface>; | ||
export function getRollbarFromContext(context: Context): Rollbar; | ||
export function useRollbar(): Rollbar; | ||
@@ -58,0 +68,0 @@ export function useRollbarConfiguration(config: Rollbar.Configuration): void; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
@@ -22,3 +22,3 @@ var _LEVEL_DEBUG$LEVEL_IN; | ||
exports.LEVEL_WARN = LEVEL_WARN; | ||
exports.default = constants; | ||
exports["default"] = constants; | ||
//# sourceMappingURL=constant.js.map |
@@ -5,9 +5,8 @@ 'use strict'; | ||
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
var React = require('react'); | ||
var PropTypes = require('prop-types'); | ||
var tinyInvariant_esm = require('./tiny-invariant.esm-da746012.js'); | ||
var tinyInvariant_esm = require('./tiny-invariant.esm-50f7ea43.js'); | ||
var constant = require('./constant.js'); | ||
var Provider = require('./Provider.js'); | ||
var utils = require('./utils-5f898db1.js'); | ||
var Provider = require('./provider-d3de4196.js'); | ||
require('rollbar'); | ||
@@ -40,3 +39,3 @@ | ||
tinyInvariant_esm.invariant(utils.isValidLevel(props.level), "".concat(props.level, " is not a valid level setting for Rollbar")); | ||
tinyInvariant_esm.invariant(Provider.isValidLevel(props.level), "".concat(props.level, " is not a valid level setting for Rollbar")); | ||
_this.state = _rollupPluginBabelHelpers._objectSpread2({}, INITIAL_ERROR_STATE); | ||
@@ -54,7 +53,7 @@ return _this; | ||
callback = _this$props.callback; | ||
var custom = utils.value(extra, {}, error, info); | ||
var custom = Provider.value(extra, {}, error, info); | ||
var data = _rollupPluginBabelHelpers._objectSpread2(_rollupPluginBabelHelpers._objectSpread2({}, info), custom); | ||
var level = utils.value(targetLevel, constant.LEVEL_ERROR, error, info); | ||
var level = Provider.value(targetLevel, constant.LEVEL_ERROR, error, info); | ||
var rollbar = Provider.getRollbarFromContext(this.context); | ||
@@ -65,3 +64,3 @@ | ||
} else { | ||
var logMessage = utils.value(errorMessage, '', error, info); | ||
var logMessage = Provider.value(errorMessage, '', error, info); | ||
rollbar[level](logMessage, error, data, callback); | ||
@@ -88,3 +87,3 @@ } | ||
return /*#__PURE__*/React__default['default'].createElement(FallbackUI, { | ||
return /*#__PURE__*/React__default["default"].createElement(FallbackUI, { | ||
error: error, | ||
@@ -110,7 +109,7 @@ resetError: this.resetError | ||
_rollupPluginBabelHelpers._defineProperty(ErrorBoundary, "propTypes", { | ||
fallbackUI: PropTypes__default['default'].oneOfType([PropTypes__default['default'].node, PropTypes__default['default'].func]), | ||
errorMessage: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].func]), | ||
extra: PropTypes__default['default'].oneOfType([PropTypes__default['default'].object, PropTypes__default['default'].func]), | ||
level: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].func]), | ||
callback: PropTypes__default['default'].func | ||
fallbackUI: PropTypes__default["default"].oneOfType([PropTypes__default["default"].node, PropTypes__default["default"].func]), | ||
errorMessage: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]), | ||
extra: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].func]), | ||
level: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]), | ||
callback: PropTypes__default["default"].func | ||
}); | ||
@@ -117,0 +116,0 @@ |
@@ -5,5 +5,5 @@ 'use strict'; | ||
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
var Rollbar = require('rollbar'); | ||
var tinyInvariant_esm = require('./tiny-invariant.esm-da746012.js'); | ||
var tinyInvariant_esm = require('./tiny-invariant.esm-50f7ea43.js'); | ||
@@ -19,3 +19,3 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
tinyInvariant_esm.invariant(rollbar instanceof Rollbar__default['default'], 'historyContext must have an instance of Rollbar'); | ||
tinyInvariant_esm.invariant(rollbar instanceof Rollbar__default["default"], 'historyContext must have an instance of Rollbar'); | ||
tinyInvariant_esm.invariant(formatter == null || typeof formatter === 'function', "formatter option must be a function, received ".concat(_rollupPluginBabelHelpers._typeof(formatter), " instead")); | ||
@@ -22,0 +22,0 @@ tinyInvariant_esm.invariant(filter == null || typeof filter === 'function', "filter option must be a function, received ".concat(_rollupPluginBabelHelpers._typeof(filter), " instead")); // v4 of history.listen callback signature is (location, action) |
@@ -7,6 +7,5 @@ 'use strict'; | ||
var historyContext = require('./historyContext.js'); | ||
var Provider = require('./Provider.js'); | ||
var Provider = require('./provider-d3de4196.js'); | ||
var ErrorBoundary = require('./ErrorBoundary.js'); | ||
var RollbarContext = require('./RollbarContext.js'); | ||
var utils = require('./utils-5f898db1.js'); | ||
var useRollbar = require('./useRollbar.js'); | ||
@@ -17,5 +16,5 @@ var useRollbarConfiguration = require('./useRollbarConfiguration.js'); | ||
var useRollbarCaptureEvent = require('./useRollbarCaptureEvent.js'); | ||
require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
require('rollbar'); | ||
require('./tiny-invariant.esm-da746012.js'); | ||
require('./tiny-invariant.esm-50f7ea43.js'); | ||
require('react'); | ||
@@ -32,6 +31,8 @@ require('prop-types'); | ||
exports.historyContext = historyContext.historyContext; | ||
exports.Context = Provider.Context; | ||
exports.Provider = Provider.Provider; | ||
exports.getRollbarFromContext = Provider.getRollbarFromContext; | ||
exports.isValidLevel = Provider.isValidLevel; | ||
exports.ErrorBoundary = ErrorBoundary.ErrorBoundary; | ||
exports.RollbarContext = RollbarContext.RollbarContext; | ||
exports.isValidLevel = utils.isValidLevel; | ||
exports.useRollbar = useRollbar.useRollbar; | ||
@@ -38,0 +39,0 @@ exports.useRollbarConfiguration = useRollbarConfiguration.useRollbarConfiguration; |
@@ -5,109 +5,19 @@ 'use strict'; | ||
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
var React = require('react'); | ||
var PropTypes = require('prop-types'); | ||
var Rollbar = require('rollbar'); | ||
var tinyInvariant_esm = require('./tiny-invariant.esm-da746012.js'); | ||
require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
require('react'); | ||
require('prop-types'); | ||
require('rollbar'); | ||
require('./tiny-invariant.esm-50f7ea43.js'); | ||
var Provider = require('./provider-d3de4196.js'); | ||
require('./constant.js'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes); | ||
var Rollbar__default = /*#__PURE__*/_interopDefaultLegacy(Rollbar); | ||
var Context = /*#__PURE__*/React.createContext(); | ||
Context.displayName = 'Rollbar'; | ||
var RollbarInstance = Symbol('RollbarInstance'); | ||
var BaseOptions = Symbol('BaseOptions'); | ||
var RollbarCtor = Symbol('RollbarCtor'); | ||
function getRollbarFromContext(context) { | ||
var rollbar = context[RollbarInstance]; | ||
return rollbar; | ||
} | ||
function getRollbarConstructorFromContext(context) { | ||
var ctor = context[RollbarCtor]; | ||
return ctor; | ||
} | ||
var Provider = /*#__PURE__*/function (_Component) { | ||
_rollupPluginBabelHelpers._inherits(Provider, _Component); | ||
var _super = _rollupPluginBabelHelpers._createSuper(Provider); | ||
function Provider(props) { | ||
var _this; | ||
_rollupPluginBabelHelpers._classCallCheck(this, Provider); | ||
_this = _super.call(this, props); | ||
var _this$props = _this.props, | ||
config = _this$props.config, | ||
_this$props$Rollbar = _this$props.Rollbar, | ||
ctor = _this$props$Rollbar === void 0 ? Rollbar__default['default'] : _this$props$Rollbar, | ||
instance = _this$props.instance; | ||
tinyInvariant_esm.invariant(!instance || instance instanceof Rollbar__default['default'], 'providing `instance` must be of type Rollbar'); | ||
var options = typeof config === 'function' ? config() : config; | ||
var rollbar = instance || new ctor(options); // TODO: use isUncaught to filter if this is 2nd Provider added | ||
// unless customer wants that | ||
_this.state = { | ||
rollbar: rollbar, | ||
options: options | ||
}; | ||
return _this; | ||
} // componentDidUpdate() | ||
_rollupPluginBabelHelpers._createClass(Provider, [{ | ||
key: "render", | ||
value: function render() { | ||
var _ref; | ||
var _this$props2 = this.props, | ||
children = _this$props2.children, | ||
_this$props2$Rollbar = _this$props2.Rollbar, | ||
ctor = _this$props2$Rollbar === void 0 ? Rollbar__default['default'] : _this$props2$Rollbar; | ||
var _this$state = this.state, | ||
rollbar = _this$state.rollbar, | ||
options = _this$state.options; | ||
return /*#__PURE__*/React__default['default'].createElement(Context.Provider, { | ||
value: (_ref = {}, _rollupPluginBabelHelpers._defineProperty(_ref, RollbarInstance, rollbar), _rollupPluginBabelHelpers._defineProperty(_ref, BaseOptions, options), _rollupPluginBabelHelpers._defineProperty(_ref, RollbarCtor, ctor), _ref) | ||
}, children); | ||
} | ||
}]); | ||
return Provider; | ||
}(React.Component); | ||
_rollupPluginBabelHelpers._defineProperty(Provider, "propTypes", { | ||
Rollbar: PropTypes__default['default'].func, | ||
config: function config(props, propName, componentName) { | ||
if (!props.config && !props.instance) { | ||
return new Error("One of the required props 'config' or 'instance' must be set for ".concat(componentName, ".")); | ||
} | ||
if (props.config) { | ||
var configType = _rollupPluginBabelHelpers._typeof(props.config); | ||
if (configType === 'function' || configType === 'object' && !Array.isArray(configType)) { | ||
return; | ||
} | ||
return new Error("".concat(propName, " must be either an Object or a Function")); | ||
} | ||
}, | ||
instance: function instance(props, propName, componentName) { | ||
if (!props.config && !props.instance) { | ||
return new Error("One of the required props 'config' or 'instance' must be set for ".concat(componentName, ".")); | ||
} | ||
if (props.instance && !(props.instance instanceof Rollbar__default['default'])) { | ||
return new Error("".concat(propName, " must be an instance of Rollbar")); | ||
} | ||
} | ||
}); | ||
exports.Context = Context; | ||
exports.Provider = Provider; | ||
exports.getRollbarConstructorFromContext = getRollbarConstructorFromContext; | ||
exports.getRollbarFromContext = getRollbarFromContext; | ||
exports.BaseOptions = Provider.BaseOptions; | ||
exports.Context = Provider.Context; | ||
exports.Provider = Provider.Provider; | ||
exports.RollbarCtor = Provider.RollbarCtor; | ||
exports.RollbarInstance = Provider.RollbarInstance; | ||
exports.getRollbarConstructorFromContext = Provider.getRollbarConstructorFromContext; | ||
exports.getRollbarFromContext = Provider.getRollbarFromContext; | ||
//# sourceMappingURL=Provider.js.map |
@@ -5,8 +5,9 @@ 'use strict'; | ||
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
var _rollupPluginBabelHelpers = require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
var React = require('react'); | ||
var PropTypes = require('prop-types'); | ||
var Provider = require('./Provider.js'); | ||
var Provider = require('./provider-d3de4196.js'); | ||
require('rollbar'); | ||
require('./tiny-invariant.esm-da746012.js'); | ||
require('./tiny-invariant.esm-50f7ea43.js'); | ||
require('./constant.js'); | ||
@@ -103,4 +104,4 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
_rollupPluginBabelHelpers._defineProperty(RollbarContext, "propTypes", { | ||
context: PropTypes__default['default'].string.isRequired, | ||
onRender: PropTypes__default['default'].bool | ||
context: PropTypes__default["default"].string.isRequired, | ||
onRender: PropTypes__default["default"].bool | ||
}); | ||
@@ -107,0 +108,0 @@ |
@@ -6,7 +6,8 @@ 'use strict'; | ||
var React = require('react'); | ||
var Provider = require('./Provider.js'); | ||
require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
var Provider = require('./provider-d3de4196.js'); | ||
require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
require('prop-types'); | ||
require('rollbar'); | ||
require('./tiny-invariant.esm-da746012.js'); | ||
require('./tiny-invariant.esm-50f7ea43.js'); | ||
require('./constant.js'); | ||
@@ -13,0 +14,0 @@ function useRollbar() { |
@@ -5,9 +5,8 @@ 'use strict'; | ||
var tinyInvariant_esm = require('./tiny-invariant.esm-da746012.js'); | ||
var tinyInvariant_esm = require('./tiny-invariant.esm-50f7ea43.js'); | ||
var constant = require('./constant.js'); | ||
var useRollbar = require('./useRollbar.js'); | ||
var utils = require('./utils-5f898db1.js'); | ||
require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
var Provider = require('./provider-d3de4196.js'); | ||
require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
require('react'); | ||
require('./Provider.js'); | ||
require('prop-types'); | ||
@@ -18,3 +17,3 @@ require('rollbar'); | ||
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : constant.LEVEL_INFO; | ||
tinyInvariant_esm.invariant(utils.isValidLevel(level), "".concat(level, " is not a valid level setting for Rollbar")); | ||
tinyInvariant_esm.invariant(Provider.isValidLevel(level), "".concat(level, " is not a valid level setting for Rollbar")); | ||
var rollbar = useRollbar.useRollbar(); | ||
@@ -21,0 +20,0 @@ useEffect(function () { |
@@ -7,7 +7,8 @@ 'use strict'; | ||
require('react'); | ||
require('./Provider.js'); | ||
require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
require('./provider-d3de4196.js'); | ||
require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
require('prop-types'); | ||
require('rollbar'); | ||
require('./tiny-invariant.esm-da746012.js'); | ||
require('./tiny-invariant.esm-50f7ea43.js'); | ||
require('./constant.js'); | ||
@@ -14,0 +15,0 @@ function useRollbarConfiguration(config) { |
@@ -5,9 +5,10 @@ 'use strict'; | ||
var tinyInvariant_esm = require('./tiny-invariant.esm-da746012.js'); | ||
var tinyInvariant_esm = require('./tiny-invariant.esm-50f7ea43.js'); | ||
var React = require('react'); | ||
var useRollbar = require('./useRollbar.js'); | ||
require('./Provider.js'); | ||
require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
require('./provider-d3de4196.js'); | ||
require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
require('prop-types'); | ||
require('rollbar'); | ||
require('./constant.js'); | ||
@@ -14,0 +15,0 @@ // export function useRollbarContext(context) { |
@@ -8,7 +8,8 @@ 'use strict'; | ||
require('react'); | ||
require('./Provider.js'); | ||
require('./_rollupPluginBabelHelpers-9a0ca35a.js'); | ||
require('./provider-d3de4196.js'); | ||
require('./_rollupPluginBabelHelpers-41b6ce9e.js'); | ||
require('prop-types'); | ||
require('rollbar'); | ||
require('./tiny-invariant.esm-da746012.js'); | ||
require('./tiny-invariant.esm-50f7ea43.js'); | ||
require('./constant.js'); | ||
@@ -15,0 +16,0 @@ function useRollbarPerson(person) { |
{ | ||
"name": "@rollbar/react", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "React features to enhance using Rollbar.js in React Applications", | ||
@@ -60,5 +60,5 @@ "main": "lib", | ||
"@rollup/plugin-node-resolve": "^11.2.1", | ||
"@testing-library/dom": "^7.30.3", | ||
"@testing-library/jest-dom": "^5.11.10", | ||
"@testing-library/react": "^11.2.6", | ||
"@testing-library/dom": "^7.31.2", | ||
"@testing-library/jest-dom": "^5.16.2", | ||
"@testing-library/react": "^11.2.7", | ||
"@testing-library/react-hooks": "^5.1.1", | ||
@@ -76,2 +76,4 @@ "babel-jest": "^26.6.3", | ||
"react": "^16.14.0", | ||
"react-dom": "^17.0.2", | ||
"regenerator-runtime": "^0.13.9", | ||
"rimraf": "^3.0.2", | ||
@@ -86,3 +88,11 @@ "rollbar": "^2.21.1", | ||
"rollbar": "^2.21.1" | ||
}, | ||
"jest": { | ||
"roots": [ | ||
"src/tests" | ||
], | ||
"setupFilesAfterEnv": [ | ||
"./src/tests/jest-setup.js" | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
166512
1834
33