@sentry/integrations
Advanced tools
Comparing version 6.2.1 to 6.2.2
@@ -73,3 +73,73 @@ (function (__window) { | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/** | ||
* Checks whether given value's type is one of a few Error or Error-like | ||
* {@link isError}. | ||
* | ||
* @param wat A value to be checked. | ||
* @returns A boolean representing the result. | ||
*/ | ||
function isError(wat) { | ||
switch (Object.prototype.toString.call(wat)) { | ||
case '[object Error]': | ||
return true; | ||
case '[object Exception]': | ||
return true; | ||
case '[object DOMException]': | ||
return true; | ||
default: | ||
return isInstanceOf(wat, Error); | ||
} | ||
} | ||
/** | ||
* Checks whether given value's type is a string | ||
* {@link isString}. | ||
* | ||
* @param wat A value to be checked. | ||
* @returns A boolean representing the result. | ||
*/ | ||
function isString(wat) { | ||
return Object.prototype.toString.call(wat) === '[object String]'; | ||
} | ||
/** | ||
* Checks whether given value's is a primitive (undefined, null, number, boolean, string, bigint, symbol) | ||
* {@link isPrimitive}. | ||
* | ||
* @param wat A value to be checked. | ||
* @returns A boolean representing the result. | ||
*/ | ||
function isPrimitive(wat) { | ||
return wat === null || (typeof wat !== 'object' && typeof wat !== 'function'); | ||
} | ||
/** | ||
* Checks whether given value's type is an object literal | ||
* {@link isPlainObject}. | ||
* | ||
* @param wat A value to be checked. | ||
* @returns A boolean representing the result. | ||
*/ | ||
function isPlainObject(wat) { | ||
return Object.prototype.toString.call(wat) === '[object Object]'; | ||
} | ||
/** | ||
* Checks whether given value's type is an Event instance | ||
* {@link isEvent}. | ||
* | ||
* @param wat A value to be checked. | ||
* @returns A boolean representing the result. | ||
*/ | ||
function isEvent(wat) { | ||
return typeof Event !== 'undefined' && isInstanceOf(wat, Event); | ||
} | ||
/** | ||
* Checks whether given value's type is an Element instance | ||
* {@link isElement}. | ||
* | ||
* @param wat A value to be checked. | ||
* @returns A boolean representing the result. | ||
*/ | ||
function isElement(wat) { | ||
return typeof Element !== 'undefined' && isInstanceOf(wat, Element); | ||
} | ||
/** | ||
* Checks whether given value has a then function. | ||
@@ -82,3 +152,109 @@ * @param wat A value to be checked. | ||
} | ||
/** | ||
* Checks whether given value's type is a SyntheticEvent | ||
* {@link isSyntheticEvent}. | ||
* | ||
* @param wat A value to be checked. | ||
* @returns A boolean representing the result. | ||
*/ | ||
function isSyntheticEvent(wat) { | ||
return isPlainObject(wat) && 'nativeEvent' in wat && 'preventDefault' in wat && 'stopPropagation' in wat; | ||
} | ||
/** | ||
* Checks whether given value's type is an instance of provided constructor. | ||
* {@link isInstanceOf}. | ||
* | ||
* @param wat A value to be checked. | ||
* @param base A constructor to be used in a check. | ||
* @returns A boolean representing the result. | ||
*/ | ||
function isInstanceOf(wat, base) { | ||
try { | ||
return wat instanceof base; | ||
} | ||
catch (_e) { | ||
return false; | ||
} | ||
} | ||
/** | ||
* Given a child DOM element, returns a query-selector statement describing that | ||
* and its ancestors | ||
* e.g. [HTMLElement] => body > div > input#foo.btn[name=baz] | ||
* @returns generated DOM path | ||
*/ | ||
function htmlTreeAsString(elem) { | ||
// try/catch both: | ||
// - accessing event.target (see getsentry/raven-js#838, #768) | ||
// - `htmlTreeAsString` because it's complex, and just accessing the DOM incorrectly | ||
// - can throw an exception in some circumstances. | ||
try { | ||
var currentElem = elem; | ||
var MAX_TRAVERSE_HEIGHT = 5; | ||
var MAX_OUTPUT_LEN = 80; | ||
var out = []; | ||
var height = 0; | ||
var len = 0; | ||
var separator = ' > '; | ||
var sepLength = separator.length; | ||
var nextStr = void 0; | ||
// eslint-disable-next-line no-plusplus | ||
while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) { | ||
nextStr = _htmlElementAsString(currentElem); | ||
// bail out if | ||
// - nextStr is the 'html' element | ||
// - the length of the string that would be created exceeds MAX_OUTPUT_LEN | ||
// (ignore this limit if we are on the first iteration) | ||
if (nextStr === 'html' || (height > 1 && len + out.length * sepLength + nextStr.length >= MAX_OUTPUT_LEN)) { | ||
break; | ||
} | ||
out.push(nextStr); | ||
len += nextStr.length; | ||
currentElem = currentElem.parentNode; | ||
} | ||
return out.reverse().join(separator); | ||
} | ||
catch (_oO) { | ||
return '<unknown>'; | ||
} | ||
} | ||
/** | ||
* Returns a simple, query-selector representation of a DOM element | ||
* e.g. [HTMLElement] => input#foo.btn[name=baz] | ||
* @returns generated DOM path | ||
*/ | ||
function _htmlElementAsString(el) { | ||
var elem = el; | ||
var out = []; | ||
var className; | ||
var classes; | ||
var key; | ||
var attr; | ||
var i; | ||
if (!elem || !elem.tagName) { | ||
return ''; | ||
} | ||
out.push(elem.tagName.toLowerCase()); | ||
if (elem.id) { | ||
out.push("#" + elem.id); | ||
} | ||
// eslint-disable-next-line prefer-const | ||
className = elem.className; | ||
if (className && isString(className)) { | ||
classes = className.split(/\s+/); | ||
for (i = 0; i < classes.length; i++) { | ||
out.push("." + classes[i]); | ||
} | ||
} | ||
var allowedAttrs = ['type', 'name', 'title', 'alt']; | ||
for (i = 0; i < allowedAttrs.length; i++) { | ||
key = allowedAttrs[i]; | ||
attr = elem.getAttribute(key); | ||
if (attr) { | ||
out.push("[" + key + "=\"" + attr + "\"]"); | ||
} | ||
} | ||
return out.join(''); | ||
} | ||
var setPrototypeOf = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties); | ||
@@ -284,2 +460,269 @@ /** | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
/** | ||
* Memo class used for decycle json objects. Uses WeakSet if available otherwise array. | ||
*/ | ||
var Memo = /** @class */ (function () { | ||
function Memo() { | ||
this._hasWeakSet = typeof WeakSet === 'function'; | ||
this._inner = this._hasWeakSet ? new WeakSet() : []; | ||
} | ||
/** | ||
* Sets obj to remember. | ||
* @param obj Object to remember | ||
*/ | ||
Memo.prototype.memoize = function (obj) { | ||
if (this._hasWeakSet) { | ||
if (this._inner.has(obj)) { | ||
return true; | ||
} | ||
this._inner.add(obj); | ||
return false; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/prefer-for-of | ||
for (var i = 0; i < this._inner.length; i++) { | ||
var value = this._inner[i]; | ||
if (value === obj) { | ||
return true; | ||
} | ||
} | ||
this._inner.push(obj); | ||
return false; | ||
}; | ||
/** | ||
* Removes object from internal storage. | ||
* @param obj Object to forget | ||
*/ | ||
Memo.prototype.unmemoize = function (obj) { | ||
if (this._hasWeakSet) { | ||
this._inner.delete(obj); | ||
} | ||
else { | ||
for (var i = 0; i < this._inner.length; i++) { | ||
if (this._inner[i] === obj) { | ||
this._inner.splice(i, 1); | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
return Memo; | ||
}()); | ||
var defaultFunctionName = '<anonymous>'; | ||
/** | ||
* Safely extract function name from itself | ||
*/ | ||
function getFunctionName(fn) { | ||
try { | ||
if (!fn || typeof fn !== 'function') { | ||
return defaultFunctionName; | ||
} | ||
return fn.name || defaultFunctionName; | ||
} | ||
catch (e) { | ||
// Just accessing custom props in some Selenium environments | ||
// can cause a "Permission denied" exception (see raven-js#495). | ||
return defaultFunctionName; | ||
} | ||
} | ||
/** | ||
* Transforms any object into an object literal with all its attributes | ||
* attached to it. | ||
* | ||
* @param value Initial source that we have to transform in order for it to be usable by the serializer | ||
*/ | ||
function getWalkSource(value) { | ||
if (isError(value)) { | ||
var error = value; | ||
var err = { | ||
message: error.message, | ||
name: error.name, | ||
stack: error.stack, | ||
}; | ||
for (var i in error) { | ||
if (Object.prototype.hasOwnProperty.call(error, i)) { | ||
err[i] = error[i]; | ||
} | ||
} | ||
return err; | ||
} | ||
if (isEvent(value)) { | ||
var event_1 = value; | ||
var source = {}; | ||
source.type = event_1.type; | ||
// Accessing event.target can throw (see getsentry/raven-js#838, #768) | ||
try { | ||
source.target = isElement(event_1.target) | ||
? htmlTreeAsString(event_1.target) | ||
: Object.prototype.toString.call(event_1.target); | ||
} | ||
catch (_oO) { | ||
source.target = '<unknown>'; | ||
} | ||
try { | ||
source.currentTarget = isElement(event_1.currentTarget) | ||
? htmlTreeAsString(event_1.currentTarget) | ||
: Object.prototype.toString.call(event_1.currentTarget); | ||
} | ||
catch (_oO) { | ||
source.currentTarget = '<unknown>'; | ||
} | ||
if (typeof CustomEvent !== 'undefined' && isInstanceOf(value, CustomEvent)) { | ||
source.detail = event_1.detail; | ||
} | ||
for (var i in event_1) { | ||
if (Object.prototype.hasOwnProperty.call(event_1, i)) { | ||
source[i] = event_1; | ||
} | ||
} | ||
return source; | ||
} | ||
return value; | ||
} | ||
/** | ||
* Transform any non-primitive, BigInt, or Symbol-type value into a string. Acts as a no-op on strings, numbers, | ||
* booleans, null, and undefined. | ||
* | ||
* @param value The value to stringify | ||
* @returns For non-primitive, BigInt, and Symbol-type values, a string denoting the value's type, type and value, or | ||
* type and `description` property, respectively. For non-BigInt, non-Symbol primitives, returns the original value, | ||
* unchanged. | ||
*/ | ||
function serializeValue(value) { | ||
var type = Object.prototype.toString.call(value); | ||
// Node.js REPL notation | ||
if (typeof value === 'string') { | ||
return value; | ||
} | ||
if (type === '[object Object]') { | ||
return '[Object]'; | ||
} | ||
if (type === '[object Array]') { | ||
return '[Array]'; | ||
} | ||
var normalized = normalizeValue(value); | ||
return isPrimitive(normalized) ? normalized : type; | ||
} | ||
/** | ||
* normalizeValue() | ||
* | ||
* Takes unserializable input and make it serializable friendly | ||
* | ||
* - translates undefined/NaN values to "[undefined]"/"[NaN]" respectively, | ||
* - serializes Error objects | ||
* - filter global objects | ||
*/ | ||
function normalizeValue(value, key) { | ||
if (key === 'domain' && value && typeof value === 'object' && value._events) { | ||
return '[Domain]'; | ||
} | ||
if (key === 'domainEmitter') { | ||
return '[DomainEmitter]'; | ||
} | ||
if (typeof global !== 'undefined' && value === global) { | ||
return '[Global]'; | ||
} | ||
if (typeof window !== 'undefined' && value === window) { | ||
return '[Window]'; | ||
} | ||
if (typeof document !== 'undefined' && value === document) { | ||
return '[Document]'; | ||
} | ||
// React's SyntheticEvent thingy | ||
if (isSyntheticEvent(value)) { | ||
return '[SyntheticEvent]'; | ||
} | ||
if (typeof value === 'number' && value !== value) { | ||
return '[NaN]'; | ||
} | ||
if (value === void 0) { | ||
return '[undefined]'; | ||
} | ||
if (typeof value === 'function') { | ||
return "[Function: " + getFunctionName(value) + "]"; | ||
} | ||
// symbols and bigints are considered primitives by TS, but aren't natively JSON-serilaizable | ||
if (typeof value === 'symbol') { | ||
return "[" + String(value) + "]"; | ||
} | ||
if (typeof value === 'bigint') { | ||
return "[BigInt: " + String(value) + "]"; | ||
} | ||
return value; | ||
} | ||
/** | ||
* Walks an object to perform a normalization on it | ||
* | ||
* @param key of object that's walked in current iteration | ||
* @param value object to be walked | ||
* @param depth Optional number indicating how deep should walking be performed | ||
* @param memo Optional Memo class handling decycling | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
function walk(key, value, depth, memo) { | ||
if (depth === void 0) { depth = +Infinity; } | ||
if (memo === void 0) { memo = new Memo(); } | ||
// If we reach the maximum depth, serialize whatever has left | ||
if (depth === 0) { | ||
return serializeValue(value); | ||
} | ||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ | ||
// If value implements `toJSON` method, call it and return early | ||
if (value !== null && value !== undefined && typeof value.toJSON === 'function') { | ||
return value.toJSON(); | ||
} | ||
/* eslint-enable @typescript-eslint/no-unsafe-member-access */ | ||
// If normalized value is a primitive, there are no branches left to walk, so we can just bail out, as theres no point in going down that branch any further | ||
var normalized = normalizeValue(value, key); | ||
if (isPrimitive(normalized)) { | ||
return normalized; | ||
} | ||
// Create source that we will use for next itterations, either objectified error object (Error type with extracted keys:value pairs) or the input itself | ||
var source = getWalkSource(value); | ||
// Create an accumulator that will act as a parent for all future itterations of that branch | ||
var acc = Array.isArray(value) ? [] : {}; | ||
// If we already walked that branch, bail out, as it's circular reference | ||
if (memo.memoize(value)) { | ||
return '[Circular ~]'; | ||
} | ||
// Walk all keys of the source | ||
for (var innerKey in source) { | ||
// Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration. | ||
if (!Object.prototype.hasOwnProperty.call(source, innerKey)) { | ||
continue; | ||
} | ||
// Recursively walk through all the child nodes | ||
acc[innerKey] = walk(innerKey, source[innerKey], depth - 1, memo); | ||
} | ||
// Once walked through all the branches, remove the parent from memo storage | ||
memo.unmemoize(value); | ||
// Return accumulated values | ||
return acc; | ||
} | ||
/** | ||
* normalize() | ||
* | ||
* - Creates a copy to prevent original input mutation | ||
* - Skip non-enumerablers | ||
* - Calls `toJSON` if implemented | ||
* - Removes circular references | ||
* - Translates non-serializeable values (undefined/NaN/Functions) to serializable format | ||
* - Translates known global objects/Classes to a string representations | ||
* - Takes care of Error objects serialization | ||
* - Optionally limit depth of final output | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
function normalize(input, depth) { | ||
try { | ||
return JSON.parse(JSON.stringify(input, function (key, value) { return walk(key, value, depth); })); | ||
} | ||
catch (_oO) { | ||
return '**non-serializable**'; | ||
} | ||
} | ||
var global$2 = getGlobalObject(); | ||
@@ -654,3 +1097,3 @@ | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.offlineEventStore.setItem(uuid4(), event)]; | ||
return [2 /*return*/, this.offlineEventStore.setItem(uuid4(), normalize(event))]; | ||
}); | ||
@@ -657,0 +1100,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
!function(n){var t={};Object.defineProperty(t,"__esModule",{value:!0});var e=function(n,t){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)t.hasOwnProperty(e)&&(n[e]=t[e])})(n,t)};function r(n,t,e,r){return new(e||(e=Promise))(function(o,i){function c(n){try{a(r.next(n))}catch(n){i(n)}}function u(n){try{a(r.throw(n))}catch(n){i(n)}}function a(n){n.done?o(n.value):new e(function(t){t(n.value)}).then(c,u)}a((r=r.apply(n,t||[])).next())})}function o(n,t){var e,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;c;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,r=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){c.label=i[1];break}if(6===i[0]&&c.label<o[1]){c.label=o[1],o=i;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(i);break}o[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(n,c)}catch(n){i=[6,n],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var i=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(n,t){return n.__proto__=t,n}:function(n,t){for(var e in t)n.hasOwnProperty(e)||(n[e]=t[e]);return n});!function(n){function t(t){var e=this.constructor,r=n.call(this,t)||this;return r.message=t,r.name=e.prototype.constructor.name,i(r,e.prototype),r}(function(n,t){function r(){this.constructor=n}e(n,t),n.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)})(t,n)}(Error);function c(){return"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}var u={};function a(){return c()?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:u}function f(){var n=a(),t=n.crypto||n.msCrypto;if(void 0!==t&&t.getRandomValues){var e=new Uint16Array(8);t.getRandomValues(e),e[3]=4095&e[3]|16384,e[4]=16383&e[4]|32768;var r=function(n){for(var t=n.toString(16);t.length<4;)t="0"+t;return t};return r(e[0])+r(e[1])+r(e[2])+r(e[3])+r(e[4])+r(e[5])+r(e[6])+r(e[7])}return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(n){var t=16*Math.random()|0;return("x"===n?t:3&t|8).toString(16)})}function s(n){var t=a();if(!("console"in t))return n();var e=t.console,r={};["debug","info","warn","error","log","assert"].forEach(function(n){n in t.console&&e[n].__sentry_original__&&(r[n]=e[n],e[n]=e[n].__sentry_original__)});var o=n();return Object.keys(r).forEach(function(n){e[n]=r[n]}),o}var l=a(),h="Sentry Logger ",v=function(){function n(){this._enabled=!1}return n.prototype.disable=function(){this._enabled=!1},n.prototype.enable=function(){this._enabled=!0},n.prototype.log=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];this._enabled&&s(function(){l.console.log(h+"[Log]: "+n.join(" "))})},n.prototype.warn=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];this._enabled&&s(function(){l.console.warn(h+"[Warn]: "+n.join(" "))})},n.prototype.error=function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];this._enabled&&s(function(){l.console.error(h+"[Error]: "+n.join(" "))})},n}();l.__SENTRY__=l.__SENTRY__||{};var p,d=l.__SENTRY__.logger||(l.__SENTRY__.logger=new v);a();!function(n){n.PENDING="PENDING",n.RESOLVED="RESOLVED",n.REJECTED="REJECTED"}(p||(p={}));!function(){function n(n){var t=this;this._state=p.PENDING,this._handlers=[],this._resolve=function(n){t._setResult(p.RESOLVED,n)},this._reject=function(n){t._setResult(p.REJECTED,n)},this._setResult=function(n,e){var r;t._state===p.PENDING&&(r=e,Boolean(r&&r.then&&"function"==typeof r.then)?e.then(t._resolve,t._reject):(t._state=n,t._value=e,t._executeHandlers()))},this._attachHandler=function(n){t._handlers=t._handlers.concat(n),t._executeHandlers()},this._executeHandlers=function(){if(t._state!==p.PENDING){var n=t._handlers.slice();t._handlers=[],n.forEach(function(n){n.done||(t._state===p.RESOLVED&&n.onfulfilled&&n.onfulfilled(t._value),t._state===p.REJECTED&&n.onrejected&&n.onrejected(t._value),n.done=!0)})}};try{n(this._resolve,this._reject)}catch(n){this._reject(n)}}n.resolve=function(t){return new n(function(n){n(t)})},n.reject=function(t){return new n(function(n,e){e(t)})},n.all=function(t){return new n(function(e,r){if(Array.isArray(t))if(0!==t.length){var o=t.length,i=[];t.forEach(function(t,c){n.resolve(t).then(function(n){i[c]=n,0===(o-=1)&&e(i)}).then(null,r)})}else e([]);else r(new TypeError("Promise.all requires an array as input."))})},n.prototype.then=function(t,e){var r=this;return new n(function(n,o){r._attachHandler({done:!1,onfulfilled:function(e){if(t)try{return void n(t(e))}catch(n){return void o(n)}else n(e)},onrejected:function(t){if(e)try{return void n(e(t))}catch(n){return void o(n)}else o(t)}})})},n.prototype.catch=function(n){return this.then(function(n){return n},n)},n.prototype.finally=function(t){var e=this;return new n(function(n,r){var o,i;return e.then(function(n){i=!1,o=n,t&&t()},function(n){i=!0,o=n,t&&t()}).then(function(){i?r(o):n(o)})})},n.prototype.toString=function(){return"[object SyncPromise]"}}();var _={nowSeconds:function(){return Date.now()/1e3}};var y=c()?function(){try{return(n=module,t="perf_hooks",n.require(t)).performance}catch(n){return}var n,t}():function(){var n=a().performance;if(n&&n.now)return{now:function(){return n.now()},timeOrigin:Date.now()-n.now()}}(),g=void 0===y?_:{nowSeconds:function(){return(y.timeOrigin+y.now())/1e3}},E=(_.nowSeconds.bind(_),g.nowSeconds.bind(g),function(){var n=a().performance;if(n)n.timeOrigin?n.timeOrigin:n.timing&&n.timing.navigationStart||Date.now()}(),require("localforage")),b=function(){function n(t){void 0===t&&(t={}),this.name=n.id,this.global=a(),this.maxStoredEvents=t.maxStoredEvents||30,this.offlineEventStore=E.createInstance({name:"sentry/offlineEventStore"})}return n.prototype.setupOnce=function(t,e){var r=this;this.hub=e(),"addEventListener"in this.global&&this.global.addEventListener("online",function(){r._sendEvents().catch(function(){d.warn("could not send cached events")})}),t(function(t){return r.hub&&r.hub.getIntegration(n)&&"navigator"in r.global&&"onLine"in r.global.navigator&&!r.global.navigator.onLine?(r._cacheEvent(t).then(function(n){return r._enforceMaxEvents()}).catch(function(n){d.warn("could not cache event while offline")}),null):t}),"navigator"in this.global&&"onLine"in this.global.navigator&&this.global.navigator.onLine&&this._sendEvents().catch(function(){d.warn("could not send cached events")})},n.prototype._cacheEvent=function(n){return r(this,void 0,void 0,function(){return o(this,function(t){return[2,this.offlineEventStore.setItem(f(),n)]})})},n.prototype._enforceMaxEvents=function(){return r(this,void 0,void 0,function(){var n,t=this;return o(this,function(e){return n=[],[2,this.offlineEventStore.iterate(function(t,e,r){n.push({cacheKey:e,event:t})}).then(function(){return t._purgeEvents(n.sort(function(n,t){return(t.event.timestamp||0)-(n.event.timestamp||0)}).slice(t.maxStoredEvents<n.length?t.maxStoredEvents:n.length).map(function(n){return n.cacheKey}))}).catch(function(n){d.warn("could not enforce max events")})]})})},n.prototype._purgeEvent=function(n){return r(this,void 0,void 0,function(){return o(this,function(t){return[2,this.offlineEventStore.removeItem(n)]})})},n.prototype._purgeEvents=function(n){return r(this,void 0,void 0,function(){var t=this;return o(this,function(e){return[2,Promise.all(n.map(function(n){return t._purgeEvent(n)})).then()]})})},n.prototype._sendEvents=function(){return r(this,void 0,void 0,function(){var n=this;return o(this,function(t){return[2,this.offlineEventStore.iterate(function(t,e,r){n.hub?(n.hub.captureEvent(t),n._purgeEvent(e).catch(function(n){d.warn("could not purge event from cache")})):d.warn("no hub found - could not send cached event")})]})})},n.id="Offline",n}();for(var w in t.Offline=b,n.Sentry=n.Sentry||{},n.Sentry.Integrations=n.Sentry.Integrations||{},t)Object.prototype.hasOwnProperty.call(t,w)&&(n.Sentry.Integrations[w]=t[w])}(window); | ||
!function(t){var n={};Object.defineProperty(n,"__esModule",{value:!0});var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function r(t,n,e,r){return new(e||(e=Promise))(function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){t.done?o(t.value):new e(function(n){n(t.value)}).then(u,a)}c((r=r.apply(t,n||[])).next())})}function o(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function i(t){return null===t||"object"!=typeof t&&"function"!=typeof t}function u(t){return"undefined"!=typeof Element&&c(t,Element)}function a(t){return function(t){return"[object Object]"===Object.prototype.toString.call(t)}(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}function c(t,n){try{return t instanceof n}catch(t){return!1}}function f(t){try{for(var n=t,e=[],r=0,o=0,i=" > ".length,u=void 0;n&&r++<5&&!("html"===(u=s(n))||r>1&&o+e.length*i+u.length>=80);)e.push(u),o+=u.length,n=n.parentNode;return e.reverse().join(" > ")}catch(t){return"<unknown>"}}function s(t){var n,e,r,o,i,u,a=t,c=[];if(!a||!a.tagName)return"";if(c.push(a.tagName.toLowerCase()),a.id&&c.push("#"+a.id),(n=a.className)&&(u=n,"[object String]"===Object.prototype.toString.call(u)))for(e=n.split(/\s+/),i=0;i<e.length;i++)c.push("."+e[i]);var f=["type","name","title","alt"];for(i=0;i<f.length;i++)r=f[i],(o=a.getAttribute(r))&&c.push("["+r+'="'+o+'"]');return c.join("")}var l=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,n){return t.__proto__=n,t}:function(t,n){for(var e in n)t.hasOwnProperty(e)||(t[e]=n[e]);return t});!function(t){function n(n){var e=this.constructor,r=t.call(this,n)||this;return r.message=n,r.name=e.prototype.constructor.name,l(r,e.prototype),r}(function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)})(n,t)}(Error);function h(){return"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}var p={};function v(){return h()?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:p}function d(){var t=v(),n=t.crypto||t.msCrypto;if(void 0!==n&&n.getRandomValues){var e=new Uint16Array(8);n.getRandomValues(e),e[3]=4095&e[3]|16384,e[4]=16383&e[4]|32768;var r=function(t){for(var n=t.toString(16);n.length<4;)n="0"+n;return n};return r(e[0])+r(e[1])+r(e[2])+r(e[3])+r(e[4])+r(e[5])+r(e[6])+r(e[7])}return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}function y(t){var n=v();if(!("console"in n))return t();var e=n.console,r={};["debug","info","warn","error","log","assert"].forEach(function(t){t in n.console&&e[t].__sentry_original__&&(r[t]=e[t],e[t]=e[t].__sentry_original__)});var o=t();return Object.keys(r).forEach(function(t){e[t]=r[t]}),o}var _=v(),g="Sentry Logger ",b=function(){function t(){this._enabled=!1}return t.prototype.disable=function(){this._enabled=!1},t.prototype.enable=function(){this._enabled=!0},t.prototype.log=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._enabled&&y(function(){_.console.log(g+"[Log]: "+t.join(" "))})},t.prototype.warn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._enabled&&y(function(){_.console.warn(g+"[Warn]: "+t.join(" "))})},t.prototype.error=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._enabled&&y(function(){_.console.error(g+"[Error]: "+t.join(" "))})},t}();_.__SENTRY__=_.__SENTRY__||{};var E=_.__SENTRY__.logger||(_.__SENTRY__.logger=new b),m=function(){function t(){this._hasWeakSet="function"==typeof WeakSet,this._inner=this._hasWeakSet?new WeakSet:[]}return t.prototype.memoize=function(t){if(this._hasWeakSet)return!!this._inner.has(t)||(this._inner.add(t),!1);for(var n=0;n<this._inner.length;n++){if(this._inner[n]===t)return!0}return this._inner.push(t),!1},t.prototype.unmemoize=function(t){if(this._hasWeakSet)this._inner.delete(t);else for(var n=0;n<this._inner.length;n++)if(this._inner[n]===t){this._inner.splice(n,1);break}},t}(),w="<anonymous>";function S(t){if(function(t){switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return c(t,Error)}}(t)){var n=t,e={message:n.message,name:n.name,stack:n.stack};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}if(a=t,"undefined"!=typeof Event&&c(a,Event)){var o=t,i={};i.type=o.type;try{i.target=u(o.target)?f(o.target):Object.prototype.toString.call(o.target)}catch(t){i.target="<unknown>"}try{i.currentTarget=u(o.currentTarget)?f(o.currentTarget):Object.prototype.toString.call(o.currentTarget)}catch(t){i.currentTarget="<unknown>"}for(var r in"undefined"!=typeof CustomEvent&&c(t,CustomEvent)&&(i.detail=o.detail),o)Object.prototype.hasOwnProperty.call(o,r)&&(i[r]=o);return i}var a;return t}function x(t,n){return"domain"===n&&t&&"object"==typeof t&&t._events?"[Domain]":"domainEmitter"===n?"[DomainEmitter]":"undefined"!=typeof global&&t===global?"[Global]":"undefined"!=typeof window&&t===window?"[Window]":"undefined"!=typeof document&&t===document?"[Document]":a(t)?"[SyntheticEvent]":"number"==typeof t&&t!=t?"[NaN]":void 0===t?"[undefined]":"function"==typeof t?"[Function: "+function(t){try{return t&&"function"==typeof t&&t.name||w}catch(t){return w}}(t)+"]":"symbol"==typeof t?"["+String(t)+"]":"bigint"==typeof t?"[BigInt: "+String(t)+"]":t}function j(t,n,e,r){if(void 0===e&&(e=1/0),void 0===r&&(r=new m),0===e)return function(t){var n=Object.prototype.toString.call(t);if("string"==typeof t)return t;if("[object Object]"===n)return"[Object]";if("[object Array]"===n)return"[Array]";var e=x(t);return i(e)?e:n}(n);if(null!=n&&"function"==typeof n.toJSON)return n.toJSON();var o=x(n,t);if(i(o))return o;var u=S(n),a=Array.isArray(n)?[]:{};if(r.memoize(n))return"[Circular ~]";for(var c in u)Object.prototype.hasOwnProperty.call(u,c)&&(a[c]=j(c,u[c],e-1,r));return r.unmemoize(n),a}function O(t,n){try{return JSON.parse(JSON.stringify(t,function(t,e){return j(t,e,n)}))}catch(t){return"**non-serializable**"}}var N;v();!function(t){t.PENDING="PENDING",t.RESOLVED="RESOLVED",t.REJECTED="REJECTED"}(N||(N={}));!function(){function t(t){var n=this;this._state=N.PENDING,this._handlers=[],this._resolve=function(t){n._setResult(N.RESOLVED,t)},this._reject=function(t){n._setResult(N.REJECTED,t)},this._setResult=function(t,e){var r;n._state===N.PENDING&&(r=e,Boolean(r&&r.then&&"function"==typeof r.then)?e.then(n._resolve,n._reject):(n._state=t,n._value=e,n._executeHandlers()))},this._attachHandler=function(t){n._handlers=n._handlers.concat(t),n._executeHandlers()},this._executeHandlers=function(){if(n._state!==N.PENDING){var t=n._handlers.slice();n._handlers=[],t.forEach(function(t){t.done||(n._state===N.RESOLVED&&t.onfulfilled&&t.onfulfilled(n._value),n._state===N.REJECTED&&t.onrejected&&t.onrejected(n._value),t.done=!0)})}};try{t(this._resolve,this._reject)}catch(t){this._reject(t)}}t.resolve=function(n){return new t(function(t){t(n)})},t.reject=function(n){return new t(function(t,e){e(n)})},t.all=function(n){return new t(function(e,r){if(Array.isArray(n))if(0!==n.length){var o=n.length,i=[];n.forEach(function(n,u){t.resolve(n).then(function(t){i[u]=t,0===(o-=1)&&e(i)}).then(null,r)})}else e([]);else r(new TypeError("Promise.all requires an array as input."))})},t.prototype.then=function(n,e){var r=this;return new t(function(t,o){r._attachHandler({done:!1,onfulfilled:function(e){if(n)try{return void t(n(e))}catch(t){return void o(t)}else t(e)},onrejected:function(n){if(e)try{return void t(e(n))}catch(t){return void o(t)}else o(n)}})})},t.prototype.catch=function(t){return this.then(function(t){return t},t)},t.prototype.finally=function(n){var e=this;return new t(function(t,r){var o,i;return e.then(function(t){i=!1,o=t,n&&n()},function(t){i=!0,o=t,n&&n()}).then(function(){i?r(o):t(o)})})},t.prototype.toString=function(){return"[object SyncPromise]"}}();var D={nowSeconds:function(){return Date.now()/1e3}};var P=h()?function(){try{return(t=module,n="perf_hooks",t.require(n)).performance}catch(t){return}var t,n}():function(){var t=v().performance;if(t&&t.now)return{now:function(){return t.now()},timeOrigin:Date.now()-t.now()}}(),k=void 0===P?D:{nowSeconds:function(){return(P.timeOrigin+P.now())/1e3}},R=(D.nowSeconds.bind(D),k.nowSeconds.bind(k),function(){var t=v().performance;if(t)t.timeOrigin?t.timeOrigin:t.timing&&t.timing.navigationStart||Date.now()}(),require("localforage")),T=function(){function t(n){void 0===n&&(n={}),this.name=t.id,this.global=v(),this.maxStoredEvents=n.maxStoredEvents||30,this.offlineEventStore=R.createInstance({name:"sentry/offlineEventStore"})}return t.prototype.setupOnce=function(n,e){var r=this;this.hub=e(),"addEventListener"in this.global&&this.global.addEventListener("online",function(){r._sendEvents().catch(function(){E.warn("could not send cached events")})}),n(function(n){return r.hub&&r.hub.getIntegration(t)&&"navigator"in r.global&&"onLine"in r.global.navigator&&!r.global.navigator.onLine?(r._cacheEvent(n).then(function(t){return r._enforceMaxEvents()}).catch(function(t){E.warn("could not cache event while offline")}),null):n}),"navigator"in this.global&&"onLine"in this.global.navigator&&this.global.navigator.onLine&&this._sendEvents().catch(function(){E.warn("could not send cached events")})},t.prototype._cacheEvent=function(t){return r(this,void 0,void 0,function(){return o(this,function(n){return[2,this.offlineEventStore.setItem(d(),O(t))]})})},t.prototype._enforceMaxEvents=function(){return r(this,void 0,void 0,function(){var t,n=this;return o(this,function(e){return t=[],[2,this.offlineEventStore.iterate(function(n,e,r){t.push({cacheKey:e,event:n})}).then(function(){return n._purgeEvents(t.sort(function(t,n){return(n.event.timestamp||0)-(t.event.timestamp||0)}).slice(n.maxStoredEvents<t.length?n.maxStoredEvents:t.length).map(function(t){return t.cacheKey}))}).catch(function(t){E.warn("could not enforce max events")})]})})},t.prototype._purgeEvent=function(t){return r(this,void 0,void 0,function(){return o(this,function(n){return[2,this.offlineEventStore.removeItem(t)]})})},t.prototype._purgeEvents=function(t){return r(this,void 0,void 0,function(){var n=this;return o(this,function(e){return[2,Promise.all(t.map(function(t){return n._purgeEvent(t)})).then()]})})},t.prototype._sendEvents=function(){return r(this,void 0,void 0,function(){var t=this;return o(this,function(n){return[2,this.offlineEventStore.iterate(function(n,e,r){t.hub?(t.hub.captureEvent(n),t._purgeEvent(e).catch(function(t){E.warn("could not purge event from cache")})):E.warn("no hub found - could not send cached event")})]})})},t.id="Offline",t}();for(var I in n.Offline=T,t.Sentry=t.Sentry||{},t.Sentry.Integrations=t.Sentry.Integrations||{},n)Object.prototype.hasOwnProperty.call(n,I)&&(t.Sentry.Integrations[I]=n[I])}(window); | ||
//# sourceMappingURL=offline.min.js.map |
@@ -69,3 +69,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.offlineEventStore.setItem(utils_1.uuid4(), event)]; | ||
return [2 /*return*/, this.offlineEventStore.setItem(utils_1.uuid4(), utils_1.normalize(event))]; | ||
}); | ||
@@ -72,0 +72,0 @@ }); |
import { __awaiter, __generator } from "tslib"; | ||
import { getGlobalObject, logger, uuid4 } from '@sentry/utils'; | ||
import { getGlobalObject, logger, normalize, uuid4 } from '@sentry/utils'; | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
@@ -68,3 +68,3 @@ var localForage = require('localforage'); | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.offlineEventStore.setItem(uuid4(), event)]; | ||
return [2 /*return*/, this.offlineEventStore.setItem(uuid4(), normalize(event))]; | ||
}); | ||
@@ -71,0 +71,0 @@ }); |
{ | ||
"name": "@sentry/integrations", | ||
"version": "6.2.1", | ||
"version": "6.2.2", | ||
"description": "Pluggable integrations that can be used to enhance JS SDKs", | ||
@@ -19,4 +19,4 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/types": "6.2.1", | ||
"@sentry/utils": "6.2.1", | ||
"@sentry/types": "6.2.2", | ||
"@sentry/utils": "6.2.2", | ||
"localforage": "^1.8.1", | ||
@@ -26,3 +26,3 @@ "tslib": "^1.9.3" | ||
"devDependencies": { | ||
"@sentry-internal/eslint-config-sdk": "6.2.1", | ||
"@sentry-internal/eslint-config-sdk": "6.2.2", | ||
"chai": "^4.1.2", | ||
@@ -29,0 +29,0 @@ "eslint": "7.6.0", |
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
2035040
11209
+ Added@sentry/types@6.2.2(transitive)
+ Added@sentry/utils@6.2.2(transitive)
- Removed@sentry/types@6.2.1(transitive)
- Removed@sentry/utils@6.2.1(transitive)
Updated@sentry/types@6.2.2
Updated@sentry/utils@6.2.2