Initialization

Before using any reporting feature, you must initialize Notaify once at the entryway of your application.

Basic Initialization

Import and call notaify.init() using the credentials from your environment variables. Make sure this code runs before your main application logic or server starts.

javascript
import notaify from '@notaify/node'; notaify.init({ apiKeyId: process.env.NOTAIFY_API_KEY_ID, apiKey: process.env.NOTAIFY_API_KEY, });

Why is initialization required?

The init() method accomplishes several things:

  • It authenticates your app with the Notaify servers.
  • It configures global settings like environment tags and custom app names.
  • It prepares the internal queue for efficiently buffering error events.
  • Crucially: It enables global Auto-Capture (if used) to listen for uncaught exceptions and unhandled promise rejections.

Is this safe to run in development?

Yes. However, if you don't want to consume your quota during local testing, you can easily bypass initialization conditionally:

javascript
if (process.env.NODE_ENV === 'production') { notaify.init(...) }