@xcodleox/devinspector 7.4.0 → 8.0.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/vue.js CHANGED
@@ -1 +1 @@
1
- var u=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()}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,s]of Object.entries(e))o[i]=this.truncate(s,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)}}},c="__DEVINSPECT_AUDIT_CORE_INSTANCE__",p=()=>{let r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return r[c]||(r[c]=new u),r[c]},a=p();async function l(r,e){let t="";if(typeof r=="string"?t=r:r instanceof URL?t=r.toString():typeof r=="object"&&r!==null&&"url"in r&&(t=r.url),t&&(t.includes("devinspector.com.br")||t.includes("/ingest/track")))return fetch(r,e);let n=e?.method||(typeof r=="object"&&r!==null&&"method"in r?r.method:"GET"),o=typeof performance<"u"?performance.now():Date.now();try{let i=await fetch(r,e),s=Math.round((typeof performance<"u"?performance.now():Date.now())-o);return(i.status>=400||s>=300)&&a.captureRequest({method:n,url:t,statusCode:i.status,durationMs:s,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,route:t}),i}catch(i){let s=Math.round((typeof performance<"u"?performance.now():Date.now())-o);throw a.captureRequest({method:n,url:t,statusCode:0,durationMs:s,userAgent:typeof navigator<"u"?navigator.userAgent:void 0,route:t}),a.captureException(i instanceof Error?i:new Error(String(i)),{url:t,method:n,type:"vue_network_error"}),i}}var y={install(r,e){if(a.init(e),r.config){let t=r.config.errorHandler;r.config.errorHandler=(n,o,i)=>{let s=n instanceof Error?n:new Error(String(n)),d=o?.$options?.name||o?.$options?.__name||o?.$type?.name;a.captureError(s,{framework:"vue",vueInfo:i,component:d}),typeof t=="function"?t(n,o,i):console.error(n)}}}};function w(){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 l(e,t)})}export{y as DevInspectorVue,a as audit,l as auditFetch,w as enableNetworkTracing};
1
+ var h=class{constructor(){this.apiKey="PENDING_API_KEY";this.endpoint="https://api.devinspector.com.br/api/ingest/track";this.environment="production";this.slowThresholdMs=300;this.breadcrumbs=[];this.maxBreadcrumbs=50;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),e.release&&(this.release=e.release),typeof e.slowThresholdMs=="number"&&e.slowThresholdMs>=0&&(this.slowThresholdMs=e.slowThresholdMs),this.initialized=!0,this.listenGlobalErrors()}getEnvironment(){return this.environment}getRelease(){return this.release}getSlowThresholdMs(){return this.slowThresholdMs}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")}}generateId(e){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return`${e}_${crypto.randomUUID()}`}catch{}return`${e}_${Date.now()}_${Math.random().toString(36).substring(2,12)}`}createRequestId(){return this.generateId("req")}createTraceId(){return this.generateId("trace")}createSpanId(){return this.generateId("span")}setUser(e){this.user=this.truncate(e,2e3)}clearUser(){this.user=void 0}getUser(){return this.user}addBreadcrumb(e){let r={...e,timestamp:new Date().toISOString()},t=this.truncate(r,2e3);this.breadcrumbs.push(t),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}clearBreadcrumbs(){this.breadcrumbs=[]}getBreadcrumbs(){return[...this.breadcrumbs]}getContext(){return{environment:this.environment,release:this.release,user:this.user,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,timestamp:new Date().toISOString()}}captureRequest(e){let r=this.getContext(),t={type:"request_metric",method:e.method,url:e.url,statusCode:e.statusCode,durationMs:e.durationMs,browser:e.userAgent||"",requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:r.environment,release:r.release,user:r.user,breadcrumbs:r.breadcrumbs,metadata:this.truncate({environment:r.environment,timestamp:r.timestamp,route:e.route||e.url,dbQueriesCount:e.dbQueriesCount||0,slowQueryMs:e.slowQueryMs||0},5e3)};this.send(t)}captureDbQuery(e){let r=this.getContext(),t=e.operation?.trim()||"query",s=e.collection?.trim()||"Unknown",o={type:"db_query",message:`Database operation [${t}]`,stackTrace:"",url:e.url||(typeof window<"u"?window.location.href:""),browser:typeof navigator<"u"?navigator.userAgent:"",method:t,durationMs:e.durationMs,requestId:e.requestId,traceId:e.traceId,spanId:e.spanId,environment:r.environment,release:r.release,user:r.user,breadcrumbs:r.breadcrumbs,metadata:this.truncate({...e.metadata,collection:s,operation:t,durationMs:e.durationMs,environment:r.environment,timestamp:r.timestamp},5e3)};this.send(o)}listenGlobalErrors(){if(this.listenersAttached)return;this.listenersAttached=!0;let e=globalThis;if(e.ErrorUtils&&typeof e.ErrorUtils.setGlobalHandler=="function"){let r=typeof e.ErrorUtils.getGlobalHandler=="function"?e.ErrorUtils.getGlobalHandler():void 0;e.ErrorUtils.setGlobalHandler((t,s)=>{let o=t instanceof Error?t:new Error(String(t?.message||t||"Erro React Native desconhecido"));this.captureError(o,{type:"react_native_error",isFatal:!!s}),r&&r(t,s)})}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 s=t instanceof Error?t:new Error(String(t));this.captureError(s,{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"){let s=e;if(t.has(s))return"[Circular Reference]";if(t.add(s),Array.isArray(e))return e.map(i=>this.truncate(i,r,t));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",s=e?.stack||"",o=this.getContext(),i=r.requestId,c=r.traceId,u=r.spanId,l={type:"error",message:this.truncate(t,500),stackTrace:this.truncate(s,1e4),url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:i,traceId:c,spanId:u,environment:o.environment,release:o.release,user:o.user,breadcrumbs:o.breadcrumbs,metadata:this.truncate({...r,environment:o.environment,release:o.release,timestamp:o.timestamp},5e3)};this.send(l)}captureException(e,r={}){this.captureError(e,r)}captureMessage(e,r={}){let t=this.getContext(),s={type:"message",message:this.truncate(e,500),stackTrace:"",url:typeof window<"u"?window.location.href:"",browser:typeof navigator<"u"?navigator.userAgent:"",requestId:r.requestId,traceId:r.traceId,spanId:r.spanId,environment:t.environment,release:t.release,user:t.user,breadcrumbs:t.breadcrumbs,metadata:this.truncate({...r,level:"info",environment:t.environment,release:t.release,timestamp:t.timestamp},5e3)};this.send(s)}async send(e){if(this.initialized&&!(!this.apiKey||this.apiKey==="PENDING_API_KEY"))try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},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)}}},m="__DEVINSPECT_AUDIT_CORE_INSTANCE__",w=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[m]||(n[m]=new h),n[m]},a=w();async function f(n,e,r){let t=r?.nativeFetch||(typeof window<"u"?window.fetch.bind(window):typeof globalThis<"u"?globalThis.fetch:fetch),s="";if(typeof n=="string"?s=n:n instanceof URL?s=n.toString():typeof n=="object"&&n!==null&&"url"in n&&(s=n.url),s&&a.isIngestUrl(s))return t(n,e);let o=e?.method||(typeof n=="object"&&n!==null&&"method"in n?n.method:"GET"),i=a.createRequestId(),c=a.createTraceId(),u=a.createSpanId(),l=new Headers(e?.headers||(typeof n=="object"&&n!==null&&"headers"in n?n.headers:void 0));l.set("x-devinspector-request-id",i),l.set("x-devinspector-trace-id",c),l.set("x-devinspector-span-id",u);let b={...e,headers:l},g=typeof performance<"u"?performance.now():Date.now();try{let d=await t(n,b),p=Math.round((typeof performance<"u"?performance.now():Date.now())-g),y=a.getSlowThresholdMs();return(d.status>=400||p>=y)&&a.captureRequest({method:o,url:s,statusCode:d.status,durationMs:p,route:s,requestId:i,traceId:c,spanId:u,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),a.addBreadcrumb({type:"http",message:`${o} ${s}`,metadata:{statusCode:d.status,durationMs:p,requestId:i,traceId:c,spanId:u}}),d}catch(d){let p=Math.round((typeof performance<"u"?performance.now():Date.now())-g);throw a.captureRequest({method:o,url:s,statusCode:0,durationMs:p,route:s,requestId:i,traceId:c,spanId:u,userAgent:typeof navigator<"u"?navigator.userAgent:r?.defaultUserAgent}),a.captureException(d instanceof Error?d:new Error(String(d)),{url:s,method:o,type:r?.errorType||"network_error",requestId:i,traceId:c,spanId:u}),a.addBreadcrumb({type:"http_error",message:`${o} ${s}`,metadata:{durationMs:p,requestId:i,traceId:c,spanId:u}}),d}}async function _(n,e){return f(n,e,{errorType:"vue_network_error"})}var T={install(n,e){if(a.init(e),!n.config)return;let r=n.config.errorHandler;n.config.errorHandler=(t,s,o)=>{let i=t instanceof Error?t:new Error(String(t)),c=s?.$options?.name||s?.$options?.__name||s?.$type?.name;a.addBreadcrumb({type:"vue_error",message:i.message||"Erro capturado pelo Vue",metadata:{component:c,vueInfo:o}}),a.captureError(i,{framework:"Vue",vueInfo:o,component:c}),typeof r=="function"?r(t,s,o):console.error(t)}}};function R(){let n=typeof window<"u"?window:globalThis;if(!n.fetch||n.__DEVINSPECTOR_FETCH_PATCHED__)return;let e=n.fetch.bind(n);n.__DEVINSPECTOR_FETCH_PATCHED__=!0,n.fetch=function(r,t){return f(r,t,{errorType:"vue_network_error",nativeFetch:e})}}export{T as DevInspectorVue,a as audit,_ as auditFetch,R as enableNetworkTracing};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcodleox/devinspector",
3
- "version": "7.4.0",
3
+ "version": "8.0.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",
@@ -8,9 +8,8 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "unpkg": "./dist/vanilla.global.js",
10
10
  "jsdelivr": "./dist/vanilla.global.js",
11
- "sideEffects": false,
12
11
  "engines": {
13
- "node": ">=16.0.0"
12
+ "node": ">=18.0.0"
14
13
  },
15
14
  "files": [
16
15
  "dist"
@@ -93,12 +92,15 @@
93
92
  "default": "./dist/angular.js"
94
93
  },
95
94
  "./vue": {
96
- "types": {
97
- "require": "./dist/vue.d.cts",
98
- "import": "./dist/vue.d.ts"
95
+ "import": {
96
+ "types": "./dist/vue.d.ts",
97
+ "default": "./dist/vue.js"
98
+ },
99
+ "require": {
100
+ "types": "./dist/vue.d.cts",
101
+ "default": "./dist/vue.cjs"
99
102
  },
100
- "require": "./dist/vue.cjs",
101
- "import": "./dist/vue.js"
103
+ "default": "./dist/vue.js"
102
104
  },
103
105
  "./svelte": {
104
106
  "import": {
@@ -196,4 +198,4 @@
196
198
  "vue": "^3.4.0",
197
199
  "zone.js": "^0.16.2"
198
200
  }
199
- }
201
+ }