Capturing events in Sentry.io

    0

    0

    David Jozwik

    This code captures three types of events: messages, exceptions, and events.

    1. To capture a message, use the "message" method.

    2. To capture an exception, use the "exception" method.

    3. To capture an event with a deep customization, use the "event" method.

    Library: next

    import * as Sentry from '@sentry/nextjs';
    
    Sentry.captureEvent({
      message: "Event"
    });
    Sentry.captureException(new CustomException("CustomException"));
    Sentry.captureException(new Error("Exception"));
    Sentry.captureMessage("Minimalistic Message");
    Sentry.captureMessage("Log Message", 'log');
    Sentry.captureMessage("Kitchen Sink Message", {
      tags: {
        grade: "5"
      },
      contexts: {
        context1: {
          contextual: "context"
        }
      },
      extra: {
        battery: 0.4
      },
      level: "fatal",
      user: {
        id: 'helloworld123abc',
        email: "jimbob@nonexistent-4353456.com"
      },
      fingerprint: [
        Date.now().toString()
      ],
      requestSession: {
        status: "ok"
      }
    });
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.