Skip to content

Latest commit

 

History

History
622 lines (604 loc) · 19.6 KB

CLIENT_EVENTS.md

File metadata and controls

622 lines (604 loc) · 19.6 KB

Client Events Guide

This serves as a guide to events emitted by the javascript via the embed events hook, as described below in Viewer Events.

Table of Contents

Viewer Events

Viewer Events are emitted when the viewer performs certain actions. They can be subscribed to using the events parameter in Coral.createStreamEmbed.

<script>
  const CoralStreamEmbed = Coral.createStreamEmbed({
    events: function(events) {
      events.onAny(function(eventName, data) {
        console.log(eventName, data);
      });
    },
  });
</script>

Example events:

  • setMainTab {tab: "PROFILE"}
  • showFeaturedCommentTooltip
  • viewConversation {from: "FEATURED_COMMENTS", commentID: "c45fb5f5-03f9-49a3-a755-488c698ca0df"}

Viewer Network Events

Viewer Network Events are events that involves a network request and thus can succeed or fail. Succeeding events will have a .success appended to the event name while failing events have an .error appended to the event name.

Moreover Viewer Network Events contains the rtt field which indicates the time it needed from initiating the request until the UI has been updated with the response data.

Example events:

createComment.success
{
  body: "Hello world!",
  storyID: "238b95ec-2b80-43f4-ab68-a6ea1f4e2584",
  rtt: 307,
  success: {
    id: "6fecfb11-4d0f-4edc-89b7-878a9928addd"
    status: "APPROVED"`
  }
}
createComment.error
{
  body: "Hi!",
  storyID: "238b95ec-2b80-43f4-ab68-a6ea1f4e2584",
  rtt: 229,
  error: {
    code: "COMMENT_BODY_TOO_SHORT"
    message: "Comment body must have at least 10 characters."
  }
}

Event List

Index

Events

  • approveComment.success, approveComment.error: This event is emitted when the viewer approves a comment.
    {
        commentID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • banUser.success, banUser.error: This event is emitted when the viewer bans a user.
    {
        userID: string;
        commentID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • cancelAccountDeletion.success, cancelAccountDeletion.error: This event is emitted when the viewer cancels the account deletion.
    {
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • changeEmail.success, changeEmail.error: This event is emitted when the viewer changes its email.
    {
        oldEmail: string;
        newEmail: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • changePassword.success, changePassword.error: This event is emitted when the viewer changes its password.
    {
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • changeUsername.success, changeUsername.error: This event is emitted when the viewer changes its username.
    {
        oldUsername: string;
        newUsername: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • closeStory.success, closeStory.error: This event is emitted when the viewer closes the story.
    {
        storyID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • copyPermalink: This event is emitted when the viewer copies the permalink with the button.
    {
        commentID: string;
    }
  • createComment.success, createComment.error: This event is emitted when a top level comment is created.
    {
        storyID: string;
        body: string;
        success: {
            id: string;
            status: COMMENT_STATUS;
        };
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • createCommentFocus: This event is emitted when the viewer focus on the RTE to create a comment.
  • createCommentReaction.success, createCommentReaction.error: This event is emitted when the viewer reacts to a comment.
    {
        commentID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • createCommentReply.success, createCommentReply.error: This event is emitted when a comment reply is created.
    {
        body: string;
        parentID: string;
        success: {
            id: string;
            status: COMMENT_STATUS;
        };
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • editComment.success, editComment.error: This event is emitted when the viewer edits a comment.
    {
        body: string;
        commentID: string;
        success: {
            status: COMMENT_STATUS;
        };
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • featureComment.success, featureComment.error: This event is emitted when the viewer features a comment.
    {
        commentID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • gotoModeration: This event is emitted when the viewer goes to moderation.
    {
        commentID: string;
    }
  • ignoreUser.success, ignoreUser.error: This event is emitted when the viewer ignores a user.
    {
        userID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • loadMoreAllComments.success, loadMoreAllComments.error: This event is emitted when the viewer loads more top level comments into the comment stream.
    {
        storyID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • loadMoreFeaturedComments.success, loadMoreFeaturedComments.error: This event is emitted when the viewer loads more featured comments.
    {
        storyID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • loadMoreHistoryComments.success, loadMoreHistoryComments.error: This event is emitted when the viewer loads more top level comments into the history comment stream.
    {
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • loginPrompt: This event is emitted when the viewer does an action that will prompt a login dialog.
  • openSortMenu: This event is emitted when the viewer clicks on the sort menu.
  • openStory.success, openStory.error: This event is emitted when the viewer opens the story.
    {
        storyID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • rejectComment.success, rejectComment.error: This event is emitted when the viewer rejects a comment.
    {
        commentID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • removeCommentReaction.success, removeCommentReaction.error: This event is emitted when the viewer removes its reaction from a comment.
    {
        commentID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • removeUserIgnore.success, removeUserIgnore.error: This event is emitted when the viewer remove a user from its ignored users list.
    {
        userID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • replyCommentFocus: This event is emitted when the viewer focus on the RTE to reply to a comment.
  • reportComment.success, reportComment.error: This event is emitted when the viewer reports a comment.
    {
        reason: string;
        commentID: string;
        additionalDetails?: string | undefined;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • requestAccountDeletion.success, requestAccountDeletion.error: This event is emitted when the viewer requests to delete its account.
    {
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • requestDownloadCommentHistory.success, requestDownloadCommentHistory.error: This event is emitted when the viewer requests to download its comment history.
    {
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • resendEmailVerification.success, resendEmailVerification.error: This event is emitted when the viewer request another email verification email.
    {
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • setCommentsOrderBy: This event is emitted when the viewer changes the sort order of the comments.
    {
        orderBy: string;
    }
  • setCommentsTab: This event is emitted when the viewer changes the tab of the comments tab bar.
    {
        tab: string;
    }
  • setMainTab: This event is emitted when the viewer changes the tab of the main tab bar.
    {
        tab: string;
    }
  • setProfileTab: This event is emitted when the viewer changes the tab of the profile tab bar.
    {
        tab: string;
    }
  • showAbsoluteTimestamp: This event is emitted when the viewer clicks on the relative timestamp to show the absolute time.
  • showAllReplies.success, showAllReplies.error: This event is emitted when the viewer reveals all replies of a comment.
    {
        commentID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • showAuthPopup: This event is emitted when the viewer requests the auth popup.
    {
        view: string;
    }
  • showEditEmailDialog: This event is emitted when the viewer opens the edit email dialog.
  • showEditForm: This event is emitted when the viewer opens the edit form.
    {
        commentID: string;
    }
  • showEditPasswordDialog: This event is emitted when the viewer opens the edit password dialog.
  • showEditUsernameDialog: This event is emitted when the viewer opens the edit username dialog.
  • showFeaturedCommentTooltip: This event is emitted when the viewer clicks to show the featured comment tooltip.
  • showIgnoreUserdDialog: This event is emitted when the viewer opens the ignore user dialog.
  • showModerationPopover: This event is emitted when the viewer opens the moderation popover.
    {
        commentID: string;
    }
  • showMoreOfConversation.success, showMoreOfConversation.error: This event is emitted when the viewer reveals more of the parent conversation thread.
    {
        commentID: string | null;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • showMoreReplies: This event is emitted when the viewer reveals new live replies.
    {
        commentID: string;
        count: number;
    }
  • showReplyForm: This event is emitted when the viewer opens the reply form.
    {
        commentID: string;
    }
  • showReportPopover: This event is emitted when the viewer opens the report popover.
    {
        commentID: string;
    }
  • showSharePopover: This event is emitted when the viewer opens the share popover.
    {
        commentID: string;
    }
  • showUserPopover: This event is emitted when the viewer clicks on a username which shows the user popover.
    {
        userID: string;
    }
  • signOut.success, signOut.error: This event is emitted when the viewer signs out.
    {
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • signedIn: This event is emitted when the viewer signed in (not applicable for SSO).
  • unfeatureComment.success, unfeatureComment.error: This event is emitted when the viewer unfeatures a comment.
    {
        commentID: string;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • updateNotificationSettings.success, updateNotificationSettings.error: This event is emitted when the viewer updates its notification settings.
    {
        onReply?: boolean | null | undefined;
        onFeatured?: boolean | null | undefined;
        onStaffReplies?: boolean | null | undefined;
        onModeration?: boolean | null | undefined;
        digestFrequency?: "NONE" | "DAILY" | "HOURLY" | null | undefined;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • updateStorySettings.success, updateStorySettings.error: This event is emitted when the viewer updates the story settings.
    {
        storyID: string;
        live?: {
            enabled?: boolean | null | undefined;
        } | null | undefined;
        moderation?: "POST" | "PRE" | null | undefined;
        premodLinksEnable?: boolean | null | undefined;
        messageBox?: {
            enabled?: boolean | null | undefined;
            icon?: string | null | undefined;
            content?: string | null | undefined;
        } | null | undefined;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • updateUserMediaSettings.success, updateUserMediaSettings.error:
    {
        unfurlEmbeds?: boolean | null | undefined;
        success: {};
        error: {
            message: string;
            code?: string | undefined;
        };
    }
  • viewConversation: This event is emitted when the viewer changes to the single conversation view.
    {
        from: "FEATURED_COMMENTS" | "COMMENT_STREAM" | "COMMENT_HISTORY";
        commentID: string;
    }
  • viewFullDiscussion: This event is emitted when the viewer exits the single conversation.
    {
        commentID: string | null;
    }
  • viewNewComments: This event is emitted when the viewer reveals new live comments.
    {
        storyID: string;
        count: number;
    }