Events
You can subscribe to events using InAppStoryManager instance
Example
import { InAppStoryManager } from "@inappstory/js-sdk";
const inAppStoryManager = new InAppStoryManager({ apiKey: "{projectToken}" });
inAppStoryManager.on("clickOnStory", (payload) => console.log(payload));
clickOnStoryshowStorycloseStoryshowSlidelikeStorydislikeStoryfavoriteStoryshareStoryshareStoryWithPathfeedImpressionvisibleAreaUpdatedwidgetEventstartGamecloseGameeventGame
clickOnStory
Description: Triggered when a user clicks on a story card in the slider list.
Payload:
| Field | Type | Description |
|---|---|---|
id | number | Story ID. |
title | string? | Story title. |
slidesCount | number? | Number of slides in the story. |
feed | string? | Feed name where the story belongs. |
source | string? | Story source. |
filter | object | Applied filters. |
ugcPayload | object | UGC-related payload. |
defaultListLength | number | Default list length. |
favoriteListLength | number | Favorite list length. |
index | number | Index of the story in the list. |
isDeeplink | boolean | Whether the story was opened via deeplink. |
url | string? | Deeplink URL. |
showStory
Description: Triggered when a story is opened (from slider or reader).
Payload:
| Field | Type | Description |
|---|---|---|
id | number | Story ID. |
title | string? | Story title. |
slidesCount | number? | Number of slides in the story. |
feed | string? | Feed name where the story belongs. |
source | string? | Story source. |
filter | object | Applied filters. |
ugcPayload | object | UGC-related payload. |
defaultListLength | number | Default list length. |
favoriteListLength | number | Favorite list length. |
closeStory
Description: Triggered when a story is closed.
Payload:
| Field | Type | Description |
|---|---|---|
id | number | Story ID. |
title | string? | Story title. |
slidesCount | number? | Number of slides in the story. |
feed | string? | Feed name where the story belongs. |
source | string? | Story source. |
filter | object | Applied filters. |
ugcPayload | object | UGC-related payload. |
defaultListLength | number | Default list length. |
favoriteListLength | number | Favorite list length. |
action | string | Close action (closeReaderByCloseBtn, closeReaderByEscBtn, swipeDown, swipe, lastSlideClick, auto, externalCloseReader). |
showSlide
Description: Triggered when a slide is shown.
Payload:
| Field | Type | Description |
|---|---|---|
id | number | Story ID. |
title | string? | Story title. |
slidesCount | number? | Number of slides in the story. |
feed | string? | Feed name where the story belongs. |
source | string? | Story source. |
filter | object | Applied filters. |
ugcPayload | object | UGC-related payload. |
defaultListLength | number | Default list length. |
favoriteListLength | number | Favorite list length. |
index | number | Slide index. |
payload | string | Slide payload. |
likeStory
Description: Triggered when a user likes/unlikes a story.
Payload:
| Field | Type | Description |
|---|---|---|
id | number | Story ID. |
title | string? | Story title. |
slidesCount | number? | Number of slides in the story. |
feed | string? | Feed name where the story belongs. |
source | string? | Story source. |
filter | object | Applied filters. |
ugcPayload | object | UGC-related payload. |
defaultListLength | number | Default list length. |
favoriteListLength | number | Favorite list length. |
value | boolean | true if liked, false if unliked. |
dislikeStory
Description: Triggered when a user dislikes/undislikes a story.
Payload:
| Field | Type | Description |
|---|---|---|
id | number | Story ID. |
title | string? | Story title. |
slidesCount | number? | Number of slides in the story. |
feed | string? | Feed name where the story belongs. |
source | string? | Story source. |
filter | object | Applied filters. |
ugcPayload | object | UGC-related payload. |
defaultListLength | number | Default list length. |
favoriteListLength | number | Favorite list length. |
value | boolean | true if disliked, false if removed. |
favoriteStory
Description: Triggered when a user adds/removes a story to favorites.
Payload:
| Field | Type | Description |
|---|---|---|
id | number | Story ID. |
title | string? | Story title. |
slidesCount | number? | Number of slides in the story. |
feed | string? | Feed name where the story belongs. |
source | string? | Story source. |
filter | object | Applied filters. |
ugcPayload | object | UGC-related payload. |
defaultListLength | number | Default list length. |
favoriteListLength | number | Favorite list length. |
value | boolean | true if favorited, false if removed. |
shareStory
Description: Triggered when a user clicks on story sharing.
Payload:
| Field | Type | Description |
|---|---|---|
id | number | Story ID. |
title | string? | Story title. |
slidesCount | number? | Number of slides in the story. |
feed | string? | Feed name where the story belongs. |
source | string? | Story source. |
filter | object | Applied filters. |
ugcPayload | object | UGC-related payload. |
defaultListLength | number | Default list length. |
favoriteListLength | number | Favorite list length. |
shareStoryWithPath
Description: Triggered after successful creation of the sharing path.
Payload:
| Field | Type | Description |
|---|---|---|
id | number | Story ID. |
title | string? | Story title. |
slidesCount | number? | Number of slides in the story. |
feed | string? | Feed name where the story belongs. |
source | string? | Story source. |
filter | object | Applied filters. |
ugcPayload | object | UGC-related payload. |
defaultListLength | number | Default list length. |
favoriteListLength | number | Favorite list length. |
url | string | Generated sharing URL. |
feedImpression
Description: Triggered after stories appear in the viewport.
Payload:
| Field | Type | Description |
|---|---|---|
feed | string | Feed name. |
stories | array | Array of stories { id: number; title: string; slidesCount: number }. |
visibleAreaUpdated
Description: Triggered when the visible area of stories is updated in the viewport.
Payload:
| Field | Type | Description |
|---|---|---|
feed | string | Feed name. |
stories | array | Array of stories { id: number; title: string; slidesCount: number }. |
widgetEvent
Description: Triggered by widgets inside a story.
Payload:
| Field | Type | Description |
|---|---|---|
name | string | Widget name. |
data | any | Widget-specific data. |
startGame
Description: Fired when a game starts.
Payload:
| Field | Type | Description |
|---|---|---|
id | string | Unique game ID |
closeGame
Description: Fired when a game is closed.
Payload:
| Field | Type | Description |
|---|---|---|
id | string | ID of the closed game |
eventGame
Description: Fired when a custom game event occurs.
Payload:
| Field | Type | Description |
|---|---|---|
name | string | Name of the event |
payload | any | Event-specific payload |