@xcodleox/devinspector 7.2.0 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +4 -2
- package/dist/angular.d.ts +4 -2
- package/dist/angular.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/next.cjs +1 -1
- package/dist/next.js +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +5 -1
- package/dist/node.d.ts +5 -1
- package/dist/node.js +1 -1
- package/dist/react-native.cjs +1 -0
- package/dist/react-native.d.cts +22 -0
- package/dist/react-native.d.ts +22 -0
- package/dist/react-native.js +1 -0
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +7 -3
- package/dist/react.d.ts +7 -3
- package/dist/react.js +1 -1
- package/dist/svelte.cjs +1 -1
- package/dist/svelte.d.cts +3 -2
- package/dist/svelte.d.ts +3 -2
- package/dist/svelte.js +1 -1
- package/dist/vanilla.cjs +1 -1
- package/dist/vanilla.global.js +1 -1
- package/dist/vanilla.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +2 -1
- package/dist/vue.d.ts +2 -1
- package/dist/vue.js +1 -1
- package/package.json +16 -1
package/dist/angular.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var H=Object.create;var l=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var K=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),g=n=>{throw TypeError(n)};var z=(n,e,t)=>e in n?l(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var S=(n,e)=>l(n,"name",{value:e,configurable:!0});var W=(n,e)=>{for(var t in e)l(n,t,{get:e[t],enumerable:!0})},B=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of $(e))!Y.call(n,r)&&r!==t&&l(n,r,{get:()=>e[r],enumerable:!(o=j(e,r))||o.enumerable});return n};var J=n=>B(l({},"__esModule",{value:!0}),n);var O=n=>[,,,H(n?.[K("metadata")]??null)],P=["class","method","getter","setter","accessor","field","value","get","set"],w=n=>n!==void 0&&typeof n!="function"?g("Function expected"):n,V=(n,e,t,o,r)=>({kind:P[n],name:e,metadata:o,addInitializer:i=>t._?g("Already initialized"):r.push(w(i||null))}),X=(n,e)=>z(e,K("metadata"),n[3]),G=(n,e,t,o)=>{for(var r=0,i=n[e>>1],c=i&&i.length;r<c;r++)e&1?i[r].call(t):o=i[r].call(t,o);return o},N=(n,e,t,o,r,i)=>{var c,a,D,y,m,s=e&7,E=!!(e&8),p=!!(e&16),b=s>3?n.length+1:s?E?1:2:0,T=P[s+5],M=s>3&&(n[b-1]=[]),F=n[b]||(n[b]=[]),d=s&&(!p&&!E&&(r=r.prototype),s<5&&(s>3||!p)&&j(s<4?r:{get[t](){return x(this,i)},set[t](u){return C(this,i,u)}},t));s?p&&s<4&&S(i,(s>2?"set ":s>1?"get ":"")+t):S(r,t);for(var v=o.length-1;v>=0;v--)y=V(s,t,D={},n[3],F),s&&(y.static=E,y.private=p,m=y.access={has:p?u=>Z(r,u):u=>t in u},s^3&&(m.get=p?u=>(s^1?x:ee)(u,r,s^4?i:d.get):u=>u[t]),s>2&&(m.set=p?(u,I)=>C(u,r,I,s^4?i:d.set):(u,I)=>u[t]=I)),a=(0,o[v])(s?s<4?p?i:d[T]:s>4?void 0:{get:d.get,set:d.set}:r,y),D._=1,s^4||a===void 0?w(a)&&(s>4?M.unshift(a):s?p?i=a:d[T]=a:r=a):typeof a!="object"||a===null?g("Object expected"):(w(c=a.get)&&(d.get=c),w(c=a.set)&&(d.set=c),w(c=a.init)&&M.unshift(c));return s||X(n,r),d&&l(r,t,d),p?s^4?i:d:r};var R=(n,e,t)=>e.has(n)||g("Cannot "+t),Z=(n,e)=>Object(e)!==e?g('Cannot use the "in" operator on this value'):n.has(e),x=(n,e,t)=>(R(n,e,"read from private field"),t?t.call(n):e.get(n));var C=(n,e,t,o)=>(R(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t),ee=(n,e,t)=>(R(n,e,"access private method"),t);var re={};W(re,{AuditAngularErrorHandler:()=>h,audit:()=>f,auditInterceptor:()=>ne,devInspectorInterceptor:()=>q});module.exports=J(re);var L=require("@angular/core"),Q=require("rxjs/operators");var A=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((o,r)=>{let i=o instanceof Error?o:new Error(String(o?.message||o||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!r}),t&&t(o,r)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let o=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(o,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",o=>{this.captureError(o,{type:"uncaught_exception"})}),t.on("unhandledRejection",o=>{let r=o instanceof Error?o:new Error(String(o));this.captureError(r,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,o=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(o.has(e))return"[Circular Reference]";o.add(e);let r={};for(let[i,c]of Object.entries(e))r[i]=this.truncate(c,t,o);return r}return e}captureError(e,t={}){let o=e.message||"Erro Desconhecido",r=e.stack||"",i={type:"error",message:this.truncate(o,500),stackTrace:this.truncate(r,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let o={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(o)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let o=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});o.ok||console.error(`[DevInspector] Erro na API (${o.status}): ${o.statusText}`)}catch(o){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",o)}}},k="__DEVINSPECT_AUDIT_CORE_INSTANCE__",te=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[k]||(n[k]=new A),n[k]},f=te();var U,_;U=[(0,L.Injectable)()];var h=class{handleError(e){let t=e instanceof Error?e:new Error(String(e));f.captureError(t,{framework:"Angular",platform:typeof window<"u"?"browser":"server",url:typeof window<"u"?window.location.href:""}),console.error("[DevInspector Angular Error]:",e)}};_=O(null),h=N(_,0,"AuditAngularErrorHandler",U,h),G(_,1,h);var q=(n,e)=>{let t=n.urlWithParams||n.url||"";if(t&&f.isIngestUrl(t))return e(n);let o=typeof performance<"u"?performance.now():Date.now();return e(n).pipe((0,Q.tap)({next:r=>{if(r&&typeof r=="object"&&"status"in r&&"clone"in r){let c=Math.round((typeof performance<"u"?performance.now():Date.now())-o),a=r.status;(a>=400||c>=300)&&f.captureRequest({method:n.method,url:t,statusCode:a,durationMs:c,userAgent:typeof navigator<"u"?navigator.userAgent:"",route:n.url})}},error:r=>{let i=Math.round((typeof performance<"u"?performance.now():Date.now())-o);f.captureRequest({method:n.method,url:t,statusCode:r?.status||0,durationMs:i,userAgent:typeof navigator<"u"?navigator.userAgent:"",route:n.url}),f.captureException(new Error(`HTTP Error ${r?.status||0}: ${r?.message||r?.statusText||"Erro de rede no cliente"}`),{url:t,method:n.method,status:r?.status,type:"angular_network_error"})}}))},ne=q;0&&(module.exports={AuditAngularErrorHandler,audit,auditInterceptor,devInspectorInterceptor});
|
package/dist/angular.d.cts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ErrorHandler } from '@angular/core';
|
|
2
|
+
export { audit } from './index.cjs';
|
|
2
3
|
|
|
3
4
|
declare class AuditAngularErrorHandler implements ErrorHandler {
|
|
4
5
|
handleError(error: unknown): void;
|
|
5
6
|
}
|
|
6
|
-
declare const
|
|
7
|
+
declare const devInspectorInterceptor: (req: any, next: any) => any;
|
|
8
|
+
declare const auditInterceptor: (req: any, next: any) => any;
|
|
7
9
|
|
|
8
|
-
export { AuditAngularErrorHandler, auditInterceptor };
|
|
10
|
+
export { AuditAngularErrorHandler, auditInterceptor, devInspectorInterceptor };
|
package/dist/angular.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ErrorHandler } from '@angular/core';
|
|
2
|
+
export { audit } from './index.js';
|
|
2
3
|
|
|
3
4
|
declare class AuditAngularErrorHandler implements ErrorHandler {
|
|
4
5
|
handleError(error: unknown): void;
|
|
5
6
|
}
|
|
6
|
-
declare const
|
|
7
|
+
declare const devInspectorInterceptor: (req: any, next: any) => any;
|
|
8
|
+
declare const auditInterceptor: (req: any, next: any) => any;
|
|
7
9
|
|
|
8
|
-
export { AuditAngularErrorHandler, auditInterceptor };
|
|
10
|
+
export { AuditAngularErrorHandler, auditInterceptor, devInspectorInterceptor };
|
package/dist/angular.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var L=Object.create;var I=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var j=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),y=n=>{throw TypeError(n)};var q=(n,e,t)=>e in n?I(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var S=(n,e)=>I(n,"name",{value:e,configurable:!0});var K=n=>[,,,L(n?.[j("metadata")]??null)],O=["class","method","getter","setter","accessor","field","value","get","set"],h=n=>n!==void 0&&typeof n!="function"?y("Function expected"):n,F=(n,e,t,r,o)=>({kind:O[n],name:e,metadata:r,addInitializer:i=>t._?y("Already initialized"):o.push(h(i||null))}),H=(n,e)=>q(e,j("metadata"),n[3]),P=(n,e,t,r)=>{for(var o=0,i=n[e>>1],c=i&&i.length;o<c;o++)e&1?i[o].call(t):r=i[o].call(t,r);return r},G=(n,e,t,r,o,i)=>{var c,a,D,l,g,s=e&7,m=!!(e&8),p=!!(e&16),E=s>3?n.length+1:s?m?1:2:0,T=O[s+5],M=s>3&&(n[E-1]=[]),U=n[E]||(n[E]=[]),d=s&&(!p&&!m&&(o=o.prototype),s<5&&(s>3||!p)&&Q(s<4?o:{get[t](){return x(this,i)},set[t](u){return C(this,i,u)}},t));s?p&&s<4&&S(i,(s>2?"set ":s>1?"get ":"")+t):S(o,t);for(var b=r.length-1;b>=0;b--)l=F(s,t,D={},n[3],U),s&&(l.static=m,l.private=p,g=l.access={has:p?u=>$(o,u):u=>t in u},s^3&&(g.get=p?u=>(s^1?x:Y)(u,o,s^4?i:d.get):u=>u[t]),s>2&&(g.set=p?(u,v)=>C(u,o,v,s^4?i:d.set):(u,v)=>u[t]=v)),a=(0,r[b])(s?s<4?p?i:d[T]:s>4?void 0:{get:d.get,set:d.set}:o,l),D._=1,s^4||a===void 0?h(a)&&(s>4?M.unshift(a):s?p?i=a:d[T]=a:o=a):typeof a!="object"||a===null?y("Object expected"):(h(c=a.get)&&(d.get=c),h(c=a.set)&&(d.set=c),h(c=a.init)&&M.unshift(c));return s||H(n,o),d&&I(o,t,d),p?s^4?i:d:o};var R=(n,e,t)=>e.has(n)||y("Cannot "+t),$=(n,e)=>Object(e)!==e?y('Cannot use the "in" operator on this value'):n.has(e),x=(n,e,t)=>(R(n,e,"read from private field"),t?t.call(n):e.get(n));var C=(n,e,t,r)=>(R(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Y=(n,e,t)=>(R(n,e,"access private method"),t);import{Injectable as W}from"@angular/core";import{tap as B}from"rxjs/operators";var A=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((r,o)=>{let i=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),t&&t(r,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let r=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(r,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",r=>{this.captureError(r,{type:"uncaught_exception"})}),t.on("unhandledRejection",r=>{let o=r instanceof Error?r:new Error(String(r));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,r=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(r.has(e))return"[Circular Reference]";r.add(e);let o={};for(let[i,c]of Object.entries(e))o[i]=this.truncate(c,t,r);return o}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let r={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(r)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},k="__DEVINSPECT_AUDIT_CORE_INSTANCE__",z=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[k]||(n[k]=new A),n[k]},f=z();var N,_;N=[W()];var w=class{handleError(e){let t=e instanceof Error?e:new Error(String(e));f.captureError(t,{framework:"Angular",platform:typeof window<"u"?"browser":"server",url:typeof window<"u"?window.location.href:""}),console.error("[DevInspector Angular Error]:",e)}};_=K(null),w=G(_,0,"AuditAngularErrorHandler",N,w),P(_,1,w);var J=(n,e)=>{let t=n.urlWithParams||n.url||"";if(t&&f.isIngestUrl(t))return e(n);let r=typeof performance<"u"?performance.now():Date.now();return e(n).pipe(B({next:o=>{if(o&&typeof o=="object"&&"status"in o&&"clone"in o){let c=Math.round((typeof performance<"u"?performance.now():Date.now())-r),a=o.status;(a>=400||c>=300)&&f.captureRequest({method:n.method,url:t,statusCode:a,durationMs:c,userAgent:typeof navigator<"u"?navigator.userAgent:"",route:n.url})}},error:o=>{let i=Math.round((typeof performance<"u"?performance.now():Date.now())-r);f.captureRequest({method:n.method,url:t,statusCode:o?.status||0,durationMs:i,userAgent:typeof navigator<"u"?navigator.userAgent:"",route:n.url}),f.captureException(new Error(`HTTP Error ${o?.status||0}: ${o?.message||o?.statusText||"Erro de rede no cliente"}`),{url:t,method:n.method,status:o?.status,type:"angular_network_error"})}}))},re=J;export{w as AuditAngularErrorHandler,f as audit,re as auditInterceptor,J as devInspectorInterceptor};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var h=(o,e)=>{for(var t in e)a(o,t,{get:e[t],enumerable:!0})},y=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of l(e))!f.call(o,r)&&r!==t&&a(o,r,{get:()=>e[r],enumerable:!(n=p(e,r))||n.enumerable});return o};var g=o=>y(a({},"__esModule",{value:!0}),o);var m={};h(m,{AuditCore:()=>s,audit:()=>d});module.exports=g(m);var s=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((n,r)=>{let i=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!r}),t&&t(n,r)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let n=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),t.on("unhandledRejection",n=>{let r=n instanceof Error?n:new Error(String(n));this.captureError(r,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,n=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(n.has(e))return"[Circular Reference]";n.add(e);let r={};for(let[i,u]of Object.entries(e))r[i]=this.truncate(u,t,n);return r}return e}captureError(e,t={}){let n=e.message||"Erro Desconhecido",r=e.stack||"",i={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(r,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let n={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(n)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});n.ok||console.error(`[DevInspector] Erro na API (${n.status}): ${n.statusText}`)}catch(n){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",n)}}},c="__DEVINSPECT_AUDIT_CORE_INSTANCE__",w=()=>{let o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return o[c]||(o[c]=new s),o[c]},d=w();0&&(module.exports={AuditCore,audit});
|
package/dist/index.d.cts
CHANGED
|
@@ -21,6 +21,7 @@ declare class AuditCore {
|
|
|
21
21
|
initialized: boolean;
|
|
22
22
|
private listenersAttached;
|
|
23
23
|
init(options: InitOptions): void;
|
|
24
|
+
isIngestUrl(targetUrl: string): boolean;
|
|
24
25
|
captureRequest(data: RequestMetricData): void;
|
|
25
26
|
private listenGlobalErrors;
|
|
26
27
|
private truncate;
|
|
@@ -31,4 +32,4 @@ declare class AuditCore {
|
|
|
31
32
|
}
|
|
32
33
|
declare const audit: AuditCore;
|
|
33
34
|
|
|
34
|
-
export { type InitOptions, audit };
|
|
35
|
+
export { AuditCore, type InitOptions, type RequestMetricData, audit };
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ declare class AuditCore {
|
|
|
21
21
|
initialized: boolean;
|
|
22
22
|
private listenersAttached;
|
|
23
23
|
init(options: InitOptions): void;
|
|
24
|
+
isIngestUrl(targetUrl: string): boolean;
|
|
24
25
|
captureRequest(data: RequestMetricData): void;
|
|
25
26
|
private listenGlobalErrors;
|
|
26
27
|
private truncate;
|
|
@@ -31,4 +32,4 @@ declare class AuditCore {
|
|
|
31
32
|
}
|
|
32
33
|
declare const audit: AuditCore;
|
|
33
34
|
|
|
34
|
-
export { type InitOptions, audit };
|
|
35
|
+
export { AuditCore, type InitOptions, type RequestMetricData, audit };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var s=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((n,r)=>{let o=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(o,{type:"react_native_error",isFatal:!!r}),t&&t(n,r)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let n=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),t.on("unhandledRejection",n=>{let r=n instanceof Error?n:new Error(String(n));this.captureError(r,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,n=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(n.has(e))return"[Circular Reference]";n.add(e);let r={};for(let[o,c]of Object.entries(e))r[o]=this.truncate(c,t,n);return r}return e}captureError(e,t={}){let n=e.message||"Erro Desconhecido",r=e.stack||"",o={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(r,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(o)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let n={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(n)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});n.ok||console.error(`[DevInspector] Erro na API (${n.status}): ${n.statusText}`)}catch(n){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",n)}}},a="__DEVINSPECT_AUDIT_CORE_INSTANCE__",d=()=>{let i=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return i[a]||(i[a]=new s),i[a]},u=d();export{s as AuditCore,u as audit};
|
package/dist/next.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var t in e)p(n,t,{get:e[t],enumerable:!0})},v=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!E.call(n,o)&&o!==t&&p(n,o,{get:()=>e[o],enumerable:!(r=g(e,o))||r.enumerable});return n};var A=n=>v(p({},"__esModule",{value:!0}),n);var M={};b(M,{audit:()=>i,auditFetch:()=>T,captureNextError:()=>h,initNextDevInspector:()=>I,withAuditAction:()=>D,withAuditApi:()=>_});module.exports=A(M);var l=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((r,o)=>{let s=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(s,{type:"react_native_error",isFatal:!!o}),t&&t(r,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let r=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(r,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",r=>{this.captureError(r,{type:"uncaught_exception"})}),t.on("unhandledRejection",r=>{let o=r instanceof Error?r:new Error(String(r));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,r=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(r.has(e))return"[Circular Reference]";r.add(e);let o={};for(let[s,c]of Object.entries(e))o[s]=this.truncate(c,t,r);return o}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",o=e.stack||"",s={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(s)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let r={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(r)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},f="__DEVINSPECT_AUDIT_CORE_INSTANCE__",R=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[f]||(n[f]=new l),n[f]},i=R();async function w(n,e,t){let r=t?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&i.isIngestUrl(o))return r(n,e);let s=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let a=await r(n,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(a.status>=400||u>=300)&&i.captureRequest({method:s,url:o,statusCode:a.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),a}catch(a){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw i.captureRequest({method:s,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),i.captureException(a instanceof Error?a:new Error(String(a)),{url:o,method:s,type:t?.errorType||"network_error"}),a}}function I(n){i.init(n)}function h(n,e={}){let t=n instanceof Error?n:new Error(String(n));i.captureError(t,{framework:"nextjs",...e})}async function T(n,e){return w(n,e,{errorType:"nextjs_network_error"})}function _(n){return async function(...e){let t=typeof performance<"u"?performance.now():Date.now(),r=e[0],o=e[1],s=r?.method||"GET",c=r?.url||r?.nextUrl?.href||"/api",a=typeof r?.headers?.get=="function"?r.headers.get("user-agent")||"":r?.headers?.["user-agent"]||"";try{let u=await n(...e),d=Math.round((typeof performance<"u"?performance.now():Date.now())-t),y=u?.status||o?.statusCode||200;return(y>=400||d>=300)&&i.captureRequest({method:s,url:c,statusCode:y,durationMs:d,route:c,userAgent:a}),u}catch(u){let d=Math.round((typeof performance<"u"?performance.now():Date.now())-t);throw i.captureRequest({method:s,url:c,statusCode:500,durationMs:d,route:c,userAgent:a}),h(u,{url:c,method:s,type:"api_route_error"}),u}}}function D(n,e){return(async(...t)=>{let r=typeof performance<"u"?performance.now():Date.now();try{let o=await e(...t),s=Math.round((typeof performance<"u"?performance.now():Date.now())-r);return s>=300&&i.captureRequest({method:"ACTION",url:n,statusCode:200,durationMs:s,route:n}),o}catch(o){let s=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw i.captureRequest({method:"ACTION",url:n,statusCode:500,durationMs:s,route:n}),h(o,{actionName:n,type:"server_action_error"}),o}})}0&&(module.exports={audit,auditFetch,captureNextError,initNextDevInspector,withAuditAction,withAuditApi});
|
package/dist/next.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((n,o)=>{let s=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(s,{type:"react_native_error",isFatal:!!o}),t&&t(n,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let n=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),t.on("unhandledRejection",n=>{let o=n instanceof Error?n:new Error(String(n));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,n=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(n.has(e))return"[Circular Reference]";n.add(e);let o={};for(let[s,c]of Object.entries(e))o[s]=this.truncate(c,t,n);return o}return e}captureError(e,t={}){let n=e.message||"Erro Desconhecido",o=e.stack||"",s={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(s)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let n={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(n)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});n.ok||console.error(`[DevInspector] Erro na API (${n.status}): ${n.statusText}`)}catch(n){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",n)}}},p="__DEVINSPECT_AUDIT_CORE_INSTANCE__",w=()=>{let r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return r[p]||(r[p]=new f),r[p]},a=w();async function h(r,e,t){let n=t?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof r=="string"?o=r:r instanceof URL?o=r.toString():typeof r=="object"&&r!==null&&"url"in r&&(o=r.url),o&&a.isIngestUrl(o))return n(r,e);let s=e?.method||(typeof r=="object"&&r!==null&&"method"in r?r.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let i=await n(r,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(i.status>=400||u>=300)&&a.captureRequest({method:s,url:o,statusCode:i.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),i}catch(i){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw a.captureRequest({method:s,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),a.captureException(i instanceof Error?i:new Error(String(i)),{url:o,method:s,type:t?.errorType||"network_error"}),i}}function b(r){a.init(r)}function y(r,e={}){let t=r instanceof Error?r:new Error(String(r));a.captureError(t,{framework:"nextjs",...e})}async function v(r,e){return h(r,e,{errorType:"nextjs_network_error"})}function A(r){return async function(...e){let t=typeof performance<"u"?performance.now():Date.now(),n=e[0],o=e[1],s=n?.method||"GET",c=n?.url||n?.nextUrl?.href||"/api",i=typeof n?.headers?.get=="function"?n.headers.get("user-agent")||"":n?.headers?.["user-agent"]||"";try{let u=await r(...e),d=Math.round((typeof performance<"u"?performance.now():Date.now())-t),l=u?.status||o?.statusCode||200;return(l>=400||d>=300)&&a.captureRequest({method:s,url:c,statusCode:l,durationMs:d,route:c,userAgent:i}),u}catch(u){let d=Math.round((typeof performance<"u"?performance.now():Date.now())-t);throw a.captureRequest({method:s,url:c,statusCode:500,durationMs:d,route:c,userAgent:i}),y(u,{url:c,method:s,type:"api_route_error"}),u}}}function R(r,e){return(async(...t)=>{let n=typeof performance<"u"?performance.now():Date.now();try{let o=await e(...t),s=Math.round((typeof performance<"u"?performance.now():Date.now())-n);return s>=300&&a.captureRequest({method:"ACTION",url:r,statusCode:200,durationMs:s,route:r}),o}catch(o){let s=Math.round((typeof performance<"u"?performance.now():Date.now())-n);throw a.captureRequest({method:"ACTION",url:r,statusCode:500,durationMs:s,route:r}),y(o,{actionName:r,type:"server_action_error"}),o}})}export{a as audit,v as auditFetch,y as captureNextError,b as initNextDevInspector,R as withAuditAction,A as withAuditApi};
|
package/dist/node.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var S=(n,e)=>{for(var r in e)p(n,r,{get:e[r],enumerable:!0})},T=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of A(e))!M.call(n,o)&&o!==r&&p(n,o,{get:()=>e[o],enumerable:!(t=R(e,o))||t.enumerable});return n};var k=n=>T(p({},"__esModule",{value:!0}),n);var Q={};S(Q,{audit:()=>a,auditFetch:()=>D,auditOperation:()=>O,devInspector:()=>_,devInspectorErrorHandler:()=>P});module.exports=k(Q);var m=require("async_hooks");var h=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let r=new URL(this.endpoint);return e.includes(r.host)||e.includes(r.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let r={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(r)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((t,o)=>{let s=t instanceof Error?t:new Error(String(t?.message||t||"Erro React Native desconhecido"));this.captureError(s,{type:"react_native_error",isFatal:!!o}),r&&r(t,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",r=>{this.captureError(r.error||new Error(r.message||"Erro global desconhecido"),{filename:r.filename,lineno:r.lineno,colno:r.colno})}),window.addEventListener("unhandledrejection",r=>{let t=r.reason instanceof Error?r.reason:new Error(String(r.reason));this.captureError(t,{type:"unhandled_rejection"})});else if(e.process?.on){let r=e.process;r.on("uncaughtException",t=>{this.captureError(t,{type:"uncaught_exception"})}),r.on("unhandledRejection",t=>{let o=t instanceof Error?t:new Error(String(t));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,r=5e3,t=new WeakSet){if(typeof e=="string")return e.length>r?e.substring(0,r)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(t.has(e))return"[Circular Reference]";t.add(e);let o={};for(let[s,i]of Object.entries(e))o[s]=this.truncate(i,r,t);return o}return e}captureError(e,r={}){let t=e.message||"Erro Desconhecido",o=e.stack||"",s={type:"error",message:this.truncate(t,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(s)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let t={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(t)}async send(e){let r=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify(e),keepalive:!0});t.ok||console.error(`[DevInspector] Erro na API (${t.status}): ${t.statusText}`)}catch(t){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",t)}}},f="__DEVINSPECT_AUDIT_CORE_INSTANCE__",x=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[f]||(n[f]=new h),n[f]},a=x();async function w(n,e,r){let t=r?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&a.isIngestUrl(o))return t(n,e);let s=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),i=typeof performance<"u"?performance.now():Date.now();try{let c=await t(n,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-i);return(c.status>=400||u>=300)&&a.captureRequest({method:s,url:o,statusCode:c.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),c}catch(c){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-i);throw a.captureRequest({method:s,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),a.captureException(c instanceof Error?c:new Error(String(c)),{url:o,method:s,type:r?.errorType||"network_error"}),c}}var y=new m.AsyncLocalStorage;function C(n){if(!n)return{};let e={...n},r=["authorization","cookie","set-cookie","x-api-key","proxy-authorization"];for(let t of r)e[t]&&(e[t]="[REDACTED]");return e}function _(n){a.init(n);let e=n.slowThresholdMs??300,r=n.ignorePaths??["/uploads","/favicon.ico"];return(t,o,s)=>{let i=t.originalUrl||t.url||"";if(i&&a.isIngestUrl(i)||r.some(d=>typeof d=="string"?i.startsWith(d):d.test(i)))return s();let u=performance.now();y.run({req:t,queriesCount:0,slowQueries:0},()=>{o.on("finish",()=>{let d=Math.round(performance.now()-u),l=y.getStore(),g=o.statusCode,b=g>=400,E=d>=e,v=(l?.slowQueries||0)>0;if(b||E||v){let I=t.route?.path?`${t.baseUrl||""}${t.route.path}`:t.baseUrl||i;a.captureRequest({method:t.method,url:i,statusCode:g,durationMs:d,userAgent:t.headers?.["user-agent"],route:I,dbQueriesCount:l?.queriesCount||0,slowQueryMs:l?.slowQueries||0})}}),s()})}}async function D(n,e){return w(n,e,{errorType:"node_network_error"})}async function O(n,e,r=300){let t=y.getStore(),o=performance.now();t&&t.queriesCount++;try{let s=await e(),i=performance.now()-o;return i>r&&t&&(t.slowQueries=Math.max(t.slowQueries,Math.round(i)),a.captureMessage(`Slow Query detectada em [${n}]`,{durationMs:Math.round(i),operationName:n,url:t.req?.originalUrl||t.req?.url})),s}catch(s){let i=performance.now()-o;throw a.captureException(s,{operationName:n,durationMs:Math.round(i)}),s}}function P(){return(n,e,r,t)=>{a.captureException(n,{url:e.originalUrl||e.url,method:e.method,headers:C(e.headers)}),t(n)}}0&&(module.exports={audit,auditFetch,auditOperation,devInspector,devInspectorErrorHandler});
|
package/dist/node.d.cts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { InitOptions } from './index.cjs';
|
|
2
|
+
export { audit } from './index.cjs';
|
|
2
3
|
|
|
3
4
|
interface DevInspectorNodeOptions extends InitOptions {
|
|
5
|
+
slowThresholdMs?: number;
|
|
6
|
+
ignorePaths?: (string | RegExp)[];
|
|
4
7
|
}
|
|
5
8
|
declare function devInspector(options: DevInspectorNodeOptions): (req: any, res: any, next: any) => any;
|
|
9
|
+
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
6
10
|
declare function auditOperation<T>(name: string, operation: () => Promise<T>, thresholdMs?: number): Promise<T>;
|
|
7
11
|
declare function devInspectorErrorHandler(): (err: any, req: any, res: any, next: any) => void;
|
|
8
12
|
|
|
9
|
-
export { type DevInspectorNodeOptions, auditOperation, devInspector, devInspectorErrorHandler };
|
|
13
|
+
export { type DevInspectorNodeOptions, InitOptions, auditFetch, auditOperation, devInspector, devInspectorErrorHandler };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { InitOptions } from './index.js';
|
|
2
|
+
export { audit } from './index.js';
|
|
2
3
|
|
|
3
4
|
interface DevInspectorNodeOptions extends InitOptions {
|
|
5
|
+
slowThresholdMs?: number;
|
|
6
|
+
ignorePaths?: (string | RegExp)[];
|
|
4
7
|
}
|
|
5
8
|
declare function devInspector(options: DevInspectorNodeOptions): (req: any, res: any, next: any) => any;
|
|
9
|
+
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
6
10
|
declare function auditOperation<T>(name: string, operation: () => Promise<T>, thresholdMs?: number): Promise<T>;
|
|
7
11
|
declare function devInspectorErrorHandler(): (err: any, req: any, res: any, next: any) => void;
|
|
8
12
|
|
|
9
|
-
export { type DevInspectorNodeOptions, auditOperation, devInspector, devInspectorErrorHandler };
|
|
13
|
+
export { type DevInspectorNodeOptions, InitOptions, auditFetch, auditOperation, devInspector, devInspectorErrorHandler };
|
package/dist/node.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AsyncLocalStorage as
|
|
1
|
+
import{AsyncLocalStorage as I}from"async_hooks";var f=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let r=new URL(this.endpoint);return e.includes(r.host)||e.includes(r.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let r={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(r)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((t,o)=>{let s=t instanceof Error?t:new Error(String(t?.message||t||"Erro React Native desconhecido"));this.captureError(s,{type:"react_native_error",isFatal:!!o}),r&&r(t,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",r=>{this.captureError(r.error||new Error(r.message||"Erro global desconhecido"),{filename:r.filename,lineno:r.lineno,colno:r.colno})}),window.addEventListener("unhandledrejection",r=>{let t=r.reason instanceof Error?r.reason:new Error(String(r.reason));this.captureError(t,{type:"unhandled_rejection"})});else if(e.process?.on){let r=e.process;r.on("uncaughtException",t=>{this.captureError(t,{type:"uncaught_exception"})}),r.on("unhandledRejection",t=>{let o=t instanceof Error?t:new Error(String(t));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,r=5e3,t=new WeakSet){if(typeof e=="string")return e.length>r?e.substring(0,r)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(t.has(e))return"[Circular Reference]";t.add(e);let o={};for(let[s,i]of Object.entries(e))o[s]=this.truncate(i,r,t);return o}return e}captureError(e,r={}){let t=e.message||"Erro Desconhecido",o=e.stack||"",s={type:"error",message:this.truncate(t,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(s)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let t={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(t)}async send(e){let r=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify(e),keepalive:!0});t.ok||console.error(`[DevInspector] Erro na API (${t.status}): ${t.statusText}`)}catch(t){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",t)}}},p="__DEVINSPECT_AUDIT_CORE_INSTANCE__",v=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[p]||(n[p]=new f),n[p]},a=v();async function g(n,e,r){let t=r?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&a.isIngestUrl(o))return t(n,e);let s=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),i=typeof performance<"u"?performance.now():Date.now();try{let c=await t(n,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-i);return(c.status>=400||u>=300)&&a.captureRequest({method:s,url:o,statusCode:c.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),c}catch(c){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-i);throw a.captureRequest({method:s,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),a.captureException(c instanceof Error?c:new Error(String(c)),{url:o,method:s,type:r?.errorType||"network_error"}),c}}var h=new I;function R(n){if(!n)return{};let e={...n},r=["authorization","cookie","set-cookie","x-api-key","proxy-authorization"];for(let t of r)e[t]&&(e[t]="[REDACTED]");return e}function T(n){a.init(n);let e=n.slowThresholdMs??300,r=n.ignorePaths??["/uploads","/favicon.ico"];return(t,o,s)=>{let i=t.originalUrl||t.url||"";if(i&&a.isIngestUrl(i)||r.some(d=>typeof d=="string"?i.startsWith(d):d.test(i)))return s();let u=performance.now();h.run({req:t,queriesCount:0,slowQueries:0},()=>{o.on("finish",()=>{let d=Math.round(performance.now()-u),l=h.getStore(),y=o.statusCode,w=y>=400,m=d>=e,b=(l?.slowQueries||0)>0;if(w||m||b){let E=t.route?.path?`${t.baseUrl||""}${t.route.path}`:t.baseUrl||i;a.captureRequest({method:t.method,url:i,statusCode:y,durationMs:d,userAgent:t.headers?.["user-agent"],route:E,dbQueriesCount:l?.queriesCount||0,slowQueryMs:l?.slowQueries||0})}}),s()})}}async function k(n,e){return g(n,e,{errorType:"node_network_error"})}async function x(n,e,r=300){let t=h.getStore(),o=performance.now();t&&t.queriesCount++;try{let s=await e(),i=performance.now()-o;return i>r&&t&&(t.slowQueries=Math.max(t.slowQueries,Math.round(i)),a.captureMessage(`Slow Query detectada em [${n}]`,{durationMs:Math.round(i),operationName:n,url:t.req?.originalUrl||t.req?.url})),s}catch(s){let i=performance.now()-o;throw a.captureException(s,{operationName:n,durationMs:Math.round(i)}),s}}function C(){return(n,e,r,t)=>{a.captureException(n,{url:e.originalUrl||e.url,method:e.method,headers:R(e.headers)}),t(n)}}export{a as audit,k as auditFetch,x as auditOperation,T as devInspector,C as devInspectorErrorHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var r in e)d(n,r,{get:e[r],enumerable:!0})},v=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!w.call(n,o)&&o!==r&&d(n,o,{get:()=>e[o],enumerable:!(t=E(e,o))||t.enumerable});return n};var R=n=>v(d({},"__esModule",{value:!0}),n);var A={};b(A,{AuditErrorBoundary:()=>f,audit:()=>a,auditFetch:()=>y,enableNetworkTracing:()=>I});module.exports=R(A);var g=require("react");var l=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let r=new URL(this.endpoint);return e.includes(r.host)||e.includes(r.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let r={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(r)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((t,o)=>{let i=t instanceof Error?t:new Error(String(t?.message||t||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),r&&r(t,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",r=>{this.captureError(r.error||new Error(r.message||"Erro global desconhecido"),{filename:r.filename,lineno:r.lineno,colno:r.colno})}),window.addEventListener("unhandledrejection",r=>{let t=r.reason instanceof Error?r.reason:new Error(String(r.reason));this.captureError(t,{type:"unhandled_rejection"})});else if(e.process?.on){let r=e.process;r.on("uncaughtException",t=>{this.captureError(t,{type:"uncaught_exception"})}),r.on("unhandledRejection",t=>{let o=t instanceof Error?t:new Error(String(t));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,r=5e3,t=new WeakSet){if(typeof e=="string")return e.length>r?e.substring(0,r)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(t.has(e))return"[Circular Reference]";t.add(e);let o={};for(let[i,c]of Object.entries(e))o[i]=this.truncate(c,r,t);return o}return e}captureError(e,r={}){let t=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(t,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let t={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(t)}async send(e){let r=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify(e),keepalive:!0});t.ok||console.error(`[DevInspector] Erro na API (${t.status}): ${t.statusText}`)}catch(t){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",t)}}},p="__DEVINSPECT_AUDIT_CORE_INSTANCE__",_=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[p]||(n[p]=new l),n[p]},a=_();async function h(n,e,r){let t=r?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&a.isIngestUrl(o))return t(n,e);let i=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let s=await t(n,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(s.status>=400||u>=300)&&a.captureRequest({method:i,url:o,statusCode:s.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),s}catch(s){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw a.captureRequest({method:i,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),a.captureException(s instanceof Error?s:new Error(String(s)),{url:o,method:i,type:r?.errorType||"network_error"}),s}}var f=class extends g.Component{constructor(){super(...arguments);this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,t){a.captureError(r,{platform:"react-native",componentStack:t.componentStack}),this.props.onError&&this.props.onError(r,t)}render(){if(this.state.hasError){let{fallback:r}=this.props,t=this.state.error||new Error("Erro desconhecido");return typeof r=="function"?r(t):r??null}return this.props.children}};async function y(n,e){return h(n,e,{errorType:"react_native_network_error",defaultUserAgent:"React-Native"})}function I(){let n=globalThis;!n.fetch||n.__DEVINSPECTOR_FETCH_PATCHED__||(n.__DEVINSPECTOR_FETCH_PATCHED__=!0,n.fetch=async function(e,r){return y(e,r)})}0&&(module.exports={AuditErrorBoundary,audit,auditFetch,enableNetworkTracing});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Component, ReactNode, ErrorInfo } from 'react';
|
|
2
|
+
export { audit } from './index.cjs';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
fallback?: ReactNode | ((error: Error) => ReactNode);
|
|
7
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
8
|
+
}
|
|
9
|
+
interface State {
|
|
10
|
+
hasError: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
}
|
|
13
|
+
declare class AuditErrorBoundary extends Component<Props, State> {
|
|
14
|
+
state: State;
|
|
15
|
+
static getDerivedStateFromError(error: Error): State;
|
|
16
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
17
|
+
render(): ReactNode;
|
|
18
|
+
}
|
|
19
|
+
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
20
|
+
declare function enableNetworkTracing(): void;
|
|
21
|
+
|
|
22
|
+
export { AuditErrorBoundary, auditFetch, enableNetworkTracing };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Component, ReactNode, ErrorInfo } from 'react';
|
|
2
|
+
export { audit } from './index.js';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
fallback?: ReactNode | ((error: Error) => ReactNode);
|
|
7
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
8
|
+
}
|
|
9
|
+
interface State {
|
|
10
|
+
hasError: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
}
|
|
13
|
+
declare class AuditErrorBoundary extends Component<Props, State> {
|
|
14
|
+
state: State;
|
|
15
|
+
static getDerivedStateFromError(error: Error): State;
|
|
16
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
17
|
+
render(): ReactNode;
|
|
18
|
+
}
|
|
19
|
+
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
20
|
+
declare function enableNetworkTracing(): void;
|
|
21
|
+
|
|
22
|
+
export { AuditErrorBoundary, auditFetch, enableNetworkTracing };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Component as g}from"react";var p=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let r=new URL(this.endpoint);return e.includes(r.host)||e.includes(r.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let r={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(r)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((t,o)=>{let i=t instanceof Error?t:new Error(String(t?.message||t||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),r&&r(t,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",r=>{this.captureError(r.error||new Error(r.message||"Erro global desconhecido"),{filename:r.filename,lineno:r.lineno,colno:r.colno})}),window.addEventListener("unhandledrejection",r=>{let t=r.reason instanceof Error?r.reason:new Error(String(r.reason));this.captureError(t,{type:"unhandled_rejection"})});else if(e.process?.on){let r=e.process;r.on("uncaughtException",t=>{this.captureError(t,{type:"uncaught_exception"})}),r.on("unhandledRejection",t=>{let o=t instanceof Error?t:new Error(String(t));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,r=5e3,t=new WeakSet){if(typeof e=="string")return e.length>r?e.substring(0,r)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(t.has(e))return"[Circular Reference]";t.add(e);let o={};for(let[i,c]of Object.entries(e))o[i]=this.truncate(c,r,t);return o}return e}captureError(e,r={}){let t=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(t,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let t={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(t)}async send(e){let r=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify(e),keepalive:!0});t.ok||console.error(`[DevInspector] Erro na API (${t.status}): ${t.statusText}`)}catch(t){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",t)}}},d="__DEVINSPECT_AUDIT_CORE_INSTANCE__",h=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[d]||(n[d]=new p),n[d]},a=h();async function l(n,e,r){let t=r?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&a.isIngestUrl(o))return t(n,e);let i=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let s=await t(n,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(s.status>=400||u>=300)&&a.captureRequest({method:i,url:o,statusCode:s.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),s}catch(s){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw a.captureRequest({method:i,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),a.captureException(s instanceof Error?s:new Error(String(s)),{url:o,method:i,type:r?.errorType||"network_error"}),s}}var f=class extends g{constructor(){super(...arguments);this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,t){a.captureError(r,{platform:"react-native",componentStack:t.componentStack}),this.props.onError&&this.props.onError(r,t)}render(){if(this.state.hasError){let{fallback:r}=this.props,t=this.state.error||new Error("Erro desconhecido");return typeof r=="function"?r(t):r??null}return this.props.children}};async function y(n,e){return l(n,e,{errorType:"react_native_network_error",defaultUserAgent:"React-Native"})}function _(){let n=globalThis;!n.fetch||n.__DEVINSPECTOR_FETCH_PATCHED__||(n.__DEVINSPECTOR_FETCH_PATCHED__=!0,n.fetch=async function(e,r){return y(e,r)})}export{f as AuditErrorBoundary,a as audit,y as auditFetch,_ as enableNetworkTracing};
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var v=(n,e)=>{for(var r in e)u(n,r,{get:e[r],enumerable:!0})},R=(n,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!b.call(n,o)&&o!==r&&u(n,o,{get:()=>e[o],enumerable:!(t=w(e,o))||t.enumerable});return n};var _=n=>R(u({},"__esModule",{value:!0}),n);var S={};v(S,{AuditErrorBoundary:()=>f,audit:()=>a,auditFetch:()=>g,enableNetworkTracing:()=>A});module.exports=_(S);var y=require("react");var l=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let r=new URL(this.endpoint);return e.includes(r.host)||e.includes(r.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let r={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(r)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((t,o)=>{let i=t instanceof Error?t:new Error(String(t?.message||t||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),r&&r(t,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",r=>{this.captureError(r.error||new Error(r.message||"Erro global desconhecido"),{filename:r.filename,lineno:r.lineno,colno:r.colno})}),window.addEventListener("unhandledrejection",r=>{let t=r.reason instanceof Error?r.reason:new Error(String(r.reason));this.captureError(t,{type:"unhandled_rejection"})});else if(e.process?.on){let r=e.process;r.on("uncaughtException",t=>{this.captureError(t,{type:"uncaught_exception"})}),r.on("unhandledRejection",t=>{let o=t instanceof Error?t:new Error(String(t));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,r=5e3,t=new WeakSet){if(typeof e=="string")return e.length>r?e.substring(0,r)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(t.has(e))return"[Circular Reference]";t.add(e);let o={};for(let[i,c]of Object.entries(e))o[i]=this.truncate(c,r,t);return o}return e}captureError(e,r={}){let t=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(t,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let t={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(t)}async send(e){let r=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify(e),keepalive:!0});t.ok||console.error(`[DevInspector] Erro na API (${t.status}): ${t.statusText}`)}catch(t){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",t)}}},p="__DEVINSPECT_AUDIT_CORE_INSTANCE__",I=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[p]||(n[p]=new l),n[p]},a=I();async function h(n,e,r){let t=r?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&a.isIngestUrl(o))return t(n,e);let i=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let s=await t(n,e),d=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(s.status>=400||d>=300)&&a.captureRequest({method:i,url:o,statusCode:s.status,durationMs:d,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),s}catch(s){let d=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw a.captureRequest({method:i,url:o,statusCode:0,durationMs:d,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),a.captureException(s instanceof Error?s:new Error(String(s)),{url:o,method:i,type:r?.errorType||"network_error"}),s}}var E=require("react/jsx-runtime"),f=class extends y.Component{constructor(){super(...arguments);this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,t){a.captureError(r,{framework:"React",componentStack:t.componentStack,url:typeof window<"u"?window.location.href:""}),this.props.onError&&this.props.onError(r,t)}render(){if(this.state.hasError){let{fallback:r}=this.props,t=this.state.error||new Error("Erro desconhecido no componente");return typeof r=="function"?r(t):r??(0,E.jsx)("h1",{children:"Algo deu errado na aplica\xE7\xE3o."})}return this.props.children}};async function g(n,e){return h(n,e,{errorType:"react_network_error"})}function A(){let n=globalThis;!n.fetch||n.__DEVINSPECTOR_FETCH_PATCHED__||(n.__DEVINSPECTOR_FETCH_PATCHED__=!0,n.fetch=async function(e,r){return g(e,r)})}0&&(module.exports={AuditErrorBoundary,audit,auditFetch,enableNetworkTracing});
|
package/dist/react.d.cts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { Component, ReactNode, ErrorInfo } from 'react';
|
|
2
|
+
export { audit } from './index.cjs';
|
|
2
3
|
|
|
3
4
|
interface Props {
|
|
4
5
|
children: ReactNode;
|
|
5
|
-
fallback?: ReactNode;
|
|
6
|
+
fallback?: ReactNode | ((error: Error) => ReactNode);
|
|
7
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
6
8
|
}
|
|
7
9
|
interface State {
|
|
8
10
|
hasError: boolean;
|
|
11
|
+
error: Error | null;
|
|
9
12
|
}
|
|
10
13
|
declare class AuditErrorBoundary extends Component<Props, State> {
|
|
11
14
|
state: State;
|
|
12
|
-
static getDerivedStateFromError(): State;
|
|
15
|
+
static getDerivedStateFromError(error: Error): State;
|
|
13
16
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
14
17
|
render(): ReactNode;
|
|
15
18
|
}
|
|
16
19
|
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
20
|
+
declare function enableNetworkTracing(): void;
|
|
17
21
|
|
|
18
|
-
export { AuditErrorBoundary, auditFetch };
|
|
22
|
+
export { AuditErrorBoundary, auditFetch, enableNetworkTracing };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { Component, ReactNode, ErrorInfo } from 'react';
|
|
2
|
+
export { audit } from './index.js';
|
|
2
3
|
|
|
3
4
|
interface Props {
|
|
4
5
|
children: ReactNode;
|
|
5
|
-
fallback?: ReactNode;
|
|
6
|
+
fallback?: ReactNode | ((error: Error) => ReactNode);
|
|
7
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
6
8
|
}
|
|
7
9
|
interface State {
|
|
8
10
|
hasError: boolean;
|
|
11
|
+
error: Error | null;
|
|
9
12
|
}
|
|
10
13
|
declare class AuditErrorBoundary extends Component<Props, State> {
|
|
11
14
|
state: State;
|
|
12
|
-
static getDerivedStateFromError(): State;
|
|
15
|
+
static getDerivedStateFromError(error: Error): State;
|
|
13
16
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
14
17
|
render(): ReactNode;
|
|
15
18
|
}
|
|
16
19
|
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
20
|
+
declare function enableNetworkTracing(): void;
|
|
17
21
|
|
|
18
|
-
export { AuditErrorBoundary, auditFetch };
|
|
22
|
+
export { AuditErrorBoundary, auditFetch, enableNetworkTracing };
|
package/dist/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Component as
|
|
1
|
+
import{Component as y}from"react";var p=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let r=new URL(this.endpoint);return e.includes(r.host)||e.includes(r.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let r={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(r)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((t,o)=>{let i=t instanceof Error?t:new Error(String(t?.message||t||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),r&&r(t,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",r=>{this.captureError(r.error||new Error(r.message||"Erro global desconhecido"),{filename:r.filename,lineno:r.lineno,colno:r.colno})}),window.addEventListener("unhandledrejection",r=>{let t=r.reason instanceof Error?r.reason:new Error(String(r.reason));this.captureError(t,{type:"unhandled_rejection"})});else if(e.process?.on){let r=e.process;r.on("uncaughtException",t=>{this.captureError(t,{type:"uncaught_exception"})}),r.on("unhandledRejection",t=>{let o=t instanceof Error?t:new Error(String(t));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,r=5e3,t=new WeakSet){if(typeof e=="string")return e.length>r?e.substring(0,r)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(t.has(e))return"[Circular Reference]";t.add(e);let o={};for(let[i,c]of Object.entries(e))o[i]=this.truncate(c,r,t);return o}return e}captureError(e,r={}){let t=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(t,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let t={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(t)}async send(e){let r=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify(e),keepalive:!0});t.ok||console.error(`[DevInspector] Erro na API (${t.status}): ${t.statusText}`)}catch(t){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",t)}}},u="__DEVINSPECT_AUDIT_CORE_INSTANCE__",h=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[u]||(n[u]=new p),n[u]},a=h();async function l(n,e,r){let t=r?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&a.isIngestUrl(o))return t(n,e);let i=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let s=await t(n,e),d=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(s.status>=400||d>=300)&&a.captureRequest({method:i,url:o,statusCode:s.status,durationMs:d,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),s}catch(s){let d=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw a.captureRequest({method:i,url:o,statusCode:0,durationMs:d,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),a.captureException(s instanceof Error?s:new Error(String(s)),{url:o,method:i,type:r?.errorType||"network_error"}),s}}import{jsx as E}from"react/jsx-runtime";var f=class extends y{constructor(){super(...arguments);this.state={hasError:!1,error:null}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,t){a.captureError(r,{framework:"React",componentStack:t.componentStack,url:typeof window<"u"?window.location.href:""}),this.props.onError&&this.props.onError(r,t)}render(){if(this.state.hasError){let{fallback:r}=this.props,t=this.state.error||new Error("Erro desconhecido no componente");return typeof r=="function"?r(t):r??E("h1",{children:"Algo deu errado na aplica\xE7\xE3o."})}return this.props.children}};async function g(n,e){return l(n,e,{errorType:"react_network_error"})}function I(){let n=globalThis;!n.fetch||n.__DEVINSPECTOR_FETCH_PATCHED__||(n.__DEVINSPECTOR_FETCH_PATCHED__=!0,n.fetch=async function(e,r){return g(e,r)})}export{f as AuditErrorBoundary,a as audit,g as auditFetch,I as enableNetworkTracing};
|
package/dist/svelte.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var E=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},b=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of w(e))!m.call(t,o)&&o!==r&&d(t,o,{get:()=>e[o],enumerable:!(n=g(e,o))||n.enumerable});return t};var v=t=>b(d({},"__esModule",{value:!0}),t);var k={};E(k,{audit:()=>a,auditFetch:()=>h,auditHandle:()=>I,enableNetworkTracing:()=>T,handleSvelteKitError:()=>A,initSvelteDevInspector:()=>_});module.exports=v(k);var f=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let r=new URL(this.endpoint);return e.includes(r.host)||e.includes(r.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let r={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(r)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((n,o)=>{let i=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),r&&r(n,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",r=>{this.captureError(r.error||new Error(r.message||"Erro global desconhecido"),{filename:r.filename,lineno:r.lineno,colno:r.colno})}),window.addEventListener("unhandledrejection",r=>{let n=r.reason instanceof Error?r.reason:new Error(String(r.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let r=e.process;r.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),r.on("unhandledRejection",n=>{let o=n instanceof Error?n:new Error(String(n));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,r=5e3,n=new WeakSet){if(typeof e=="string")return e.length>r?e.substring(0,r)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(n.has(e))return"[Circular Reference]";n.add(e);let o={};for(let[i,u]of Object.entries(e))o[i]=this.truncate(u,r,n);return o}return e}captureError(e,r={}){let n=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let n={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...r,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(n)}async send(e){let r=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":r},body:JSON.stringify(e),keepalive:!0});n.ok||console.error(`[DevInspector] Erro na API (${n.status}): ${n.statusText}`)}catch(n){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",n)}}},p="__DEVINSPECT_AUDIT_CORE_INSTANCE__",R=()=>{let t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return t[p]||(t[p]=new f),t[p]},a=R();async function l(t,e,r){let n=r?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof t=="string"?o=t:t instanceof URL?o=t.toString():typeof t=="object"&&t!==null&&"url"in t&&(o=t.url),o&&a.isIngestUrl(o))return n(t,e);let i=e?.method||(typeof t=="object"&&t!==null&&"method"in t?t.method:"GET"),u=typeof performance<"u"?performance.now():Date.now();try{let s=await n(t,e),c=Math.round((typeof performance<"u"?performance.now():Date.now())-u);return(s.status>=400||c>=300)&&a.captureRequest({method:i,url:o,statusCode:s.status,durationMs:c,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),s}catch(s){let c=Math.round((typeof performance<"u"?performance.now():Date.now())-u);throw a.captureRequest({method:i,url:o,statusCode:0,durationMs:c,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),a.captureException(s instanceof Error?s:new Error(String(s)),{url:o,method:i,type:r?.errorType||"network_error"}),s}}function _(t){a.init(t)}async function h(t,e){return l(t,e,{errorType:"svelte_network_error"})}async function I({event:t,resolve:e}){let r=typeof performance<"u"?performance.now():Date.now(),n=t.request?.method||"GET",o=t.url?.pathname||t.url?.href||"/",i=t.route?.id||o;if(o&&a.isIngestUrl(o))return e(t);let u=typeof t.request?.headers?.get=="function"&&t.request.headers.get("user-agent")||"";try{let s=await e(t),c=Math.round((typeof performance<"u"?performance.now():Date.now())-r);return(s.status>=400||c>=300)&&a.captureRequest({method:n,url:o,statusCode:s.status,durationMs:c,route:i,userAgent:u}),s}catch(s){let c=Math.round((typeof performance<"u"?performance.now():Date.now())-r);a.captureRequest({method:n,url:o,statusCode:500,durationMs:c,route:i,userAgent:u});let y=s instanceof Error?s:new Error(String(s));throw a.captureError(y,{framework:"sveltekit",url:o,method:n,route:i}),s}}function A({error:t,event:e,status:r,message:n}){let o=t instanceof Error?t:new Error(String(t||n||"Erro SvelteKit"));a.captureError(o,{framework:"sveltekit",status:r||500,url:e?.url?.href||"",route:e?.route?.id||""})}function T(){let t=globalThis;!t.fetch||t.__DEVINSPECTOR_FETCH_PATCHED__||(t.__DEVINSPECTOR_FETCH_PATCHED__=!0,t.fetch=async function(e,r){return h(e,r)})}0&&(module.exports={audit,auditFetch,auditHandle,enableNetworkTracing,handleSvelteKitError,initSvelteDevInspector});
|
package/dist/svelte.d.cts
CHANGED
|
@@ -4,6 +4,7 @@ export { audit } from './index.cjs';
|
|
|
4
4
|
declare function initSvelteDevInspector(options: InitOptions): void;
|
|
5
5
|
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
6
6
|
declare function auditHandle({ event, resolve }: any): Promise<any>;
|
|
7
|
-
declare function handleSvelteKitError({ error, event }: any): void;
|
|
7
|
+
declare function handleSvelteKitError({ error, event, status, message }: any): void;
|
|
8
|
+
declare function enableNetworkTracing(): void;
|
|
8
9
|
|
|
9
|
-
export { InitOptions, auditFetch, auditHandle, handleSvelteKitError, initSvelteDevInspector };
|
|
10
|
+
export { InitOptions, auditFetch, auditHandle, enableNetworkTracing, handleSvelteKitError, initSvelteDevInspector };
|
package/dist/svelte.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { audit } from './index.js';
|
|
|
4
4
|
declare function initSvelteDevInspector(options: InitOptions): void;
|
|
5
5
|
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
6
6
|
declare function auditHandle({ event, resolve }: any): Promise<any>;
|
|
7
|
-
declare function handleSvelteKitError({ error, event }: any): void;
|
|
7
|
+
declare function handleSvelteKitError({ error, event, status, message }: any): void;
|
|
8
|
+
declare function enableNetworkTracing(): void;
|
|
8
9
|
|
|
9
|
-
export { InitOptions, auditFetch, auditHandle, handleSvelteKitError, initSvelteDevInspector };
|
|
10
|
+
export { InitOptions, auditFetch, auditHandle, enableNetworkTracing, handleSvelteKitError, initSvelteDevInspector };
|
package/dist/svelte.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((n,o)=>{let i=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),t&&t(n,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let n=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),t.on("unhandledRejection",n=>{let o=n instanceof Error?n:new Error(String(n));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,n=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(n.has(e))return"[Circular Reference]";n.add(e);let o={};for(let[i,u]of Object.entries(e))o[i]=this.truncate(u,t,n);return o}return e}captureError(e,t={}){let n=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let n={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(n)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});n.ok||console.error(`[DevInspector] Erro na API (${n.status}): ${n.statusText}`)}catch(n){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",n)}}},d="__DEVINSPECT_AUDIT_CORE_INSTANCE__",h=()=>{let r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return r[d]||(r[d]=new p),r[d]},a=h();async function f(r,e,t){let n=t?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof r=="string"?o=r:r instanceof URL?o=r.toString():typeof r=="object"&&r!==null&&"url"in r&&(o=r.url),o&&a.isIngestUrl(o))return n(r,e);let i=e?.method||(typeof r=="object"&&r!==null&&"method"in r?r.method:"GET"),u=typeof performance<"u"?performance.now():Date.now();try{let s=await n(r,e),c=Math.round((typeof performance<"u"?performance.now():Date.now())-u);return(s.status>=400||c>=300)&&a.captureRequest({method:i,url:o,statusCode:s.status,durationMs:c,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),s}catch(s){let c=Math.round((typeof performance<"u"?performance.now():Date.now())-u);throw a.captureRequest({method:i,url:o,statusCode:0,durationMs:c,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),a.captureException(s instanceof Error?s:new Error(String(s)),{url:o,method:i,type:t?.errorType||"network_error"}),s}}function E(r){a.init(r)}async function y(r,e){return f(r,e,{errorType:"svelte_network_error"})}async function b({event:r,resolve:e}){let t=typeof performance<"u"?performance.now():Date.now(),n=r.request?.method||"GET",o=r.url?.pathname||r.url?.href||"/",i=r.route?.id||o;if(o&&a.isIngestUrl(o))return e(r);let u=typeof r.request?.headers?.get=="function"&&r.request.headers.get("user-agent")||"";try{let s=await e(r),c=Math.round((typeof performance<"u"?performance.now():Date.now())-t);return(s.status>=400||c>=300)&&a.captureRequest({method:n,url:o,statusCode:s.status,durationMs:c,route:i,userAgent:u}),s}catch(s){let c=Math.round((typeof performance<"u"?performance.now():Date.now())-t);a.captureRequest({method:n,url:o,statusCode:500,durationMs:c,route:i,userAgent:u});let l=s instanceof Error?s:new Error(String(s));throw a.captureError(l,{framework:"sveltekit",url:o,method:n,route:i}),s}}function v({error:r,event:e,status:t,message:n}){let o=r instanceof Error?r:new Error(String(r||n||"Erro SvelteKit"));a.captureError(o,{framework:"sveltekit",status:t||500,url:e?.url?.href||"",route:e?.route?.id||""})}function R(){let r=globalThis;!r.fetch||r.__DEVINSPECTOR_FETCH_PATCHED__||(r.__DEVINSPECTOR_FETCH_PATCHED__=!0,r.fetch=async function(e,t){return y(e,t)})}export{a as audit,y as auditFetch,b as auditHandle,R as enableNetworkTracing,v as handleSvelteKitError,E as initSvelteDevInspector};
|
package/dist/vanilla.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var t in e)d(n,t,{get:e[t],enumerable:!0})},v=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!m.call(n,o)&&o!==t&&d(n,o,{get:()=>e[o],enumerable:!(r=w(e,o))||r.enumerable});return n};var _=n=>v(d({},"__esModule",{value:!0}),n);var A={};b(A,{audit:()=>i,auditFetch:()=>l,default:()=>I,enableNetworkTracing:()=>g});module.exports=_(A);var f=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((r,o)=>{let s=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(s,{type:"react_native_error",isFatal:!!o}),t&&t(r,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let r=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(r,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",r=>{this.captureError(r,{type:"uncaught_exception"})}),t.on("unhandledRejection",r=>{let o=r instanceof Error?r:new Error(String(r));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,r=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(r.has(e))return"[Circular Reference]";r.add(e);let o={};for(let[s,c]of Object.entries(e))o[s]=this.truncate(c,t,r);return o}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",o=e.stack||"",s={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(s)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let r={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(r)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},p="__DEVINSPECT_AUDIT_CORE_INSTANCE__",R=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[p]||(n[p]=new f),n[p]},i=R();async function h(n,e,t){let r=t?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&i.isIngestUrl(o))return r(n,e);let s=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let a=await r(n,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(a.status>=400||u>=300)&&i.captureRequest({method:s,url:o,statusCode:a.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),a}catch(a){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw i.captureRequest({method:s,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),i.captureException(a instanceof Error?a:new Error(String(a)),{url:o,method:s,type:t?.errorType||"network_error"}),a}}var y=null;async function l(n,e,t){return h(n,e,{errorType:"vanilla_network_error",nativeFetch:t||y||void 0})}function g(){let n=typeof window<"u"?window:globalThis;if(!n.fetch||n.__DEVINSPECTOR_FETCH_PATCHED__)return;let e=n.fetch.bind(n);y=e,n.__DEVINSPECTOR_FETCH_PATCHED__=!0,n.fetch=async function(...t){let[r,o]=t;return l(r,o,e)}}typeof window<"u"&&(window.DevInspector={init:n=>i.init(n),captureError:(n,e)=>i.captureError(n,e),captureException:(n,e)=>i.captureException(n,e),captureMessage:(n,e)=>i.captureMessage(n,e),auditFetch:l,enableNetworkTracing:g,core:i});var I=i;0&&(module.exports={audit,auditFetch,enableNetworkTracing});
|
package/dist/vanilla.global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var DevInspector=(()=>{var d=Object.defineProperty;var
|
|
1
|
+
"use strict";var DevInspector=(()=>{var d=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var b=(n,e)=>{for(var t in e)d(n,t,{get:e[t],enumerable:!0})},v=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E(e))!m.call(n,o)&&o!==t&&d(n,o,{get:()=>e[o],enumerable:!(r=w(e,o))||r.enumerable});return n};var _=n=>v(d({},"__esModule",{value:!0}),n);var A={};b(A,{audit:()=>i,auditFetch:()=>l,default:()=>I,enableNetworkTracing:()=>g});var f=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((r,o)=>{let s=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(s,{type:"react_native_error",isFatal:!!o}),t&&t(r,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let r=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(r,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",r=>{this.captureError(r,{type:"uncaught_exception"})}),t.on("unhandledRejection",r=>{let o=r instanceof Error?r:new Error(String(r));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,r=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(r.has(e))return"[Circular Reference]";r.add(e);let o={};for(let[s,c]of Object.entries(e))o[s]=this.truncate(c,t,r);return o}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",o=e.stack||"",s={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(s)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let r={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(r)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},p="__DEVINSPECT_AUDIT_CORE_INSTANCE__",R=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[p]||(n[p]=new f),n[p]},i=R();async function h(n,e,t){let r=t?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&i.isIngestUrl(o))return r(n,e);let s=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let a=await r(n,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(a.status>=400||u>=300)&&i.captureRequest({method:s,url:o,statusCode:a.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),a}catch(a){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw i.captureRequest({method:s,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),i.captureException(a instanceof Error?a:new Error(String(a)),{url:o,method:s,type:t?.errorType||"network_error"}),a}}var y=null;async function l(n,e,t){return h(n,e,{errorType:"vanilla_network_error",nativeFetch:t||y||void 0})}function g(){let n=typeof window<"u"?window:globalThis;if(!n.fetch||n.__DEVINSPECTOR_FETCH_PATCHED__)return;let e=n.fetch.bind(n);y=e,n.__DEVINSPECTOR_FETCH_PATCHED__=!0,n.fetch=async function(...t){let[r,o]=t;return l(r,o,e)}}typeof window<"u"&&(window.DevInspector={init:n=>i.init(n),captureError:(n,e)=>i.captureError(n,e),captureException:(n,e)=>i.captureException(n,e),captureMessage:(n,e)=>i.captureMessage(n,e),auditFetch:l,enableNetworkTracing:g,core:i});var I=i;return _(A);})();
|
package/dist/vanilla.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((r,o)=>{let s=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(s,{type:"react_native_error",isFatal:!!o}),t&&t(r,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let r=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(r,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",r=>{this.captureError(r,{type:"uncaught_exception"})}),t.on("unhandledRejection",r=>{let o=r instanceof Error?r:new Error(String(r));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,r=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(r.has(e))return"[Circular Reference]";r.add(e);let o={};for(let[s,c]of Object.entries(e))o[s]=this.truncate(c,t,r);return o}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",o=e.stack||"",s={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(s)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let r={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(r)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});r.ok||console.error(`[DevInspector] Erro na API (${r.status}): ${r.statusText}`)}catch(r){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",r)}}},d="__DEVINSPECT_AUDIT_CORE_INSTANCE__",y=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[d]||(n[d]=new p),n[d]},i=y();async function f(n,e,t){let r=t?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof n=="string"?o=n:n instanceof URL?o=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(o=n.url),o&&i.isIngestUrl(o))return r(n,e);let s=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let a=await r(n,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(a.status>=400||u>=300)&&i.captureRequest({method:s,url:o,statusCode:a.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),a}catch(a){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw i.captureRequest({method:s,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),i.captureException(a instanceof Error?a:new Error(String(a)),{url:o,method:s,type:t?.errorType||"network_error"}),a}}var l=null;async function h(n,e,t){return f(n,e,{errorType:"vanilla_network_error",nativeFetch:t||l||void 0})}function g(){let n=typeof window<"u"?window:globalThis;if(!n.fetch||n.__DEVINSPECTOR_FETCH_PATCHED__)return;let e=n.fetch.bind(n);l=e,n.__DEVINSPECTOR_FETCH_PATCHED__=!0,n.fetch=async function(...t){let[r,o]=t;return h(r,o,e)}}typeof window<"u"&&(window.DevInspector={init:n=>i.init(n),captureError:(n,e)=>i.captureError(n,e),captureException:(n,e)=>i.captureException(n,e),captureMessage:(n,e)=>i.captureMessage(n,e),auditFetch:h,enableNetworkTracing:g,core:i});var b=i;export{i as audit,h as auditFetch,b as default,g as enableNetworkTracing};
|
package/dist/vue.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var m=(r,e)=>{for(var t in e)d(r,t,{get:e[t],enumerable:!0})},E=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of g(e))!w.call(r,o)&&o!==t&&d(r,o,{get:()=>e[o],enumerable:!(n=y(e,o))||n.enumerable});return r};var b=r=>E(d({},"__esModule",{value:!0}),r);var R={};m(R,{DevInspectorVue:()=>_,audit:()=>a,auditFetch:()=>h,enableNetworkTracing:()=>I});module.exports=b(R);var f=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((n,o)=>{let i=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),t&&t(n,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let n=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),t.on("unhandledRejection",n=>{let o=n instanceof Error?n:new Error(String(n));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,n=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(n.has(e))return"[Circular Reference]";n.add(e);let o={};for(let[i,c]of Object.entries(e))o[i]=this.truncate(c,t,n);return o}return e}captureError(e,t={}){let n=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let n={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(n)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});n.ok||console.error(`[DevInspector] Erro na API (${n.status}): ${n.statusText}`)}catch(n){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",n)}}},p="__DEVINSPECT_AUDIT_CORE_INSTANCE__",v=()=>{let r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return r[p]||(r[p]=new f),r[p]},a=v();async function l(r,e,t){let n=t?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof r=="string"?o=r:r instanceof URL?o=r.toString():typeof r=="object"&&r!==null&&"url"in r&&(o=r.url),o&&a.isIngestUrl(o))return n(r,e);let i=e?.method||(typeof r=="object"&&r!==null&&"method"in r?r.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let s=await n(r,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(s.status>=400||u>=300)&&a.captureRequest({method:i,url:o,statusCode:s.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),s}catch(s){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw a.captureRequest({method:i,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),a.captureException(s instanceof Error?s:new Error(String(s)),{url:o,method:i,type:t?.errorType||"network_error"}),s}}async function h(r,e){return l(r,e,{errorType:"vue_network_error"})}var _={install(r,e){if(a.init(e),r.config){let t=r.config.errorHandler;r.config.errorHandler=(n,o,i)=>{let c=n instanceof Error?n:new Error(String(n)),s=o?.$options?.name||o?.$options?.__name||o?.$type?.name;a.captureError(c,{framework:"vue",vueInfo:i,component:s}),typeof t=="function"?t(n,o,i):console.error(n)}}}};function I(){let r=typeof window<"u"?window:globalThis;!r.fetch||r.__DEVINSPECTOR_FETCH_PATCHED__||(r.__DEVINSPECTOR_FETCH_PATCHED__=!0,r.fetch=async function(e,t){return h(e,t)})}0&&(module.exports={DevInspectorVue,audit,auditFetch,enableNetworkTracing});
|
package/dist/vue.d.cts
CHANGED
|
@@ -5,5 +5,6 @@ declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promi
|
|
|
5
5
|
declare const DevInspectorVue: {
|
|
6
6
|
install(app: any, options: InitOptions): void;
|
|
7
7
|
};
|
|
8
|
+
declare function enableNetworkTracing(): void;
|
|
8
9
|
|
|
9
|
-
export { DevInspectorVue, InitOptions, auditFetch };
|
|
10
|
+
export { DevInspectorVue, InitOptions, auditFetch, enableNetworkTracing };
|
package/dist/vue.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promi
|
|
|
5
5
|
declare const DevInspectorVue: {
|
|
6
6
|
install(app: any, options: InitOptions): void;
|
|
7
7
|
};
|
|
8
|
+
declare function enableNetworkTracing(): void;
|
|
8
9
|
|
|
9
|
-
export { DevInspectorVue, InitOptions, auditFetch };
|
|
10
|
+
export { DevInspectorVue, InitOptions, auditFetch, enableNetworkTracing };
|
package/dist/vue.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.initialized=!1;this.listenersAttached=!1}init(e){if(!e.apiKey){console.warn("[AuditSDK] API Key n\xE3o fornecida no init().");return}this.apiKey=e.apiKey,e.endpoint&&(this.endpoint=e.endpoint),e.environment&&(this.environment=e.environment),this.initialized=!0,this.listenGlobalErrors()}isIngestUrl(e){if(!e)return!1;try{if(this.endpoint&&e.includes(this.endpoint))return!0;let t=new URL(this.endpoint);return e.includes(t.host)||e.includes(t.pathname)}catch{return e.includes("devinspector.com.br")||e.includes("/ingest/track")}}captureRequest(e){let t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",metadata:{environment:this.environment,timestamp:new Date().toISOString(),route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0}};this.send(t)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let t=e.ErrorUtils.getGlobalHandler();e.ErrorUtils.setGlobalHandler((n,o)=>{let i=n instanceof Error?n:new Error(String(n?.message||n||"Erro React Native desconhecido"));this.captureError(i,{type:"react_native_error",isFatal:!!o}),t&&t(n,o)})}else if(typeof window<"u"&&window.addEventListener)window.addEventListener("error",t=>{this.captureError(t.error||new Error(t.message||"Erro global desconhecido"),{filename:t.filename,lineno:t.lineno,colno:t.colno})}),window.addEventListener("unhandledrejection",t=>{let n=t.reason instanceof Error?t.reason:new Error(String(t.reason));this.captureError(n,{type:"unhandled_rejection"})});else if(e.process?.on){let t=e.process;t.on("uncaughtException",n=>{this.captureError(n,{type:"uncaught_exception"})}),t.on("unhandledRejection",n=>{let o=n instanceof Error?n:new Error(String(n));this.captureError(o,{type:"unhandled_rejection"})})}}truncate(e,t=5e3,n=new WeakSet){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){if(n.has(e))return"[Circular Reference]";n.add(e);let o={};for(let[i,c]of Object.entries(e))o[i]=this.truncate(c,t,n);return o}return e}captureError(e,t={}){let n=e.message||"Erro Desconhecido",o=e.stack||"",i={type:"error",message:this.truncate(n,500),stackTrace:this.truncate(o,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(i)}captureException(e,t={}){this.captureError(e,t)}captureMessage(e,t={}){let n={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",metadata:this.truncate({...t,level:"info",environment:this.environment,timestamp:new Date().toISOString()},5e3)};this.send(n)}async send(e){let t=this.apiKey&&this.apiKey!=="PENDING_API_KEY"?this.apiKey:"dev-fallback-key";try{let n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":t},body:JSON.stringify(e),keepalive:!0});n.ok||console.error(`[DevInspector] Erro na API (${n.status}): ${n.statusText}`)}catch(n){console.error("[DevInspector] Falha ao enviar requisi\xE7\xE3o para o painel:",n)}}},d="__DEVINSPECT_AUDIT_CORE_INSTANCE__",l=()=>{let r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return r[d]||(r[d]=new p),r[d]},a=l();async function f(r,e,t){let n=t?.nativeFetch||(typeof window<"u"?window.fetch:typeof globalThis<"u"?globalThis.fetch:fetch),o="";if(typeof r=="string"?o=r:r instanceof URL?o=r.toString():typeof r=="object"&&r!==null&&"url"in r&&(o=r.url),o&&a.isIngestUrl(o))return n(r,e);let i=e?.method||(typeof r=="object"&&r!==null&&"method"in r?r.method:"GET"),c=typeof performance<"u"?performance.now():Date.now();try{let s=await n(r,e),u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);return(s.status>=400||u>=300)&&a.captureRequest({method:i,url:o,statusCode:s.status,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),s}catch(s){let u=Math.round((typeof performance<"u"?performance.now():Date.now())-c);throw a.captureRequest({method:i,url:o,statusCode:0,durationMs:u,route:o,userAgent:typeof navigator<"u"?navigator.userAgent:t?.defaultUserAgent}),a.captureException(s instanceof Error?s:new Error(String(s)),{url:o,method:i,type:t?.errorType||"network_error"}),s}}async function h(r,e){return f(r,e,{errorType:"vue_network_error"})}var m={install(r,e){if(a.init(e),r.config){let t=r.config.errorHandler;r.config.errorHandler=(n,o,i)=>{let c=n instanceof Error?n:new Error(String(n)),s=o?.$options?.name||o?.$options?.__name||o?.$type?.name;a.captureError(c,{framework:"vue",vueInfo:i,component:s}),typeof t=="function"?t(n,o,i):console.error(n)}}}};function E(){let r=typeof window<"u"?window:globalThis;!r.fetch||r.__DEVINSPECTOR_FETCH_PATCHED__||(r.__DEVINSPECTOR_FETCH_PATCHED__=!0,r.fetch=async function(e,t){return h(e,t)})}export{m as DevInspectorVue,a as audit,h as auditFetch,E as enableNetworkTracing};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xcodleox/devinspector",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.5.0",
|
|
4
4
|
"description": "SDK de monitoramento e auditoria de erros em tempo real | Dev Inspector",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"devinspector",
|
|
30
30
|
"logger",
|
|
31
31
|
"react",
|
|
32
|
+
"react-native",
|
|
32
33
|
"angular",
|
|
33
34
|
"vue",
|
|
34
35
|
"svelte",
|
|
@@ -69,6 +70,17 @@
|
|
|
69
70
|
},
|
|
70
71
|
"default": "./dist/react.js"
|
|
71
72
|
},
|
|
73
|
+
"./react-native": {
|
|
74
|
+
"import": {
|
|
75
|
+
"types": "./dist/react-native.d.ts",
|
|
76
|
+
"default": "./dist/react-native.js"
|
|
77
|
+
},
|
|
78
|
+
"require": {
|
|
79
|
+
"types": "./dist/react-native.d.cts",
|
|
80
|
+
"default": "./dist/react-native.cjs"
|
|
81
|
+
},
|
|
82
|
+
"default": "./dist/react-native.js"
|
|
83
|
+
},
|
|
72
84
|
"./angular": {
|
|
73
85
|
"import": {
|
|
74
86
|
"types": "./dist/angular.d.ts",
|
|
@@ -131,6 +143,9 @@
|
|
|
131
143
|
"react": [
|
|
132
144
|
"./dist/react.d.ts"
|
|
133
145
|
],
|
|
146
|
+
"react-native": [
|
|
147
|
+
"./dist/react-native.d.ts"
|
|
148
|
+
],
|
|
134
149
|
"angular": [
|
|
135
150
|
"./dist/angular.d.ts"
|
|
136
151
|
],
|