@upscopeio/sdk 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +145 -0
- package/index.js +33 -0
- package/package.json +7 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export type SubmitRating = {
|
|
2
|
+
userSessionRating?: number;
|
|
3
|
+
userAgentRating?: number;
|
|
4
|
+
userAgentFeedback?: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type CobrowsingSdkConfiguration = {
|
|
8
|
+
jsConfiguration?: boolean;
|
|
9
|
+
uniqueId?: null | string;
|
|
10
|
+
identities?: null | string | string[];
|
|
11
|
+
tags?: null | string | string[];
|
|
12
|
+
integrationIds?: null | string | string[];
|
|
13
|
+
agentPrompt?: string;
|
|
14
|
+
callName?: string;
|
|
15
|
+
|
|
16
|
+
// Automatic
|
|
17
|
+
version: string;
|
|
18
|
+
apiKey: string;
|
|
19
|
+
beta: boolean;
|
|
20
|
+
region: string | null;
|
|
21
|
+
readonly regionWhitelist: string[] | null;
|
|
22
|
+
dataEndpoint: string;
|
|
23
|
+
pageviewsEndpoint: string;
|
|
24
|
+
phoneEndpoint: string;
|
|
25
|
+
javascriptEndpoint: string;
|
|
26
|
+
storageImplementation: null | Storage;
|
|
27
|
+
proxyRedirectEndpoint: string;
|
|
28
|
+
requireAuthorizationForSession: boolean;
|
|
29
|
+
integrateWithLivechat: boolean;
|
|
30
|
+
liveChatRewrite: boolean;
|
|
31
|
+
grabIdentityFromLivechat: boolean;
|
|
32
|
+
showUpscopeLink: boolean;
|
|
33
|
+
cursorColor: string;
|
|
34
|
+
enlargeCursor: boolean;
|
|
35
|
+
showTerminateButton: boolean;
|
|
36
|
+
useFingerprinting: boolean;
|
|
37
|
+
autoconnect: boolean;
|
|
38
|
+
trackConsole: boolean;
|
|
39
|
+
allowRemoteConsole: boolean;
|
|
40
|
+
allowRemoteClick: boolean;
|
|
41
|
+
allowRemoteScroll: boolean;
|
|
42
|
+
allowRemoteType: boolean;
|
|
43
|
+
allowAgentRedirect: boolean;
|
|
44
|
+
rewriteExternalLinks: boolean;
|
|
45
|
+
collectHistory: boolean;
|
|
46
|
+
consoleAllowed: boolean;
|
|
47
|
+
drawingsTtlMs: number;
|
|
48
|
+
enableLookupCodeOnKey: boolean;
|
|
49
|
+
lookupCodeKey: number;
|
|
50
|
+
lookupCodeKeyRepetitions: number;
|
|
51
|
+
lookupCodeKeyTitle: string;
|
|
52
|
+
lookupCodeKeyMessage: string;
|
|
53
|
+
lookupCodeElement: null | HTMLElement | string;
|
|
54
|
+
injectLookupCodeButton: boolean;
|
|
55
|
+
lookupCodeButtonPages: string[];
|
|
56
|
+
lookupCodeButtonStyle: string;
|
|
57
|
+
disconnectAfterSeconds: number;
|
|
58
|
+
proxyAssets: string[];
|
|
59
|
+
maskedElements: string[];
|
|
60
|
+
domChangesDelay: number;
|
|
61
|
+
ignoreBrowserSupport: boolean;
|
|
62
|
+
enableCanvases: boolean;
|
|
63
|
+
customCallController: null | ((callback: (accepted: boolean) => void) => void);
|
|
64
|
+
callPromptText: string;
|
|
65
|
+
callRingtone: string;
|
|
66
|
+
authorizationPromptTitle: string;
|
|
67
|
+
authorizationPromptMessage: string;
|
|
68
|
+
endOfScreenshareMessage: null | string;
|
|
69
|
+
callWaitMessage: string;
|
|
70
|
+
translationsYes: string;
|
|
71
|
+
translationsNo: string;
|
|
72
|
+
translationsOk: string;
|
|
73
|
+
translationsStopSession: string;
|
|
74
|
+
agentRequestButtonStyle: string;
|
|
75
|
+
agentRequestButtonTitle: string;
|
|
76
|
+
agentRequestButtonSubtitle: string;
|
|
77
|
+
agentRequestButtonRequestingTitle: string;
|
|
78
|
+
agentRequestButtonRequestingSubtitle: string;
|
|
79
|
+
agentRequestResultTitle: string;
|
|
80
|
+
agentRequestNotAvailableText: string;
|
|
81
|
+
agentRequestAcceptedText: string;
|
|
82
|
+
showAgentRequestButton: "always" | "when_available" | "never"; // One of: always / when_available / never
|
|
83
|
+
agentRequestButtonPages: string[];
|
|
84
|
+
callPopupFailedTitle: string;
|
|
85
|
+
callPopupFailedMessage: string;
|
|
86
|
+
unavailableAgentRequestRedirectImmediately: boolean;
|
|
87
|
+
unavailableAgentRequestRedirectTo: null | string;
|
|
88
|
+
fromProxy: boolean;
|
|
89
|
+
sfdcFieldLabel: string;
|
|
90
|
+
sfdcFieldId: string;
|
|
91
|
+
baseProxyUrl: string;
|
|
92
|
+
proxyDomain: string;
|
|
93
|
+
needsProxy: (url: string) => boolean;
|
|
94
|
+
onSessionRequest: (cb: (accepted: boolean) => void, requestingAgent: string | null) => void;
|
|
95
|
+
onSessionStart: () => void;
|
|
96
|
+
onSessionEnd: () => void;
|
|
97
|
+
onWaitingForCall: () => void;
|
|
98
|
+
onSessionContinue: () => void;
|
|
99
|
+
onConnection: null | (() => void);
|
|
100
|
+
maskElementMiddleware: (element: HTMLElement) => boolean;
|
|
101
|
+
noRemoteElements: string[];
|
|
102
|
+
allowRemoteMiddleware: (element: HTMLElement) => boolean;
|
|
103
|
+
styleSheetContentFromRules: (stylesheet: HTMLLinkElement | HTMLStyleElement) => boolean;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type Instruction =
|
|
107
|
+
| ["init", Partial<CobrowsingSdkConfiguration>]
|
|
108
|
+
| ["reset"]
|
|
109
|
+
| ["connect"]
|
|
110
|
+
| ["cancelRequestAgent"]
|
|
111
|
+
| ["getShortId", (shortId: string) => void]
|
|
112
|
+
| ["getUserId", (shortId: string) => void] // Legacy version of getShortId
|
|
113
|
+
| ["getLookupCode", (code: string) => void]
|
|
114
|
+
| ["getWatchLink", (link: string) => void]
|
|
115
|
+
| ["logEvent", 'success' | 'error' | 'info' | 'warn' | 'contact', string]
|
|
116
|
+
| ["newPageview"]
|
|
117
|
+
| ["on", ...string[], (event: any) => void]
|
|
118
|
+
| ["requestAgent"]
|
|
119
|
+
| ["reset", boolean]
|
|
120
|
+
| ["redirect", string]
|
|
121
|
+
| ["saveHistory"]
|
|
122
|
+
| ["stopSession"]
|
|
123
|
+
| ["submitRating", SubmitRating]
|
|
124
|
+
| ["updateConnection", Partial<CobrowsingSdkConfiguration>];
|
|
125
|
+
|
|
126
|
+
export type Upscope = {
|
|
127
|
+
_config?: CobrowsingSdkConfiguration;
|
|
128
|
+
__defaultConfiguration?: CobrowsingSdkConfiguration;
|
|
129
|
+
__defaultRegion?: string;
|
|
130
|
+
_version?: string;
|
|
131
|
+
_integrations?: string[];
|
|
132
|
+
q: Instruction[];
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
declare global {
|
|
136
|
+
interface Window {
|
|
137
|
+
Upscope: Upscope;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare global {
|
|
142
|
+
function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
|
|
143
|
+
function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
|
|
144
|
+
}
|
|
145
|
+
export = Upscope;
|
package/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function loadSDK(apiKey) {
|
|
2
|
+
const i = function (...args) {
|
|
3
|
+
i.q.push(args);
|
|
4
|
+
};
|
|
5
|
+
i.q = [];
|
|
6
|
+
// The real Upscope implementation is loaded below
|
|
7
|
+
window.Upscope = i;
|
|
8
|
+
const s = document.createElement("script");
|
|
9
|
+
s.type = "text/javascript";
|
|
10
|
+
s.async = true;
|
|
11
|
+
s.src = `https://code.upscope.io/${apiKey}.js`;
|
|
12
|
+
const x = document.getElementsByTagName("script")[0];
|
|
13
|
+
x.parentNode?.insertBefore(s, x);
|
|
14
|
+
}
|
|
15
|
+
const _Upscope = function () {
|
|
16
|
+
const args = arguments;
|
|
17
|
+
if (window.Upscope === _Upscope) {
|
|
18
|
+
// The real Upscope implementation is not loaded yet, so load it
|
|
19
|
+
if (args[0] === "init") {
|
|
20
|
+
const config = args[1];
|
|
21
|
+
if (!config?.apiKey) {
|
|
22
|
+
throw new Error("API key not specified");
|
|
23
|
+
}
|
|
24
|
+
loadSDK(config.apiKey);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
throw new Error("Upscope is not loaded");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return window.Upscope(...args);
|
|
31
|
+
};
|
|
32
|
+
window.Upscope = _Upscope;
|
|
33
|
+
export default _Upscope;
|