@channel.io/channel-web-sdk-loader
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -12,101 +12,360 @@ declare global { | ||
} | ||
interface BootOption { | ||
appearance?: string; | ||
/** | ||
* @see https://developers.channel.io/docs/web-user-object | ||
*/ | ||
export interface User { | ||
/** | ||
* - The number of important notifications that the user has not read. | ||
* - It is displayed as a number on the channel button. | ||
* @see https://developers.channel.io/docs/glossary#channel-button | ||
*/ | ||
alert: number; | ||
/** The avatar image URL of a user. */ | ||
avatarUrl: string; | ||
/** The id of a user */ | ||
id: string; | ||
/** | ||
* - The language of a user. | ||
* - Used for translation. | ||
* - Set by updateUser and language of boot option. | ||
* - Following 32 languages supported. | ||
* - 'de'(German), 'hi'(Hindi), 'no'(Norwegian), 'ru'(Russian), 'fi'(Finnish), 'pt'(Portuguese), 'hr'(Croatian), 'fr'(French), 'hu'(Hungarian), 'uk'(Ukrainian), 'sk'(Slovak), 'ca'(Catalan), 'sv'(Swedish), 'ko'(Korean), 'id'(Indonesian), 'ms'(Malay), 'el'(Greek), 'en'(English), 'it'(Italian), 'es'(Spanish), 'he'(Hebrew), 'zh'(Chinese), 'cs'(Czech), 'ar'(Arabic), 'vi'(Vietnamese),'th'(Thai), 'ja'(Japanese), 'pl'(Polish), 'ro'(Romanian), 'da'(Danish), 'nl'(Dutch), 'tr'(Turkish) | ||
*/ | ||
language: string; | ||
/** | ||
* - The id used for identifying a member user. | ||
* - If you set memberId in the boot option, the user is regarded as a member user. | ||
*/ | ||
memberId: string; | ||
/** | ||
* - The name of a user | ||
* - Set by updateUser | ||
*/ | ||
name?: string; | ||
/** | ||
* - A user's profile information. | ||
* - Set by updateUser or profile of boot option. | ||
*/ | ||
profile?: Profile | null; | ||
/** | ||
* - The tags of a user. | ||
* - Always lowercase. | ||
* - Set by updateUser, addTags, or removeTags. | ||
*/ | ||
tags?: string[] | null; | ||
/** | ||
* - The number of all unread notifications the user has not read. | ||
* - It includes the number of alert. It is displayed as a red dot on the channel button. | ||
* @see https://developers.channel.io/docs/glossary#channel-button | ||
*/ | ||
unread: number; | ||
/** | ||
* - Whether to unsubscribe the marketing email. | ||
* - Set by updateUser or unsubscribeEmail of boot option. | ||
*/ | ||
unsubscribeEmail: boolean; | ||
/** | ||
* - Whether to unsubscribe the marketing email. | ||
* - Set by updateUser or unsubscribeTexting of boot option. | ||
*/ | ||
unsubscribeTexting: boolean; | ||
} | ||
/** | ||
* - When it fails, the callback passes an error object at the first argument, null at the second argunent. | ||
* - When it succeeds, the callback passes null at the first argument, an user object at the second argument. | ||
*/ | ||
export type Callback = (error: Error | null, user: User | null) => void; | ||
/** | ||
* - A User’s profile information. | ||
* - Set by updateUser or profile of boot option. | ||
*/ | ||
export interface Profile { | ||
[key: string]: string | number | boolean | null; | ||
} | ||
/** | ||
* - light: Use the light theme. | ||
* - dark: Use the dark theme. | ||
* - system: Follow the System theme. | ||
* - null: Follow the desk's theme setting. | ||
*/ | ||
export type Appearance = 'light' | 'dark' | 'system' | null; | ||
/** | ||
* Load the Channel SDK script. | ||
*/ | ||
export declare function loadScript(): void; | ||
/** @see https://developers.channel.io/docs/web-boot-option */ | ||
export interface BootOption { | ||
/** | ||
* - Set the initial appearance of the theme. | ||
* - The default value is null. | ||
*/ | ||
appearance?: Appearance; | ||
/** | ||
* - string The CSS Selector to select custom launcher. | ||
* - Use when you customize default chat button. | ||
* @see https://developers.channel.io/docs/web-customization | ||
*/ | ||
customLauncherSelector?: string; | ||
/** | ||
* - Set whether to hide the default chat button. | ||
* - The default value is false. | ||
*/ | ||
hideChannelButtonOnBoot?: boolean; | ||
/** | ||
* - Set whether to hide the marketing pop-ups and the message alarm pop-ups. | ||
* - The default value is false. | ||
*/ | ||
hidePopup?: boolean; | ||
language?: string; | ||
/** | ||
* - Set the default value of the language. | ||
* - Texts differ based on the language. | ||
* - When a user is created newly, the user’s language is set as the language. | ||
* - language doesn’t change the user’s language already created. | ||
*/ | ||
language?: 'en' | 'ko' | 'ja'; | ||
/** Set the hashed value of the memberId using HMAC-SHA256. */ | ||
memberHash?: string; | ||
/** | ||
* The id of member user. | ||
* @see https://developers.channel.io/docs/glossary#member-user | ||
*/ | ||
memberId?: string; | ||
/** | ||
* The plugin key of your channel. | ||
* @see https://developers.channel.io/docs/sdk#get-a-plugin-key | ||
*/ | ||
pluginKey: string; | ||
/** | ||
* Set the user’s profile. | ||
* @see https://developers.channel.io/docs/web-user-object#profile | ||
*/ | ||
profile?: Profile; | ||
/** | ||
* - Set whether to track the default event(PageView) or not. | ||
* - The default value is true. | ||
* @see https://developers.channel.io/docs/event | ||
*/ | ||
trackDefaultEvent?: boolean; | ||
/** | ||
* - Set whether to track the UTM source and referrer or not. | ||
* - The default value is true. | ||
* @see https://support.google.com/analytics/answer/1033863#zippy=%2Cin-this-article | ||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer | ||
*/ | ||
trackUtmSource?: boolean; | ||
/** | ||
* - Set whether to unsubscribe marketing email and SMS for the user. | ||
* - The default value is false. | ||
*/ | ||
unsubscribe?: boolean; | ||
/** | ||
* - Set whether to unsubscribe marketing email for the user. | ||
* - The default value is false. | ||
*/ | ||
unsubscribeEmail?: boolean; | ||
/** | ||
* - Set whether to unsubscribe marketing SMS for the user. | ||
* - The default value is false. | ||
*/ | ||
unsubscribeTexting?: boolean; | ||
/** | ||
* - Set the z-index of the elements made by the SDK. | ||
* - Applied at chat button, messenger, and marketing pop-up. | ||
* - The default value is 10000000. | ||
* @see https://developers.channel.io/docs/glossary#messenger | ||
*/ | ||
zIndex?: number; | ||
} | ||
interface Callback { | ||
(error: Error | null, user: CallbackUser | null): void; | ||
/** | ||
* - Initialize for the SDK. | ||
* - Channel button shows up, and features like marketing pop-up are ready to operate. | ||
* @param {BootOption} option - A boot option to initialize SDK. | ||
* @param {Callback | undefined} callback - Callback called after boot. When boot fails, the callback passes an error object at the first argument, null at the second argunent. When boot succeeds, the callback passes null at the first argument, a user object at the second argument. | ||
* @see https://developers.channel.io/docs/glossary#boot | ||
* @see https://developers.channel.io/docs/web-boot-option | ||
* @see https://developers.channel.io/docs/web-user-object | ||
*/ | ||
export declare function boot(option: BootOption, callback?: Callback): void; | ||
/** | ||
* Stop all operations of the SDK and initialize internal data. | ||
*/ | ||
export declare function shutdown(): void; | ||
/** | ||
* Show the messenger. | ||
* @see https://developers.channel.io/docs/glossary#messenger | ||
*/ | ||
export declare function showMessenger(): void; | ||
/** | ||
* Hide the messenger. | ||
* @see https://developers.channel.io/docs/glossary#messenger | ||
*/ | ||
export declare function hideMessenger(): void; | ||
/** | ||
* - Open a chat. | ||
* - A new chat is opened if you pass an empty value to chatId. In this case, if you pass a message, the message is entered in the input. If the support bot is active, the support bot runs. | ||
* - The chat is opened if the chat with the given chatId exists. In this case, a message is ignored. The lounge is opened if the chat doesn't exist. | ||
* - If you use openChat outside of the click event handler, it may not work properly in the Safari browser on the mobile device. | ||
* @param {string | number | undefined} chatId | ||
* @param {string | undefined} message - Message to enter in the input | ||
*/ | ||
export declare function openChat(chatId?: string | number, message?: string): void; | ||
export interface EventProperty { | ||
[key: string]: string | number | boolean | null; | ||
} | ||
interface CallbackUser { | ||
alert: number; | ||
avatarUrl: string; | ||
id: string; | ||
language: string; | ||
memberId: string; | ||
name?: string; | ||
profile?: Profile | null; | ||
tags?: string[] | null; | ||
unread: number; | ||
unsubscribeEmail: boolean; | ||
unsubscribeTexting: boolean; | ||
/** | ||
* - Track an event. | ||
* - If you track a new event that has never been created, the event is newly created. | ||
* - It takes a few minutes to a few hours to see the event at the desk. | ||
* @param {string} eventName - The name of the event. Max 30 characters are allowed. | ||
* @param {EventProperty | undefined} eventProperty - The property of the event. | ||
* @see https://developers.channel.io/docs/event | ||
*/ | ||
export declare function track(eventName: string, eventProperty?: EventProperty): void; | ||
/** | ||
* Register a callback invoked when the messenger is shown. | ||
* @param {Function} callback | ||
*/ | ||
export declare function onShowMessenger(callback: () => void): void; | ||
/** | ||
* Register a callback invoked when the messenger is hidden. | ||
* @param {Function} callback | ||
*/ | ||
export declare function onHideMessenger(callback: () => void): void; | ||
/** | ||
* @param {number} unread - unread is the number of all unread notifications the user has not read. It includes the number of alert. It is displayed as a red dot on the channel button. | ||
* @param {number} alert - alert is the number of important notifications that the user has not read. It is displayed as a number on the channel button. | ||
* @see https://developers.channel.io/docs/web-customization | ||
*/ | ||
export type BadgeChangedCallback = (unread: number, alert: number) => void; | ||
/** | ||
* Register a callback invoked when the count of messages that the user has not yet read. | ||
* @param {BadgeChangedCallback} callback | ||
* @see https://developers.channel.io/docs/glossary#channel-button | ||
* @see https://developers.channel.io/docs/web-customization | ||
*/ | ||
export declare function onBadgeChanged(callback: BadgeChangedCallback): void; | ||
/** | ||
* Register a callback invoked when a chat is created. | ||
* @param {Function} callback | ||
*/ | ||
export declare function onChatCreated(callback: () => void): void; | ||
export interface FollowUpProfile { | ||
/** The name of a user. */ | ||
name?: string | null; | ||
/** The mobile number of a user. It follows E.164 format. */ | ||
mobileNumber?: string | null; | ||
/** The email of a user. */ | ||
email?: string | null; | ||
} | ||
interface UpdateUserInfo { | ||
export type FollowUpChangedCallback = (profile: FollowUpProfile) => void; | ||
/** | ||
* Register a callback invoked when the user changes the user’s profile. | ||
* @param {FollowUpChangedCallback} callback - The callback invoked when the user changes the user’s profile. It receives the profile object as the argument. | ||
*/ | ||
export declare function onFollowUpChanged(callback: FollowUpChangedCallback): void; | ||
export type UrlClickedCallback = (url: string) => void; | ||
/** | ||
* - Register a callback invoked when the user clicks a link. | ||
* - The links that the user can click include the following list. | ||
* - Link button/text in marketing pop-up | ||
* - Link button/text sent by manager in chat | ||
* @param {UrlClickedCallback} callback - The callback invoked when the user clicks a link. It receives the URL of the link as the argument. | ||
*/ | ||
export declare function onUrlClicked(callback: UrlClickedCallback): void; | ||
/** | ||
* - Clear all callbacks registered by following APIs. | ||
* - onShowMessenger | ||
* - onHideMessenger | ||
* - onBadgeChanged | ||
* - onChatCreated | ||
* - onFollowUpChanged | ||
* - onUrlClicked | ||
*/ | ||
export declare function clearCallbacks(): void; | ||
export interface UpdateUserInfo { | ||
/** | ||
* - If language is ‘ko’ or ‘ja’, UI text inside ChannelTalk changes with that language. | ||
* - Otherwise, UI text is set with English. | ||
*/ | ||
language?: string; | ||
/** | ||
* - If you pass null, the whole profile is initialized. | ||
* - If you pass null to the specific field inside profile object, that specific field is initialized. | ||
* - An empty object is not allowed. | ||
* - The name of the field must follow Camel Case. | ||
* - If you pass mobileNumber, it must follow e.164 format. | ||
*/ | ||
profile?: Profile | null; | ||
/** Among the fields inside profileOnce object, only the fields with no existing value are added. */ | ||
profileOnce?: Profile; | ||
/** | ||
* - Max 10 tags are allowed. | ||
* - If you pass null, tags are initialized. | ||
* - An empty array([]) is not allowed. | ||
*/ | ||
tags?: string[] | null; | ||
/** | ||
* - Set whether the user subscribes to the marketing email. | ||
* - Terminates subscription if the value is true. | ||
*/ | ||
unsubscribeEmail?: boolean; | ||
/** | ||
* - Set whether the user subscribes to the marketing SMS. | ||
* - Terminates subscription if the value is true. | ||
*/ | ||
unsubscribeTexting?: boolean; | ||
} | ||
interface Profile { | ||
[key: string]: string | number | boolean | null; | ||
} | ||
interface FollowUpProfile { | ||
name?: string | null; | ||
mobileNumber?: string | null; | ||
email?: string | null; | ||
} | ||
interface EventProperty { | ||
[key: string]: string | number | boolean | null; | ||
} | ||
type Appearance = 'light' | 'dark' | 'system' | null; | ||
declare function init(): void; | ||
declare function boot(option: BootOption, callback?: Callback): void; | ||
declare function shutdown(): void; | ||
declare function showMessenger(): void; | ||
declare function hideMessenger(): void; | ||
declare function openChat(chatId?: string | number, message?: string): void; | ||
declare function track(eventName: string, eventProperty?: EventProperty): void; | ||
declare function onShowMessenger(callback: () => void): void; | ||
declare function onHideMessenger(callback: () => void): void; | ||
declare function onBadgeChanged(callback: (unread: number, alert: number) => void): void; | ||
declare function onChatCreated(callback: () => void): void; | ||
declare function onFollowUpChanged(callback: (profile: FollowUpProfile) => void): void; | ||
declare function onUrlClicked(callback: (url: string) => void): void; | ||
declare function clearCallbacks(): void; | ||
declare function updateUser(userInfo: UpdateUserInfo, callback?: Callback): void; | ||
declare function addTags(tags: string[], callback?: Callback): void; | ||
declare function removeTags(tags: string[], callback?: Callback): void; | ||
declare function setPage(page: string): void; | ||
declare function resetPage(): void; | ||
declare function showChannelButton(): void; | ||
declare function hideChannelButton(): void; | ||
declare function setAppearance(appearance: Appearance): void; | ||
declare const _default: { | ||
init: typeof init; | ||
boot: typeof boot; | ||
shutdown: typeof shutdown; | ||
showMessenger: typeof showMessenger; | ||
hideMessenger: typeof hideMessenger; | ||
openChat: typeof openChat; | ||
track: typeof track; | ||
onShowMessenger: typeof onShowMessenger; | ||
onHideMessenger: typeof onHideMessenger; | ||
onBadgeChanged: typeof onBadgeChanged; | ||
onChatCreated: typeof onChatCreated; | ||
onFollowUpChanged: typeof onFollowUpChanged; | ||
onUrlClicked: typeof onUrlClicked; | ||
clearCallbacks: typeof clearCallbacks; | ||
updateUser: typeof updateUser; | ||
addTags: typeof addTags; | ||
removeTags: typeof removeTags; | ||
setPage: typeof setPage; | ||
resetPage: typeof resetPage; | ||
showChannelButton: typeof showChannelButton; | ||
hideChannelButton: typeof hideChannelButton; | ||
setAppearance: typeof setAppearance; | ||
}; | ||
export default _default; | ||
/** | ||
* Update user’s information. | ||
* @param {UpdateUserInfo} userInfo - Object with user’s information. | ||
* @param {Callback} callback - When it fails, the callback passes an error object at the first argument, null at the second argument. When it succeeds, the callback passes null at the first argument, an user object at the second argument. | ||
* @see https://developers.channel.io/docs/web-user-object | ||
*/ | ||
export declare function updateUser(userInfo: UpdateUserInfo, callback?: Callback): void; | ||
/** | ||
* Add a user’s tags. | ||
* @param {string[]} tags - If the same tag exists, only one tag is added. Max 10 tags allowed. Always lowercase. | ||
* @param {Callback} callback - If it fails, the callback passes an error object at the first argument, null at the second argument. If it succeeds, the callback passes null at the first argument, a user object at the second argument. | ||
* @see https://developers.channel.io/docs/web-user-object | ||
*/ | ||
export declare function addTags(tags: string[], callback?: Callback): void; | ||
/** | ||
* Remove a user’s tags. | ||
* @param {string[]} tags - If the corresponding tag don’t exist, that tag is ignored. null or an empty array([]) not allowed. | ||
* @param {Callback} callback - If fails, the callback passes an error object at the first argument, null at the second argument. If succeeds, the callback passes null at the first argument, a user object at the second argument. | ||
* @see https://developers.channel.io/docs/web-user-object | ||
*/ | ||
export declare function removeTags(tags: string[], callback?: Callback): void; | ||
/** | ||
* - Set page. | ||
* - Page can be used instead of canonical URL. | ||
* @param {string} page - The page value to change. Don’t pass null or undefined to page. To reset the page, use resetPage. | ||
* @see https://developers.channel.io/docs/page | ||
* @see https://developers.channel.io/docs/canonical-url | ||
*/ | ||
export declare function setPage(page: string): void; | ||
/** | ||
* - Reset the page value set by setPage. | ||
* - If you use resetPage, the canonical URL is used as the page value. | ||
* @see https://developers.channel.io/docs/page | ||
* @see https://developers.channel.io/docs/canonical-url | ||
*/ | ||
export declare function resetPage(): void; | ||
/** | ||
* - Show the channel button. | ||
* - After boot, channel button shows without showChannelButton. | ||
* - Only when you set hideChannelButtonOnBoot to true or call hideChannelButton, you should manually execute showChannelButton. | ||
* @see https://developers.channel.io/docs/glossary#channel-button | ||
*/ | ||
export declare function showChannelButton(): void; | ||
/** | ||
* Hide the channel button. | ||
* @see https://developers.channel.io/docs/glossary#channel-button | ||
*/ | ||
export declare function hideChannelButton(): void; | ||
/** | ||
* Set the appearance of the theme. | ||
* @param {Appearance} appearance | ||
*/ | ||
export declare function setAppearance(appearance: Appearance): void; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function init() { | ||
exports.setAppearance = exports.hideChannelButton = exports.showChannelButton = exports.resetPage = exports.setPage = exports.removeTags = exports.addTags = exports.updateUser = exports.clearCallbacks = exports.onUrlClicked = exports.onFollowUpChanged = exports.onChatCreated = exports.onBadgeChanged = exports.onHideMessenger = exports.onShowMessenger = exports.track = exports.openChat = exports.hideMessenger = exports.showMessenger = exports.shutdown = exports.boot = exports.loadScript = void 0; | ||
/** | ||
* Load the Channel SDK script. | ||
*/ | ||
function loadScript() { | ||
(function () { var w = window; if (w.ChannelIO) { | ||
@@ -18,2 +22,12 @@ return w.console.error("ChannelIO script included twice."); | ||
} | ||
exports.loadScript = loadScript; | ||
/** | ||
* - Initialize for the SDK. | ||
* - Channel button shows up, and features like marketing pop-up are ready to operate. | ||
* @param {BootOption} option - A boot option to initialize SDK. | ||
* @param {Callback | undefined} callback - Callback called after boot. When boot fails, the callback passes an error object at the first argument, null at the second argunent. When boot succeeds, the callback passes null at the first argument, a user object at the second argument. | ||
* @see https://developers.channel.io/docs/glossary#boot | ||
* @see https://developers.channel.io/docs/web-boot-option | ||
* @see https://developers.channel.io/docs/web-user-object | ||
*/ | ||
function boot(option, callback) { | ||
@@ -23,2 +37,6 @@ var _a; | ||
} | ||
exports.boot = boot; | ||
/** | ||
* Stop all operations of the SDK and initialize internal data. | ||
*/ | ||
function shutdown() { | ||
@@ -28,2 +46,7 @@ var _a; | ||
} | ||
exports.shutdown = shutdown; | ||
/** | ||
* Show the messenger. | ||
* @see https://developers.channel.io/docs/glossary#messenger | ||
*/ | ||
function showMessenger() { | ||
@@ -33,2 +56,7 @@ var _a; | ||
} | ||
exports.showMessenger = showMessenger; | ||
/** | ||
* Hide the messenger. | ||
* @see https://developers.channel.io/docs/glossary#messenger | ||
*/ | ||
function hideMessenger() { | ||
@@ -38,2 +66,11 @@ var _a; | ||
} | ||
exports.hideMessenger = hideMessenger; | ||
/** | ||
* - Open a chat. | ||
* - A new chat is opened if you pass an empty value to chatId. In this case, if you pass a message, the message is entered in the input. If the support bot is active, the support bot runs. | ||
* - The chat is opened if the chat with the given chatId exists. In this case, a message is ignored. The lounge is opened if the chat doesn't exist. | ||
* - If you use openChat outside of the click event handler, it may not work properly in the Safari browser on the mobile device. | ||
* @param {string | number | undefined} chatId | ||
* @param {string | undefined} message - Message to enter in the input | ||
*/ | ||
function openChat(chatId, message) { | ||
@@ -43,2 +80,11 @@ var _a; | ||
} | ||
exports.openChat = openChat; | ||
/** | ||
* - Track an event. | ||
* - If you track a new event that has never been created, the event is newly created. | ||
* - It takes a few minutes to a few hours to see the event at the desk. | ||
* @param {string} eventName - The name of the event. Max 30 characters are allowed. | ||
* @param {EventProperty | undefined} eventProperty - The property of the event. | ||
* @see https://developers.channel.io/docs/event | ||
*/ | ||
function track(eventName, eventProperty) { | ||
@@ -48,2 +94,7 @@ var _a; | ||
} | ||
exports.track = track; | ||
/** | ||
* Register a callback invoked when the messenger is shown. | ||
* @param {Function} callback | ||
*/ | ||
function onShowMessenger(callback) { | ||
@@ -53,2 +104,7 @@ var _a; | ||
} | ||
exports.onShowMessenger = onShowMessenger; | ||
/** | ||
* Register a callback invoked when the messenger is hidden. | ||
* @param {Function} callback | ||
*/ | ||
function onHideMessenger(callback) { | ||
@@ -58,2 +114,9 @@ var _a; | ||
} | ||
exports.onHideMessenger = onHideMessenger; | ||
/** | ||
* Register a callback invoked when the count of messages that the user has not yet read. | ||
* @param {BadgeChangedCallback} callback | ||
* @see https://developers.channel.io/docs/glossary#channel-button | ||
* @see https://developers.channel.io/docs/web-customization | ||
*/ | ||
function onBadgeChanged(callback) { | ||
@@ -63,2 +126,7 @@ var _a; | ||
} | ||
exports.onBadgeChanged = onBadgeChanged; | ||
/** | ||
* Register a callback invoked when a chat is created. | ||
* @param {Function} callback | ||
*/ | ||
function onChatCreated(callback) { | ||
@@ -68,2 +136,7 @@ var _a; | ||
} | ||
exports.onChatCreated = onChatCreated; | ||
/** | ||
* Register a callback invoked when the user changes the user’s profile. | ||
* @param {FollowUpChangedCallback} callback - The callback invoked when the user changes the user’s profile. It receives the profile object as the argument. | ||
*/ | ||
function onFollowUpChanged(callback) { | ||
@@ -73,2 +146,10 @@ var _a; | ||
} | ||
exports.onFollowUpChanged = onFollowUpChanged; | ||
/** | ||
* - Register a callback invoked when the user clicks a link. | ||
* - The links that the user can click include the following list. | ||
* - Link button/text in marketing pop-up | ||
* - Link button/text sent by manager in chat | ||
* @param {UrlClickedCallback} callback - The callback invoked when the user clicks a link. It receives the URL of the link as the argument. | ||
*/ | ||
function onUrlClicked(callback) { | ||
@@ -78,2 +159,12 @@ var _a; | ||
} | ||
exports.onUrlClicked = onUrlClicked; | ||
/** | ||
* - Clear all callbacks registered by following APIs. | ||
* - onShowMessenger | ||
* - onHideMessenger | ||
* - onBadgeChanged | ||
* - onChatCreated | ||
* - onFollowUpChanged | ||
* - onUrlClicked | ||
*/ | ||
function clearCallbacks() { | ||
@@ -83,2 +174,9 @@ var _a; | ||
} | ||
exports.clearCallbacks = clearCallbacks; | ||
/** | ||
* Update user’s information. | ||
* @param {UpdateUserInfo} userInfo - Object with user’s information. | ||
* @param {Callback} callback - When it fails, the callback passes an error object at the first argument, null at the second argument. When it succeeds, the callback passes null at the first argument, an user object at the second argument. | ||
* @see https://developers.channel.io/docs/web-user-object | ||
*/ | ||
function updateUser(userInfo, callback) { | ||
@@ -88,2 +186,9 @@ var _a; | ||
} | ||
exports.updateUser = updateUser; | ||
/** | ||
* Add a user’s tags. | ||
* @param {string[]} tags - If the same tag exists, only one tag is added. Max 10 tags allowed. Always lowercase. | ||
* @param {Callback} callback - If it fails, the callback passes an error object at the first argument, null at the second argument. If it succeeds, the callback passes null at the first argument, a user object at the second argument. | ||
* @see https://developers.channel.io/docs/web-user-object | ||
*/ | ||
function addTags(tags, callback) { | ||
@@ -93,2 +198,9 @@ var _a; | ||
} | ||
exports.addTags = addTags; | ||
/** | ||
* Remove a user’s tags. | ||
* @param {string[]} tags - If the corresponding tag don’t exist, that tag is ignored. null or an empty array([]) not allowed. | ||
* @param {Callback} callback - If fails, the callback passes an error object at the first argument, null at the second argument. If succeeds, the callback passes null at the first argument, a user object at the second argument. | ||
* @see https://developers.channel.io/docs/web-user-object | ||
*/ | ||
function removeTags(tags, callback) { | ||
@@ -98,2 +210,10 @@ var _a; | ||
} | ||
exports.removeTags = removeTags; | ||
/** | ||
* - Set page. | ||
* - Page can be used instead of canonical URL. | ||
* @param {string} page - The page value to change. Don’t pass null or undefined to page. To reset the page, use resetPage. | ||
* @see https://developers.channel.io/docs/page | ||
* @see https://developers.channel.io/docs/canonical-url | ||
*/ | ||
function setPage(page) { | ||
@@ -103,2 +223,9 @@ var _a; | ||
} | ||
exports.setPage = setPage; | ||
/** | ||
* - Reset the page value set by setPage. | ||
* - If you use resetPage, the canonical URL is used as the page value. | ||
* @see https://developers.channel.io/docs/page | ||
* @see https://developers.channel.io/docs/canonical-url | ||
*/ | ||
function resetPage() { | ||
@@ -108,2 +235,9 @@ var _a; | ||
} | ||
exports.resetPage = resetPage; | ||
/** | ||
* - Show the channel button. | ||
* - After boot, channel button shows without showChannelButton. | ||
* - Only when you set hideChannelButtonOnBoot to true or call hideChannelButton, you should manually execute showChannelButton. | ||
* @see https://developers.channel.io/docs/glossary#channel-button | ||
*/ | ||
function showChannelButton() { | ||
@@ -113,2 +247,7 @@ var _a; | ||
} | ||
exports.showChannelButton = showChannelButton; | ||
/** | ||
* Hide the channel button. | ||
* @see https://developers.channel.io/docs/glossary#channel-button | ||
*/ | ||
function hideChannelButton() { | ||
@@ -118,2 +257,7 @@ var _a; | ||
} | ||
exports.hideChannelButton = hideChannelButton; | ||
/** | ||
* Set the appearance of the theme. | ||
* @param {Appearance} appearance | ||
*/ | ||
function setAppearance(appearance) { | ||
@@ -123,25 +267,2 @@ var _a; | ||
} | ||
exports.default = { | ||
init, | ||
boot, | ||
shutdown, | ||
showMessenger, | ||
hideMessenger, | ||
openChat, | ||
track, | ||
onShowMessenger, | ||
onHideMessenger, | ||
onBadgeChanged, | ||
onChatCreated, | ||
onFollowUpChanged, | ||
onUrlClicked, | ||
clearCallbacks, | ||
updateUser, | ||
addTags, | ||
removeTags, | ||
setPage, | ||
resetPage, | ||
showChannelButton, | ||
hideChannelButton, | ||
setAppearance, | ||
}; | ||
exports.setAppearance = setAppearance; |
{ | ||
"name": "@channel.io/channel-web-sdk-loader", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Channel Web SDK Loader for web", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"sideEffects": false, | ||
"scripts": { | ||
"prepublishOnly": "tsc -d", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"commit": "git-cz" | ||
"commit": "git-cz", | ||
"build:typedoc": "typedoc src/index.ts" | ||
}, | ||
"files": [ | ||
"dist", | ||
"README.md" | ||
], | ||
"repository": { | ||
@@ -28,2 +34,5 @@ "type": "git", | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"author": "Channel Corp.", | ||
@@ -38,2 +47,3 @@ "license": "Apache-2.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"typedoc": "^0.25.1", | ||
"typescript": "^5.2.2" | ||
@@ -40,0 +50,0 @@ }, |
# channel-web-sdk-loader | ||
> Channel Web SDK Loader | ||
> Official Channel Web SDK Loader | ||
## Documentation | ||
- [API Reference](https://developers.channel.io/docs/web-channelio) | ||
## Links | ||
- [Official SDK Docs](https://developers.channel.io/docs/web-channelio) | ||
- [TypeDoc](https://channel-io.github.io/channel-web-sdk-loader/) | ||
@@ -14,18 +15,20 @@ ## Install | ||
Import ChannelService | ||
### Step1: Import ChannelService | ||
```typescript | ||
import ChannelService from '@channel-io/channel-web-sdk-loader'; | ||
import * as ChannelService from '@channel-io/channel-web-sdk-loader'; | ||
``` | ||
Initialize Channel SDK (load channel web sdk) | ||
### Step2: Load Channel Web SDK | ||
```typescript | ||
ChannelService.init() | ||
ChannelService.loadScript() | ||
``` | ||
Boot Channel SDK | ||
### Step3: Initialize Channel Web SDK | ||
```typescript | ||
ChannelService.boot() | ||
ChannelService.boot({ | ||
pluginKey: 'YOUR_PLUGIN_KEY' | ||
}) | ||
``` | ||
## Example | ||
## API References | ||
- [TypeDoc](https://channel-io.github.io/channel-web-sdk-loader/) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
618
33
39868
4
5
1