Front-end Events
You can "listen" to events that happens inside Hyvor Talk embed using Javascript. One common use case is reporting comment events in an analytics tool.
You have to set the onEvent
property in the HYVOR_TALK_CONFIG
variable to a callback. It will be called with two parameters: type and data.
HYVOR_TALK_CONFIG = {
id: false,
url: false,
onEvent: function(type, data) {
}
}
Event Types
The following event types are supported:
comment-publish
comment-edit
comment-delete
reaction-create
reaction-edit
reaction-delete
rating-create
rating-edit
sso-login
sso-signup
The data
variable will be an object that contains more details about the event.
For comment events:
{
id: 123, // comment ID
parent_ids: [] // array of parent comment IDs
created_at: 1646215479, // timestamp in UNIX seconds
}
For reaction events:
{
// reaction ID
id: 123,
// one of ['superb', 'love', 'wow', 'sad', 'laugh', 'angry']
type: 'superb',
// old_type only for reaction-edit (null for others)
old_type: 'love',
created_at: 1646215479, // timestamp in UNIX seconds
/**
* reactions count of the page as an array
* (ex: there are 52 superb reactions and other reactions are 0)
*/
page_reactions: [52,0,0,0,0,0]
}
For ratings events:
{
id: 123, // rating ID
created_at: 1646215479, // timestamp in UNIX seconds
rating: 4, // current rating
page_ratings: { // total page ratings similar to the API
average: 4.5,
count: 4
}
}
SSO events do not provide data
. See using modals for SSO login for more details.