Skip to main content

Events

You can subscribe to events in two ways:


Using <IASContainer> props

import { IASContainer } from "@inappstory/react-sdk"

<IASContainer
config={storyManagerConfig}
onClickOnStory={(event) => console.log("Click on story", event)}
onShowStory={(event) => console.log("Show story", event)}
onCloseStory={(event) => console.log("Close story", event)}
onShowSlide={(event) => console.log("Show slide", event)}
onLikeStory={(event) => console.log("Like story", event)}
onDislikeStory={(event) => console.log("Dislike story", event)}
onFavoriteStory={(event) => console.log("Favorite story", event)}
onShareStory={(event) => console.log("Share story", event)}
onFeedImpression={(event) => console.log("Feed impression", event)}
onVisibleAreaUpdated={(event) => console.log("Visible area updated", event)}
onWidgetEvent={(event) => console.log("Widget event", event)}
/>

Using StoryManager instance

import { storyManager } from "@inappstory/react-sdk"

useEffect(() => {
const handleClickOnStory = (payload: ClickOnStoryEvent) => {
console.log("Click on story", payload);
};

storyManager.on("clickOnStory", handleClickOnStory);

return () => {
storyManager.off("clickOnStory", handleClickOnStory);
};
}, []);


clickOnStory

Description: Triggered when a user clicks on a story card in the slider list.

Payload:

FieldTypeDescription
idnumberStory ID.
titlestring?Story title.
slidesCountnumber?Number of slides in the story.
feedstring?Feed name where the story belongs.
sourcestring?Story source.
filterobjectApplied filters.
ugcPayloadobjectUGC-related payload.
defaultListLengthnumberDefault list length.
favoriteListLengthnumberFavorite list length.
indexnumberIndex of the story in the list.
isDeeplinkbooleanWhether the story was opened via deeplink.
urlstring?Deeplink URL.

showStory

Description: Triggered when a story is opened (from slider or reader).

Payload:

FieldTypeDescription
idnumberStory ID.
titlestring?Story title.
slidesCountnumber?Number of slides in the story.
feedstring?Feed name where the story belongs.
sourcestring?Story source.
filterobjectApplied filters.
ugcPayloadobjectUGC-related payload.
defaultListLengthnumberDefault list length.
favoriteListLengthnumberFavorite list length.

closeStory

Description: Triggered when a story is closed.

Payload:

FieldTypeDescription
idnumberStory ID.
titlestring?Story title.
slidesCountnumber?Number of slides in the story.
feedstring?Feed name where the story belongs.
sourcestring?Story source.
filterobjectApplied filters.
ugcPayloadobjectUGC-related payload.
defaultListLengthnumberDefault list length.
favoriteListLengthnumberFavorite list length.
actionstringClose action (closeReaderByCloseBtn, closeReaderByEscBtn, swipeDown, swipe, lastSlideClick, auto, externalCloseReader).

showSlide

Description: Triggered when a slide is shown.

Payload:

FieldTypeDescription
idnumberStory ID.
titlestring?Story title.
slidesCountnumber?Number of slides in the story.
feedstring?Feed name where the story belongs.
sourcestring?Story source.
filterobjectApplied filters.
ugcPayloadobjectUGC-related payload.
defaultListLengthnumberDefault list length.
favoriteListLengthnumberFavorite list length.
indexnumberSlide index.
payloadstringSlide payload.

likeStory

Description: Triggered when a user likes/unlikes a story.

Payload:

FieldTypeDescription
idnumberStory ID.
titlestring?Story title.
slidesCountnumber?Number of slides in the story.
feedstring?Feed name where the story belongs.
sourcestring?Story source.
filterobjectApplied filters.
ugcPayloadobjectUGC-related payload.
defaultListLengthnumberDefault list length.
favoriteListLengthnumberFavorite list length.
valuebooleantrue if liked, false if unliked.

dislikeStory

Description: Triggered when a user dislikes/undislikes a story.

Payload:

FieldTypeDescription
idnumberStory ID.
titlestring?Story title.
slidesCountnumber?Number of slides in the story.
feedstring?Feed name where the story belongs.
sourcestring?Story source.
filterobjectApplied filters.
ugcPayloadobjectUGC-related payload.
defaultListLengthnumberDefault list length.
favoriteListLengthnumberFavorite list length.
valuebooleantrue if disliked, false if removed.

favoriteStory

Description: Triggered when a user adds/removes a story to favorites.

Payload:

FieldTypeDescription
idnumberStory ID.
titlestring?Story title.
slidesCountnumber?Number of slides in the story.
feedstring?Feed name where the story belongs.
sourcestring?Story source.
filterobjectApplied filters.
ugcPayloadobjectUGC-related payload.
defaultListLengthnumberDefault list length.
favoriteListLengthnumberFavorite list length.
valuebooleantrue if favorited, false if removed.

shareStory

Description: Triggered when a user clicks on story sharing.

Payload:

FieldTypeDescription
idnumberStory ID.
titlestring?Story title.
slidesCountnumber?Number of slides in the story.
feedstring?Feed name where the story belongs.
sourcestring?Story source.
filterobjectApplied filters.
ugcPayloadobjectUGC-related payload.
defaultListLengthnumberDefault list length.
favoriteListLengthnumberFavorite list length.

shareStoryWithPath

Description: Triggered after successful creation of the sharing path.

Payload:

FieldTypeDescription
idnumberStory ID.
titlestring?Story title.
slidesCountnumber?Number of slides in the story.
feedstring?Feed name where the story belongs.
sourcestring?Story source.
filterobjectApplied filters.
ugcPayloadobjectUGC-related payload.
defaultListLengthnumberDefault list length.
favoriteListLengthnumberFavorite list length.
urlstringGenerated sharing URL.

feedImpression

Description: Triggered after stories appear in the viewport.

Payload:

FieldTypeDescription
feedstringFeed name.
storiesarrayArray of stories { id: number; title: string; slidesCount: number }.

visibleAreaUpdated

Description: Triggered when the visible area of stories is updated in the viewport.

Payload:

FieldTypeDescription
feedstringFeed name.
storiesarrayArray of stories { id: number; title: string; slidesCount: number }.

widgetEvent

Description: Triggered by widgets inside a story.

Payload:

FieldTypeDescription
namestringWidget name.
dataanyWidget-specific data.

startGame

Description: Fired when a game starts.

Payload:

FieldTypeDescription
idstringUnique game ID

closeGame

Description: Fired when a game is closed.

Payload:

FieldTypeDescription
idstringID of the closed game

eventGame

Description: Fired when a custom game event occurs.

Payload:

FieldTypeDescription
namestringName of the event
payloadanyEvent-specific payload