App Events
AppEvent
App events are received from app using the Window.addEventListener
using the message
event. When receiving events check the eventType
property to discriminate between different types.
AppLoadedEvent
This event is received when the app loads for the first time.
Name | Type | Required | Description |
---|---|---|---|
eventType |
"appLoaded" |
Yes | A constant appLoadedEvent |
eventData |
AppLoadedEventData | Yes | The data of the event |
AppLoadedEventData
Name | Type | Required | Description |
---|---|---|---|
status |
"success" | "error" |
Yes | The status of the Packhunt app after loading - success indicates the app loaded successfully- error when the app could not load for instance because it failed to authenticate |
message |
string | null |
Yes | Contains additional info on the errors that occured (if any) |
AppUserEvent
This event is received when the Packhunt app sends a message. Only events found in availableEvents
of the embedLoadedEvent
eventData
can be expected in the data.
Name | Type | Required | Description |
---|---|---|---|
eventType |
"userEvent" |
Yes | A constant appUserEvent |
eventData |
AppUserEventData | Yes | The data of the event |
AppUserEventData
Name | Type | Required | Description |
---|---|---|---|
eventId |
string |
Yes | The id of the event. Available event ids can be found in the availableEvents of the embedLoadedEvent eventData |
eventPayload |
any |
Yes | The payload of the event. To see what payload schema to expect here consult the corresponding event in availableEvents of the embedLoadedEvent eventData |
InvalidRequestEvent
This event when any message request send to the app is considered invalid. Consult the eventData
of the event to check what errors occured during validation
Name | Type | Required | Description |
---|---|---|---|
eventType |
"invalidRequest" |
Yes | A constant invalidRequestEvent |
eventData |
{ message: string } |
Yes | The data of the event contains information on the error that occured |
EmbedLoadedEvent
This event is received when embed configuration is loaded in the Packhunt app. This event contains useful information about the state of the app and the events and messages that may be used to communicatie to it.
Name | Type | Required | Description |
---|---|---|---|
eventType |
"embedLoaded" |
Yes | A constant embedLoadedEvent |
eventData |
EmbedLoadedEventData | Yes | The data of the event |
EmbedLoadedEventData
Name | Type | Required | Description |
---|---|---|---|
name |
string |
Yes | This is the name of the embed configuration. Use this name when posting AppUserMessage messages to the app |
status |
"success" | "error" |
Yes | The status of the embedding configuration - success indicating the configuration loaded successfully and can now receive messages- error indicating something went wrong while loading the configuration |
message |
string | null |
Yes | Contains additional info on the errors that occured (if any) |
allowedMessages |
Dictionary<string , EmbedMessage> |
Yes | Contains a Dictionary of messageId and embed message definitions. Consult this type to check what AppUserMessage messages can be send to the app. |
availableEvents |
Dictionary<string , EmbedMessage> |
Yes | Contains a Dictionary of eventId and embed message definitions. Consult this type to check what AppUserMessage messages can be send to the app |
allowedOrigins |
List<string > |
Yes | A list of allowed origins which this app allows. The host website’s origin must match one of these origins to be allowed to communicate to this app |
EmbedMessage
Name | Type | Required | Description |
---|---|---|---|
description |
string |
Yes | A description of the user message or event |
schema |
Dictionary<string, any> |
Yes | A JSON Schema used to validate the definition |