UNPKG

@benshi.ai/js-sdk

Version:

Benshi SDK

266 lines (265 loc) 6.44 kB
import { Country, Language, SearchFilter } from "../../core/commonTypes"; import { TypedItem } from "../ECommerce/typings"; export declare enum NavigationTypes { App = "app", Identify = "identify", Media = "media", NudgeResponse = "nudge_response", Page = "page", Promo = "promo", Rate = "rate", Scroll = "scroll", Search = "search", Track = "track" } export declare enum ContentBlock { Core = "core", ELearning = "e-learning", ECommerce = "e-commerce", Social = "social", Payment = "payment", Loyalty = "loyalty" } export declare enum AppAction { Background = "background", Close = "close", Open = "open", Resume = "resume" } export declare enum IdentifyAction { Login = "login", Logout = "logout", Register = "register" } export declare enum MediaActionForVideo { Play = "play", Pause = "pause", Seek = "seek", Finish = "finish" } export declare enum MediaActionForImage { Play = "play" } export interface AppProperties { action: AppAction; } export interface IdentifyProperties { action: IdentifyAction; } export interface UserInfo extends IdentifyProperties { user_props: UserProperties; } export type ImageProperties = { /** * The block or module where the media is embedded. For example, * 'e-elearning' if the media is included as an activity * of the course * */ contentBlock?: ContentBlock; type: ImageType; id: string; action: MediaActionForImage; time: number; meta?: any; }; export declare enum ImageType { Image = "image" } export declare enum AudioVideoType { Audio = "audio", Video = "video" } export type AudioVideoProperties = { /** * The block or module where the media is embedded. For example, * 'e-elearning' if the the video or audio is included as an activity * of the course * */ contentBlock?: ContentBlock; type: AudioVideoType; id: string; action: MediaActionForVideo; time: number; meta?: any; }; export type MediaProperties = ImageProperties | AudioVideoProperties; /** * @internal */ export type InternalMediaProperties = MediaProperties & { id_source: string; }; export type MediaData = { name?: string; length: string; description?: string; resolution?: string; language?: Language; }; /** * @internal */ export type InternalMediaData = MediaData & { id_source: string; id: string; type: AudioVideoType; }; export declare enum PageType { View = "view", Completed = "completed" } export interface PageProperties { path: string; title?: string; duration?: number; meta?: any; } export declare enum NudgeAction { Block = "block", Discard = "discard", Open = "open" } export declare enum NudgeResponseType { Push = "push_notification", InApp = "in_app_message" } export interface NudgeResponseProperties { nudge_id: number; type: NudgeResponseType; response: { action: NudgeAction; }; resolved_action: any; } /** * This interface represents the information related to * a search */ export interface SearchProperties { /** * The block or module where the search was peformed. For example, * 'e-commerce' if the user made a serch in the marketplace section, * or 'e-elearning' is the search was performed in the courses/classes * section */ contentBlock?: ContentBlock; /** * Free text introduced by the user to search */ query: string; /** * If the search results are shown paginaged, or with infinite scroll, * this field represent the number of page/subset the current result_ids * belongs to */ page: number; /** * Current list of items IDs obtained for this search and page. * If the user have pressed in a new page number, of scroll down * and the web automatically retrieved new item, include here only * the new ones */ results_ids?: Array<string | TypedItem>; /** * If the search engine allow to select specific value to search * in a selectable list, include here an object whose keys are the * attributes to search, and the values the actual values that must * match */ filter?: SearchFilter; /** * Any other additional information to be available in the logs */ meta?: any; } /** * @internal * * checkers do not support Omit, which will be usefull here to remove the result_ids list */ export interface InternalSearchProperties { id: string; results_list: Array<TypedItem>; contentBlock?: ContentBlock; query: string; page: number; filter?: SearchFilter; meta?: any; } export declare enum EducationLevel { Primary = "primary", LowerSecondary = "lower_secondary", UpperSecondary = "upper_secondary", NonTertiary = "non_tertiary", Tertiary = "tertiary", Bachelors = "bachelors", Masters = "masters", Doctorate = "doctorate" } export interface UserProperties { name?: string; organization_id?: string; organization_name?: string; experience?: string; region_state?: string; city?: string; workplace?: string; profession?: string; zipcode?: string; /** * ISO 8601 string (ie.: +0200) * Generated automatically by the SDK */ timezone?: string; /** * country which the user is, represented as * two characters in ISO 3166 */ country?: Country; /** * iSO 639-1 */ language?: Language; education_level?: EducationLevel; } /** * @internal */ export interface InternalUserProperties extends UserProperties { id: string; } export declare enum TrackTypes { ReferenceGuide = "reference_guide" } export declare enum TrackActions { ViewList = "view_list", ViewItem = "view_item", ExternalLink = "external_link" } export type TrackProperties = { action: TrackActions.ViewList | TrackActions.ExternalLink; meta?: any; } | { action: TrackActions.ViewItem; item_id: string; meta?: any; }; /** * @internal */ export type TrackPropertiesInternal = TrackProperties & { type: TrackTypes; }; export declare enum RateType { App = "app", Exam = "exam", Media = "media", Order = "order" } export interface RateProperties { rate_value: number; type: RateType; subject_id: string; }