SDK Functions
Here's a list of all the functions supported by Co-Browsing API's SDK. These can be called with Upscope('FUNCTION_NAME', ...args);.
| Function Name | Arguments | Description |
|---|---|---|
connect | — | Starts the socket connection to the servers. |
customMessage | (message: Record | Sends a custom message to all observers. Observers can listen for these messages using the customMessage event. |
expectDisconnect | ({ returnTimeSeconds?: number; message?: string; title?: string; }) | Call this before redirecting the Visitor to a page without the SDK installed (e.g. an external log in flow) to indicate to the Agent why the Visitor is offline and that they will return shortly. Optionally set returnTimeSeconds to revert to the default "Visitor is not connected anymore" message after a while. |
fullTabEnd | — | Ends full tab sharing. |
fullTabStart | — | Starts full tab sharing, allowing the agent to see the entire browser tab including content outside of the page where the SDK is installed. |
getLookupCode | (callback: function(code: string)) | Returns the lookup code through the callback. |
getPublicLink | ({ agentId: string, agentName: string }, callback: function(publicLink: string)) | Returns a public link for the specified agent through the callback (only for presentation sharing mode). |
getShortId | (callback: function(shortId: string)) | Returns the Visitor's shortId through the callback. |
getWatchLink | (callback: function(link: string)) | Returns the watch link through the callback. |
init | (configuration: Partial | Used to initiate the SDK. This must be the first function called. |
on | (...events: string, callback: function) | Adds a listener for the events provided. |
prefetchAssets | — | Call if you know a Session is about to happen to start prepping for it and make it go live faster. |
registerScreenStream | (stream: MediaStream) | Registers a pre-acquired screen capture stream to be used the next time full tab sharing starts, instead of prompting the Visitor for screen sharing permission. The stream is used once and must contain a live video track. The SDK never stops the stream's tracks: your app keeps ownership and is responsible for stopping them when done. |
registerVideoStream | (stream: MediaStream) | Registers a pre-acquired camera stream to be used the next time the Visitor's camera is turned on during a video call, instead of prompting the Visitor for camera permission. The same rules as registerScreenStream apply: the stream is used once, must contain a live video track, and its tracks are never stopped by the SDK. |
reset | (reopenConnection: boolean) | Used to reset the connection and clear all identity from the Visitor. A new Visitor will be generated with a fresh ID. If reopenConnection is false, the connection will not be automatically re-opened, and the SDK will be in its initial idle state. |
stopRemoteControl | — | Revokes the Agent's remote control of the page during an active Session. The Agent can request control again. |
stopSession | — | Terminates an active Session. |
submitRating | (ratings: { userSessionRating?: 1 | 2 | 3 | 4 | 5, userAgentRating?: 1 | 2 | 3 | 4 | 5, userAgentFeedback?: string }) | Submits a user rating after a Session has ended. |
updateConnection | (updates: {uniqueId?: string, identities?: string[], tags?: string[], integrationIds?: string[], callName?: string, agentPrompt?: string, allowRemoteConsole?: boolean, allowRemoteClick?: boolean, allowRemoteScroll?: boolean, allowRemoteType?: boolean, allowAgentRedirect?: boolean}) | Used to update the identity of the visitor or settings after pageload. |