fix(error tracking): streamline Rybbit integration by removing unnecessary type assertions
- Updated ErrorBoundary and ErrorTracking components to directly access the Rybbit object without type assertions. - Enhanced error tracking by ensuring stack traces and component stacks are only included if available. - Improved the HeroSection component by replacing the standard img tag with Next.js Image component for better performance and optimization.
This commit is contained in:
1 parent
4e14cc79ff
commit
50ffed4fee
4 files changed
+43
-10
No files matched your search
@@ -27,12 +27,12 @@ export class ErrorBoundary extends Component<Props, State> {
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||
// Enviar erro ao Rybbit se disponível
|
||||
if (typeof window !== "undefined" && (window as any).rybbit) {
|
||||
if (typeof window !== "undefined" && window.rybbit) {
|
||||
try {
|
||||
(window as any).rybbit.track("error", {
|
||||
window.rybbit.track("error", {
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
componentStack: errorInfo.componentStack,
|
||||
stack: error.stack || undefined,
|
||||
componentStack: errorInfo.componentStack || undefined,
|
||||
errorName: error.name,
|
||||
timestamp: new Date().toISOString(),
|
||||
});
|
||||
|
||||
@@ -10,9 +10,9 @@ export function ErrorTracking() {
|
||||
useEffect(() => {
|
||||
// Handler para erros JavaScript não capturados
|
||||
const handleError = (event: ErrorEvent) => {
|
||||
if (typeof window !== "undefined" && (window as any).rybbit) {
|
||||
if (typeof window !== "undefined" && window.rybbit) {
|
||||
try {
|
||||
(window as any).rybbit.track("error", {
|
||||
window.rybbit.track("error", {
|
||||
message: event.message,
|
||||
filename: event.filename,
|
||||
lineno: event.lineno,
|
||||
@@ -30,11 +30,11 @@ export function ErrorTracking() {
|
||||
|
||||
// Handler para Promise rejections não tratadas
|
||||
const handleUnhandledRejection = (event: PromiseRejectionEvent) => {
|
||||
if (typeof window !== "undefined" && (window as any).rybbit) {
|
||||
if (typeof window !== "undefined" && window.rybbit) {
|
||||
try {
|
||||
const error = event.reason instanceof Error ? event.reason : new Error(String(event.reason));
|
||||
|
||||
(window as any).rybbit.track("error", {
|
||||
window.rybbit.track("error", {
|
||||
message: error.message || String(event.reason),
|
||||
stack: error.stack,
|
||||
errorName: error.name || "UnhandledPromiseRejection",
|
||||
|
||||
Reference in new issue
Block a user