Skip to main content

Recording Controls

The Nudge SDK provides several methods to programmatically control the recording session.

Basic Controls

Once you've initialized the SDK and embedded the capture module, you can control the recording using the following methods:

// Start a new recording session
recorder.start();

// Stop the current recording
recorder.stop();

// Reset the current recording (clears recorded steps)
recorder.reset();

// Submit the recording to be processed
recorder.submit();

Usage Example

Here's an example of how to implement these controls in your application:

// Initialize the SDK
const nudgeai = NudgeAI('<YOUR_API_SECRET>', options);

// Embed the capture module
const recorder = nudgeai.embed_capture(
element_id="capture_session_id",
client_id="042491a0-5341-4420-a2f8-74c7e893ac1c"
);

// Example: Start recording when a button is clicked
document.getElementById('startBtn').addEventListener('click', () => {
recorder.start();
});

// Example: Stop recording
document.getElementById('stopBtn').addEventListener('click', () => {
recorder.stop();
});

// Example: Reset the recording
document.getElementById('resetBtn').addEventListener('click', () => {
recorder.reset();
});

// Example: Submit the recording
document.getElementById('submitBtn').addEventListener('click', () => {
recorder.submit();
});

Control States

  • start(): Begins a new recording session. If a session is already in progress, it will continue recording.
  • stop(): Pauses the current recording session. The recorded steps are preserved and can be resumed.
  • reset(): Clears all recorded steps in the current session and returns to the initial state.
  • submit(): Sends the recorded session to be processed. This should be called when the recording is complete.

Best Practices

  • Always call stop() before submit() to ensure all steps are properly recorded
  • Use reset() when you want to start fresh without submitting the current recording
  • Consider implementing error handling around these methods to provide feedback to users