@upscopeio/sdk 1.0.5 → 2.2.137

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/README.md ADDED
@@ -0,0 +1 @@
1
+ # Upscope SDK
package/index.d.ts CHANGED
@@ -33,6 +33,7 @@ type CobrowsingSdkConfiguration = {
33
33
  cursorColor: string;
34
34
  enlargeCursor: boolean;
35
35
  showTerminateButton: boolean;
36
+ screenWakeLock: boolean;
36
37
  useFingerprinting: boolean;
37
38
  autoconnect: boolean;
38
39
  trackConsole: boolean;
@@ -83,6 +84,10 @@ type CobrowsingSdkConfiguration = {
83
84
  agentRequestButtonPages: string[];
84
85
  callPopupFailedTitle: string;
85
86
  callPopupFailedMessage: string;
87
+ callPopupNoInputTitle: string;
88
+ callPopupNoInputMessage: string;
89
+ callPopupNoOutputTitle: string;
90
+ callPopupNoOutputMessage: string;
86
91
  callAudioAuthorizationFailedTitle: string;
87
92
  callAudioAuthorizationFailedMessage: string;
88
93
  unavailableAgentRequestRedirectImmediately: boolean;
@@ -105,6 +110,23 @@ type CobrowsingSdkConfiguration = {
105
110
  styleSheetContentFromRules: (stylesheet: HTMLLinkElement | HTMLStyleElement) => boolean;
106
111
  };
107
112
 
113
+ type SDKEvents = {
114
+ connection: undefined;
115
+ waitingForCall: undefined;
116
+ sessionStart: undefined;
117
+ callStart: undefined;
118
+ callAccepted: undefined;
119
+ agentRequestUpdate: ["pending" | "unavailable" | "canceled" | "accepted"];
120
+ newObserver: [string];
121
+ observerGone: [string];
122
+ agentsAvailable: undefined;
123
+ sessionContinue: undefined;
124
+ sessionEnd: undefined;
125
+ callEnd: undefined;
126
+ connectionReset: undefined;
127
+ sessionRequest: undefined;
128
+ };
129
+
108
130
  type Instruction =
109
131
  | ["init", Partial<CobrowsingSdkConfiguration>]
110
132
  | ["reset"]
@@ -116,32 +138,22 @@ type Instruction =
116
138
  | ["getWatchLink", (link: string) => void]
117
139
  | ["logEvent", "success" | "error" | "info" | "warn" | "contact", string]
118
140
  | ["newPageview"]
119
- | ["on", ...string[], (event: any) => void]
141
+ | ["on", ...(keyof SDKEvents)[], (event: any) => void]
120
142
  | ["requestAgent"]
121
143
  | ["reset", boolean]
122
144
  | ["redirect", string]
123
145
  | ["saveHistory"]
124
146
  | ["stopSession"]
125
- | ["submitRating", SubmitRating]
147
+ | [
148
+ "submitRating",
149
+ {
150
+ userSessionRating?: number;
151
+ userAgentRating?: number;
152
+ userAgentFeedback?: string;
153
+ },
154
+ ]
126
155
  | ["updateConnection", Partial<CobrowsingSdkConfiguration>];
127
156
 
128
- type Upscope = {
129
- (...args: Instruction): void;
130
- _config?: CobrowsingSdkConfiguration;
131
- __defaultConfiguration?: CobrowsingSdkConfiguration;
132
- __defaultRegion?: string;
133
- _version?: string;
134
- _integrations?: string[];
135
- q: Instruction[];
136
- };
137
-
138
- declare global {
139
- interface Window {
140
- Upscope: Upscope;
141
- }
142
-
143
- function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
144
- function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
145
- }
157
+ type Upscope = (...instruction: Instruction) => void;
146
158
 
147
- export {CobrowsingSdkConfiguration, Instruction, Upscope};
159
+ export default function Upscope(...instruction: Instruction): void;
package/index.js ADDED
@@ -0,0 +1,71 @@
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function _iterableToArray(iter) {
10
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
+ }
12
+ function _nonIterableSpread() {
13
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
+ }
15
+ function _toConsumableArray(arr) {
16
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
17
+ }
18
+ function _unsupportedIterableToArray(o, minLen) {
19
+ if (!o) return;
20
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
21
+ var n = Object.prototype.toString.call(o).slice(8, -1);
22
+ if (n === "Object" && o.constructor) n = o.constructor.name;
23
+ if (n === "Map" || n === "Set") return Array.from(n);
24
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
+ }
26
+ var loaded = false;
27
+ function loadSDK(apiKey) {
28
+ var _x_parentNode;
29
+ if (typeof window.Upscope !== "undefined") {
30
+ loaded = true;
31
+ return;
32
+ }
33
+ var i = function i1() {
34
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
35
+ args[_key] = arguments[_key];
36
+ }
37
+ i.q.push(args);
38
+ };
39
+ i.q = [];
40
+ // The real Upscope implementation is loaded below
41
+ window.Upscope = i;
42
+ var s = document.createElement("script");
43
+ s.type = "text/javascript";
44
+ s.async = true;
45
+ s.src = "https://code.upscope.io/".concat(apiKey, ".js");
46
+ var x = document.getElementsByTagName("script")[0];
47
+ (_x_parentNode = x.parentNode) === null || _x_parentNode === void 0 ? void 0 : _x_parentNode.insertBefore(s, x);
48
+ loaded = true;
49
+ }
50
+ var _Upscope = function _Upscope() {
51
+ for(var _len = arguments.length, instruction = new Array(_len), _key = 0; _key < _len; _key++){
52
+ instruction[_key] = arguments[_key];
53
+ }
54
+ var _window;
55
+ if (!loaded) {
56
+ if (instruction[0] === "init") {
57
+ var config = instruction[1];
58
+ if (!(config === null || config === void 0 ? void 0 : config.apiKey)) {
59
+ throw new Error("API key not specified");
60
+ }
61
+ loadSDK(config.apiKey);
62
+ } else {
63
+ throw new Error("Upscope is not loaded");
64
+ }
65
+ }
66
+ return (_window = window).Upscope.apply(_window, _toConsumableArray(instruction));
67
+ };
68
+ export default _Upscope;
69
+
70
+
71
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,SAAS,KAAK;AAClB,SAAS,QAAQ,MAAM,EAAE;QAgBrB;IAfA,IAAI,OAAO,OAAO,OAAO,KAAK,aAAa;QACvC,SAAS,IAAI;QACb;IACJ,CAAC;IACD,IAAM,IAAI,SAAJ,KAAuB;QAAT,IAAA,IAAA,OAAA,UAAA,QAAA,AAAG,OAAH,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA,OAAA;YAAG,KAAH,QAAA,SAAA,CAAA,KAAO;QAAD;QACtB,EAAE,CAAC,CAAC,IAAI,CAAC;IACb;IACA,EAAE,CAAC,GAAG,EAAE;IACR,kDAAkD;IAClD,OAAO,OAAO,GAAG;IACjB,IAAM,IAAI,SAAS,aAAa,CAAC;IACjC,EAAE,IAAI,GAAG;IACT,EAAE,KAAK,GAAG,IAAI;IACd,EAAE,GAAG,GAAG,AAAC,2BAAiC,OAAP,QAAO;IAC1C,IAAM,IAAI,SAAS,oBAAoB,CAAC,SAAS,CAAC,EAAE;IACpD,CAAA,gBAAA,EAAE,UAAU,cAAZ,2BAAA,KAAA,IAAA,cAAc,aAAa,GAAG;IAC9B,SAAS,IAAI;AACjB;AACA,IAAM,WAAW,SAAX,WAAqC;IAAhB,IAAA,IAAA,OAAA,UAAA,QAAA,AAAG,cAAH,UAAA,OAAA,OAAA,GAAA,OAAA,MAAA,OAAA;QAAG,YAAH,QAAA,SAAA,CAAA,KAAc;IAAD;QAa7B;IAZP,IAAI,CAAC,QAAQ;QACT,IAAI,WAAW,CAAC,EAAE,KAAK,QAAQ;YAC3B,IAAM,SAAS,WAAW,CAAC,EAAE;YAC7B,IAAI,CAAC,CAAA,mBAAA,oBAAA,KAAA,IAAA,OAAQ,MAAK,AAAC,GAAE;gBACjB,MAAM,IAAI,MAAM,yBAAyB;YAC7C,CAAC;YACD,QAAQ,OAAO,MAAM;QACzB,OACK;YACD,MAAM,IAAI,MAAM,yBAAyB;QAC7C,CAAC;IACL,CAAC;IACD,OAAO,CAAA,UAAA,QAAO,OAAO,CAAd,MAAA,SAAe,mBAAG;AAC7B;AACA,eAAe,SAAS","file":"index.js","sourcesContent":["let loaded = false;\nfunction loadSDK(apiKey) {\n if (typeof window.Upscope !== \"undefined\") {\n loaded = true;\n return;\n }\n const i = function (...args) {\n i.q.push(args);\n };\n i.q = [];\n // The real Upscope implementation is loaded below\n window.Upscope = i;\n const s = document.createElement(\"script\");\n s.type = \"text/javascript\";\n s.async = true;\n s.src = `https://code.upscope.io/${apiKey}.js`;\n const x = document.getElementsByTagName(\"script\")[0];\n x.parentNode?.insertBefore(s, x);\n loaded = true;\n}\nconst _Upscope = function (...instruction) {\n if (!loaded) {\n if (instruction[0] === \"init\") {\n const config = instruction[1];\n if (!config?.apiKey) {\n throw new Error(\"API key not specified\");\n }\n loadSDK(config.apiKey);\n }\n else {\n throw new Error(\"Upscope is not loaded\");\n }\n }\n return window.Upscope(...instruction);\n};\nexport default _Upscope;\n"]}
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@upscopeio/sdk",
3
- "main": "sdk.js",
3
+ "main": "index.js",
4
4
  "type": "module",
5
- "types": "index.d.ts",
6
5
  "dependencies": {},
7
- "version": "1.0.5"
6
+ "version": "2.2.137"
8
7
  }
package/sdk.js DELETED
@@ -1,33 +0,0 @@
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;