{"ast":null,"code":"import { dropUndefinedKeys } from '@sentry/utils';\nimport { getCurrentHub } from './hub.js';\n\n/**\n * @inheritdoc\n */\nclass SessionFlusher {\n __init() {\n this.flushTimeout = 60;\n }\n __init2() {\n this._pendingAggregates = {};\n }\n __init3() {\n this._isEnabled = true;\n }\n constructor(client, attrs) {\n ;\n SessionFlusher.prototype.__init.call(this);\n SessionFlusher.prototype.__init2.call(this);\n SessionFlusher.prototype.__init3.call(this);\n this._client = client;\n // Call to setInterval, so that flush is called every 60 seconds\n this._intervalId = setInterval(() => this.flush(), this.flushTimeout * 1000);\n this._sessionAttrs = attrs;\n }\n\n /** Checks if `pendingAggregates` has entries, and if it does flushes them by calling `sendSession` */\n flush() {\n var sessionAggregates = this.getSessionAggregates();\n if (sessionAggregates.aggregates.length === 0) {\n return;\n }\n this._pendingAggregates = {};\n this._client.sendSession(sessionAggregates);\n }\n\n /** Massages the entries in `pendingAggregates` and returns aggregated sessions */\n getSessionAggregates() {\n var aggregates = Object.keys(this._pendingAggregates).map(key => {\n return this._pendingAggregates[parseInt(key)];\n });\n var sessionAggregates = {\n attrs: this._sessionAttrs,\n aggregates\n };\n return dropUndefinedKeys(sessionAggregates);\n }\n\n /** JSDoc */\n close() {\n clearInterval(this._intervalId);\n this._isEnabled = false;\n this.flush();\n }\n\n /**\n * Wrapper function for _incrementSessionStatusCount that checks if the instance of SessionFlusher is enabled then\n * fetches the session status of the request from `Scope.getRequestSession().status` on the scope and passes them to\n * `_incrementSessionStatusCount` along with the start date\n */\n incrementSessionStatusCount() {\n if (!this._isEnabled) {\n return;\n }\n var scope = getCurrentHub().getScope();\n var requestSession = scope && scope.getRequestSession();\n if (requestSession && requestSession.status) {\n this._incrementSessionStatusCount(requestSession.status, new Date());\n // This is not entirely necessarily but is added as a safe guard to indicate the bounds of a request and so in\n // case captureRequestSession is called more than once to prevent double count\n if (scope) {\n scope.setRequestSession(undefined);\n }\n }\n }\n\n /**\n * Increments status bucket in pendingAggregates buffer (internal state) corresponding to status of\n * the session received\n */\n _incrementSessionStatusCount(status, date) {\n // Truncate minutes and seconds on Session Started attribute to have one minute bucket keys\n var sessionStartedTrunc = new Date(date).setSeconds(0, 0);\n this._pendingAggregates[sessionStartedTrunc] = this._pendingAggregates[sessionStartedTrunc] || {};\n\n // corresponds to aggregated sessions in one specific minute bucket\n // for example, {\"started\":\"2021-03-16T08:00:00.000Z\",\"exited\":4, \"errored\": 1}\n var aggregationCounts = this._pendingAggregates[sessionStartedTrunc];\n if (!aggregationCounts.started) {\n aggregationCounts.started = new Date(sessionStartedTrunc).toISOString();\n }\n switch (status) {\n case 'errored':\n aggregationCounts.errored = (aggregationCounts.errored || 0) + 1;\n return aggregationCounts.errored;\n case 'ok':\n aggregationCounts.exited = (aggregationCounts.exited || 0) + 1;\n return aggregationCounts.exited;\n default:\n aggregationCounts.crashed = (aggregationCounts.crashed || 0) + 1;\n return aggregationCounts.crashed;\n }\n }\n}\nexport { SessionFlusher };","map":{"version":3,"names":["dropUndefinedKeys","getCurrentHub","SessionFlusher","__init","flushTimeout","__init2","_pendingAggregates","__init3","_isEnabled","constructor","client","attrs","prototype","call","_client","_intervalId","setInterval","flush","_sessionAttrs","sessionAggregates","getSessionAggregates","aggregates","length","sendSession","Object","keys","map","key","parseInt","close","clearInterval","incrementSessionStatusCount","scope","getScope","requestSession","getRequestSession","status","_incrementSessionStatusCount","Date","setRequestSession","undefined","date","sessionStartedTrunc","setSeconds","aggregationCounts","started","toISOString","errored","exited","crashed"],"sources":["C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/@sentry/hub/esm/sessionflusher.js"],"sourcesContent":["import { dropUndefinedKeys } from '@sentry/utils';\nimport { getCurrentHub } from './hub.js';\n\n/**\n * @inheritdoc\n */\nclass SessionFlusher {\n __init() {this.flushTimeout = 60;}\n __init2() {this._pendingAggregates = {};}\n \n \n __init3() {this._isEnabled = true;}\n \n\n constructor(client, attrs) {;SessionFlusher.prototype.__init.call(this);SessionFlusher.prototype.__init2.call(this);SessionFlusher.prototype.__init3.call(this);\n this._client = client;\n // Call to setInterval, so that flush is called every 60 seconds\n this._intervalId = setInterval(() => this.flush(), this.flushTimeout * 1000);\n this._sessionAttrs = attrs;\n }\n\n /** Checks if `pendingAggregates` has entries, and if it does flushes them by calling `sendSession` */\n flush() {\n var sessionAggregates = this.getSessionAggregates();\n if (sessionAggregates.aggregates.length === 0) {\n return;\n }\n this._pendingAggregates = {};\n this._client.sendSession(sessionAggregates);\n }\n\n /** Massages the entries in `pendingAggregates` and returns aggregated sessions */\n getSessionAggregates() {\n var aggregates = Object.keys(this._pendingAggregates).map((key) => {\n return this._pendingAggregates[parseInt(key)];\n });\n\n var sessionAggregates = {\n attrs: this._sessionAttrs,\n aggregates,\n };\n return dropUndefinedKeys(sessionAggregates);\n }\n\n /** JSDoc */\n close() {\n clearInterval(this._intervalId);\n this._isEnabled = false;\n this.flush();\n }\n\n /**\n * Wrapper function for _incrementSessionStatusCount that checks if the instance of SessionFlusher is enabled then\n * fetches the session status of the request from `Scope.getRequestSession().status` on the scope and passes them to\n * `_incrementSessionStatusCount` along with the start date\n */\n incrementSessionStatusCount() {\n if (!this._isEnabled) {\n return;\n }\n var scope = getCurrentHub().getScope();\n var requestSession = scope && scope.getRequestSession();\n\n if (requestSession && requestSession.status) {\n this._incrementSessionStatusCount(requestSession.status, new Date());\n // This is not entirely necessarily but is added as a safe guard to indicate the bounds of a request and so in\n // case captureRequestSession is called more than once to prevent double count\n if (scope) {\n scope.setRequestSession(undefined);\n }\n }\n }\n\n /**\n * Increments status bucket in pendingAggregates buffer (internal state) corresponding to status of\n * the session received\n */\n _incrementSessionStatusCount(status, date) {\n // Truncate minutes and seconds on Session Started attribute to have one minute bucket keys\n var sessionStartedTrunc = new Date(date).setSeconds(0, 0);\n this._pendingAggregates[sessionStartedTrunc] = this._pendingAggregates[sessionStartedTrunc] || {};\n\n // corresponds to aggregated sessions in one specific minute bucket\n // for example, {\"started\":\"2021-03-16T08:00:00.000Z\",\"exited\":4, \"errored\": 1}\n var aggregationCounts = this._pendingAggregates[sessionStartedTrunc];\n if (!aggregationCounts.started) {\n aggregationCounts.started = new Date(sessionStartedTrunc).toISOString();\n }\n\n switch (status) {\n case 'errored':\n aggregationCounts.errored = (aggregationCounts.errored || 0) + 1;\n return aggregationCounts.errored;\n case 'ok':\n aggregationCounts.exited = (aggregationCounts.exited || 0) + 1;\n return aggregationCounts.exited;\n default:\n aggregationCounts.crashed = (aggregationCounts.crashed || 0) + 1;\n return aggregationCounts.crashed;\n }\n }\n}\n\nexport { SessionFlusher };\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,eAAe;AACjD,SAASC,aAAa,QAAQ,UAAU;;AAExC;AACA;AACA;AACA,MAAMC,cAAc,CAAE;EAClBC,MAAMA,CAAA,EAAG;IAAC,IAAI,CAACC,YAAY,GAAG,EAAE;EAAC;EAClCC,OAAOA,CAAA,EAAG;IAAC,IAAI,CAACC,kBAAkB,GAAG,CAAC,CAAC;EAAC;EAGxCC,OAAOA,CAAA,EAAG;IAAC,IAAI,CAACC,UAAU,GAAG,IAAI;EAAC;EAGlCC,WAAWA,CAACC,MAAM,EAAEC,KAAK,EAAE;IAAC;IAACT,cAAc,CAACU,SAAS,CAACT,MAAM,CAACU,IAAI,CAAC,IAAI,CAAC;IAACX,cAAc,CAACU,SAAS,CAACP,OAAO,CAACQ,IAAI,CAAC,IAAI,CAAC;IAACX,cAAc,CAACU,SAAS,CAACL,OAAO,CAACM,IAAI,CAAC,IAAI,CAAC;IAC9J,IAAI,CAACC,OAAO,GAAGJ,MAAM;IACrB;IACA,IAAI,CAACK,WAAW,GAAGC,WAAW,CAAC,MAAM,IAAI,CAACC,KAAK,CAAC,CAAC,EAAE,IAAI,CAACb,YAAY,GAAG,IAAI,CAAC;IAC5E,IAAI,CAACc,aAAa,GAAGP,KAAK;EAC5B;;EAEA;EACCM,KAAKA,CAAA,EAAG;IACP,IAAIE,iBAAiB,GAAG,IAAI,CAACC,oBAAoB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