Skip to content

Step 6: Managing Recording State

By default, calling Nveal.init() will automatically start the recording process. However, depending on your application's privacy requirements (e.g., waiting for GDPR consent), you might want to control exactly when recording starts and stops.

Stopping the SDK (Optional)

Calling stop() is completely optional.

If a user simply closes the browser tab, navigates away, or abandons the page, the SDK automatically handles it. The session is safely flushed and stored before the page unloads using native browser APIs (beacon or keepalive).

You only need to manually call stop() if you want to explicitly end a recording while the user is still actively using the page (for example, if they enter a highly sensitive area of your app where you don't want any recording to happen at all).

// Stop recording and flush any pending events
await Nveal.stop();
console.log("Recording stopped manually.");

Restarting the SDK

If you need to resume recording after stopping it, you simply call init() again with your configuration.

// Resume recording (generates a new Session ID)
Nveal.init({
  apiKey: 'YOUR_API_KEY'
});

Note

Stopping and restarting the SDK will split the user's journey into two separate sessions in the Nveal dashboard, each with a distinct Session ID.