@upscopeio/sdk 2.2.136 → 2.2.138
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 +1 -0
- package/index.d.ts +31 -19
- package/index.js +69 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Upscope SDK
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
type SubmitRating = {
|
|
2
2
|
userSessionRating?: number;
|
|
3
3
|
userAgentRating?: number;
|
|
4
4
|
userAgentFeedback?: string;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
type CobrowsingSdkConfiguration = {
|
|
8
8
|
jsConfiguration?: boolean;
|
|
9
9
|
uniqueId?: null | string;
|
|
10
10
|
identities?: null | string | string[];
|
|
@@ -110,7 +110,24 @@ export type CobrowsingSdkConfiguration = {
|
|
|
110
110
|
styleSheetContentFromRules: (stylesheet: HTMLLinkElement | HTMLStyleElement) => boolean;
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
|
|
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
|
+
|
|
130
|
+
type Instruction =
|
|
114
131
|
| ["init", Partial<CobrowsingSdkConfiguration>]
|
|
115
132
|
| ["reset"]
|
|
116
133
|
| ["connect"]
|
|
@@ -121,27 +138,22 @@ export type Instruction =
|
|
|
121
138
|
| ["getWatchLink", (link: string) => void]
|
|
122
139
|
| ["logEvent", "success" | "error" | "info" | "warn" | "contact", string]
|
|
123
140
|
| ["newPageview"]
|
|
124
|
-
| ["on", ...
|
|
141
|
+
| ["on", ...(keyof SDKEvents)[], (event: any) => void]
|
|
125
142
|
| ["requestAgent"]
|
|
126
143
|
| ["reset", boolean]
|
|
127
144
|
| ["redirect", string]
|
|
128
145
|
| ["saveHistory"]
|
|
129
146
|
| ["stopSession"]
|
|
130
|
-
| [
|
|
147
|
+
| [
|
|
148
|
+
"submitRating",
|
|
149
|
+
{
|
|
150
|
+
userSessionRating?: number;
|
|
151
|
+
userAgentRating?: number;
|
|
152
|
+
userAgentFeedback?: string;
|
|
153
|
+
},
|
|
154
|
+
]
|
|
131
155
|
| ["updateConnection", Partial<CobrowsingSdkConfiguration>];
|
|
132
156
|
|
|
133
|
-
|
|
134
|
-
_config?: CobrowsingSdkConfiguration;
|
|
135
|
-
__defaultConfiguration?: CobrowsingSdkConfiguration;
|
|
136
|
-
__defaultRegion?: string;
|
|
137
|
-
_version?: string;
|
|
138
|
-
_integrations?: string[];
|
|
139
|
-
q: Instruction[];
|
|
140
|
-
};
|
|
157
|
+
type Upscope = (...instruction: Instruction) => void;
|
|
141
158
|
|
|
142
|
-
|
|
143
|
-
interface Window {
|
|
144
|
-
Upscope: Upscope;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
export = Upscope;
|
|
159
|
+
export default function Upscope(...instruction: Instruction): void;
|
package/index.js
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
function _arrayLikeToArray(arr,
|
|
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
|
+
|
|
2
70
|
|
|
3
71
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
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