Waymark Plugin — Client-side Events

The Waymark Plugin emits a variety of client-side events which you may subscribe to to keep track of changes to the Plugin's state.

Subscribing to events

Events can be subscribed to in 3 different ways:

  1. Events can be subscribed to with the Waymark.on method.

    waymark.on('waymarkOpened', () => {
      console.log('The Waymark AI view has opened successfully');
    });
  2. Events are also emitted globally on the document where each event's name follows the format "waymark:<eventName>".

    document.addEventListener('waymark:waymarkOpened', () => {
      console.log('The Waymark AI view has opened successfully');
    });
  3. Events can also be subscribed to by passing callbacks to the callbacks option in the Waymark constructor.

    const waymark = new Waymark('my-partner-id', {
      callbacks: {
        waymarkOpened: () => {
          console.log('The Waymark AI view has opened successfully');
        },
      },
    });

Event list

The Plugin may emit the following events:

waymarkOpened

type: CustomEvent<undefined>

Emitted when the Waymark AI view has successfully opened.

This will happen when:

waymarkOpenFailed

type: CustomEvent<Error>

Emitted when an error occurred while attempting to open the Waymark AI view with a Waymark.openWaymark call.

The event detail will be an Error object with details about the error which occurred.

A generic error event will be emitted along with this event as well.

editorExited

type: CustomEvent<undefined>

Emitted when the user exits the Waymark Editor by either clicking the "Exit" button to close the editor or the "Finish" button to complete the video.

If the user clicked the "Exit" button:

If the user clicked the "Finish" button:

editorOpened

type: CustomEvent<VideoData>

Emitted when the Waymark Editor has successfully opened for a video.

The event detail will be a VideoData object with details about the video which was opened in the editor.

This event will be emitted both when the Editor was opened directly via waymark.openEditorForVideo, or if the user opens a video in the Editor from the Waymark AI view.

editorOpenFailed

type: CustomEvent<Error>

Emitted when an error has occurred while attempting to open the Waymark Editor.

The event detail will be an Error object with details about the error which occurred.

This event will be emitted both if an error occurs when attempting to directly open the Editor via waymark.openEditorForVideo, or if an error occurs when the user tries to open a video in the Editor from the Waymark AI view.

A generic error event will be emitted along with this event as well.

videoCreated

type: CustomEvent<VideoData>

Emitted when the user saves a new video to their account.

The event detail will be a VideoData object with details about the video which was created.

This event will be emitted when the user clicks the "Edit & Continue" button in the Waymark AI flow to save a new video to their account and open it in the Editor.

videoSaved

Event type: CustomEvent<VideoData>

Emitted when Waymark saves changes to the user's video.

The event detail will be a VideoData object with details about the video which was saved.

This event will be emitted in the following scenarios:

videoCompleted

type: CustomEvent<VideoData>

Emitted when a user has clicked the "Finish" button to complete their video. Waymark will start rendering the video at this point.

The event detail will be a VideoData object with details about the video which was completed.

Note that if a user re-opens a video which they have already completed and clicks the "Finish" button again without making any changes, Waymark will not kick off a new render.

videoRendered

type: CustomEvent<VideoData>

Emitted when a video belonging to the user's account finishes rendering.

The event detail will be a VideoData object with details about the video which rendered.

error

Event type: CustomEvent<Error>

Emitted when any error occurs in the Plugin.

The event detail will be an Error object with details about the error which occurred.