diff --git a/Jenkinsfile b/Jenkinsfile index 467f7f6..ff87c5d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -77,7 +77,13 @@ pipeline { "JS Lint": { node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-jslint" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/jslint4java''' + script { + try { + sh '''docker run -i --rm --name="$BUILD_TAG-jslint" -e GIT_SRC="https://github.com/eea/$GIT_NAME.git" -e GIT_NAME="$GIT_NAME" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/jslint4java''' + } catch (err) { + echo "Unstable: ${err}" + } + } } }, @@ -132,7 +138,7 @@ pipeline { "Plone5": { node(label: 'docker') { - sh '''docker run -i --rm --name="$BUILD_TAG-plone5" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:5 -v -vv -s $GIT_NAME''' + sh '''docker pull eeacms/plone-test:5; docker run -i --rm --name="$BUILD_TAG-plone5" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:5 -v -vv -s $GIT_NAME''' } }, @@ -140,17 +146,7 @@ pipeline { node(label: 'docker') { sh '''docker run -i --rm --name="$BUILD_TAG-python3" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:5-python3 -v -vv -s $GIT_NAME''' } - }, - - "Zope2": { - node(label: 'eea') { - script { - checkout scm - sh '''cd buildouts/zope2 && ./install.sh && ./bin/instance-uptest''' - } - } } - ) } } @@ -250,7 +246,7 @@ pipeline { withSonarQubeEnv('Sonarqube') { sh '''sed -i "s|/plone/instance/src/$GIT_NAME|$(pwd)|g" coverage.xml''' sh '''find xunit-functional -type f -exec mv {} xunit-reports/ ";"''' - sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; sonar-scanner -Dsonar.python.xunit.skipDetails=true -Dsonar.python.xunit.reportPath=xunit-reports/*.xml -Dsonar.python.coverage.reportPath=coverage.xml -Dsonar.sources=./eea -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" + sh "export PATH=$PATH:${scannerHome}/bin:${nodeJS}/bin; sonar-scanner -Dsonar.python.xunit.skipDetails=true -Dsonar.python.xunit.reportPath=xunit-reports/*.xml -Dsonar.python.coverage.reportPaths=coverage.xml -Dsonar.sources=./eea -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER" sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done''' } } diff --git a/README.rst b/README.rst index e894507..d847c14 100644 --- a/README.rst +++ b/README.rst @@ -54,7 +54,7 @@ Install
- + diff --git a/buildouts/zope2/.gitignore b/buildouts/zope2/.gitignore deleted file mode 100644 index 2d22114..0000000 --- a/buildouts/zope2/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -pip-selfcheck.json -.*.cfg -src -parts -*eggs -*-dev.yml -bootstrap* -bin -lib* -var -local -share -secret.cfg -include -.Python -.idea -uuid.txt diff --git a/buildouts/zope2/buildout.cfg b/buildouts/zope2/buildout.cfg deleted file mode 100644 index 955394e..0000000 --- a/buildouts/zope2/buildout.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[buildout] -extends = versions.cfg -package-name = eea.sentry -develop = ../../ diff --git a/buildouts/zope2/install.sh b/buildouts/zope2/install.sh deleted file mode 100755 index f71e583..0000000 --- a/buildouts/zope2/install.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash -set -e - -red="\e[1;31m" -green="\e[1;32m" -blink="\e[1;31m" -NC="\e[0m" # No Color - -function info { - echo -e "${green}INFO: ${NC} $1" -} -function warn { - echo -e "${blink}WARN: ${NC} $1" -} -function error { - echo -e "${red}ERROR: ${NC} $1" -} - -CONFIG=$1 - -VERSION_CFG="versions.cfg" - -PIP=$(cat $VERSION_CFG | grep "^pip\s*=\s*" | sed 's/ *//g' | sed 's/^.*\=\s*//g') -SETUPTOOLS=$(cat $VERSION_CFG | grep "^setuptools\s*\=\s*" | sed 's/ *//g' | sed 's/=//g' | sed 's/[a-z]//g') -ZCBUILDOUT=$(cat $VERSION_CFG | grep "^zc\.buildout\s*=\s*" | sed 's/ *//g' | sed 's/^.*\=\s*//g') -WHEEL=$(cat $VERSION_CFG | grep "^wheel\s*=\s*" | sed 's/ *//g' | sed 's/^.*\=\s*//g') - -if [ -z "$CONFIG" ]; then - if [ -s "development.cfg" ]; then - CONFIG="development.cfg" - else - CONFIG="buildout.cfg" - fi -fi - -#echo -e "${green}" -info "Using $CONFIG" - -if [ -z "$PIP" ]; then - PIP="9.0.1" -fi - -info "Using pip $PIP" - -if [ -z "$SETUPTOOLS" ]; then - SETUPTOOLS="33.1.1" -fi - -info "Using setuptools $SETUPTOOLS" - -if [ -z "$ZCBUILDOUT" ]; then - ZCBUILDOUT="2.9.5" -fi - -info "Using zc.buildout $ZCBUILDOUT" - -if [ -z "$WHEEL" ]; then - WHEEL="0.29.0" -fi - -info "Using wheel $WHEEL" - -if [ -z "$PYTHON" ]; then - PYTHON="/usr/bin/env python2.7" -fi - -# Make sure python is 2.7 or later -PYTHON_OK=`$PYTHON -c 'import sys -print (sys.version_info >= (2, 7) and "1" or "0")'` - -if [ "$PYTHON_OK" = '0' ]; then - error "Python 2.7 or later is required" - error "EXAMPLE USAGE: PYTHON=/path/to/python2.7 ./install.sh" - exit 0 -fi - -info "Using Python: " -$($PYTHON --version) - -if [ -z "$VIRTUALENV" ]; then - VIRTUALENV="/usr/bin/env virtualenv" -fi - -info "Using virtualenv $VIRTUALENV" - - -info "Adding eggs directory" -mkdir -vp eggs - -if [ -s "bin/activate" ]; then - - warn "Already a virtualenv environment." - warn "Please remove bin/activate if you want to reinitialize it." - -else - - info "Running: $VIRTUALENV --clear ." - $VIRTUALENV --clear . - - info "Running: bin/pip install pip==$PIP setuptools==$SETUPTOOLS zc.buildout==$ZCBUILDOUT wheel==$WHEEL" - ./bin/pip install pip==$PIP setuptools==$SETUPTOOLS zc.buildout==$ZCBUILDOUT wheel==$WHEEL - -fi - -echo "" -echo "=========================================================================" -info "All set. Running ./bin/buildout -c $CONFIG" -echo "=========================================================================" -echo "" -exec bin/buildout -c $CONFIG diff --git a/buildouts/zope2/versions.cfg b/buildouts/zope2/versions.cfg deleted file mode 100644 index 91def22..0000000 --- a/buildouts/zope2/versions.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[buildout] -extends = https://svn.eionet.europa.eu/repositories/Zope/trunk/www.eea.europa.eu/trunk/buildout-configs/latest-zope.cfg - -[versions] -plone.recipe.zope2instance = 4.3 -zc.buildout = 2.11.2 -setuptools = diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index bec3bc3..fe8e8c4 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -1,6 +1,11 @@ Changelog ========= +1.5 - (2021-09-24) +--------------------------- +* Change: Migrate to the new sentry SDK + [valipod] + 1.4 - (2019-12-02) --------------------------- * Bug fix: Fix JS integration diff --git a/eea/sentry/__init__.py b/eea/sentry/__init__.py index 03cece5..336c1e8 100644 --- a/eea/sentry/__init__.py +++ b/eea/sentry/__init__.py @@ -1,15 +1,26 @@ """ Main product initializer """ import os +import re +import sys import six import logging from contextlib import closing -from raven.contrib.zope import ZopeSentryHandler +from AccessControl.SecurityManagement import getSecurityManager +from AccessControl.users import nobody from zope.i18nmessageid.message import MessageFactory +from zope.globalrequest import getRequest if six.PY2: from eventlet.green import urllib2 as request else: from eventlet.green.urllib import request +from zope.component import adapter + +from ZPublisher.HTTPRequest import _filterPasswordFields +from ZPublisher.interfaces import IPubFailure +import sentry_sdk +from sentry_sdk.integrations.logging import ignore_logger +from eea.sentry.browser.sentry import get_site EEAMessageFactory = MessageFactory('eea') logger = logging.getLogger() @@ -28,19 +39,166 @@ def environment(): return env -def initialize(context): - """Initializer called when used as a Zope 2 product. +def _get_user_from_request(request): + user = request.get("AUTHENTICATED_USER", None) + + if user is None: + user = getSecurityManager().getUser() + + if user is not None and user != nobody: + user_dict = { + "id": user.getId(), + "email": user.getProperty("email") or "", + } + else: + user_dict = {'id': 'Anonymous'} + + return user_dict + + +def _get_other_from_request(request): + other = {} + for k, v in _filterPasswordFields(request.other.items()): + if k in ("PARENTS", "RESPONSE"): + continue + other[k] = repr(v) + return other + + +def _get_lazyitems_from_request(request): + lazy_items = {} + for k, v in _filterPasswordFields(request._lazies.items()): + lazy_items[k] = repr(v) + return lazy_items + + +def _get_form_from_request(request): + form = {} + for k, v in _filterPasswordFields(request.form.items()): + form[k] = repr(v) + return form + + +def _get_request_from_request(request): + # ensure that all header key-value pairs are strings + headers = dict() + for k, v in request.environ.items(): + if not isinstance(v, str): + v = str(v) + headers[k] = v + + body_pos = request.stdin.tell() + request.stdin.seek(0) + request.stdin.seek(body_pos) + http = dict( + headers=headers, + url=request.getURL(), + method=request.method, + host=request.environ.get("REMOTE_ADDR", ""), + ) + if "HTTP_USER_AGENT" in http["headers"]: + if "User-Agent" not in http["headers"]: + http["headers"]["User-Agent"] = http["headers"]["HTTP_USER_AGENT"] + if "QUERY_STRING" in http["headers"]: + http["query_string"] = http["headers"]["QUERY_STRING"] + + return http + + +def _before_send(event, hint): + """ + Inject Plone/Zope specific information (based on raven.contrib.zope) """ + request = getRequest() + + if request: + # We have no request if event is captured by errorRaisedSubscriber + # (see below) so extra information must be set there. + # If the event is send by pythons logging module + # we set extra info here. + if "other" not in event["extra"]: + event["extra"]["other"] = _get_other_from_request(request) + if "lazy items" not in event["extra"]: + event["extra"]["lazy items"] = _get_lazyitems_from_request(request) + if "form" not in event["extra"]: + event["extra"]["form"] = _get_form_from_request(request) + if "request" not in event["extra"]: + event["extra"]["request"] = _get_request_from_request(request) + + return event + + +def _get_browser_from_request(request): + ''' return browser and version as a tuple ''' + browsers = {'MSIE': 'Internet Explorer', 'OPR': 'Opera', + 'Trident': 'Internet Explorer', 'Edg': 'Edge'} + user_agent = request.environ['HTTP_USER_AGENT'] + for browser in ['Edg', 'Firefox', 'Seamonkey', 'OPR', 'Opera', 'Trident', + 'MSIE', 'Chrome', 'Chromium', 'Safari']: + match = re.findall(browser + '[/ ]?([0-9.]+)', user_agent) + if match: + return (browsers.get(browser, browser), match[0]) + + +def before_send(event, hint): + try: + return _before_send(event, hint) + except KeyError: + logger.warn("Could not extract data from request", exc_info=True) + + +def initialize(context): + """ Initializer """ + sentry_dsn = os.environ.get('SENTRY_DSN', '') if not sentry_dsn: return - - sentry_handler = ZopeSentryHandler(sentry_dsn, - site=os.environ.get('SENTRY_SITE', - os.environ.get('SERVER_NAME', "dev")), + sentry_sdk.init( + sentry_dsn, + max_breadcrumbs=50, + before_send=before_send, release=os.environ.get('SENTRY_RELEASE', - os.environ.get('EEA_KGS_VERSION', 'dev')), + os.environ.get('EEA_KGS_VERSION', 'dev')), environment=os.environ.get("SENTRY_ENVIRONMENT", environment()), - processors=['eea.sentry.processors.SanitizeZopeProcessor'], + traces_sample_rate=1.0, ) - logger.addHandler(sentry_handler) + logger.info('Sentry integration enabled') + ignore_logger("Zope.SiteErrorLog") + + +@adapter(IPubFailure) +def errorRaisedSubscriber(event): + exc_info = ( + sys.exc_info() + ) # Save exc_info before new exceptions (CannotGetPortalError) arise + portal = get_site(event.request) + try: + error_log = portal.error_log + except AttributeError: + error_log = None + + if error_log and exc_info[0].__name__ in error_log._ignored_exceptions: + return + + with sentry_sdk.push_scope() as scope: + scope.set_extra("other", _get_other_from_request(event.request)) + scope.set_extra("lazy items", + _get_lazyitems_from_request(event.request)) + scope.set_extra("form", _get_form_from_request(event.request)) + scope.set_extra("request", _get_request_from_request(event.request)) + user_info = _get_user_from_request(event.request) + if user_info and "id" in user_info: + scope.user = user_info + if portal: + site_id = portal.getId() + else: + site_id = os.environ.get('SENTRY_SITE', + os.environ.get('SERVER_NAME', "dev")) + scope.set_tag('site', site_id) + browser = _get_browser_from_request(event.request) + if browser: + scope.set_tag('browser', '%s %s' % browser) + scope.set_tag('browser.name', browser[0]) + scope.set_tag('browser.version', browser[1]) + + sentry_sdk.capture_exception(exc_info) \ No newline at end of file diff --git a/eea/sentry/browser/configure.zcml b/eea/sentry/browser/configure.zcml index 1bfb8bb..0e6c02b 100644 --- a/eea/sentry/browser/configure.zcml +++ b/eea/sentry/browser/configure.zcml @@ -4,7 +4,7 @@ xmlns:browser="http://namespaces.zope.org/browser" i18n_domain="eea"> - + =t.length&&(t=void 0),{value:t&&t[i++],done:!t}}}}function d(t,n){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var r,e,o=i.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(t){e={error:t}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}return u}function l(){for(var t=[],n=0;n ".length,s=void 0;i&&e++<5&&!("html"===(s=O(i,n))||e>1&&o+r.length*u+s.length>=80);)r.push(s),o+=s.length,i=i.parentNode;return r.reverse().join(" > ")}catch(t){return""}}function O(t,n){var i,r,e,o,u,s,a,c=t,f=[];if(!c||!c.tagName)return"";f.push(c.tagName.toLowerCase());var h=(null===(i=n)||void 0===i?void 0:i.length)?n.filter(function(t){return c.getAttribute(t)}).map(function(t){return[t,c.getAttribute(t)]}):null;if(null===(r=h)||void 0===r?void 0:r.length)h.forEach(function(t){f.push("["+t[0]+'="'+t[1]+'"]')});else if(c.id&&f.push("#"+c.id),(e=c.className)&&g(e))for(o=e.split(/\s+/),a=0;a=200&&n<300?t.Success:429===n?t.RateLimit:n>=400&&n<500?t.Invalid:n>=500?t.Failed:t.Unknown}}(t.Status||(t.Status={})),function(t){t.Explicit="explicitly_set",t.Sampler="client_sampler",t.Rate="client_rate",t.Inheritance="inheritance"}(a||(a={})),function(t){t.BeforeSend="before_send",t.EventProcessor="event_processor",t.NetworkError="network_error",t.QueueOverflow="queue_overflow",t.RateLimitBackoff="ratelimit_backoff",t.SampleRate="sample_rate"}(c||(c={}));var j=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,n){return t.__proto__=n,t}:function(t,n){for(var i in n)t.hasOwnProperty(i)||(t[i]=n[i]);return t});var k=function(t){function n(n){var i=this.constructor,r=t.call(this,n)||this;return r.message=n,r.name=i.prototype.constructor.name,j(r,i.prototype),r}return i(n,t),n}(Error),D=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/,N=function(){function t(t){"string"==typeof t?this.t(t):this.i(t),this.o()}return t.prototype.toString=function(t){void 0===t&&(t=!1);var n=this,i=n.host,r=n.path,e=n.pass,o=n.port,u=n.projectId;return n.protocol+"://"+n.publicKey+(t&&e?":"+e:"")+"@"+i+(o?":"+o:"")+"/"+(r?r+"/":r)+u},t.prototype.t=function(t){var n=D.exec(t);if(!n)throw new k("Invalid Dsn");var i=d(n.slice(1),6),r=i[0],e=i[1],o=i[2],u=void 0===o?"":o,s=i[3],a=i[4],c=void 0===a?"":a,f="",h=i[5],v=h.split("/");if(v.length>1&&(f=v.slice(0,-1).join("/"),h=v.pop()),h){var l=h.match(/^\d+/);l&&(h=l[0])}this.i({host:s,pass:u,path:f,projectId:h,port:c,protocol:r,publicKey:e})},t.prototype.i=function(t){"user"in t&&!("publicKey"in t)&&(t.publicKey=t.user),this.user=t.publicKey||"",this.protocol=t.protocol,this.publicKey=t.publicKey||"",this.pass=t.pass||"",this.host=t.host,this.port=t.port||"",this.path=t.path||"",this.projectId=t.projectId},t.prototype.o=function(){var t=this;if(["protocol","publicKey","host","projectId"].forEach(function(n){if(!t[n])throw new k("Invalid Dsn: "+n+" missing")}),!this.projectId.match(/^\d+$/))throw new k("Invalid Dsn: Invalid projectId "+this.projectId);if("http"!==this.protocol&&"https"!==this.protocol)throw new k("Invalid Dsn: Invalid protocol "+this.protocol);if(this.port&&isNaN(parseInt(this.port,10)))throw new k("Invalid Dsn: Invalid port "+this.port)},t}();function I(){return"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)}function C(t,n){return t.require(n)}function R(t,n){return void 0===n&&(n=0),"string"!=typeof t||0===n?t:t.length<=n?t:t.substr(0,n)+"..."}function A(t,n){if(!Array.isArray(t))return"";for(var i=[],r=0;r"}return t.event_id||""}function H(t){var n=q();if(!("console"in n))return t();var i=n.console,r={};["debug","info","warn","error","log","assert"].forEach(function(t){t in n.console&&i[t].__sentry_original__&&(r[t]=i[t],i[t]=i[t].__sentry_original__)});var e=t();return Object.keys(r).forEach(function(t){i[t]=r[t]}),e}function J(t,n,i){t.exception=t.exception||{},t.exception.values=t.exception.values||[],t.exception.values[0]=t.exception.values[0]||{},t.exception.values[0].value=t.exception.values[0].value||n||"",t.exception.values[0].type=t.exception.values[0].type||i||"Error"}function B(t,n){void 0===n&&(n={});try{t.exception.values[0].mechanism=t.exception.values[0].mechanism||{},Object.keys(n).forEach(function(i){t.exception.values[0].mechanism[i]=n[i]})}catch(t){}}var X=6e4;var G=q(),W="Sentry Logger ",z=function(){function t(){this.u=!1}return t.prototype.disable=function(){this.u=!1},t.prototype.enable=function(){this.u=!0},t.prototype.log=function(){for(var t=[],n=0;n";function Y(t){try{return t&&"function"==typeof t&&t.name||V}catch(t){return V}}function Q(t,n,i){if(n in t){var r=t[n],e=i(r);if("function"==typeof e)try{e.prototype=e.prototype||{},Object.defineProperties(e,{__sentry_original__:{enumerable:!1,value:r}})}catch(t){}t[n]=e}}function Z(t){if(p(t)){var n=t,i={message:n.message,name:n.name,stack:n.stack};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r]);return i}if(T(t)){var e=t,o={};o.type=e.type;try{o.target=E(e.target)?_(e.target):Object.prototype.toString.call(e.target)}catch(t){o.target=""}try{o.currentTarget=E(e.currentTarget)?_(e.currentTarget):Object.prototype.toString.call(e.currentTarget)}catch(t){o.currentTarget=""}for(var u in"undefined"!=typeof CustomEvent&&x(t,CustomEvent)&&(o.detail=e.detail),e)Object.prototype.hasOwnProperty.call(e,u)&&(o[u]=e[u]);return o}return t}function tt(t){return function(t){return~-encodeURI(t).split(/%..|./).length}(JSON.stringify(t))}function nt(t,n,i){void 0===n&&(n=3),void 0===i&&(i=102400);var r=et(t,n);return tt(r)>i?nt(t,n-1,i):r}function it(t,n){return"domain"===n&&t&&"object"==typeof t&&t.v?"[Domain]":"domainEmitter"===n?"[DomainEmitter]":"undefined"!=typeof global&&t===global?"[Global]":"undefined"!=typeof window&&t===window?"[Window]":"undefined"!=typeof document&&t===document?"[Document]":w(i=t)&&"nativeEvent"in i&&"preventDefault"in i&&"stopPropagation"in i?"[SyntheticEvent]":"number"==typeof t&&t!=t?"[NaN]":void 0===t?"[undefined]":"function"==typeof t?"[Function: "+Y(t)+"]":"symbol"==typeof t?"["+String(t)+"]":"bigint"==typeof t?"[BigInt: "+String(t)+"]":t;var i}function rt(t,n,i,r){if(void 0===i&&(i=1/0),void 0===r&&(r=new K),0===i)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 i=it(t);return b(i)?i:n}(n);if(null!=n&&"function"==typeof n.toJSON)return n.toJSON();var e=it(n,t);if(b(e))return e;var o=Z(n),u=Array.isArray(n)?[]:{};if(r.memoize(n))return"[Circular ~]";for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(u[s]=rt(s,o[s],i-1,r));return r.unmemoize(n),u}function et(t,n){try{return JSON.parse(JSON.stringify(t,function(t,i){return rt(t,i,n)}))}catch(t){return"**non-serializable**"}}function ot(t,n){void 0===n&&(n=40);var i=Object.keys(Z(t));if(i.sort(),!i.length)return"[object has no keys]";if(i[0].length>=n)return R(i[0],n);for(var r=i.length;r>0;r--){var e=i.slice(0,r).join(", ");if(!(e.length>n))return r===i.length?e:R(e,n)}return""}function ut(t){var n,i;if(w(t)){var r=t,e={};try{for(var o=v(Object.keys(r)),u=o.next();!u.done;u=o.next()){var s=u.value;void 0!==r[s]&&(e[s]=ut(r[s]))}}catch(t){n={error:t}}finally{try{u&&!u.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return e}return Array.isArray(t)?t.map(ut):t}function st(){if(!("fetch"in q()))return!1;try{return new Headers,new Request(""),new Response,!0}catch(t){return!1}}function at(t){return t&&/^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test(t.toString())}function ct(){if(!st())return!1;try{return new Request("_",{referrerPolicy:"origin"}),!0}catch(t){return!1}}var ft,ht=q(),vt={},dt={};function lt(t){if(!dt[t])switch(dt[t]=!0,t){case"console":!function(){if(!("console"in ht))return;["debug","info","warn","error","log","assert"].forEach(function(t){t in ht.console&&Q(ht.console,t,function(n){return function(){for(var i=[],r=0;r2?n[2]:void 0;if(r){var e=ft,o=String(r);ft=o,mt("history",{from:e,to:o})}return t.apply(this,n)}}ht.onpopstate=function(){for(var t=[],n=0;n0&&i(!1)},t);Ot.all(n.k).then(function(){clearTimeout(r),i(!0)}).then(null,function(){i(!0)})})},t}(),kt={nowSeconds:function(){return Date.now()/1e3}};var Dt=I()?function(){try{return C(module,"perf_hooks").performance}catch(t){return}}():function(){var t=q().performance;if(t&&t.now)return{now:function(){return t.now()},timeOrigin:Date.now()-t.now()}}(),Nt=void 0===Dt?kt:{nowSeconds:function(){return(Dt.timeOrigin+Dt.now())/1e3}},It=kt.nowSeconds.bind(kt),Ct=Nt.nowSeconds.bind(Nt),Rt=Ct,At=function(){var t=q().performance;if(t&&t.now){var n=t.now(),i=Date.now(),r=t.timeOrigin?Math.abs(t.timeOrigin+n-i):36e5,e=r<36e5,o=t.timing&&t.timing.navigationStart,u="number"==typeof o?Math.abs(o+n-i):36e5;return e||u<36e5?r<=u?t.timeOrigin:o:i}}(),Mt=function(){function t(){this.D=!1,this.N=[],this.I=[],this.C=[],this.R={},this.A={},this.M={},this.L={}}return t.clone=function(n){var i=new t;return n&&(i.C=l(n.C),i.A=f({},n.A),i.M=f({},n.M),i.L=f({},n.L),i.R=n.R,i.q=n.q,i.F=n.F,i.P=n.P,i.U=n.U,i.H=n.H,i.I=l(n.I),i.J=n.J),i},t.prototype.addScopeListener=function(t){this.N.push(t)},t.prototype.addEventProcessor=function(t){return this.I.push(t),this},t.prototype.setUser=function(t){return this.R=t||{},this.P&&this.P.update({user:t}),this.B(),this},t.prototype.getUser=function(){return this.R},t.prototype.getRequestSession=function(){return this.J},t.prototype.setRequestSession=function(t){return this.J=t,this},t.prototype.setTags=function(t){return this.A=f(f({},this.A),t),this.B(),this},t.prototype.setTag=function(t,n){var i;return this.A=f(f({},this.A),((i={})[t]=n,i)),this.B(),this},t.prototype.setExtras=function(t){return this.M=f(f({},this.M),t),this.B(),this},t.prototype.setExtra=function(t,n){var i;return this.M=f(f({},this.M),((i={})[t]=n,i)),this.B(),this},t.prototype.setFingerprint=function(t){return this.H=t,this.B(),this},t.prototype.setLevel=function(t){return this.q=t,this.B(),this},t.prototype.setTransactionName=function(t){return this.U=t,this.B(),this},t.prototype.setTransaction=function(t){return this.setTransactionName(t)},t.prototype.setContext=function(t,n){var i;return null===n?delete this.L[t]:this.L=f(f({},this.L),((i={})[t]=n,i)),this.B(),this},t.prototype.setSpan=function(t){return this.F=t,this.B(),this},t.prototype.getSpan=function(){return this.F},t.prototype.getTransaction=function(){var t,n,i,r,e=this.getSpan();return(null===(t=e)||void 0===t?void 0:t.transaction)?null===(n=e)||void 0===n?void 0:n.transaction:(null===(r=null===(i=e)||void 0===i?void 0:i.spanRecorder)||void 0===r?void 0:r.spans[0])?e.spanRecorder.spans[0]:void 0},t.prototype.setSession=function(t){return t?this.P=t:delete this.P,this.B(),this},t.prototype.getSession=function(){return this.P},t.prototype.update=function(n){if(!n)return this;if("function"==typeof n){var i=n(this);return i instanceof t?i:this}return n instanceof t?(this.A=f(f({},this.A),n.A),this.M=f(f({},this.M),n.M),this.L=f(f({},this.L),n.L),n.R&&Object.keys(n.R).length&&(this.R=n.R),n.q&&(this.q=n.q),n.H&&(this.H=n.H),n.J&&(this.J=n.J)):w(n)&&(n=n,this.A=f(f({},this.A),n.tags),this.M=f(f({},this.M),n.extra),this.L=f(f({},this.L),n.contexts),n.user&&(this.R=n.user),n.level&&(this.q=n.level),n.fingerprint&&(this.H=n.fingerprint),n.requestSession&&(this.J=n.requestSession)),this},t.prototype.clear=function(){return this.C=[],this.A={},this.M={},this.R={},this.L={},this.q=void 0,this.U=void 0,this.H=void 0,this.J=void 0,this.F=void 0,this.P=void 0,this.B(),this},t.prototype.addBreadcrumb=function(t,n){var i="number"==typeof n?Math.min(n,100):100;if(i<=0)return this;var r=f({timestamp:It()},t);return this.C=l(this.C,[r]).slice(-i),this.B(),this},t.prototype.clearBreadcrumbs=function(){return this.C=[],this.B(),this},t.prototype.applyToEvent=function(t,n){var i;if(this.M&&Object.keys(this.M).length&&(t.extra=f(f({},this.M),t.extra)),this.A&&Object.keys(this.A).length&&(t.tags=f(f({},this.A),t.tags)),this.R&&Object.keys(this.R).length&&(t.user=f(f({},this.R),t.user)),this.L&&Object.keys(this.L).length&&(t.contexts=f(f({},this.L),t.contexts)),this.q&&(t.level=this.q),this.U&&(t.transaction=this.U),this.F){t.contexts=f({trace:this.F.getTraceContext()},t.contexts);var r=null===(i=this.F.transaction)||void 0===i?void 0:i.name;r&&(t.tags=f({transaction:r},t.tags))}return this.X(t),t.breadcrumbs=l(t.breadcrumbs||[],this.C),t.breadcrumbs=t.breadcrumbs.length>0?t.breadcrumbs:void 0,this.G(l(Lt(),this.I),t,n)},t.prototype.G=function(t,n,i,r){var e=this;return void 0===r&&(r=0),new Ot(function(o,u){var s=t[r];if(null===n||"function"!=typeof s)o(n);else{var a=s(f({},n),i);S(a)?a.then(function(n){return e.G(t,n,i,r+1).then(o)}).then(null,u):e.G(t,a,i,r+1).then(o).then(null,u)}})},t.prototype.B=function(){var t=this;this.D||(this.D=!0,this.N.forEach(function(n){n(t)}),this.D=!1)},t.prototype.X=function(t){t.fingerprint=t.fingerprint?Array.isArray(t.fingerprint)?t.fingerprint:[t.fingerprint]:[],this.H&&(t.fingerprint=t.fingerprint.concat(this.H)),t.fingerprint&&!t.fingerprint.length&&delete t.fingerprint},t}();function Lt(){var t=q();return t.__SENTRY__=t.__SENTRY__||{},t.__SENTRY__.globalEventProcessors=t.__SENTRY__.globalEventProcessors||[],t.__SENTRY__.globalEventProcessors}function qt(t){Lt().push(t)}var Ft=function(){function t(t){this.errors=0,this.sid=F(),this.duration=0,this.status=e.Ok,this.init=!0,this.ignoreDuration=!1;var n=Ct();this.timestamp=n,this.started=n,t&&this.update(t)}return t.prototype.update=function(t){if(void 0===t&&(t={}),t.user&&(!this.ipAddress&&t.user.ip_address&&(this.ipAddress=t.user.ip_address),this.did||t.did||(this.did=t.user.id||t.user.email||t.user.username)),this.timestamp=t.timestamp||Ct(),t.ignoreDuration&&(this.ignoreDuration=t.ignoreDuration),t.sid&&(this.sid=32===t.sid.length?t.sid:F()),void 0!==t.init&&(this.init=t.init),!this.did&&t.did&&(this.did=""+t.did),"number"==typeof t.started&&(this.started=t.started),this.ignoreDuration)this.duration=void 0;else if("number"==typeof t.duration)this.duration=t.duration;else{var n=this.timestamp-this.started;this.duration=n>=0?n:0}t.release&&(this.release=t.release),t.environment&&(this.environment=t.environment),!this.ipAddress&&t.ipAddress&&(this.ipAddress=t.ipAddress),!this.userAgent&&t.userAgent&&(this.userAgent=t.userAgent),"number"==typeof t.errors&&(this.errors=t.errors),t.status&&(this.status=t.status)},t.prototype.close=function(t){t?this.update({status:t}):this.status===e.Ok?this.update({status:e.Exited}):this.update()},t.prototype.toJSON=function(){return ut({sid:""+this.sid,init:this.init,started:new Date(1e3*this.started).toISOString(),timestamp:new Date(1e3*this.timestamp).toISOString(),status:this.status,errors:this.errors,did:"number"==typeof this.did||"string"==typeof this.did?""+this.did:void 0,duration:this.duration,attrs:ut({release:this.release,environment:this.environment,ip_address:this.ipAddress,user_agent:this.userAgent})})},t}(),Pt=4,Ut=function(){function t(t,n,i){void 0===n&&(n=new Mt),void 0===i&&(i=Pt),this.W=i,this.$=[{}],this.getStackTop().scope=n,t&&this.bindClient(t)}return t.prototype.isOlderThan=function(t){return this.W=t&&(clearInterval(e),i(!1)))},1)})},t.prototype.ht=function(){return this.st},t.prototype.dt=function(){return!1!==this.getOptions().enabled&&void 0!==this.ct},t.prototype.gt=function(t,n,i){var r=this,e=this.getOptions().normalizeDepth,o=void 0===e?3:e,u=f(f({},t),{event_id:t.event_id||(i&&i.event_id?i.event_id:F()),timestamp:t.timestamp||It()});this.bt(u),this.wt(u);var s=n;i&&i.captureContext&&(s=Mt.clone(s).update(i.captureContext));var a=Ot.resolve(u);return s&&(a=s.applyToEvent(u,i)),a.then(function(t){return"number"==typeof o&&o>0?r.Tt(t,o):t})},t.prototype.Tt=function(t,n){if(!t)return null;var i=f(f(f(f(f({},t),t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(function(t){return f(f({},t),t.data&&{data:et(t.data,n)})})}),t.user&&{user:et(t.user,n)}),t.contexts&&{contexts:et(t.contexts,n)}),t.extra&&{extra:et(t.extra,n)});t.contexts&&t.contexts.trace&&(i.contexts.trace=t.contexts.trace);var r=this.getOptions().Et;return(void 0===r?{}:r).ensureNoCircularStructures?et(i):i},t.prototype.bt=function(t){var n=this.getOptions(),i=n.environment,r=n.release,e=n.dist,o=n.maxValueLength,u=void 0===o?250:o;"environment"in t||(t.environment="environment"in n?i:"production"),void 0===t.release&&void 0!==r&&(t.release=r),void 0===t.dist&&void 0!==e&&(t.dist=e),t.message&&(t.message=R(t.message,u));var s=t.exception&&t.exception.values&&t.exception.values[0];s&&s.value&&(s.value=R(s.value,u));var a=t.request;a&&a.url&&(a.url=R(a.url,u))},t.prototype.wt=function(t){var n=Object.keys(this.ot);n.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=l(t.sdk.integrations||[],n))},t.prototype.St=function(t){this.ht().sendEvent(t)},t.prototype.vt=function(t,n,i){return this.xt(t,n,i).then(function(t){return t.event_id},function(t){$.error(t)})},t.prototype.xt=function(t,n,i){var r,e,o=this,u=this.getOptions(),s=u.beforeSend,a=u.sampleRate,f=this.getTransport();if(!this.dt())return Ot.reject(new k("SDK not enabled, will not capture event."));var h="transaction"===t.type;return!h&&"number"==typeof a&&Math.random()>a?(null===(e=(r=f).recordLostEvent)||void 0===e||e.call(r,c.SampleRate,"event"),Ot.reject(new k("Discarding event because it's not included in the random sample (sampling rate = "+a+")"))):this.gt(t,i,n).then(function(i){var r,e;if(null===i)throw null===(e=(r=f).recordLostEvent)||void 0===e||e.call(r,c.EventProcessor,t.type||"event"),new k("An event processor returned null, will not send event.");if(n&&n.data&&!0===n.data.__sentry__||h||!s)return i;var u=s(i,n);return o._t(u)}).then(function(n){var r,e;if(null===n)throw null===(e=(r=f).recordLostEvent)||void 0===e||e.call(r,c.BeforeSend,t.type||"event"),new k("`beforeSend` returned `null`, will not send event.");var u=i&&i.getSession&&i.getSession();return!h&&u&&o.yt(u,n),o.St(n),n}).then(null,function(t){if(t instanceof k)throw t;throw o.captureException(t,{data:{__sentry__:!0},originalException:t}),new k("Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: "+t)})},t.prototype.ft=function(t){var n=this;this.ut+=1,t.then(function(t){return n.ut-=1,t},function(t){return n.ut-=1,t})},t.prototype._t=function(t){var n="`beforeSend` method has to return `null` or a valid event.";if(S(t))return t.then(function(t){if(!w(t)&&null!==t)throw new k(n);return t},function(t){throw new k("beforeSend rejected with "+t)});if(!w(t)&&null!==t)throw new k(n);return t},t}(),tn=function(){function n(){}return n.prototype.sendEvent=function(n){return Ot.resolve({reason:"NoopTransport: Event has been skipped because no Dsn is configured.",status:t.Status.Skipped})},n.prototype.close=function(t){return Ot.resolve(!0)},n}(),nn=function(){function t(t){this.at=t,this.at.dsn||$.warn("No DSN provided, backend will not do anything."),this.Ot=this.jt()}return t.prototype.eventFromException=function(t,n){throw new k("Backend has to implement `eventFromException` method")},t.prototype.eventFromMessage=function(t,n,i){throw new k("Backend has to implement `eventFromMessage` method")},t.prototype.sendEvent=function(t){this.Ot.sendEvent(t).then(null,function(t){$.error("Error while sending event: "+t)})},t.prototype.sendSession=function(t){this.Ot.sendSession?this.Ot.sendSession(t).then(null,function(t){$.error("Error while sending session: "+t)}):$.warn("Dropping session because custom transport doesn't implement sendSession")},t.prototype.getTransport=function(){return this.Ot},t.prototype.jt=function(){return new tn},t}();function rn(t){if(t.metadata&&t.metadata.sdk){var n=t.metadata.sdk;return{name:n.name,version:n.version}}}function en(t,n){return n?(t.sdk=t.sdk||{},t.sdk.name=t.sdk.name||n.name,t.sdk.version=t.sdk.version||n.version,t.sdk.integrations=l(t.sdk.integrations||[],n.integrations||[]),t.sdk.packages=l(t.sdk.packages||[],n.packages||[]),t):t}function on(t,n){var i=rn(n),r="aggregates"in t?"sessions":"session";return{body:JSON.stringify(f(f({sent_at:(new Date).toISOString()},i&&{sdk:i}),n.forceEnvelope()&&{dsn:n.getDsn().toString()}))+"\n"+JSON.stringify({type:r})+"\n"+JSON.stringify(t),type:r,url:n.getEnvelopeEndpointWithUrlEncodedAuth()}}function un(t,n){var i=rn(n),r=t.type||"event",e="transaction"===r||n.forceEnvelope(),o=t.debug_meta||{},u=o.transactionSampling,s=h(o,["transactionSampling"]),a=u||{},c=a.method,v=a.rate;0===Object.keys(s).length?delete t.debug_meta:t.debug_meta=s;var d={body:JSON.stringify(i?en(t,n.metadata.sdk):t),type:r,url:e?n.getEnvelopeEndpointWithUrlEncodedAuth():n.getStoreEndpointWithUrlEncodedAuth()};if(e){var l=JSON.stringify(f(f({event_id:t.event_id,sent_at:(new Date).toISOString()},i&&{sdk:i}),n.forceEnvelope()&&{dsn:n.getDsn().toString()}))+"\n"+JSON.stringify({type:r,sample_rates:[{id:c,rate:v}]})+"\n"+d.body;d.body=l}return d}var sn,an="6.13.2",cn=function(){function t(){this.name=t.id}return t.prototype.setupOnce=function(){sn=Function.prototype.toString,Function.prototype.toString=function(){for(var t=[],n=0;n=0;r--){var e=t[r];if(""!==(null===(n=e)||void 0===n?void 0:n.filename)&&"[native code]"!==(null===(i=e)||void 0===i?void 0:i.filename))return e.filename||null}return null},t.prototype.Rt=function(t){try{if(t.stacktrace){var n=t.stacktrace.frames;return this.Lt(n)}if(t.exception){var i=t.exception.values&&t.exception.values[0].stacktrace&&t.exception.values[0].stacktrace.frames;return this.Lt(i)}return null}catch(n){return $.error("Cannot extract url for event "+U(t)),null}},t.id="InboundFilters",t}(),vn=Object.freeze({__proto__:null,FunctionToString:cn,InboundFilters:hn}),dn="?",ln=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack||[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,pn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,mn=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,yn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,gn=/\((\S*)(?::(\d+))(?::(\d+))\)/,bn=/Minified React error #\d+;/i;function wn(t){var n=null,i=0;t&&("number"==typeof t.framesToPop?i=t.framesToPop:bn.test(t.message)&&(i=1));try{if(n=function(t){if(!t||!t.stacktrace)return null;for(var n,i=t.stacktrace,r=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,e=/ line (\d+), column (\d+)\s*(?:in (?:]+)>|([^)]+))\((.*)\))? in (.*):\s*$/i,o=i.split("\n"),u=[],s=0;s eval")>-1&&(r=yn.exec(e[3]))?(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]=""):0!==a||e[5]||void 0===t.columnNumber||(u[0].column=t.columnNumber+1);var f=e[3],h=e[1]||dn;i=d(Tn(h,f),2),h=i[0],f=i[1],o={url:f,func:h,args:e[2]?e[2].split(","):[],line:e[4]?+e[4]:null,column:e[5]?+e[5]:null}}!o.func&&o.line&&(o.func=dn),u.push(o)}if(!u.length)return null;return{message:Sn(t),name:t.name,stack:u}}(t))return En(n,i)}catch(t){}return{message:Sn(t),name:t&&t.name,stack:[],failed:!0}}var Tn=function(t,n){var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:dn,i?"safari-extension:"+n:"safari-web-extension:"+n]:[t,n]};function En(t,n){try{return f(f({},t),{stack:t.stack.slice(n)})}catch(n){return t}}function Sn(t){var n=t&&t.message;return n?n.error&&"string"==typeof n.error.message?n.error.message:n:"No error message"}var xn=50;function _n(t){var n=jn(t.stack),i={type:t.name,value:t.message};return n&&n.length&&(i.stacktrace={frames:n}),void 0===i.type&&""===i.value&&(i.value="Unrecoverable error caught"),i}function On(t){return{exception:{values:[_n(t)]}}}function jn(t){if(!t||!t.length)return[];var n=t,i=n[0].func||"",r=n[n.length-1].func||"";return-1===i.indexOf("captureMessage")&&-1===i.indexOf("captureException")||(n=n.slice(1)),-1!==r.indexOf("sentryWrapped")&&(n=n.slice(0,-1)),n.slice(0,xn).map(function(t){return{colno:null===t.column?void 0:t.column,filename:t.url||n[0].url,function:t.func||"?",in_app:!0,lineno:null===t.line?void 0:t.line}}).reverse()}function kn(t,n,i){var r,e;if(void 0===i&&(i={}),m(t)&&t.error)return r=On(wn(t=t.error));if(y(t)||(e=t,"[object DOMException]"===Object.prototype.toString.call(e))){var o=t,u=o.name||(y(o)?"DOMError":"DOMException"),s=o.message?u+": "+o.message:u;return J(r=Dn(s,n,i),s),"code"in o&&(r.tags=f(f({},r.tags),{"DOMException.code":""+o.code})),r}return p(t)?r=On(wn(t)):w(t)||T(t)?(B(r=function(t,n,i){var r={exception:{values:[{type:T(t)?t.constructor.name:i?"UnhandledRejection":"Error",value:"Non-Error "+(i?"promise rejection":"exception")+" captured with keys: "+ot(t)}]},extra:{__serialized__:nt(t)}};if(n){var e=jn(wn(n).stack);r.stacktrace={frames:e}}return r}(t,n,i.rejection),{synthetic:!0}),r):(J(r=Dn(t,n,i),""+t,void 0),B(r,{synthetic:!0}),r)}function Dn(t,n,i){void 0===i&&(i={});var r={message:t};if(i.attachStacktrace&&n){var e=jn(wn(n).stack);r.stacktrace={frames:e}}return r}var Nn={event:"error",transaction:"transaction",session:"session",attachment:"attachment"},In=q(),Cn=function(){function n(t){var n=this;this.options=t,this.k=new jt(30),this.qt={},this.Ft={},this.Pt=new Kt(t.dsn,t.Ut,t.tunnel),this.url=this.Pt.getStoreEndpointWithUrlEncodedAuth(),this.options.sendClientReports&&In.document&&In.document.addEventListener("visibilitychange",function(){"hidden"===In.document.visibilityState&&n.Ht()})}return n.prototype.sendEvent=function(t){throw new k("Transport Class has to implement `sendEvent` method")},n.prototype.close=function(t){return this.k.drain(t)},n.prototype.recordLostEvent=function(t,n){var i;if(this.options.sendClientReports){var r=Nn[n]+":"+t;$.log("Adding outcome: "+r),this.Ft[r]=(null!=(i=this.Ft[r])?i:0)+1}},n.prototype.Ht=function(){if(this.options.sendClientReports)if(In.navigator&&"function"==typeof In.navigator.sendBeacon){var t=this.Ft;if(this.Ft={},Object.keys(t).length){$.log("Flushing outcomes:\n"+JSON.stringify(t,null,2));var n=this.Pt.getEnvelopeEndpointWithUrlEncodedAuth(),i=JSON.stringify({})+"\n"+JSON.stringify({type:"client_report"})+"\n"+JSON.stringify({timestamp:It(),discarded_events:Object.keys(t).map(function(n){var i=d(n.split(":"),2),r=i[0];return{reason:i[1],category:r,quantity:t[n]}})});In.navigator.sendBeacon(n,i)}else $.log("No outcomes to flush")}else $.warn("Beacon API not available, skipping sending outcomes.")},n.prototype.Jt=function(n){var i=n.requestType,r=n.response,e=n.headers,o=n.resolve,u=n.reject,s=t.Status.fromHttpCode(r.status);this.Bt(e)&&$.warn("Too many "+i+" requests, backing off until: "+this.Xt(i)),s!==t.Status.Success?u(r):o({status:s})},n.prototype.Xt=function(t){var n=Nn[t];return this.qt[n]||this.qt.all},n.prototype.Gt=function(t){return this.Xt(t)>new Date(Date.now())},n.prototype.Bt=function(t){var n,i,r,e,o=Date.now(),u=t["x-sentry-rate-limits"],s=t["retry-after"];if(u){try{for(var a=v(u.trim().split(",")),c=a.next();!c.done;c=a.next()){var f=c.value.split(":",2),h=parseInt(f[0],10),d=1e3*(isNaN(h)?60:h);try{for(var l=(r=void 0,v(f[1].split(";"))),p=l.next();!p.done;p=l.next()){var m=p.value;this.qt[m||"all"]=new Date(o+d)}}catch(t){r={error:t}}finally{try{p&&!p.done&&(e=l.return)&&e.call(l)}finally{if(r)throw r.error}}}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return!0}return!!s&&(this.qt.all=new Date(o+function(t,n){if(!n)return X;var i=parseInt(""+n,10);if(!isNaN(i))return 1e3*i;var r=Date.parse(""+n);return isNaN(r)?X:r-t}(o,s)),!0)},n}();var Rn=function(t){function n(n,i){void 0===i&&(i=function(){var t,n,i=q();if(at(i.fetch))return i.fetch.bind(i);var r=i.document,e=i.fetch;if("function"==typeof(null===(t=r)||void 0===t?void 0:t.createElement))try{var o=r.createElement("iframe");o.hidden=!0,r.head.appendChild(o),(null===(n=o.contentWindow)||void 0===n?void 0:n.fetch)&&(e=o.contentWindow.fetch),r.head.removeChild(o)}catch(t){$.warn("Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ",t)}return e.bind(i)}());var r=t.call(this,n)||this;return r.Wt=i,r}return i(n,t),n.prototype.sendEvent=function(t){return this.zt(un(t,this.Pt),t)},n.prototype.sendSession=function(t){return this.zt(on(t,this.Pt),t)},n.prototype.zt=function(t,n){var i=this;if(this.Gt(t.type))return this.recordLostEvent(c.RateLimitBackoff,t.type),Promise.reject({event:n,type:t.type,reason:"Transport for "+t.type+" requests locked till "+this.Xt(t.type)+" due to too many requests.",status:429});var r={body:t.body,method:"POST",referrerPolicy:ct()?"origin":""};return void 0!==this.options.fetchParameters&&Object.assign(r,this.options.fetchParameters),void 0!==this.options.headers&&(r.headers=this.options.headers),this.k.add(function(){return new Ot(function(n,e){i.Wt(t.url,r).then(function(r){var o={"x-sentry-rate-limits":r.headers.get("X-Sentry-Rate-Limits"),"retry-after":r.headers.get("Retry-After")};i.Jt({requestType:t.type,response:r,headers:o,resolve:n,reject:e})}).catch(e)})}).then(void 0,function(n){throw n instanceof k?i.recordLostEvent(c.QueueOverflow,t.type):i.recordLostEvent(c.NetworkError,t.type),n})},n}(Cn),An=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n.prototype.sendEvent=function(t){return this.zt(un(t,this.Pt),t)},n.prototype.sendSession=function(t){return this.zt(on(t,this.Pt),t)},n.prototype.zt=function(t,n){var i=this;return this.Gt(t.type)?(this.recordLostEvent(c.RateLimitBackoff,t.type),Promise.reject({event:n,type:t.type,reason:"Transport for "+t.type+" requests locked till "+this.Xt(t.type)+" due to too many requests.",status:429})):this.k.add(function(){return new Ot(function(n,r){var e=new XMLHttpRequest;for(var o in e.onreadystatechange=function(){if(4===e.readyState){var o={"x-sentry-rate-limits":e.getResponseHeader("X-Sentry-Rate-Limits"),"retry-after":e.getResponseHeader("Retry-After")};i.Jt({requestType:t.type,response:e,headers:o,resolve:n,reject:r})}},e.open("POST",t.url),i.options.headers)i.options.headers.hasOwnProperty(o)&&e.setRequestHeader(o,i.options.headers[o]);e.send(t.body)})}).then(void 0,function(n){throw n instanceof k?i.recordLostEvent(c.QueueOverflow,t.type):i.recordLostEvent(c.NetworkError,t.type),n})},n}(Cn),Mn=Object.freeze({__proto__:null,BaseTransport:Cn,FetchTransport:Rn,XHRTransport:An}),Ln=function(n){function r(){return null!==n&&n.apply(this,arguments)||this}return i(r,n),r.prototype.eventFromException=function(n,i){return function(n,i,r){var e=kn(i,r&&r.syntheticException||void 0,{attachStacktrace:n.attachStacktrace});return B(e,{handled:!0,type:"generic"}),e.level=t.Severity.Error,r&&r.event_id&&(e.event_id=r.event_id),Ot.resolve(e)}(this.at,n,i)},r.prototype.eventFromMessage=function(n,i,r){return void 0===i&&(i=t.Severity.Info),function(n,i,r,e){void 0===r&&(r=t.Severity.Info);var o=Dn(i,e&&e.syntheticException||void 0,{attachStacktrace:n.attachStacktrace});return o.level=r,e&&e.event_id&&(o.event_id=e.event_id),Ot.resolve(o)}(this.at,n,i,r)},r.prototype.jt=function(){if(!this.at.dsn)return n.prototype.jt.call(this);var t=f(f({},this.at.transportOptions),{dsn:this.at.dsn,tunnel:this.at.tunnel,sendClientReports:this.at.sendClientReports,Ut:this.at.Ut});return this.at.transport?new this.at.transport(t):st()?new Rn(t):new An(t)},r}(nn),qn=q(),Fn=0;function Pn(){return Fn>0}function Un(t,n,i){if(void 0===n&&(n={}),"function"!=typeof t)return t;try{if(t.__sentry__)return t;if(t.__sentry_wrapped__)return t.__sentry_wrapped__}catch(n){return t}var sentryWrapped=function(){var r=Array.prototype.slice.call(arguments);try{i&&"function"==typeof i&&i.apply(this,arguments);var e=r.map(function(t){return Un(t,n)});return t.handleEvent?t.handleEvent.apply(this,e):t.apply(this,e)}catch(t){throw Fn+=1,setTimeout(function(){Fn-=1}),$t(function(i){i.addEventProcessor(function(t){var i=f({},t);return n.mechanism&&(J(i,void 0,void 0),B(i,n.mechanism)),i.extra=f(f({},i.extra),{arguments:r}),i}),captureException(t)}),t}};try{for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(sentryWrapped[r]=t[r])}catch(t){}t.prototype=t.prototype||{},sentryWrapped.prototype=t.prototype,Object.defineProperty(t,"__sentry_wrapped__",{enumerable:!1,value:sentryWrapped}),Object.defineProperties(sentryWrapped,{__sentry__:{enumerable:!1,value:!0},__sentry_original__:{enumerable:!1,value:t}});try{Object.getOwnPropertyDescriptor(sentryWrapped,"name").configurable&&Object.defineProperty(sentryWrapped,"name",{get:function(){return t.name}})}catch(t){}return sentryWrapped}var Hn=function(){function n(t){this.name=n.id,this.$t=!1,this.Kt=!1,this.at=f({onerror:!0,onunhandledrejection:!0},t)}return n.prototype.setupOnce=function(){Error.stackTraceLimit=50,this.at.onerror&&($.log("Global Handler attached: onerror"),this.Vt()),this.at.onunhandledrejection&&($.log("Global Handler attached: onunhandledrejection"),this.Yt())},n.prototype.Vt=function(){var t=this;this.$t||(pt({callback:function(i){var r=i.error,e=Bt(),o=e.getIntegration(n),u=r&&!0===r.__sentry_own_request__;if(o&&!Pn()&&!u){var s=e.getClient(),a=void 0===r&&g(i.msg)?t.Qt(i.msg,i.url,i.line,i.column):t.Zt(kn(r||i.msg,void 0,{attachStacktrace:s&&s.getOptions().attachStacktrace,rejection:!1}),i.url,i.line,i.column);B(a,{handled:!1,type:"onerror"}),e.captureEvent(a,{originalException:r})}},type:"error"}),this.$t=!0)},n.prototype.Yt=function(){var i=this;this.Kt||(pt({callback:function(r){var e=r;try{"reason"in r?e=r.reason:"detail"in r&&"reason"in r.detail&&(e=r.detail.reason)}catch(t){}var o=Bt(),u=o.getIntegration(n),s=e&&!0===e.__sentry_own_request__;if(!u||Pn()||s)return!0;var a=o.getClient(),c=b(e)?i.tn(e):kn(e,void 0,{attachStacktrace:a&&a.getOptions().attachStacktrace,rejection:!0});c.level=t.Severity.Error,B(c,{handled:!1,type:"onunhandledrejection"}),o.captureEvent(c,{originalException:e})},type:"unhandledrejection"}),this.Kt=!0)},n.prototype.Qt=function(t,n,i,r){var e,o=m(t)?t.message:t,u=o.match(/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i);u&&(e=u[1],o=u[2]);var s={exception:{values:[{type:e||"Error",value:o}]}};return this.Zt(s,n,i,r)},n.prototype.tn=function(t){return{exception:{values:[{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(t)}]}}},n.prototype.Zt=function(t,n,i,r){t.exception=t.exception||{},t.exception.values=t.exception.values||[],t.exception.values[0]=t.exception.values[0]||{},t.exception.values[0].stacktrace=t.exception.values[0].stacktrace||{},t.exception.values[0].stacktrace.frames=t.exception.values[0].stacktrace.frames||[];var e=isNaN(parseInt(r,10))?void 0:r,o=isNaN(parseInt(i,10))?void 0:i,u=g(n)&&n.length>0?n:function(){var t=q();try{return t.document.location.href}catch(t){return""}}();return 0===t.exception.values[0].stacktrace.frames.length&&t.exception.values[0].stacktrace.frames.push({colno:e,filename:u,function:"?",in_app:!0,lineno:o}),t},n.id="GlobalHandlers",n}(),Jn=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],Bn=function(){function t(n){this.name=t.id,this.at=f({XMLHttpRequest:!0,eventTarget:!0,requestAnimationFrame:!0,setInterval:!0,setTimeout:!0},n)}return t.prototype.setupOnce=function(){var t=q();(this.at.setTimeout&&Q(t,"setTimeout",this.nn.bind(this)),this.at.setInterval&&Q(t,"setInterval",this.nn.bind(this)),this.at.requestAnimationFrame&&Q(t,"requestAnimationFrame",this.in.bind(this)),this.at.XMLHttpRequest&&"XMLHttpRequest"in t&&Q(XMLHttpRequest.prototype,"send",this.rn.bind(this)),this.at.eventTarget)&&(Array.isArray(this.at.eventTarget)?this.at.eventTarget:Jn).forEach(this.en.bind(this))},t.prototype.nn=function(t){return function(){for(var n=[],i=0;i"}0!==n.length&&Bt().addBreadcrumb({category:"ui."+t.name,message:n},{event:t.event,name:t.name,global:t.global})},n.prototype.sn=function(t){if(t.endTimestamp){if(t.xhr.__sentry_own_request__)return;var n=t.xhr.__sentry_xhr__||{},i=n.method,r=n.url,e=n.status_code,o=n.body;Bt().addBreadcrumb({category:"xhr",data:{method:i,url:r,status_code:e},type:"http"},{xhr:t.xhr,input:o})}else;},n.prototype.an=function(n){n.endTimestamp&&(n.fetchData.url.match(/sentry_key/)&&"POST"===n.fetchData.method||(n.error?Bt().addBreadcrumb({category:"fetch",data:n.fetchData,level:t.Severity.Error,type:"http"},{data:n.error,input:n.args}):Bt().addBreadcrumb({category:"fetch",data:f(f({},n.fetchData),{status_code:n.response.status}),type:"http"},{input:n.args,response:n.response})))},n.prototype.cn=function(t){var n=q(),i=t.from,r=t.to,e=P(n.location.href),o=P(i),u=P(r);o.path||(o=e),e.protocol===u.protocol&&e.host===u.host&&(r=u.relative),e.protocol===o.protocol&&e.host===o.host&&(i=o.relative),Bt().addBreadcrumb({category:"navigation",data:{from:i,to:r}})},n.id="Breadcrumbs",n}(),Gn="cause",Wn=5,zn=function(){function t(n){void 0===n&&(n={}),this.name=t.id,this.fn=n.key||Gn,this.j=n.limit||Wn}return t.prototype.setupOnce=function(){qt(function(n,i){var r=Bt().getIntegration(t);if(r){var e=r.hn&&r.hn.bind(r);return"function"==typeof e?e(n,i):n}return n})},t.prototype.hn=function(t,n){if(!(t.exception&&t.exception.values&&n&&x(n.originalException,Error)))return t;var i=this.vn(n.originalException,this.fn);return t.exception.values=l(i,t.exception.values),t},t.prototype.vn=function(t,n,i){if(void 0===i&&(i=[]),!x(t[n],Error)||i.length+1>=this.j)return i;var r=_n(wn(t[n]));return this.vn(t[n],n,l([r],i))},t.id="LinkedErrors",t}(),$n=q(),Kn=function(){function t(){this.name=t.id}return t.prototype.setupOnce=function(){qt(function(n){var i,r,e;if(Bt().getIntegration(t)){if(!$n.navigator&&!$n.location&&!$n.document)return n;var o=(null===(i=n.request)||void 0===i?void 0:i.url)||(null===(r=$n.location)||void 0===r?void 0:r.href),u=($n.document||{}).referrer,s=($n.navigator||{}).userAgent,a=f(f(f({},null===(e=n.request)||void 0===e?void 0:e.headers),u&&{Referer:u}),s&&{"User-Agent":s}),c=f(f({},o&&{url:o}),{headers:a});return f(f({},n),{request:c})}return n})},t.id="UserAgent",t}(),Vn=function(){function t(){this.name=t.id}return t.prototype.setupOnce=function(n,i){n(function(n){var r=i().getIntegration(t);if(r){try{if(r.Dt(n,r.dn))return $.warn("Event dropped due to being a duplicate of previously captured event."),null}catch(t){return r.dn=n}return r.dn=n}return n})},t.prototype.Dt=function(t,n){return!!n&&(!!this.ln(t,n)||!!this.pn(t,n))},t.prototype.ln=function(t,n){var i=t.message,r=n.message;return!(!i&&!r)&&(!(i&&!r||!i&&r)&&(i===r&&(!!this.mn(t,n)&&!!this.yn(t,n))))},t.prototype.gn=function(t){var n=t.exception;if(n)try{return n.values[0].stacktrace.frames}catch(t){return}else if(t.stacktrace)return t.stacktrace.frames},t.prototype.yn=function(t,n){var i=this.gn(t),r=this.gn(n);if(!i&&!r)return!0;if(i&&!r||!i&&r)return!1;if(i=i,(r=r).length!==i.length)return!1;for(var e=0;e=400&&n<500)switch(n){case 401:return t.Unauthenticated;case 403:return t.PermissionDenied;case 404:return t.NotFound;case 409:return t.AlreadyExists;case 413:return t.FailedPrecondition;case 429:return t.ResourceExhausted;default:return t.InvalidArgument}if(n>=500&&n<600)switch(n){case 501:return t.Unimplemented;case 503:return t.Unavailable;case 504:return t.DeadlineExceeded;default:return t.InternalError}return t.UnknownError}}(ii||(ii={}));var ei=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function oi(t){var n;return void 0===t&&(t=null===(n=Bt().getClient())||void 0===n?void 0:n.getOptions()),!!t&&("tracesSampleRate"in t||"tracesSampler"in t)}function ui(t){var n,i;return void 0===t&&(t=Bt()),null===(i=null===(n=t)||void 0===n?void 0:n.getScope())||void 0===i?void 0:i.getTransaction()}function si(t){return t/1e3}function ai(){var t=ui();t&&($.log("[Tracing] Transaction: "+ii.InternalError+" -> Global error occured"),t.setStatus(ii.InternalError))}var ci=function(){function t(t){void 0===t&&(t=1e3),this.spans=[],this.wn=t}return t.prototype.add=function(t){this.spans.length>this.wn?t.spanRecorder=void 0:this.spans.push(t)},t}(),fi=function(){function t(t){if(this.traceId=F(),this.spanId=F().substring(16),this.startTimestamp=Rt(),this.tags={},this.data={},!t)return this;t.traceId&&(this.traceId=t.traceId),t.spanId&&(this.spanId=t.spanId),t.parentSpanId&&(this.parentSpanId=t.parentSpanId),"sampled"in t&&(this.sampled=t.sampled),t.op&&(this.op=t.op),t.description&&(this.description=t.description),t.data&&(this.data=t.data),t.tags&&(this.tags=t.tags),t.status&&(this.status=t.status),t.startTimestamp&&(this.startTimestamp=t.startTimestamp),t.endTimestamp&&(this.endTimestamp=t.endTimestamp)}return t.prototype.child=function(t){return this.startChild(t)},t.prototype.startChild=function(n){var i=new t(f(f({},n),{parentSpanId:this.spanId,sampled:this.sampled,traceId:this.traceId}));return i.spanRecorder=this.spanRecorder,i.spanRecorder&&i.spanRecorder.add(i),i.transaction=this.transaction,i},t.prototype.setTag=function(t,n){var i;return this.tags=f(f({},this.tags),((i={})[t]=n,i)),this},t.prototype.setData=function(t,n){var i;return this.data=f(f({},this.data),((i={})[t]=n,i)),this},t.prototype.setStatus=function(t){return this.status=t,this},t.prototype.setHttpStatus=function(t){this.setTag("http.status_code",String(t));var n=ii.fromHttpCode(t);return n!==ii.UnknownError&&this.setStatus(n),this},t.prototype.isSuccess=function(){return this.status===ii.Ok},t.prototype.finish=function(t){this.endTimestamp="number"==typeof t?t:Rt()},t.prototype.toTraceparent=function(){var t="";return void 0!==this.sampled&&(t=this.sampled?"-1":"-0"),this.traceId+"-"+this.spanId+t},t.prototype.toContext=function(){return ut({data:this.data,description:this.description,endTimestamp:this.endTimestamp,op:this.op,parentSpanId:this.parentSpanId,sampled:this.sampled,spanId:this.spanId,startTimestamp:this.startTimestamp,status:this.status,tags:this.tags,traceId:this.traceId})},t.prototype.updateWithContext=function(t){var n,i,r,e,o;return this.data=null!=(n=t.data)?n:{},this.description=t.description,this.endTimestamp=t.endTimestamp,this.op=t.op,this.parentSpanId=t.parentSpanId,this.sampled=t.sampled,this.spanId=null!=(i=t.spanId)?i:this.spanId,this.startTimestamp=null!=(r=t.startTimestamp)?r:this.startTimestamp,this.status=t.status,this.tags=null!=(e=t.tags)?e:{},this.traceId=null!=(o=t.traceId)?o:this.traceId,this},t.prototype.getTraceContext=function(){return ut({data:Object.keys(this.data).length>0?this.data:void 0,description:this.description,op:this.op,parent_span_id:this.parentSpanId,span_id:this.spanId,status:this.status,tags:Object.keys(this.tags).length>0?this.tags:void 0,trace_id:this.traceId})},t.prototype.toJSON=function(){return ut({data:Object.keys(this.data).length>0?this.data:void 0,description:this.description,op:this.op,parent_span_id:this.parentSpanId,span_id:this.spanId,start_timestamp:this.startTimestamp,status:this.status,tags:Object.keys(this.tags).length>0?this.tags:void 0,timestamp:this.endTimestamp,trace_id:this.traceId})},t}(),hi=function(t){function n(n,i){var r=t.call(this,n)||this;return r.Tn={},r.En=Bt(),x(i,Ut)&&(r.En=i),r.name=n.name||"",r.metadata=n.metadata||{},r.Sn=n.trimEnd,r.transaction=r,r}return i(n,t),n.prototype.setName=function(t){this.name=t},n.prototype.initSpanRecorder=function(t){void 0===t&&(t=1e3),this.spanRecorder||(this.spanRecorder=new ci(t)),this.spanRecorder.add(this)},n.prototype.setMeasurements=function(t){this.Tn=f({},t)},n.prototype.setMetadata=function(t){this.metadata=f(f({},this.metadata),t)},n.prototype.finish=function(n){var i,r,e,o=this;if(void 0===this.endTimestamp){if(this.name||($.warn("Transaction has no name, falling back to ``."),this.name=""),t.prototype.finish.call(this,n),!0!==this.sampled)return $.log("[Tracing] Discarding transaction because its trace was not chosen to be sampled."),void(null===(e=null===(i=this.En.getClient())||void 0===i?void 0:(r=i.getTransport()).recordLostEvent)||void 0===e||e.call(r,c.SampleRate,"transaction"));var u=this.spanRecorder?this.spanRecorder.spans.filter(function(t){return t!==o&&t.endTimestamp}):[];this.Sn&&u.length>0&&(this.endTimestamp=u.reduce(function(t,n){return t.endTimestamp&&n.endTimestamp?t.endTimestamp>n.endTimestamp?t:n:t}).endTimestamp);var s={contexts:{trace:this.getTraceContext()},spans:u,start_timestamp:this.startTimestamp,tags:this.tags,timestamp:this.endTimestamp,transaction:this.name,type:"transaction",debug_meta:this.metadata};return Object.keys(this.Tn).length>0&&($.log("[Measurements] Adding measurements to transaction",JSON.stringify(this.Tn,void 0,2)),s.measurements=this.Tn),$.log("[Tracing] Finishing "+this.op+" transaction: "+this.name+"."),this.En.captureEvent(s)}},n.prototype.toContext=function(){var n=t.prototype.toContext.call(this);return ut(f(f({},n),{name:this.name,trimEnd:this.Sn}))},n.prototype.updateWithContext=function(n){var i;return t.prototype.updateWithContext.call(this,n),this.name=null!=(i=n.name)?i:"",this.Sn=n.trimEnd,this},n}(fi),vi=1e3,di=function(t){function n(n,i,r,e){void 0===r&&(r="");var o=t.call(this,e)||this;return o.xn=n,o._n=i,o.transactionSpanId=r,o}return i(n,t),n.prototype.add=function(n){var i=this;n.spanId!==this.transactionSpanId&&(n.finish=function(t){n.endTimestamp="number"==typeof t?t:Rt(),i._n(n.spanId)},void 0===n.endTimestamp&&this.xn(n.spanId)),t.prototype.add.call(this,n)},n}(ci),li=function(t){function n(n,i,r,e){void 0===r&&(r=vi),void 0===e&&(e=!1);var o=t.call(this,n,i)||this;return o.On=i,o.jn=r,o.kn=e,o.activities={},o.Dn=0,o.Nn=!1,o.In=[],i&&e&&(pi(i),$.log("Setting idle transaction on scope. Span ID: "+o.spanId),i.configureScope(function(t){return t.setSpan(o)})),o.Cn=setTimeout(function(){o.Nn||o.finish()},o.jn),o}return i(n,t),n.prototype.finish=function(n){var i,r,e=this;if(void 0===n&&(n=Rt()),this.Nn=!0,this.activities={},this.spanRecorder){$.log("[Tracing] finishing IdleTransaction",new Date(1e3*n).toISOString(),this.op);try{for(var o=v(this.In),u=o.next();!u.done;u=o.next()){(0,u.value)(this,n)}}catch(t){i={error:t}}finally{try{u&&!u.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}this.spanRecorder.spans=this.spanRecorder.spans.filter(function(t){if(t.spanId===e.spanId)return!0;t.endTimestamp||(t.endTimestamp=n,t.setStatus(ii.Cancelled),$.log("[Tracing] cancelling span since transaction ended early",JSON.stringify(t,void 0,2)));var i=t.startTimestamp=3?($.log("[Tracing] Transaction finished because of no change for 3 heart beats"),this.setStatus(ii.DeadlineExceeded),this.setTag("heartbeat","failed"),this.finish()):this.Rn()}},n.prototype.Rn=function(){var t=this;$.log("pinging Heartbeat -> current counter: "+this.Dn),setTimeout(function(){t.An()},5e3)},n}(hi);function pi(t){if(t){var n=t.getScope();if(n)n.getTransaction()&&n.setSpan(void 0)}}function mi(){var t=this.getScope();if(t){var n=t.getSpan();if(n)return{"sentry-trace":n.toTraceparent()}}return{}}function yi(t,n,i){return oi()?void 0!==t.sampled?(t.setMetadata({transactionSampling:{method:a.Explicit}}),t):("function"==typeof n.tracesSampler?(r=n.tracesSampler(i),t.setMetadata({transactionSampling:{method:a.Sampler,rate:Number(r)}})):void 0!==i.parentSampled?(r=i.parentSampled,t.setMetadata({transactionSampling:{method:a.Inheritance}})):(r=n.tracesSampleRate,t.setMetadata({transactionSampling:{method:a.Rate,rate:Number(r)}})),function(t){if(isNaN(t)||"number"!=typeof t&&"boolean"!=typeof t)return $.warn("[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got "+JSON.stringify(t)+" of type "+JSON.stringify(typeof t)+"."),!1;if(t<0||t>1)return $.warn("[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got "+t+"."),!1;return!0}(r)?r?(t.sampled=Math.random()0&&(t.__SENTRY__.integrations=l(t.__SENTRY__.integrations||[],i))}}function wi(){var t;(t=Ht()).__SENTRY__&&(t.__SENTRY__.extensions=t.__SENTRY__.extensions||{},t.__SENTRY__.extensions.startTransaction||(t.__SENTRY__.extensions.startTransaction=gi),t.__SENTRY__.extensions.traceHeaders||(t.__SENTRY__.extensions.traceHeaders=mi)),I()&&bi(),pt({callback:ai,type:"error"}),pt({callback:ai,type:"unhandledrejection"})}var Ti=q();var Ei=function(t,n,i){var r;return function(e){n.value>=0&&(e||i)&&(n.delta=n.value-(r||0),(n.delta||void 0===r)&&(r=n.value,t(n)))}},Si=function(t,n){return{name:t,value:null!=n?n:-1,delta:0,entries:[],id:"v2-"+Date.now()+"-"+(Math.floor(Math.random()*(9e12-1))+1e12)}},xi=function(t,n){try{if(PerformanceObserver.supportedEntryTypes.includes(t)){if("first-input"===t&&!("PerformanceEventTiming"in self))return;var i=new PerformanceObserver(function(t){return t.getEntries().map(n)});return i.observe({type:t,buffered:!0}),i}}catch(t){}},_i=function(t,n){var i=function(r){"pagehide"!==r.type&&"hidden"!==q().document.visibilityState||(t(r),n&&(removeEventListener("visibilitychange",i,!0),removeEventListener("pagehide",i,!0)))};addEventListener("visibilitychange",i,!0),addEventListener("pagehide",i,!0)},Oi=-1,ji=function(){return Oi<0&&(Oi="hidden"===q().document.visibilityState?0:1/0,_i(function(t){var n=t.timeStamp;Oi=n},!0)),{get firstHiddenTime(){return Oi}}},ki={},Di=q(),Ni={Ln:!1},Ii=function(){function t(t){var n,i;this.Tn={},this.qn=0,!I()&&(null===(n=Di)||void 0===n?void 0:n.performance)&&(null===(i=Di)||void 0===i?void 0:i.document)&&(Di.performance.mark&&Di.performance.mark("sentry-tracing-init"),this.Fn(),this.Pn(t.Ln),this.Un())}return t.prototype.addPerformanceEntries=function(t){var n=this;if(Di&&Di.performance&&Di.performance.getEntries&&At){$.log("[Tracing] Adding & adjusting spans using Performance API");var i,r,e,o,u,s=si(At);if(Di.document&&Di.document.scripts)for(var a=0;a-1&&(r=p)}}),void 0!==r&&void 0!==e&&Ri(t,{description:"evaluation",endTimestamp:e,op:"script",startTimestamp:r}),this.qn=Math.max(performance.getEntries().length-1,0),this.Hn(t),"pageload"===t.op){var c=si(At);"number"==typeof o&&($.log("[Measurements] Adding TTFB"),this.Tn.ttfb={value:1e3*(o-t.startTimestamp)},"number"==typeof u&&u<=o&&(this.Tn["ttfb.requestTime"]={value:1e3*(o-u)})),["fcp","fp","lcp"].forEach(function(i){if(n.Tn[i]&&!(c>=t.startTimestamp)){var r=n.Tn[i].value,e=c+si(r),o=Math.abs(1e3*(e-t.startTimestamp)),u=o-r;$.log("[Measurements] Normalized "+i+" from "+r+" to "+o+" ("+u+")"),n.Tn[i].value=o}}),this.Tn["mark.fid"]&&this.Tn.fid&&Ri(t,{description:"first input delay",endTimestamp:this.Tn["mark.fid"].value+si(this.Tn.fid.value),op:"web.vitals",startTimestamp:this.Tn["mark.fid"].value}),"fcp"in this.Tn||delete this.Tn.cls,t.setMeasurements(this.Tn),this.Jn(t)}}},t.prototype.Jn=function(t){this.Bn&&($.log("[Measurements] Adding LCP Data"),this.Bn.element&&t.setTag("lcp.element",_(this.Bn.element)),this.Bn.id&&t.setTag("lcp.id",this.Bn.id),this.Bn.url&&t.setTag("lcp.url",this.Bn.url.trim().slice(0,200)),t.setTag("lcp.size",this.Bn.size)),this.Xn&&this.Xn.sources&&($.log("[Measurements] Adding CLS Data"),this.Xn.sources.forEach(function(n,i){return t.setTag("cls.source."+(i+1),_(n.node))}))},t.prototype.Fn=function(){var t,n,i,r,e,o,u,s,a=this;t=function(t){var n=t.entries.pop();n&&($.log("[Measurements] Adding CLS"),a.Tn.cls={value:t.value},a.Xn=n)},r=Si("CLS",0),e=0,o=[],(s=xi("layout-shift",u=function(t){if(t&&!t.hadRecentInput){var n=o[0],u=o[o.length-1];e&&0!==o.length&&t.startTime-u.startTime<1e3&&t.startTime-n.startTime<5e3?(e+=t.value,o.push(t)):(e=t.value,o=[t]),e>r.value&&(r.value=e,r.entries=o,i&&i())}}))&&(i=Ei(t,r,n),_i(function(){s.takeRecords().map(u),i(!0)}))},t.prototype.Hn=function(t){var n=Di.navigator;if(n){var i=n.connection;i&&(i.effectiveType&&t.setTag("effectiveConnectionType",i.effectiveType),i.type&&t.setTag("connectionType",i.type),Ai(i.rtt)&&(this.Tn["connection.rtt"]={value:i.rtt}),Ai(i.downlink)&&(this.Tn["connection.downlink"]={value:i.downlink})),Ai(n.deviceMemory)&&t.setTag("deviceMemory",String(n.deviceMemory)),Ai(n.hardwareConcurrency)&&t.setTag("hardwareConcurrency",String(n.hardwareConcurrency))}},t.prototype.Pn=function(t){var n=this;!function(t,n){var i,r=ji(),e=Si("LCP"),o=function(t){var n=t.startTime;ni&&(t.startTimestamp=i),t.startChild(f({startTimestamp:i},r))}function Ai(t){return"number"==typeof t&&isFinite(t)}var Mi={traceFetch:!0,traceXHR:!0,tracingOrigins:["localhost",/^\//]};function Li(t){var n=f(f({},Mi),t),i=n.traceFetch,r=n.traceXHR,e=n.tracingOrigins,o=n.shouldCreateSpanForRequest,u={},s=function(t){if(u[t])return u[t];var n=e;return u[t]=n.some(function(n){return M(t,n)})&&!M(t,"sentry_key"),u[t]},a=s;"function"==typeof o&&(a=function(t){return s(t)&&o(t)});var c={};i&&pt({callback:function(t){!function(t,n,i){if(!oi()||!t.fetchData||!n(t.fetchData.url))return;if(t.endTimestamp&&t.fetchData.__span){var r=i[t.fetchData.__span];return void(r&&(t.response?r.setHttpStatus(t.response.status):t.error&&r.setStatus(ii.InternalError),r.finish(),delete i[t.fetchData.__span]))}var e=ui();if(e){var r=e.startChild({data:f(f({},t.fetchData),{type:"fetch"}),description:t.fetchData.method+" "+t.fetchData.url,op:"http.client"});t.fetchData.__span=r.spanId,i[r.spanId]=r;var o=t.args[0]=t.args[0],u=t.args[1]=t.args[1]||{},s=u.headers;x(o,Request)&&(s=o.headers),s?"function"==typeof s.append?s.append("sentry-trace",r.toTraceparent()):s=Array.isArray(s)?l(s,[["sentry-trace",r.toTraceparent()]]):f(f({},s),{"sentry-trace":r.toTraceparent()}):s={"sentry-trace":r.toTraceparent()},u.headers=s}}(t,a,c)},type:"fetch"}),r&&pt({callback:function(t){!function(t,n,i){var r,e;if(!oi()||(null===(r=t.xhr)||void 0===r?void 0:r.__sentry_own_request__)||!((null===(e=t.xhr)||void 0===e?void 0:e.__sentry_xhr__)&&n(t.xhr.__sentry_xhr__.url)))return;var o=t.xhr.__sentry_xhr__;if(t.endTimestamp&&t.xhr.__sentry_xhr_span_id__){var u=i[t.xhr.__sentry_xhr_span_id__];return void(u&&(u.setHttpStatus(o.status_code),u.finish(),delete i[t.xhr.__sentry_xhr_span_id__]))}var s=ui();if(s){var u=s.startChild({data:f(f({},o.data),{type:"xhr",method:o.method,url:o.url}),description:o.method+" "+o.url,op:"http.client"});if(t.xhr.__sentry_xhr_span_id__=u.spanId,i[t.xhr.__sentry_xhr_span_id__]=u,t.xhr.setRequestHeader)try{t.xhr.setRequestHeader("sentry-trace",u.toTraceparent())}catch(t){}}}(t,a,c)},type:"xhr"})}var qi=q();var Fi=f({idleTimeout:vi,markBackgroundTransactions:!0,maxTransactionDuration:600,routingInstrumentation:function(t,n,i){if(void 0===n&&(n=!0),void 0===i&&(i=!0),qi&&qi.location){var r,e=qi.location.href;n&&(r=t({name:qi.location.pathname,op:"pageload"})),i&&pt({callback:function(n){var i=n.to,o=n.from;void 0===o&&e&&-1!==e.indexOf(i)?e=void 0:o!==i&&(e=void 0,r&&($.log("[Tracing] Finishing current transaction with op: "+r.op),r.finish()),r=t({name:qi.location.pathname,op:"navigation"}))},type:"history"})}else $.warn("Could not initialize routing instrumentation due to invalid location")},startTransactionOnLocationChange:!0,startTransactionOnPageLoad:!0},Mi),Pi=function(){function t(n){this.name=t.id,this.Gn=!1;var i=Mi.tracingOrigins;n&&n.tracingOrigins&&Array.isArray(n.tracingOrigins)&&0!==n.tracingOrigins.length?i=n.tracingOrigins:this.Gn=!0,this.options=f(f(f({},Fi),n),{tracingOrigins:i}),this.Wn=new Ii(f(f({},Ni),this.options.zn))}return t.prototype.setupOnce=function(t,n){var i=this;this.$n=n,this.Gn&&($.warn("[Tracing] You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace."),$.warn("[Tracing] We added a reasonable default for you: "+Mi.tracingOrigins));var r=this.options,e=r.routingInstrumentation,o=r.startTransactionOnLocationChange,u=r.startTransactionOnPageLoad,s=r.markBackgroundTransactions,a=r.traceFetch,c=r.traceXHR,f=r.tracingOrigins,h=r.shouldCreateSpanForRequest;e(function(t){return i.Kn(t)},u,o),s&&(Ti&&Ti.document?Ti.document.addEventListener("visibilitychange",function(){var t=ui();Ti.document.hidden&&t&&($.log("[Tracing] Transaction: "+ii.Cancelled+" -> since tab moved to the background, op: "+t.op),t.status||t.setStatus(ii.Cancelled),t.setTag("visibilitychange","document.hidden"),t.finish())}):$.warn("[Tracing] Could not set up background tab detection due to lack of global document")),Li({traceFetch:a,traceXHR:c,tracingOrigins:f,shouldCreateSpanForRequest:h})},t.prototype.Kn=function(t){var n=this;if(this.$n){var i=this.options,r=i.beforeNavigate,e=i.idleTimeout,o=i.maxTransactionDuration,u="pageload"===t.op?function(){var t=(n="sentry-trace",i=q().document.querySelector("meta[name="+n+"]"),i?i.getAttribute("content"):null);var n,i;if(t)return function(t){var n=t.match(ei);if(n){var i=void 0;return"1"===n[3]?i=!0:"0"===n[3]&&(i=!1),{traceId:n[1],parentSampled:i,parentSpanId:n[2]}}}(t);return}():void 0,s=f(f(f({},t),u),{trimEnd:!0}),a="function"==typeof r?r(s):s,c=void 0===a?f(f({},s),{sampled:!1}):a;!1===c.sampled&&$.log("[Tracing] Will not send "+c.op+" transaction because of beforeNavigate."),$.log("[Tracing] Starting "+c.op+" transaction on scope");var h=function(t,n,i,r,e){var o,u,s=(null===(o=t.getClient())||void 0===o?void 0:o.getOptions())||{},a=new li(n,t,i,r);return(a=yi(a,s,f({parentSampled:n.parentSampled,transactionContext:n},e))).sampled&&a.initSpanRecorder(null===(u=s.Et)||void 0===u?void 0:u.maxSpans),a}(this.$n(),c,e,!0,{location:q().location});return h.registerBeforeFinishCallback(function(t,i){n.Wn.addPerformanceEntries(t),function(t,n,i){var r=i-n.startTimestamp;i&&(r>t||r<0)&&(n.setStatus(ii.DeadlineExceeded),n.setTag("maxTransactionDurationExceeded","true"))}(1e3*o,t,i)}),h}$.warn("[Tracing] Did not create "+t.op+" transaction because _getCurrentHub is invalid.")},t.id="BrowserTracing",t}();var Ui={},Hi=q();Hi.Sentry&&Hi.Sentry.Integrations&&(Ui=Hi.Sentry.Integrations);var Ji=f(f(f({},Ui),ri),{BrowserTracing:Pi});return wi(),t.BrowserClient=Qn,t.Hub=Ut,t.Integrations=Ji,t.SDK_NAME="sentry.javascript.browser",t.SDK_VERSION=an,t.Scope=Mt,t.Span=fi,t.Transports=Mn,t.addBreadcrumb=function(t){zt("addBreadcrumb",t)},t.addExtensionMethods=wi,t.addGlobalEventProcessor=qt,t.captureEvent=function(t){return zt("captureEvent",t)},t.captureException=captureException,t.captureMessage=function(t,n){var i;try{throw new Error(t)}catch(t){i=t}return zt("captureMessage",t,"string"==typeof n?n:void 0,f({originalException:t,syntheticException:i},"string"!=typeof n?{captureContext:n}:void 0))},t.close=function(t){var n=Bt().getClient();return n?n.close(t):($.warn("Cannot flush events and disable SDK. No client defined."),Ot.resolve(!1))},t.configureScope=function(t){zt("configureScope",t)},t.defaultIntegrations=Zn,t.flush=function(t){var n=Bt().getClient();return n?n.flush(t):($.warn("Cannot flush events. No client defined."),Ot.resolve(!1))},t.forceLoad=function(){},t.getCurrentHub=Bt,t.getHubFromCarrier=Gt,t.init=function(t){if(void 0===t&&(t={}),void 0===t.defaultIntegrations&&(t.defaultIntegrations=Zn),void 0===t.release){var n=q();n.SENTRY_RELEASE&&n.SENTRY_RELEASE.id&&(t.release=n.SENTRY_RELEASE.id)}void 0===t.autoSessionTracking&&(t.autoSessionTracking=!0),void 0===t.sendClientReports&&(t.sendClientReports=!0),function(t,n){var i;!0===n.debug&&$.enable();var r=Bt();null===(i=r.getScope())||void 0===i||i.update(n.initialScope);var e=new t(n);r.bindClient(e)}(Qn,t),t.autoSessionTracking&&function(){if(void 0!==q().document){var t=Bt();"function"==typeof t.startSession&&"function"==typeof t.captureSession&&(t.startSession({ignoreDuration:!0}),t.captureSession(),pt({callback:function(n){var i=n.from,r=n.to;void 0!==i&&i!==r&&(t.startSession({ignoreDuration:!0}),t.captureSession())},type:"history"}))}else $.warn("Session tracking in non-browser environment with @sentry/browser is not supported.")}()},t.lastEventId=function(){return Bt().lastEventId()},t.onLoad=function(t){t()},t.setContext=function(t,n){zt("setContext",t,n)},t.setExtra=function(t,n){zt("setExtra",t,n)},t.setExtras=function(t){zt("setExtras",t)},t.setTag=function(t,n){zt("setTag",t,n)},t.setTags=function(t){zt("setTags",t)},t.setUser=function(t){zt("setUser",t)},t.showReportDialog=function(t){void 0===t&&(t={});var n=Bt(),i=n.getScope();i&&(t.user=f(f({},i.getUser()),t.user)),t.eventId||(t.eventId=n.lastEventId());var r=n.getClient();r&&r.showReportDialog(t)},t.startTransaction=function(t,n){return zt("startTransaction",f({},t),n)},t.withScope=$t,t.wrap=function(t){return Un(t)()},t}({}); +//# sourceMappingURL=bundle.tracing.min.js.map diff --git a/eea/sentry/browser/js/raven.min.js b/eea/sentry/browser/js/raven.min.js deleted file mode 100644 index 2b438bf..0000000 --- a/eea/sentry/browser/js/raven.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/* jslint:disable */ -/*! Raven.js 3.26.4 (409f3b4) | github.com/getsentry/raven-js */ -!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Raven=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gthis.k.maxBreadcrumbs&&this.u.shift(),this},addPlugin:function(a){var b=[].slice.call(arguments,1);return this.r.push([a,b]),this.n&&this.F(),this},setUserContext:function(a){return this.j.user=a,this},setExtraContext:function(a){return this.Z("extra",a),this},setTagsContext:function(a){return this.Z("tags",a),this},clearContext:function(){return this.j={},this},getContext:function(){return JSON.parse(h(this.j))},setEnvironment:function(a){return this.k.environment=a,this},setRelease:function(a){return this.k.release=a,this},setDataCallback:function(a){var b=this.k.dataCallback;return this.k.dataCallback=e(b,a),this},setBreadcrumbCallback:function(a){var b=this.k.breadcrumbCallback;return this.k.breadcrumbCallback=e(b,a),this},setShouldSendCallback:function(a){var b=this.k.shouldSendCallback;return this.k.shouldSendCallback=e(b,a),this},setTransport:function(a){return this.k.transport=a,this},lastException:function(){return this.d},lastEventId:function(){return this.f},isSetup:function(){return!!this.a&&(!!this.g||(this.ravenNotConfiguredError||(this.ravenNotConfiguredError=!0,this.z("error","Error: Raven has not been configured.")),!1))},afterLoad:function(){var a=R.RavenConfig;a&&this.config(a.dsn,a.config).install()},showReportDialog:function(a){if(S){if(a=Object.assign({eventId:this.lastEventId(),dsn:this.H,user:this.j.user||{}},a),!a.eventId)throw new j("Missing eventId");if(!a.dsn)throw new j("Missing DSN");var b=encodeURIComponent,c=[];for(var d in a)if("user"===d){var e=a.user;e.name&&c.push("name="+b(e.name)),e.email&&c.push("email="+b(e.email))}else c.push(b(d)+"="+b(a[d]));var f=this.J(this.G(a.dsn)),g=S.createElement("script");g.async=!0,g.src=f+"/api/embed/error-page/?"+c.join("&"),(S.head||S.body).appendChild(g)}},L:function(){var a=this;this.m+=1,setTimeout(function(){a.m-=1})},$:function(a,b){var c,d;if(this.b){b=b||{},a="raven"+a.substr(0,1).toUpperCase()+a.substr(1),S.createEvent?(c=S.createEvent("HTMLEvents"),c.initEvent(a,!0,!0)):(c=S.createEventObject(),c.eventType=a);for(d in b)A(b,d)&&(c[d]=b[d]);if(S.createEvent)S.dispatchEvent(c);else try{S.fireEvent("on"+c.eventType.toLowerCase(),c)}catch(e){}}},_:function(a){var b=this;return function(c){if(b.aa=null,b.v!==c){b.v=c;var d;try{d=E(c.target)}catch(e){d=""}b.captureBreadcrumb({category:"ui."+a,message:d})}}},ba:function(){var a=this,b=1e3;return function(c){var d;try{d=c.target}catch(e){return}var f=d&&d.tagName;if(f&&("INPUT"===f||"TEXTAREA"===f||d.isContentEditable)){var g=a.aa;g||a._("input")(c),clearTimeout(g),a.aa=setTimeout(function(){a.aa=null},b)}}},ca:function(a,b){var c=H(this.w.href),d=H(b),e=H(a);this.x=b,c.protocol===d.protocol&&c.host===d.host&&(b=d.relative),c.protocol===e.protocol&&c.host===e.host&&(a=e.relative),this.captureBreadcrumb({category:"navigation",data:{to:b,from:a}})},C:function(){var a=this;a.da=Function.prototype.toString,Function.prototype.toString=function(){return"function"==typeof this&&this.M?a.da.apply(this.O,arguments):a.da.apply(this,arguments)}},Q:function(){this.da&&(Function.prototype.toString=this.da)},D:function(){function a(a){return function(b,d){for(var e=new Array(arguments.length),f=0;f"}}},g)),a.apply?a.apply(this,e):a(e[0],e[1])}}function b(a){var b=R[a]&&R[a].prototype;b&&b.hasOwnProperty&&b.hasOwnProperty("addEventListener")&&(I(b,"addEventListener",function(b){return function(d,f,g,h){try{f&&f.handleEvent&&(f.handleEvent=c.wrap({mechanism:{type:"instrument",data:{target:a,"function":"handleEvent",handler:f&&f.name||""}}},f.handleEvent))}catch(i){}var j,k,l;return e&&e.dom&&("EventTarget"===a||"Node"===a)&&(k=c._("click"),l=c.ba(),j=function(a){if(a){var b;try{b=a.type}catch(c){return}return"click"===b?k(a):"keypress"===b?l(a):void 0}}),b.call(this,d,c.wrap({mechanism:{type:"instrument",data:{target:a,"function":"addEventListener",handler:f&&f.name||""}}},f,j),g,h)}},d),I(b,"removeEventListener",function(a){return function(b,c,d,e){try{c=c&&(c.N?c.N:c)}catch(f){}return a.call(this,b,c,d,e)}},d))}var c=this,d=c.t,e=this.k.autoBreadcrumbs;I(R,"setTimeout",a,d),I(R,"setInterval",a,d),R.requestAnimationFrame&&I(R,"requestAnimationFrame",function(a){return function(b){return a(c.wrap({mechanism:{type:"instrument",data:{"function":"requestAnimationFrame",handler:a&&a.name||""}}},b))}},d);for(var f=["EventTarget","Window","Node","ApplicationCache","AudioTrackList","ChannelMergerNode","CryptoOperation","EventSource","FileReader","HTMLUnknownElement","IDBDatabase","IDBRequest","IDBTransaction","KeyOperation","MediaController","MessagePort","ModalWindow","Notification","SVGElementInstance","Screen","TextTrack","TextTrackCue","TextTrackList","WebSocket","WebSocketWorker","Worker","XMLHttpRequest","XMLHttpRequestEventTarget","XMLHttpRequestUpload"],g=0;g"}}},c)})}var b=this,c=this.k.autoBreadcrumbs,d=b.t;if(c.xhr&&"XMLHttpRequest"in R){var e=R.XMLHttpRequest&&R.XMLHttpRequest.prototype;I(e,"open",function(a){return function(c,d){return t(d)&&d.indexOf(b.h)===-1&&(this.ea={method:c,url:d,status_code:null}),a.apply(this,arguments)}},d),I(e,"send",function(c){return function(){function d(){if(e.ea&&4===e.readyState){try{e.ea.status_code=e.status}catch(a){}b.captureBreadcrumb({type:"http",category:"xhr",data:e.ea})}}for(var e=this,f=["onload","onerror","onprogress"],g=0;g"}}},a,d)}):e.onreadystatechange=d,c.apply(this,arguments)}},d)}c.xhr&&J()&&I(R,"fetch",function(a){return function(){for(var c=new Array(arguments.length),d=0;d2?arguments[2]:void 0;return c&&b.ca(b.x,c+""),a.apply(this,arguments)}};I(R.history,"pushState",j,d),I(R.history,"replaceState",j,d)}if(c.console&&"console"in R&&console.log){var k=function(a,c){b.captureBreadcrumb({message:a,level:c.level,category:"console"})};w(["debug","info","warn","error","log"],function(a,b){O(console,b,k)})}},R:function(){for(var a;this.t.length;){a=this.t.shift();var b=a[0],c=a[1],d=a[2];b[c]=d}},S:function(){for(var a in this.q)this.p[a]=this.q[a]},F:function(){var a=this;w(this.r,function(b,c){var d=c[0],e=c[1];d.apply(a,[a].concat(e))})},G:function(a){var b=Q.exec(a),c={},d=7;try{for(;d--;)c[P[d]]=b[d]||""}catch(e){throw new j("Invalid DSN: "+a)}if(c.pass&&!this.k.allowSecretKey)throw new j("Do not specify your secret key in the DSN. See: http://bit.ly/raven-secret-key");return c},J:function(a){var b="//"+a.host+(a.port?":"+a.port:"");return a.protocol&&(b=a.protocol+":"+b),b},A:function(a,b){b=b||{},b.mechanism=b.mechanism||{type:"onerror",handled:!1},this.m||this.V(a,b)},V:function(a,b){var c=this.X(a,b);this.$("handle",{stackInfo:a,options:b}),this.fa(a.name,a.message,a.url,a.lineno,c,b)},X:function(a,b){var c=this,d=[];if(a.stack&&a.stack.length&&(w(a.stack,function(b,e){var f=c.ga(e,a.url);f&&d.push(f)}),b&&b.trimHeadFrames))for(var e=0;e0&&(a.breadcrumbs={values:[].slice.call(this.u,0)}),this.j.user&&(a.user=this.j.user),b.environment&&(a.environment=b.environment),b.release&&(a.release=b.release),b.serverName&&(a.server_name=b.serverName),a=this.pa(a),Object.keys(a).forEach(function(b){(null==a[b]||""===a[b]||v(a[b]))&&delete a[b]}),s(b.dataCallback)&&(a=b.dataCallback(a)||a),a&&!v(a)&&(!s(b.shouldSendCallback)||b.shouldSendCallback(a)))return this.ma()?void this.z("warn","Raven dropped error due to backoff: ",a):void("number"==typeof b.sampleRate?Math.random() ",i=h.length;a&&f++1&&g+e.length*i+b.length>=d));)e.push(b),g+=b.length,a=a.parentNode;return e.reverse().join(h)}function F(a){var b,c,d,e,f,g=[];if(!a||!a.tagName)return"";if(g.push(a.tagName.toLowerCase()),a.id&&g.push("#"+a.id),b=a.className,b&&l(b))for(c=b.split(/\s+/),f=0;fc?Q(a,b-1):d}function R(a,b){if("number"==typeof a||"string"==typeof a)return a.toString();if(!Array.isArray(a))return"";if(a=a.filter(function(a){return"string"==typeof a}),0===a.length)return"[object has no keys]";if(b="number"!=typeof b?X:b,a[0].length>=b)return a[0];for(var c=a.length;c>0;c--){var d=a.slice(0,c).join(", ");if(!(d.length>b))return c===a.length?d:d+"…"}return""}function S(a,b){function c(a){return m(a)?a.map(function(a){return c(a)}):k(a)?Object.keys(a).reduce(function(b,d){return b[d]=e.test(d)?f:c(a[d]),b},{}):a}if(!m(b)||m(b)&&0===b.length)return a;var d,e=A(b),f="********";try{d=JSON.parse(T(a))}catch(g){return a}return c(d)}var T=a(7),U="undefined"!=typeof window?window:"undefined"!=typeof c?c:"undefined"!=typeof self?self:{},V=3,W=51200,X=40;b.exports={isObject:d,isError:e,isErrorEvent:f,isDOMError:g,isDOMException:h,isUndefined:i,isFunction:j,isPlainObject:k,isString:l,isArray:m,isEmptyObject:n,supportsErrorEvent:o,supportsDOMError:p,supportsDOMException:q,supportsFetch:r,supportsReferrerPolicy:s,supportsPromiseRejectionEvent:t,wrappedCallback:u,each:v,objectMerge:w,truncate:y,objectFrozen:x,hasKey:z,joinRegExp:A,urlencode:B,uuid4:D,htmlTreeAsString:E,htmlElementAsString:F,isSameException:I,isSameStacktrace:J,parseUrl:C,fill:K,safeJoin:L,serializeException:Q,serializeKeysForMessage:R,sanitize:S}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{7:7}],6:[function(a,b,c){(function(c){function d(){return"undefined"==typeof document||null==document.location?"":document.location.href}function e(){return"undefined"==typeof document||null==document.location?"":document.location.origin?document.location.origin:document.location.protocol+"//"+document.location.hostname+(document.location.port?":"+document.location.port:"")}var f=a(5),g={collectWindowErrors:!0,debug:!1},h="undefined"!=typeof window?window:"undefined"!=typeof c?c:"undefined"!=typeof self?self:{},i=[].slice,j="?",k=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/;g.report=function(){function a(a){m(),s.push(a)}function b(a){for(var b=s.length-1;b>=0;--b)s[b]===a&&s.splice(b,1)}function c(){n(),s=[]}function e(a,b){var c=null;if(!b||g.collectWindowErrors){for(var d in s)if(s.hasOwnProperty(d))try{s[d].apply(null,[a].concat(i.call(arguments,2)))}catch(e){c=e}if(c)throw c}}function l(a,b,c,h,i){var l=null,m=f.isErrorEvent(i)?i.error:i,n=f.isErrorEvent(a)?a.message:a;if(v)g.computeStackTrace.augmentStackTraceWithInitialElement(v,b,c,n),o();else if(m&&f.isError(m))l=g.computeStackTrace(m),e(l,!0);else{var p,r={url:b,line:c,column:h},s=void 0;if("[object String]"==={}.toString.call(n)){var p=n.match(k);p&&(s=p[1],n=p[2])}r.func=j,l={name:s,message:n,url:d(),stack:[r]},e(l,!0)}return!!q&&q.apply(this,arguments)}function m(){r||(q=h.onerror,h.onerror=l,r=!0)}function n(){r&&(h.onerror=q,r=!1,q=void 0)}function o(){var a=v,b=t;t=null,v=null,u=null,e.apply(null,[a,!1].concat(b))}function p(a,b){var c=i.call(arguments,1);if(v){if(u===a)return;o()}var d=g.computeStackTrace(a);if(v=d,u=a,t=c,setTimeout(function(){u===a&&o()},d.incomplete?2e3:0),b!==!1)throw a}var q,r,s=[],t=null,u=null,v=null;return p.subscribe=a,p.unsubscribe=b,p.uninstall=c,p}(),g.computeStackTrace=function(){function a(a){if("undefined"!=typeof a.stack&&a.stack){for(var b,c,f,g=/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|native|eval|webpack||[a-z]:|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,h=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx(?:-web)|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i,i=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i,k=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,l=/\((\S*)(?::(\d+))(?::(\d+))\)/,m=a.stack.split("\n"),n=[],o=(/^(.*) is undefined$/.exec(a.message),0),p=m.length;o eval")>-1;r&&(b=k.exec(c[3]))?(c[3]=b[1],c[4]=b[2],c[5]=null):0!==o||c[5]||"undefined"==typeof a.columnNumber||(n[0].column=a.columnNumber+1),f={url:c[3],func:c[1]||j,args:c[2]?c[2].split(","):[],line:c[4]?+c[4]:null,column:c[5]?+c[5]:null}}if(!f.func&&f.line&&(f.func=j),f.url&&"blob:"===f.url.substr(0,5)){var s=new XMLHttpRequest;if(s.open("GET",f.url,!1),s.send(null),200===s.status){var t=s.responseText||"";t=t.slice(-300);var u=t.match(/\/\/# sourceMappingURL=(.*)$/);if(u){var v=u[1];"~"===v.charAt(0)&&(v=e()+v.slice(1)),f.url=v.slice(0,-4)}}}n.push(f)}return n.length?{name:a.name,message:a.message,url:d(),stack:n}:null}}function b(a,b,c,d){var e={url:b,line:c};if(e.url&&e.line){if(a.incomplete=!1,e.func||(e.func=j),a.stack.length>0&&a.stack[0].url===e.url){if(a.stack[0].line===e.line)return!1;if(!a.stack[0].line&&a.stack[0].func===e.func)return a.stack[0].line=e.line, -!1}return a.stack.unshift(e),a.partial=!0,!0}return a.incomplete=!0,!1}function c(a,e){for(var h,i,k=/function\s+([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)?\s*\(/i,l=[],m={},n=!1,o=c.caller;o&&!n;o=o.caller)if(o!==f&&o!==g.report){if(i={url:null,func:j,line:null,column:null},o.name?i.func=o.name:(h=k.exec(o.toString()))&&(i.func=h[1]),"undefined"==typeof i.func)try{i.func=h.input.substring(0,h.input.indexOf("{"))}catch(p){}m[""+o]?n=!0:m[""+o]=!0,l.push(i)}e&&l.splice(0,e);var q={name:a.name,message:a.message,url:d(),stack:l};return b(q,a.sourceURL||a.fileName,a.line||a.lineNumber,a.message||a.description),q}function f(b,e){var f=null;e=null==e?0:+e;try{if(f=a(b))return f}catch(h){if(g.debug)throw h}try{if(f=c(b,e+1))return f}catch(h){if(g.debug)throw h}return{name:b.name,message:b.message,url:d()}}return f.augmentStackTraceWithInitialElement=b,f.computeStackTraceFromStackProp=a,f}(),b.exports=g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{5:5}],7:[function(a,b,c){function d(a,b){for(var c=0;c0){var i=d(c,this);~i?c.splice(i+1):c.push(this),~i?e.splice(i,1/0,g):e.push(g),~d(c,h)&&(h=b.call(this,g,h))}else c.push(h);return null==a?h instanceof Error?f(h):h:a.call(this,g,h)}}c=b.exports=e,c.getSerialize=g},{}],8:[function(a,b,c){function d(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}function e(a,b){return a<>>32-b}function f(a,b,c,f,g,h){return d(e(d(d(b,a),d(f,h)),g),c)}function g(a,b,c,d,e,g,h){return f(b&c|~b&d,a,b,e,g,h)}function h(a,b,c,d,e,g,h){return f(b&d|c&~d,a,b,e,g,h)}function i(a,b,c,d,e,g,h){return f(b^c^d,a,b,e,g,h)}function j(a,b,c,d,e,g,h){return f(c^(b|~d),a,b,e,g,h)}function k(a,b){a[b>>5]|=128<>>9<<4)+14]=b;var c,e,f,k,l,m=1732584193,n=-271733879,o=-1732584194,p=271733878;for(c=0;c>5]>>>b%32&255);return c}function m(a){var b,c=[];for(c[(a.length>>2)-1]=void 0,b=0;b>5]|=(255&a.charCodeAt(b/8))<16&&(e=k(e,8*a.length)),c=0;c<16;c+=1)f[c]=909522486^e[c],g[c]=1549556828^e[c];return d=k(f.concat(m(b)),512+8*b.length),l(k(g.concat(d),640))}function p(a){var b,c,d="0123456789abcdef",e="";for(c=0;c>>4&15)+d.charAt(15&b);return e}function q(a){return unescape(encodeURIComponent(a))}function r(a){return n(q(a))}function s(a){return p(r(a))}function t(a,b){return o(q(a),q(b))}function u(a,b){return p(t(a,b))}function v(a,b,c){return b?c?t(b,a):u(b,a):c?r(a):s(a)}b.exports=v},{}]},{},[4])(4)}); diff --git a/eea/sentry/browser/js/sentry.js b/eea/sentry/browser/js/sentry.js index 555bc1f..73b8366 100644 --- a/eea/sentry/browser/js/sentry.js +++ b/eea/sentry/browser/js/sentry.js @@ -17,22 +17,26 @@ document.addEventListener("DOMContentLoaded", function(){ } if (sentry_dsn){ - Raven.config(sentry_dsn, { - logger: 'javascript', + Sentry.init({ + dsn: sentry_dsn, release: sentry_ver, environment: sentry_env, - serverName: sentry_server, - tags: { - site: sentry_site - }, + integrations: [new Sentry.Integrations.BrowserTracing()], + tracesSampleRate: 1.0, + attachStacktrace: true, ignoreErrors: [ 'jQuery is not defined', '$ is not defined', 'Can\'t find variable: jQuery', 'Socialite is not defined', 'Persistent storage maximum size reached' - ] - }).install(); - Raven.setUserContext(sentry_user); + ], + logger: 'javascript', + serverName: sentry_server, + tags: { + site: sentry_site + } + }); + Sentry.setUser(sentry_user); } }); diff --git a/eea/sentry/browser/sentry.py b/eea/sentry/browser/sentry.py index a19757c..fbf7ccc 100644 --- a/eea/sentry/browser/sentry.py +++ b/eea/sentry/browser/sentry.py @@ -14,11 +14,20 @@ else: from eventlet.green.urllib import request +try: + from plone import api + from plone.api.exc import CannotGetPortalError +except ImportError: + # not in plone + api = None + CannotGetPortalError = 'CannotGetPortalError' + logger = logging.getLogger("eea.sentry") RANCHER_METADATA = 'http://rancher-metadata/latest' TIMEOUT = 15 + class Sentry(BrowserView): """ return sentry DSN env variable """ @@ -34,15 +43,15 @@ def environment(self): """ Sentry environment """ if not self._environment: - self._environment = os.environ.get('ENVIRONMENT', - os.environ.get('SENTRY_ENVIRONMENT', '')) + self._environment = os.environ.get( + 'ENVIRONMENT', os.environ.get('SENTRY_ENVIRONMENT', '')) if not self._environment: url = RANCHER_METADATA + '/self/stack/environment_name' try: with closing(request.urlopen(url, timeout=TIMEOUT)) as con: self._environment = con.read() except Exception as err: - logger.warn( + logger.warning( "Please provide SENTRY_ENVIRONMENT env as we " "could not get it automatically from %s due to: %s", url, err) @@ -53,18 +62,18 @@ def environment(self): def version(self): """ KGS version """ - return os.environ.get("SENTRY_RELEASE", - os.environ.get("EEA_KGS_VERSION", "")) + return os.environ.get( + "SENTRY_RELEASE", os.environ.get("EEA_KGS_VERSION", "")) @ramcache(lambda *args: "dsn", lifetime=86400) def dsn(self): """ Public Sentry DSN """ dsn = os.environ.get("SENTRY_DSN", "") - if not "@" in dsn: + if "@" not in dsn: return dsn - # Remove password from SENTRY_DSN + # Remove password from SENTRY_DSN, if provided (old format) url = urlparse(dsn) public = url._replace(netloc="{}@{}".format( url.username, url.hostname)) @@ -72,10 +81,13 @@ def dsn(self): @ramcache(lambda *args: "site", lifetime=86400) def site(self): - """ Sentry site + """ return site id """ - return os.environ.get("SENTRY_SITE", - os.environ.get("SERVER_NAME", "")) + site = get_site(self.request) + if site: + return site.getId() + return os.environ.get( + "SENTRY_SITE", os.environ.get("SERVER_NAME", "dev")) def server(self): """ Sentry server_name @@ -96,3 +108,28 @@ def render(self): return self.index() __call__ = render + + +def get_site(request): + """ return the site id based on the request data """ + site = None + # Try Plone + if api: + try: + site = api.portal.get() + except CannotGetPortalError: + # We are not in a Plone site + pass + # Try Naaya + if not site: + try: + site = request.PARENTS[0].getSite() + except AttributeError: + # We are not in a Naaya Site + pass + if not site: + try: + site = request.PARENTS[-2] + except (IndexError): + pass + return site \ No newline at end of file diff --git a/eea/sentry/browser/zpt/sentry.pt b/eea/sentry/browser/zpt/sentry.pt index 606dbf8..c1ea5ff 100644 --- a/eea/sentry/browser/zpt/sentry.pt +++ b/eea/sentry/browser/zpt/sentry.pt @@ -5,4 +5,4 @@ data-sentry-user view/user|string:{}; data-sentry-site view/site|string:; data-sentry-server view/server|string:; -">
+"> \ No newline at end of file diff --git a/eea/sentry/configure.zcml b/eea/sentry/configure.zcml index dd703cd..ce82e74 100644 --- a/eea/sentry/configure.zcml +++ b/eea/sentry/configure.zcml @@ -12,4 +12,6 @@ + + diff --git a/eea/sentry/processors.py b/eea/sentry/processors.py index a2f5562..aecb448 100644 --- a/eea/sentry/processors.py +++ b/eea/sentry/processors.py @@ -1,31 +1,31 @@ """ Raven custom processors for Zope """ -from raven.processors import SanitizePasswordsProcessor +#from raven.processors import SanitizePasswordsProcessor -class SanitizeZopeProcessor(SanitizePasswordsProcessor): - """ Sanitize zope request - """ - HEADERS = frozenset([ - "HTTP_COOKIE", - "HTTP_X_FORWARDED_FOR", - "HTTP_X_USERNAME", - ]) - - def filter_extra(self, data): - """ Filter REQUEST headers - """ - data = super(SanitizeZopeProcessor, self).filter_extra(data) - if "request" not in data: - return data - - self.filter_http(data["request"]) - - if "headers" not in data["request"]: - return data - - for header in self.HEADERS: - if header in data["request"]["headers"]: - data["request"]["headers"][header] = self.MASK - - return data +#class SanitizeZopeProcessor(SanitizePasswordsProcessor): +# """ Sanitize zope request +# """ +# HEADERS = frozenset([ +# "HTTP_COOKIE", +# "HTTP_X_FORWARDED_FOR", +# "HTTP_X_USERNAME", +# ]) +# +# def filter_extra(self, data): +# """ Filter REQUEST headers +# """ +# data = super(SanitizeZopeProcessor, self).filter_extra(data) +# if "request" not in data: +# return data +# +# self.filter_http(data["request"]) +# +# if "headers" not in data["request"]: +# return data +# +# for header in self.HEADERS: +# if header in data["request"]["headers"]: +# data["request"]["headers"][header] = self.MASK +# +# return data diff --git a/eea/sentry/profiles/plone4/jsregistry.xml b/eea/sentry/profiles/plone4/jsregistry.xml index 9d50f00..0117853 100644 --- a/eea/sentry/profiles/plone4/jsregistry.xml +++ b/eea/sentry/profiles/plone4/jsregistry.xml @@ -1,5 +1,5 @@ - - + + diff --git a/eea/sentry/profiles/plone5/registry.xml b/eea/sentry/profiles/plone5/registry.xml index fa250a2..0654a54 100644 --- a/eea/sentry/profiles/plone5/registry.xml +++ b/eea/sentry/profiles/plone5/registry.xml @@ -2,9 +2,9 @@ - - ++resource++raven.min.js + ++resource++sentry.min.js - raven + sentrybundle sentry ++plone++static/eea-sentry.min.js diff --git a/eea/sentry/version.txt b/eea/sentry/version.txt index c068b24..c239c60 100644 --- a/eea/sentry/version.txt +++ b/eea/sentry/version.txt @@ -1 +1 @@ -1.4 +1.5 diff --git a/setup.py b/setup.py index ad702b2..35b0377 100644 --- a/setup.py +++ b/setup.py @@ -36,11 +36,11 @@ namespace_packages=['eea'], include_package_data=True, zip_safe=False, - python_requires="==2.7", - install_requires=[ + python_requires="==2.7", + install_requires=[ 'setuptools', 'eventlet', - 'raven', + 'sentry-sdk', # -*- Extra requirements: -*- ], extras_require={