@commversion/libs 0.18.2 → 0.18.4
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/.cspell.json +149 -0
- package/.editorconfig +10 -0
- package/.husky/pre-commit +27 -0
- package/.husky/prepare-commit-msg +13 -0
- package/.markdownlint.json +4 -0
- package/.oxfmtrc.json +6 -0
- package/.oxlintrc.json +34 -0
- package/.release-it.json +9 -3
- package/.vscode/extensions.json +18 -0
- package/.vscode/settings.json +12 -0
- package/README.md +20 -10
- package/dist/lc-attribution.js +1 -0
- package/dist/lc-channel-widgets.js +56 -9
- package/dist/lc-cookie-banner-update-position.js +3 -3
- package/dist/lc-device.js +1 -1
- package/dist/lc-exit-intent-debounced.js +1 -1
- package/dist/lc-exit-intent.js +1 -1
- package/dist/lc-experiment.js +1 -1
- package/dist/lc-form-abandonment.js +1 -1
- package/dist/lc-form-submission.js +1 -1
- package/dist/lc-ga-initialize-event.js +1 -1
- package/dist/lc-ga-tags.js +1 -1
- package/dist/lc-gclid.js +1 -1
- package/dist/lc-geoblocking.js +1 -1
- package/dist/lc-gtm.js +1 -1
- package/dist/lc-input-error.js +1 -1
- package/dist/lc-kill-chat-persist.js +1 -1
- package/dist/lc-kill-chat.js +1 -1
- package/dist/lc-open-on-button-click.js +1 -1
- package/dist/lc-pause-on-url.js +1 -1
- package/dist/lc-powered-by.js +1 -1
- package/dist/lc-show-by-selector.js +1 -1
- package/dist/lc-show-hide.js +1 -1
- package/dist/lc-utm-params.js +1 -1
- package/dist/lc-whatsapp-widget-combo.js +4 -4
- package/dist/lc-whatsapp-widget-only.js +8 -8
- package/dist/schedule-event.js +1 -1
- package/global.d.ts +320 -0
- package/package.json +112 -87
- package/pnpm-workspace.yaml +34 -0
- package/templates/scaffold.ts +86 -0
- package/templates/script/README.md +11 -0
- package/templates/script/package.json +4 -0
- package/templates/script/src/NAME.ts +6 -0
- package/templates/script/src/index.html +57 -0
- package/templates/script/src/main.ts +5 -0
- package/templates/script/tests/NAME.test.ts +9 -0
- package/templates/script/vite.config.ts +19 -0
- package/tsconfig.json +32 -0
- package/vitest.config.ts +18 -0
- package/.prettierignore +0 -4
- package/.prettierrc +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(){"
|
|
2
|
-
/* WA circle
|
|
1
|
+
(function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}function n(n){var r=t(n,`string`);return e(r)==`symbol`?r:r+``}function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var o=`screen and (max-width: 992px) and (pointer: coarse)`,s=()=>window.matchMedia(o).matches?`mobile`:`desktop`,c=`#chat-overlay-container`,l=`#chat-overlay-button`;function u(){if(document.getElementById(`lc-whatsapp-style`))return;let e=document.createElement(`style`);e.id=`lc-whatsapp-style`,e.textContent=`
|
|
2
|
+
/* WA circle — shared base styles */
|
|
3
3
|
.lc-whatsapp-wrapper {
|
|
4
4
|
z-index: 2147483640;
|
|
5
5
|
cursor: pointer;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
justify-content: center;
|
|
13
13
|
align-items: center;
|
|
14
14
|
border-radius: 50%;
|
|
15
|
-
/* Hidden until JS sets the correct size
|
|
15
|
+
/* Hidden until JS sets the correct size — avoids a one-frame wrong-size paint */
|
|
16
16
|
visibility: hidden;
|
|
17
17
|
flex-shrink: 0;
|
|
18
18
|
}
|
|
@@ -27,4 +27,4 @@
|
|
|
27
27
|
height: 50%;
|
|
28
28
|
object-fit: contain;
|
|
29
29
|
}
|
|
30
|
-
`,document.head.appendChild(
|
|
30
|
+
`,document.head.appendChild(e)}function d(e){if(e.style.right&&e.style.right!==`auto`)return`right`;if(e.style.left&&e.style.left!==`auto`)return`left`;let t=window.getComputedStyle(e);return t.right===`auto`?t.left===`auto`?`right`:`left`:`right`}function f(e,t){let n=document.createElement(`img`);n.className=`lc-whatsapp-icon`,n.alt=`WhatsApp`,n.src=`data:image/svg+xml;utf8,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20shape-rendering%3D%22geometricPrecision%22%20text-rendering%3D%22geometricPrecision%22%20image-rendering%3D%22optimizeQuality%22%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20viewBox%3D%220%200%20509%20511.514%22%3E%3Cpath%20fill%3D%22%23fff%22%20d%3D%22M434.762%2074.334C387.553%2026.81%20323.245%200%20256.236%200h-.768C115.795.001%202.121%20113.696%202.121%20253.456l.001.015a253.516%20253.516%200%200033.942%20126.671L0%20511.514l134.373-35.269a253.416%20253.416%200%2000121.052%2030.9h.003.053C395.472%20507.145%20509%20393.616%20509%20253.626c0-67.225-26.742-131.727-74.252-179.237l.014-.055zM255.555%20464.453c-37.753%200-74.861-10.22-107.293-29.479l-7.72-4.602-79.741%2020.889%2021.207-77.726-4.984-7.975c-21.147-33.606-32.415-72.584-32.415-112.308%200-116.371%2094.372-210.743%20210.741-210.743%2056.011%200%20109.758%2022.307%20149.277%2061.98a210.93%20210.93%200%200161.744%20149.095c0%20116.44-94.403%20210.869-210.844%20210.869h.028zm115.583-157.914c-6.363-3.202-37.474-18.472-43.243-20.593-5.769-2.121-10.01-3.202-14.315%203.203-4.305%206.404-16.373%2020.593-20.063%2024.855-3.69%204.263-7.401%204.815-13.679%201.612-6.278-3.202-26.786-9.883-50.899-31.472a192.748%20192.748%200%2001-35.411-43.867c-3.712-6.363-.404-9.777%202.82-12.873%203.224-3.096%206.363-7.381%209.48-11.092a41.58%2041.58%200%20006.357-10.597%2011.678%2011.678%200%2000-.508-11.09c-1.718-3.18-14.444-34.357-19.534-47.06-5.09-12.703-10.37-10.603-14.272-10.901-3.902-.297-7.911-.19-12.089-.19a23.322%2023.322%200%2000-16.964%207.911c-5.707%206.298-22.1%2021.673-22.1%2052.849s22.671%2061.249%2025.852%2065.532c3.182%204.284%2044.663%2068.227%20108.288%2095.649%2015.099%206.489%2026.891%2010.392%2036.053%2013.403a87.504%2087.504%200%200025.216%203.718c4.905%200%209.82-.416%2014.65-1.237%2012.174-1.782%2037.453-15.291%2042.776-30.073s5.303-27.57%203.711-30.093c-1.591-2.524-5.704-4.369-12.088-7.615l-.038.021z%22%2F%3E%3C%2Fsvg%3E`;let r=document.createElement(`div`);return r.className=`lc-whatsapp-wrapper`,r.onclick=function(){let n=t===`mobile`?`https://wa.me/${e}`:`https://web.whatsapp.com/send?phone=${e}`;window.open(n,`_blank`,`noopener,noreferrer`)},r.appendChild(n),{waDiv:r}}function p(e){let t=document.querySelector(c);if(!t)return!1;if(t.querySelector(`.lc-whatsapp-wrapper`))return!0;u();let{waDiv:n}=f(e.number,e.deviceType);n.style.position=`absolute`;let r=d(t);e.deviceType===`mobile`?(n.style.top=`100%`,n.style.marginTop=`-10px`,r===`left`?(n.style.left=`10px`,n.style.right=`auto`):(n.style.right=`10px`,n.style.left=`auto`)):(n.style.top=`50%`,n.style.transform=`translateY(-50%)`,r===`left`?(n.style.left=`100%`,n.style.marginLeft=`8px`,n.style.right=`auto`):(n.style.right=`100%`,n.style.marginRight=`8px`,n.style.left=`auto`));let i=e=>{let t=new ResizeObserver(()=>{let r=Math.round(e.getBoundingClientRect().height);if(r===0)return;let i=Math.min(Math.max(r,40),64);n.style.width=i+`px`,n.style.height=i+`px`,n.classList.add(`lc-wa-ready`),t.disconnect()});t.observe(e)};t.appendChild(n);let a=document.querySelector(l);return a?i(a):h(l,e=>i(e),{interval:300,maxRetries:130}),!0}function m(e){let{deviceType:t}=e,n=document.querySelector(e.chatWidgetSelector);if(!n||(n.style.overflow=`unset`,u(),n.querySelector(`.lc-whatsapp-wrapper`)))return;let r=d(n)===`left`,{waDiv:i}=f(e.number,t);n.appendChild(i);let a=`#chat-widget-minimized`,o=n.querySelector(a)||document.querySelector(a),s=e=>{e&&new ResizeObserver(()=>{let n=Math.round(e.getBoundingClientRect().width);if(n===0){t===`mobile`?i.style.display=`none`:(i.style.width=`40px`,i.style.height=`40px`,i.classList.add(`lc-wa-ready`));return}i.style.display=`flex`;let r=20;n===84&&(r=30),t===`mobile`&&(i.style.bottom=r===30?`-50px`:`-25px`),i.style.width=`${r*2}px`,i.style.height=`${r*2}px`,i.classList.add(`lc-wa-ready`)}).observe(e)};o?s(o):h(a,e=>s(e),{interval:300,maxRetries:130}),e.deviceType===`mobile`?r?(i.style.left=e.mobile.left,i.style.right=`auto`):(i.style.right=e.mobile.right,i.style.left=`auto`):(i.style.bottom=e.desktop.bottom,r?(i.style.right=e.desktop.right,i.style.left=`auto`):(i.style.left=e.desktop.left,i.style.right=`auto`))}function h(e,t,{interval:n=300,maxRetries:r=100}={}){let i=0,a=setInterval(()=>{let n=document.querySelector(e);if(n){clearInterval(a),t(n);return}++i>=r&&clearInterval(a)},n)}var g=!1;window.commversion=window.commversion||{},window.LiveChatWidget.on(`ready`,((e={})=>()=>{let t=e.whatsappConfig||{},n={chatWidgetSelector:t.chatWidgetSelector||`#chat-widget-container`,number:t.number||``,mobile:a(a({},{enabled:!1,left:`8px`,right:`8px`}),t.mobile),desktop:a(a({},{enabled:!1,bottom:`-100px`,left:`-43px`,right:`-43px`}),t.desktop)},r=s(),i=n[r];n.deviceType=r,i!=null&&i.enabled&&(h(c,()=>p(n)),h(n.chatWidgetSelector,()=>m(n)),g||(g=!0,document.addEventListener(`turbolinks:load`,()=>{h(c,()=>p(n)),h(n.chatWidgetSelector,()=>m(n))})))})(window.commversion))})();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
(function(){
|
|
1
|
+
(function(){var e=`screen and (max-width: 992px) and (pointer: coarse)`,t=()=>window.matchMedia(e).matches?`mobile`:`desktop`;function n(e){var t,n,r,i;if(document.getElementById(`wa-widget-style`))return;let a=e.position,o=a.position===`left`?`left`:`right`,s=(t=a[o])==null?0:t,c=(n=e.size)==null?48:n,l=document.createElement(`style`);l.id=`wa-widget-style`,l.textContent=`
|
|
2
2
|
.wa-widget-wrapper {
|
|
3
3
|
position: fixed;
|
|
4
|
-
bottom: ${(
|
|
5
|
-
${
|
|
6
|
-
${
|
|
7
|
-
z-index: ${(
|
|
4
|
+
bottom: ${(r=a.bottom)==null?0:r}px;
|
|
5
|
+
${o}: ${s}px;
|
|
6
|
+
${o===`left`?`right: auto;`:`left: auto;`}
|
|
7
|
+
z-index: ${(i=a.zIndex)==null?9999:i};
|
|
8
8
|
|
|
9
|
-
width: ${
|
|
10
|
-
height: ${
|
|
9
|
+
width: ${c}px;
|
|
10
|
+
height: ${c}px;
|
|
11
11
|
border-radius: 50%;
|
|
12
12
|
background: #25D366;
|
|
13
13
|
|
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
height: 50%;
|
|
25
25
|
object-fit: contain;
|
|
26
26
|
}
|
|
27
|
-
`,document.head.appendChild(
|
|
27
|
+
`,document.head.appendChild(l)}function r(e,r){if(document.querySelector(`.wa-widget-wrapper`))return;let i=document.getElementById(`wa-widget-style`);i&&i.remove(),n(r);let a=document.createElement(`div`);a.className=`wa-widget-wrapper`,a.onclick=()=>{let n=t()===`mobile`?`https://wa.me/${e}`:`https://web.whatsapp.com/send?phone=${e}`;window.open(n,`_blank`,`noopener,noreferrer`)};let o=document.createElement(`img`);o.className=`wa-widget-icon`,o.alt=`WhatsApp`,o.src=`data:image/svg+xml;utf8,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22utf-8%22%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20shape-rendering%3D%22geometricPrecision%22%20text-rendering%3D%22geometricPrecision%22%20image-rendering%3D%22optimizeQuality%22%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20viewBox%3D%220%200%20509%20511.514%22%3E%3Cpath%20fill%3D%22%23fff%22%20d%3D%22M434.762%2074.334C387.553%2026.81%20323.245%200%20256.236%200h-.768C115.795.001%202.121%20113.696%202.121%20253.456l.001.015a253.516%20253.516%200%200033.942%20126.671L0%20511.514l134.373-35.269a253.416%20253.416%200%2000121.052%2030.9h.003.053C395.472%20507.145%20509%20393.616%20509%20253.626c0-67.225-26.742-131.727-74.252-179.237l.014-.055zM255.555%20464.453c-37.753%200-74.861-10.22-107.293-29.479l-7.72-4.602-79.741%2020.889%2021.207-77.726-4.984-7.975c-21.147-33.606-32.415-72.584-32.415-112.308%200-116.371%2094.372-210.743%20210.741-210.743%2056.011%200%20109.758%2022.307%20149.277%2061.98a210.93%20210.93%200%200161.744%20149.095c0%20116.44-94.403%20210.869-210.844%20210.869h.028zm115.583-157.914c-6.363-3.202-37.474-18.472-43.243-20.593-5.769-2.121-10.01-3.202-14.315%203.203-4.305%206.404-16.373%2020.593-20.063%2024.855-3.69%204.263-7.401%204.815-13.679%201.612-6.278-3.202-26.786-9.883-50.899-31.472a192.748%20192.748%200%2001-35.411-43.867c-3.712-6.363-.404-9.777%202.82-12.873%203.224-3.096%206.363-7.381%209.48-11.092a41.58%2041.58%200%20006.357-10.597%2011.678%2011.678%200%2000-.508-11.09c-1.718-3.18-14.444-34.357-19.534-47.06-5.09-12.703-10.37-10.603-14.272-10.901-3.902-.297-7.911-.19-12.089-.19a23.322%2023.322%200%2000-16.964%207.911c-5.707%206.298-22.1%2021.673-22.1%2052.849s22.671%2061.249%2025.852%2065.532c3.182%204.284%2044.663%2068.227%20108.288%2095.649%2015.099%206.489%2026.891%2010.392%2036.053%2013.403a87.504%2087.504%200%200025.216%203.718c4.905%200%209.82-.416%2014.65-1.237%2012.174-1.782%2037.453-15.291%2042.776-30.073s5.303-27.57%203.711-30.093c-1.591-2.524-5.704-4.369-12.088-7.615l-.038.021z%22%2F%3E%3C%2Fsvg%3E`,a.appendChild(o),document.body.appendChild(a)}var i=!1;function a(e={}){let n=e.whatsapp;if(!(n!=null&&n.phone_number))return;let a=n[t()];a!=null&&a.enabled&&a.position&&(r(n.phone_number,a),i||(i=!0,document.addEventListener(`turbolinks:load`,()=>{r(n.phone_number,a)})))}window.commversion=window.commversion||{},a(window.commversion)})();
|
package/dist/schedule-event.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(){var e=()=>{},t=(e,t,n)=>e*1440+t*60+n,n=(n,r)=>n.toReversed().reduce((e,{from:n,to:i,callback:a})=>{let o=t(n[0],n[1],n[2]),s=t(i[0],i[1],i[2]),c=t(r[0],r[1],r[2]);return o<=c&&c<s?a:e},e);function r(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise(function(i,a){var o=e.apply(t,n);function s(e){r(o,i,a,s,c,`next`,e)}function c(e){r(o,i,a,s,c,`throw`,e)}s(void 0)})}}var a=`https://commversion-public-functions.vercel.app/api/time`,o=function(){var e=i(function*(e,t){let r=yield fetch(`${a}?tz=${t}`).then(e=>e.json());yield n(e,[r.day,r.hour,r.minute])()});return function(t,n){return e.apply(this,arguments)}}();window.commversion=window.commversion||{};var{schedule:s,timezone:c}=window.commversion;[s,c].forEach(e=>{if(e===void 0)throw Error(`Invalid configuration`)}),o(s,c)})();
|
package/global.d.ts
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
type AttributionChannel = "whatsapp" | "sms" | "facebook";
|
|
2
|
+
|
|
3
|
+
interface ChannelWidgetConfig {
|
|
4
|
+
readonly type: AttributionChannel;
|
|
5
|
+
readonly number?: string;
|
|
6
|
+
readonly mobile?: { readonly enabled?: boolean };
|
|
7
|
+
readonly desktop?: { readonly enabled?: boolean };
|
|
8
|
+
readonly popover?:
|
|
9
|
+
| boolean
|
|
10
|
+
| {
|
|
11
|
+
readonly enabled?: boolean;
|
|
12
|
+
readonly title?: string;
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
readonly buttonLabel?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ChannelWidgetsConfig {
|
|
19
|
+
readonly chatWidgetSelector?: string;
|
|
20
|
+
readonly channels?: readonly ChannelWidgetConfig[];
|
|
21
|
+
readonly mobile?: { readonly gap?: string; readonly gapBelow?: string };
|
|
22
|
+
readonly desktop?: { readonly gap?: string; readonly gapBelow?: string };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ChannelMessageConfig {
|
|
26
|
+
readonly defaultMessage?: string;
|
|
27
|
+
readonly buttonMessages?: Readonly<Record<string, string>>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface CommversionConfiguration {
|
|
31
|
+
readonly clientId: string;
|
|
32
|
+
readonly attributionUrl?: string;
|
|
33
|
+
readonly exitIntentDebounceMs?: number;
|
|
34
|
+
readonly exitIntentMargin?: number;
|
|
35
|
+
readonly formAbandonmentSelector?: string;
|
|
36
|
+
readonly formAbandonmentDelay?: number;
|
|
37
|
+
readonly formSubmissionSelector?: string;
|
|
38
|
+
readonly channelWidgetsConfig?: ChannelWidgetsConfig;
|
|
39
|
+
readonly whatsappConfig?: ChannelMessageConfig;
|
|
40
|
+
readonly smsConfig?: ChannelMessageConfig;
|
|
41
|
+
readonly facebookConfig?: ChannelMessageConfig;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
namespace LiveChat {
|
|
45
|
+
export type Availability = "online" | "offline";
|
|
46
|
+
|
|
47
|
+
export type Visibility = "maximized" | "minimized" | "hidden";
|
|
48
|
+
|
|
49
|
+
export type CustomerStatus = "queued" | "chatting" | "invited" | "browsing";
|
|
50
|
+
|
|
51
|
+
export type AuthorType = "customer" | "agent";
|
|
52
|
+
|
|
53
|
+
export type NewEventType = "message" | "rich_message" | "file";
|
|
54
|
+
|
|
55
|
+
export type FormSubmittedType = "prechat" | "postchat" | "ticket";
|
|
56
|
+
|
|
57
|
+
export type Rating = "good" | "bad" | "none";
|
|
58
|
+
|
|
59
|
+
export type SessionVariables = Record<string, string>;
|
|
60
|
+
|
|
61
|
+
export interface WidgetState {
|
|
62
|
+
readonly availability: Availability;
|
|
63
|
+
readonly visibility: Visibility;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface CustomerData {
|
|
67
|
+
readonly id: string;
|
|
68
|
+
readonly name: string | null;
|
|
69
|
+
readonly email: string | null;
|
|
70
|
+
readonly isReturning: boolean;
|
|
71
|
+
readonly status: CustomerStatus;
|
|
72
|
+
readonly sessionVariables: SessionVariables;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ChatData {
|
|
76
|
+
readonly chatId: string;
|
|
77
|
+
readonly threadId: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface Author {
|
|
81
|
+
readonly id: string;
|
|
82
|
+
readonly type: AuthorType;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface Greeting {
|
|
86
|
+
readonly id: number;
|
|
87
|
+
readonly uniqueId: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface ReadyData {
|
|
91
|
+
readonly state: WidgetState;
|
|
92
|
+
readonly customerData: CustomerData;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface AvailabilityChangedData {
|
|
96
|
+
readonly availability: Availability;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface VisibilityChangedData {
|
|
100
|
+
readonly visibility: Visibility;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface CustomerStatusChangedData {
|
|
104
|
+
readonly status: CustomerStatus;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface NewEventData {
|
|
108
|
+
readonly timestamp: number;
|
|
109
|
+
readonly type: NewEventType;
|
|
110
|
+
readonly author: Author;
|
|
111
|
+
readonly greeting?: Greeting;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface FormSubmittedData {
|
|
115
|
+
readonly type: FormSubmittedType;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface RichMessageButtonClickedData {
|
|
119
|
+
readonly eventId: string;
|
|
120
|
+
readonly postbackId: string;
|
|
121
|
+
readonly greeting?: Greeting;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface MaximizeOptions {
|
|
125
|
+
readonly messageDraft: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface SalesTrackerData {
|
|
129
|
+
readonly trackerId: string;
|
|
130
|
+
readonly orderPrice?: string;
|
|
131
|
+
readonly orderId?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface Widget {
|
|
135
|
+
on(event: "ready", handler: (data: ReadyData) => void): void;
|
|
136
|
+
on(event: "availability_changed", handler: (data: AvailabilityChangedData) => void): void;
|
|
137
|
+
on(event: "visibility_changed", handler: (data: VisibilityChangedData) => void): void;
|
|
138
|
+
on(event: "customer_status_changed", handler: (data: CustomerStatusChangedData) => void): void;
|
|
139
|
+
on(event: "new_event", handler: (data: NewEventData) => void): void;
|
|
140
|
+
on(event: "form_submitted", handler: (data: FormSubmittedData) => void): void;
|
|
141
|
+
on(event: "rating_submitted", handler: (rating: Rating) => void): void;
|
|
142
|
+
on(event: "greeting_displayed", handler: (greeting: Greeting) => void): void;
|
|
143
|
+
on(event: "greeting_hidden", handler: (greeting: Greeting) => void): void;
|
|
144
|
+
on(
|
|
145
|
+
event: "rich_message_button_clicked",
|
|
146
|
+
handler: (data: RichMessageButtonClickedData) => void,
|
|
147
|
+
): void;
|
|
148
|
+
|
|
149
|
+
once(event: "ready", handler: (data: ReadyData) => void): void;
|
|
150
|
+
once(event: "availability_changed", handler: (data: AvailabilityChangedData) => void): void;
|
|
151
|
+
once(event: "visibility_changed", handler: (data: VisibilityChangedData) => void): void;
|
|
152
|
+
once(
|
|
153
|
+
event: "customer_status_changed",
|
|
154
|
+
handler: (data: CustomerStatusChangedData) => void,
|
|
155
|
+
): void;
|
|
156
|
+
once(event: "new_event", handler: (data: NewEventData) => void): void;
|
|
157
|
+
once(event: "form_submitted", handler: (data: FormSubmittedData) => void): void;
|
|
158
|
+
once(event: "rating_submitted", handler: (rating: Rating) => void): void;
|
|
159
|
+
once(event: "greeting_displayed", handler: (greeting: Greeting) => void): void;
|
|
160
|
+
once(event: "greeting_hidden", handler: (greeting: Greeting) => void): void;
|
|
161
|
+
once(
|
|
162
|
+
event: "rich_message_button_clicked",
|
|
163
|
+
handler: (data: RichMessageButtonClickedData) => void,
|
|
164
|
+
): void;
|
|
165
|
+
|
|
166
|
+
off(event: "ready", handler: (data: ReadyData) => void): void;
|
|
167
|
+
off(event: "availability_changed", handler: (data: AvailabilityChangedData) => void): void;
|
|
168
|
+
off(event: "visibility_changed", handler: (data: VisibilityChangedData) => void): void;
|
|
169
|
+
off(event: "customer_status_changed", handler: (data: CustomerStatusChangedData) => void): void;
|
|
170
|
+
off(event: "new_event", handler: (data: NewEventData) => void): void;
|
|
171
|
+
off(event: "form_submitted", handler: (data: FormSubmittedData) => void): void;
|
|
172
|
+
off(event: "rating_submitted", handler: (rating: Rating) => void): void;
|
|
173
|
+
off(event: "greeting_displayed", handler: (greeting: Greeting) => void): void;
|
|
174
|
+
off(event: "greeting_hidden", handler: (greeting: Greeting) => void): void;
|
|
175
|
+
off(
|
|
176
|
+
event: "rich_message_button_clicked",
|
|
177
|
+
handler: (data: RichMessageButtonClickedData) => void,
|
|
178
|
+
): void;
|
|
179
|
+
|
|
180
|
+
call(method: "maximize", options?: MaximizeOptions): void;
|
|
181
|
+
call(method: "minimize"): void;
|
|
182
|
+
call(method: "hide"): void;
|
|
183
|
+
call(method: "destroy"): void;
|
|
184
|
+
call(method: "hide_greeting"): void;
|
|
185
|
+
call(method: "trigger_sales_tracker", data: SalesTrackerData): void;
|
|
186
|
+
call(method: "set_session_variables", sessionVariables: SessionVariables): void;
|
|
187
|
+
call(method: "update_session_variables", sessionVariables: SessionVariables): void;
|
|
188
|
+
call(method: "set_customer_name", name: string): void;
|
|
189
|
+
call(method: "set_customer_email", email: string): void;
|
|
190
|
+
|
|
191
|
+
get(data: "state"): WidgetState;
|
|
192
|
+
get(data: "customer_data"): CustomerData;
|
|
193
|
+
get(data: "chat_data"): ChatData;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
interface JQuery {}
|
|
198
|
+
|
|
199
|
+
namespace SegmentAnalytics {
|
|
200
|
+
export interface SegmentOpts {
|
|
201
|
+
integrations?: any;
|
|
202
|
+
anonymousId?: string | undefined;
|
|
203
|
+
context?: object | undefined;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface CookieOptions {
|
|
207
|
+
maxage?: number | undefined;
|
|
208
|
+
domain?: string | undefined;
|
|
209
|
+
path?: string | undefined;
|
|
210
|
+
secure?: boolean | undefined;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface MetricsOptions {
|
|
214
|
+
host?: string | undefined;
|
|
215
|
+
sampleRate?: number | undefined;
|
|
216
|
+
flushTimer?: number | undefined;
|
|
217
|
+
maxQueueSize?: number | undefined;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface StoreOptions {
|
|
221
|
+
enabled?: boolean | undefined;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface UserOptions {
|
|
225
|
+
cookie?: { key: string; oldKey: string } | undefined;
|
|
226
|
+
localStorage?: { key: string } | undefined;
|
|
227
|
+
persist?: boolean | undefined;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface GroupOptions {
|
|
231
|
+
cookie?: { key: string } | undefined;
|
|
232
|
+
localStorage?: { key: string } | undefined;
|
|
233
|
+
persist?: boolean | undefined;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface InitOptions {
|
|
237
|
+
cookie?: CookieOptions | undefined;
|
|
238
|
+
metrics?: MetricsOptions | undefined;
|
|
239
|
+
localStorage?: StoreOptions | undefined;
|
|
240
|
+
user?: UserOptions | undefined;
|
|
241
|
+
group?: GroupOptions | undefined;
|
|
242
|
+
integrations?:
|
|
243
|
+
| { All?: boolean | undefined; [integration: string]: boolean | undefined }
|
|
244
|
+
| undefined;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface IntegrationsSettings {
|
|
248
|
+
[key: string]: any;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface AnalyticsJS {
|
|
252
|
+
use(plugin: (analytics: AnalyticsJS) => void): this;
|
|
253
|
+
init(settings?: IntegrationsSettings, options?: InitOptions): this;
|
|
254
|
+
addIntegration(integration: (options: any) => void): this;
|
|
255
|
+
setAnonymousId(id: string): this;
|
|
256
|
+
load(writeKey: string): void;
|
|
257
|
+
load(writeKey: string, options?: SegmentOpts): void;
|
|
258
|
+
identify(userId: string, traits?: Object, options?: SegmentOpts, callback?: () => void): void;
|
|
259
|
+
identify(userId: string, traits: Object, callback?: () => void): void;
|
|
260
|
+
identify(userId: string, callback?: () => void): void;
|
|
261
|
+
identify(traits?: Object, options?: SegmentOpts, callback?: () => void): void;
|
|
262
|
+
identify(traits?: Object, callback?: () => void): void;
|
|
263
|
+
identify(callback: () => void): void;
|
|
264
|
+
track(event: string, properties?: Object, options?: SegmentOpts, callback?: () => void): void;
|
|
265
|
+
track(event: string, properties?: Object, callback?: () => void): void;
|
|
266
|
+
track(event: string, callback?: () => void): void;
|
|
267
|
+
page(
|
|
268
|
+
category?: string,
|
|
269
|
+
name?: string,
|
|
270
|
+
properties?: Object,
|
|
271
|
+
options?: SegmentOpts,
|
|
272
|
+
callback?: () => void,
|
|
273
|
+
): void;
|
|
274
|
+
page(name?: string, properties?: Object, options?: SegmentOpts, callback?: () => void): void;
|
|
275
|
+
page(name?: string, properties?: Object, callback?: () => void): void;
|
|
276
|
+
page(name?: string, callback?: () => void): void;
|
|
277
|
+
page(properties?: Object, options?: SegmentOpts, callback?: () => void): void;
|
|
278
|
+
page(callback?: () => void): void;
|
|
279
|
+
group(groupId: string, traits?: Object, options?: SegmentOpts, callback?: () => void): void;
|
|
280
|
+
group(groupId: string, traits?: Object, callback?: () => void): void;
|
|
281
|
+
group(groupId: string, callback?: () => void): void;
|
|
282
|
+
alias(userId: string, previousId?: string, options?: SegmentOpts, callback?: () => void): void;
|
|
283
|
+
alias(userId: string, previousId?: string, callback?: () => void): void;
|
|
284
|
+
alias(userId: string, callback?: () => void): void;
|
|
285
|
+
alias(userId: string, options?: SegmentOpts, callback?: () => void): void;
|
|
286
|
+
trackLink(
|
|
287
|
+
elements: JQuery | Element[] | Element,
|
|
288
|
+
event: string | { (elm: Element): string },
|
|
289
|
+
properties?: Object | { (elm: Element): Object },
|
|
290
|
+
): void;
|
|
291
|
+
trackForm(
|
|
292
|
+
elements: JQuery | Element[] | Element,
|
|
293
|
+
event: string | { (elm: Element): string },
|
|
294
|
+
properties?: Object | { (elm: Element): Object },
|
|
295
|
+
): void;
|
|
296
|
+
ready(callback: () => void): void;
|
|
297
|
+
reset(): void;
|
|
298
|
+
user(): {
|
|
299
|
+
id(newId?: string | null): string | null | undefined;
|
|
300
|
+
logout(): void;
|
|
301
|
+
reset(): void;
|
|
302
|
+
anonymousId(newId?: string): string;
|
|
303
|
+
traits(newTraits?: Object): void;
|
|
304
|
+
};
|
|
305
|
+
group(): { id(): string; traits(newTraits?: Object): void };
|
|
306
|
+
debug(state?: boolean): void;
|
|
307
|
+
on(
|
|
308
|
+
event: string,
|
|
309
|
+
callback: { (event: string, properties: Object, options: SegmentOpts): void },
|
|
310
|
+
): void;
|
|
311
|
+
timeout(milliseconds: number): void;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
interface Window {
|
|
316
|
+
commversion: CommversionConfiguration;
|
|
317
|
+
readonly LiveChatWidget: LiveChat.Widget;
|
|
318
|
+
readonly gaGlobal?: { vid?: string };
|
|
319
|
+
readonly analytics?: SegmentAnalytics.AnalyticsJS;
|
|
320
|
+
}
|