@xcodleox/devinspector 5.0.0 → 6.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/next.cjs +1 -1
- package/dist/next.d.cts +4 -1
- package/dist/next.d.ts +4 -1
- package/dist/next.js +1 -1
- package/package.json +1 -1
package/dist/next.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var u=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var m=(n,e)=>{for(var t in e)u(n,t,{get:e[t],enumerable:!0})},g=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of y(e))!w.call(n,o)&&o!==t&&u(n,o,{get:()=>e[o],enumerable:!(r=h(e,o))||r.enumerable});return n};var E=n=>g(u({},"__esModule",{value:!0}),n);var M={};m(M,{audit:()=>i,auditFetch:()=>I,captureNextError:()=>f,initNextDevInspector:()=>v,withAuditAction:()=>D,withAuditApi:()=>_});module.exports=E(M);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()}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){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){let r={};for(let[o,s]of Object.entries(e))r[o]=this.truncate(s,t);return r}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__",b=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[d]||(n[d]=new p),n[d]},i=b();function v(n){i.init(n)}function f(n,e={}){let t=n instanceof Error?n:new Error(String(n));i.captureError(t,{framework:"nextjs",...e})}async function I(n,e){let t=typeof n=="string"?n:n instanceof URL?n.toString():n.url;if(t&&t.includes("devinspector.com.br"))return fetch(n,e);let r=e?.method||"GET",o=typeof performance<"u"?performance.now():Date.now();try{let s=await fetch(n,e),a=Math.round((typeof performance<"u"?performance.now():Date.now())-o);return(s.status>=400||a>=300)&&i.captureRequest({method:r,url:t,statusCode:s.status,durationMs:a,route:t}),s}catch(s){let a=Math.round((typeof performance<"u"?performance.now():Date.now())-o);throw i.captureRequest({method:r,url:t,statusCode:0,durationMs:a,route:t}),i.captureException(s instanceof Error?s:new Error(String(s)),{url:t,method:r,type:"nextjs_network_error"}),s}}function _(n){return async function(...e){let t=typeof performance<"u"?performance.now():Date.now(),r=e[0],o=r?.method||"GET",s=r?.url||r?.nextUrl?.href||"/api";try{let a=await n(...e),c=Math.round((typeof performance<"u"?performance.now():Date.now())-t),l=a?.status||200;return i.captureRequest({method:o,url:s,statusCode:l,durationMs:c,route:s}),a}catch(a){let c=Math.round((typeof performance<"u"?performance.now():Date.now())-t);throw i.captureRequest({method:o,url:s,statusCode:500,durationMs:c,route:s}),f(a,{url:s,method:o,type:"api_route_error"}),a}}}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 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}),f(o,{actionName:n,type:"server_action_error"}),o}})}0&&(module.exports={audit,auditFetch,captureNextError,initNextDevInspector,withAuditAction,withAuditApi});
|
package/dist/next.d.cts
CHANGED
|
@@ -3,5 +3,8 @@ export { audit } from './index.cjs';
|
|
|
3
3
|
|
|
4
4
|
declare function initNextDevInspector(options: InitOptions): void;
|
|
5
5
|
declare function captureNextError(error: unknown, metadata?: Record<string, any>): void;
|
|
6
|
+
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
7
|
+
declare function withAuditApi(handler: Function): (...args: any[]) => Promise<any>;
|
|
8
|
+
declare function withAuditAction<T extends (...args: any[]) => Promise<any>>(actionName: string, action: T): T;
|
|
6
9
|
|
|
7
|
-
export { InitOptions, captureNextError, initNextDevInspector };
|
|
10
|
+
export { InitOptions, auditFetch, captureNextError, initNextDevInspector, withAuditAction, withAuditApi };
|
package/dist/next.d.ts
CHANGED
|
@@ -3,5 +3,8 @@ export { audit } from './index.js';
|
|
|
3
3
|
|
|
4
4
|
declare function initNextDevInspector(options: InitOptions): void;
|
|
5
5
|
declare function captureNextError(error: unknown, metadata?: Record<string, any>): void;
|
|
6
|
+
declare function auditFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
7
|
+
declare function withAuditApi(handler: Function): (...args: any[]) => Promise<any>;
|
|
8
|
+
declare function withAuditAction<T extends (...args: any[]) => Promise<any>>(actionName: string, action: T): T;
|
|
6
9
|
|
|
7
|
-
export { InitOptions, captureNextError, initNextDevInspector };
|
|
10
|
+
export { InitOptions, auditFetch, captureNextError, initNextDevInspector, withAuditAction, withAuditApi };
|
package/dist/next.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var d=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((r,s)=>{let o=r instanceof Error?r:new Error(String(r?.message||r||"Erro React Native desconhecido"));this.captureError(o,{type:"react_native_error",isFatal:!!s}),t&&t(r,s)})}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 s=r instanceof Error?r:new Error(String(r));this.captureError(s,{type:"unhandled_rejection"})})}}truncate(e,t=5e3){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [truncated]":e;if(e&&typeof e=="object"&&e!==null){let r={};for(let[s,o]of Object.entries(e))r[s]=this.truncate(o,t);return r}return e}captureError(e,t={}){let r=e.message||"Erro Desconhecido",s=e.stack||"",o={type:"error",message:this.truncate(r,500),stackTrace:this.truncate(s,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 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)}}},u="__DEVINSPECT_AUDIT_CORE_INSTANCE__",l=()=>{let n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};return n[u]||(n[u]=new d),n[u]},a=l();function m(n){a.init(n)}function p(n,e={}){let t=n instanceof Error?n:new Error(String(n));a.captureError(t,{framework:"nextjs",...e})}async function g(n,e){let t=typeof n=="string"?n:n instanceof URL?n.toString():n.url;if(t&&t.includes("devinspector.com.br"))return fetch(n,e);let r=e?.method||"GET",s=typeof performance<"u"?performance.now():Date.now();try{let o=await fetch(n,e),i=Math.round((typeof performance<"u"?performance.now():Date.now())-s);return(o.status>=400||i>=300)&&a.captureRequest({method:r,url:t,statusCode:o.status,durationMs:i,route:t}),o}catch(o){let i=Math.round((typeof performance<"u"?performance.now():Date.now())-s);throw a.captureRequest({method:r,url:t,statusCode:0,durationMs:i,route:t}),a.captureException(o instanceof Error?o:new Error(String(o)),{url:t,method:r,type:"nextjs_network_error"}),o}}function E(n){return async function(...e){let t=typeof performance<"u"?performance.now():Date.now(),r=e[0],s=r?.method||"GET",o=r?.url||r?.nextUrl?.href||"/api";try{let i=await n(...e),c=Math.round((typeof performance<"u"?performance.now():Date.now())-t),f=i?.status||200;return a.captureRequest({method:s,url:o,statusCode:f,durationMs:c,route:o}),i}catch(i){let c=Math.round((typeof performance<"u"?performance.now():Date.now())-t);throw a.captureRequest({method:s,url:o,statusCode:500,durationMs:c,route:o}),p(i,{url:o,method:s,type:"api_route_error"}),i}}}function b(n,e){return(async(...t)=>{let r=typeof performance<"u"?performance.now():Date.now();try{let s=await e(...t),o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);return a.captureRequest({method:"ACTION",url:n,statusCode:200,durationMs:o,route:n}),s}catch(s){let o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw a.captureRequest({method:"ACTION",url:n,statusCode:500,durationMs:o,route:n}),p(s,{actionName:n,type:"server_action_error"}),s}})}export{a as audit,g as auditFetch,p as captureNextError,m as initNextDevInspector,b as withAuditAction,E as withAuditApi};
|