@botpress/webchat 0.2.3 → 0.3.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/README.md +31 -0
- package/dist/components/Composer.d.ts +4 -5
- package/dist/components/Composer.js +13 -23
- package/dist/components/Container.d.ts +1 -1
- package/dist/components/Container.js +1 -6
- package/dist/components/ConversationList.d.ts +1 -1
- package/dist/components/ConversationList.js +5 -46
- package/dist/components/Header.d.ts +1 -3
- package/dist/components/Header.js +17 -64
- package/dist/components/VoiceRecorder.js +6 -2
- package/dist/components/common/{Avatar.d.ts → Avatar/index.d.ts} +0 -0
- package/dist/components/common/Avatar/index.js +13 -0
- package/dist/components/common/{BotInfo.d.ts → BotInfo/index.d.ts} +3 -3
- package/dist/components/common/BotInfo/index.js +102 -0
- package/dist/components/common/ConfirmDialog/index.d.ts +11 -0
- package/dist/components/common/ConfirmDialog/index.js +78 -0
- package/dist/components/common/Dialog/index.d.ts +17 -0
- package/dist/components/common/Dialog/index.js +57 -0
- package/dist/components/common/ToolTip/index.d.ts +10 -0
- package/dist/components/common/ToolTip/index.js +163 -0
- package/dist/components/common/ToolTip/utils.d.ts +15 -0
- package/dist/components/common/ToolTip/utils.js +78 -0
- package/dist/components/messages/InlineFeedback.d.ts +2 -1
- package/dist/components/messages/Message.js +2 -25
- package/dist/components/messages/MessageGroup.d.ts +1 -13
- package/dist/components/messages/MessageGroup.js +6 -40
- package/dist/components/messages/MessageList.d.ts +1 -1
- package/dist/components/messages/MessageList.js +8 -31
- package/dist/core/api.d.ts +4 -18
- package/dist/core/api.js +25 -150
- package/dist/core/constants.d.ts +4 -32
- package/dist/core/constants.js +18 -32
- package/dist/core/socket.d.ts +1 -12
- package/dist/core/socket.js +7 -73
- package/dist/{components/Stylesheet.d.ts → icons/Cancel.d.ts} +2 -2
- package/dist/icons/Cancel.js +10 -0
- package/dist/icons/Microphone.d.ts +5 -0
- package/dist/icons/Microphone.js +12 -0
- package/dist/index.d.ts +2 -8
- package/dist/index.js +9 -29
- package/dist/main.d.ts +2 -2
- package/dist/main.js +100 -168
- package/dist/store/composer.js +3 -6
- package/dist/store/index.d.ts +8 -18
- package/dist/store/index.js +98 -136
- package/dist/store/view.d.ts +3 -6
- package/dist/store/view.js +6 -23
- package/dist/translations/index.d.ts +3 -1
- package/dist/translations/index.js +44 -4
- package/dist/typings.d.ts +121 -71
- package/dist/utils/analytics.d.ts +5 -0
- package/dist/utils/analytics.js +37 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +27 -0
- package/dist/utils/storage.d.ts +16 -0
- package/dist/utils/storage.js +129 -0
- package/package.json +4 -3
- package/dist/components/ContextMenu.d.ts +0 -2
- package/dist/components/ContextMenu.js +0 -33
- package/dist/components/OverridableComponent.d.ts +0 -24
- package/dist/components/OverridableComponent.js +0 -50
- package/dist/components/Stylesheet.js +0 -7
- package/dist/components/common/Avatar.js +0 -29
- package/dist/components/common/BotInfo.js +0 -110
- package/dist/icons/CloseChat.d.ts +0 -6
- package/dist/icons/CloseChat.js +0 -9
- package/dist/icons/Send.d.ts +0 -6
- package/dist/icons/Send.js +0 -8
- package/dist/utils.d.ts +0 -8
- package/dist/utils.js +0 -111
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const mobx_react_1 = require("mobx-react");
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
class OverridableComponent extends react_1.default.Component {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.state = {
|
|
12
|
-
components: undefined
|
|
13
|
-
};
|
|
14
|
-
this.resolveComponents = () => {
|
|
15
|
-
var _a, _b;
|
|
16
|
-
return (_b = (_a = this.props.overrides) === null || _a === void 0 ? void 0 : _a[this.props.name]) === null || _b === void 0 ? void 0 : _b.map(({ module, component }) => {
|
|
17
|
-
var _a;
|
|
18
|
-
return ({
|
|
19
|
-
key: `${module}:${component}`,
|
|
20
|
-
element: (_a = window.botpress[module]) === null || _a === void 0 ? void 0 : _a[component]
|
|
21
|
-
});
|
|
22
|
-
}).filter((x) => x.element);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
componentDidMount() {
|
|
26
|
-
this.loadComponents();
|
|
27
|
-
}
|
|
28
|
-
componentDidUpdate(prevProps) {
|
|
29
|
-
if (prevProps.overrides !== this.props.overrides) {
|
|
30
|
-
this.loadComponents();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
componentDidCatch(error, info) {
|
|
34
|
-
console.error(`Error in overridable component ${this.props.name}. Loading original component.`, error, info);
|
|
35
|
-
this.setState({ components: [{ key: 'original', element: this.props.original }] });
|
|
36
|
-
}
|
|
37
|
-
loadComponents() {
|
|
38
|
-
this.setState({ components: this.resolveComponents() || [{ key: 'original', element: this.props.original }] });
|
|
39
|
-
}
|
|
40
|
-
render() {
|
|
41
|
-
const { components } = this.state;
|
|
42
|
-
return components
|
|
43
|
-
? components.map(({ element: Element, key }) => Element && react_1.default.createElement(Element, Object.assign({ key: key }, this.props)))
|
|
44
|
-
: null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
48
|
-
store,
|
|
49
|
-
overrides: store.config.overrides
|
|
50
|
-
}))(OverridableComponent);
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
exports.default = ({ href }) => react_1.default.createElement("link", { rel: "stylesheet", type: "text/css", href: href });
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const React = __importStar(require("react"));
|
|
23
|
-
const Avatar = ({ name, avatarUrl, height, width }) => {
|
|
24
|
-
return (React.createElement("div", { className: 'bpw-bot-avatar' },
|
|
25
|
-
avatarUrl && React.createElement("img", { height: height, width: width, src: avatarUrl }),
|
|
26
|
-
!avatarUrl && (React.createElement("svg", { width: width, height: width },
|
|
27
|
-
React.createElement("text", { textAnchor: 'middle', x: '50%', y: '50%', dy: '0.35em', fill: '#ffffff', fontSize: 15 }, name && name[0])))));
|
|
28
|
-
};
|
|
29
|
-
exports.default = Avatar;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
35
|
-
const mobx_react_1 = require("mobx-react");
|
|
36
|
-
const React = __importStar(require("react"));
|
|
37
|
-
const react_intl_1 = require("react-intl");
|
|
38
|
-
const Email_1 = __importDefault(require("../../icons/Email"));
|
|
39
|
-
const Phone_1 = __importDefault(require("../../icons/Phone"));
|
|
40
|
-
const Website_1 = __importDefault(require("../../icons/Website"));
|
|
41
|
-
const utils_1 = require("../../utils");
|
|
42
|
-
const Avatar_1 = __importDefault(require("./Avatar"));
|
|
43
|
-
const CoverPicture = ({ botInfo }) => (React.createElement("div", { className: 'bpw-botinfo-cover-picture-wrapper' },
|
|
44
|
-
React.createElement("img", { className: 'bpw-botinfo-cover-picture', src: (botInfo.details && botInfo.details.coverPictureUrl) ||
|
|
45
|
-
`https://via.placeholder.com/400x175?text=${botInfo.name}` })));
|
|
46
|
-
class BotInfoPage extends React.Component {
|
|
47
|
-
constructor() {
|
|
48
|
-
super(...arguments);
|
|
49
|
-
this.changeLanguage = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const lang = e.target.value;
|
|
51
|
-
yield this.props.updatePreferredLanguage(lang);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
componentDidMount() {
|
|
55
|
-
var _a;
|
|
56
|
-
(_a = this.btnEl) === null || _a === void 0 ? void 0 : _a.focus();
|
|
57
|
-
}
|
|
58
|
-
renderDescription(text) {
|
|
59
|
-
const html = (0, utils_1.renderUnsafeHTML)(text, this.props.escapeHTML);
|
|
60
|
-
return React.createElement("div", { className: 'bpw-botinfo-description', dangerouslySetInnerHTML: { __html: html } });
|
|
61
|
-
}
|
|
62
|
-
render() {
|
|
63
|
-
const { botInfo, botName, avatarUrl } = this.props;
|
|
64
|
-
const onDismiss = this.props.isConversationStarted ? this.props.toggleBotInfo : this.props.startConversation;
|
|
65
|
-
return (React.createElement("div", { className: (0, classnames_1.default)('bpw-botinfo-container', {
|
|
66
|
-
'bpw-rtl': this.props.rtl
|
|
67
|
-
}) },
|
|
68
|
-
React.createElement(CoverPicture, { botInfo: botInfo }),
|
|
69
|
-
React.createElement("div", { className: 'bpw-botinfo-summary' },
|
|
70
|
-
React.createElement(Avatar_1.default, { name: botName, avatarUrl: avatarUrl, height: 64, width: 64 }),
|
|
71
|
-
React.createElement("h3", null, botName),
|
|
72
|
-
this.renderDescription(botInfo.description)),
|
|
73
|
-
botInfo.details && (React.createElement(React.Fragment, null,
|
|
74
|
-
React.createElement("div", { className: 'bpw-botinfo-links' },
|
|
75
|
-
botInfo.details.phoneNumber && (React.createElement("div", { className: 'bpw-botinfo-link' },
|
|
76
|
-
React.createElement("i", null,
|
|
77
|
-
React.createElement(Phone_1.default, null)),
|
|
78
|
-
React.createElement("a", { target: '_blank', href: `tel:${botInfo.details.phoneNumber}` }, botInfo.details.phoneNumber))),
|
|
79
|
-
botInfo.details.website && (React.createElement("div", { className: 'bpw-botinfo-link' },
|
|
80
|
-
React.createElement("i", null,
|
|
81
|
-
React.createElement(Website_1.default, null)),
|
|
82
|
-
React.createElement("a", { target: '_blank', href: botInfo.details.website }, botInfo.details.website))),
|
|
83
|
-
botInfo.details.emailAddress && (React.createElement("div", { className: 'bpw-botinfo-link' },
|
|
84
|
-
React.createElement("i", null,
|
|
85
|
-
React.createElement(Email_1.default, null)),
|
|
86
|
-
React.createElement("a", { target: '_blank', href: `mailto:${botInfo.details.emailAddress}` }, botInfo.details.emailAddress)))),
|
|
87
|
-
botInfo.details.termsConditions && (React.createElement("div", { className: 'bpw-botinfo-terms' },
|
|
88
|
-
React.createElement("a", { target: '_blank', href: botInfo.details.termsConditions },
|
|
89
|
-
React.createElement(react_intl_1.FormattedMessage, { id: 'botInfo.termsAndConditions' })))),
|
|
90
|
-
botInfo.details.privacyPolicy && (React.createElement("div", { className: 'bpw-botinfo-terms' },
|
|
91
|
-
React.createElement("a", { target: '_blank', href: botInfo.details.privacyPolicy },
|
|
92
|
-
React.createElement(react_intl_1.FormattedMessage, { id: 'botInfo.privacyPolicy' })))))),
|
|
93
|
-
botInfo.languages.length > 1 && (React.createElement("div", { className: 'bpw-botinfo-preferred-language' },
|
|
94
|
-
React.createElement(react_intl_1.FormattedMessage, { id: 'botInfo.preferredLanguage' }),
|
|
95
|
-
React.createElement("select", { value: this.props.preferredLanguage, onChange: this.changeLanguage }, botInfo.languages.map((lang) => (React.createElement("option", { key: lang, value: lang }, lang.toUpperCase())))))),
|
|
96
|
-
React.createElement("button", { tabIndex: 1, ref: (el) => (this.btnEl = el), className: 'bpw-botinfo-start-button', onClick: onDismiss.bind(this, undefined) }, this.props.isConversationStarted ? (React.createElement(react_intl_1.FormattedMessage, { id: 'botInfo.backToConversation' })) : (React.createElement(react_intl_1.FormattedMessage, { id: 'botInfo.startConversation' })))));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.default = (0, mobx_react_1.inject)(({ store }) => ({
|
|
100
|
-
botName: store.botName,
|
|
101
|
-
botInfo: store.botInfo,
|
|
102
|
-
avatarUrl: store.botAvatarUrl,
|
|
103
|
-
startConversation: store.startConversation,
|
|
104
|
-
toggleBotInfo: store.view.toggleBotInfo,
|
|
105
|
-
isConversationStarted: store.isConversationStarted,
|
|
106
|
-
updatePreferredLanguage: store.updatePreferredLanguage,
|
|
107
|
-
preferredLanguage: store.preferredLanguage,
|
|
108
|
-
escapeHTML: store.escapeHTML,
|
|
109
|
-
rtl: store.rtl
|
|
110
|
-
}))((0, react_intl_1.injectIntl)((0, mobx_react_1.observer)(BotInfoPage)));
|
package/dist/icons/CloseChat.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
exports.default = ({ height = 17, width = 17 }) => (react_1.default.createElement("i", null,
|
|
8
|
-
react_1.default.createElement("svg", { width: width, height: height, viewBox: "0 0 17 17", xmlns: "http://www.w3.org/2000/svg" },
|
|
9
|
-
react_1.default.createElement("path", { d: "M16.726 15.402c.365.366.365.96 0 1.324-.178.178-.416.274-.663.274-.246 0-.484-.096-.663-.274L8.323 9.648h.353L1.6 16.726c-.177.178-.416.274-.663.274-.246 0-.484-.096-.663-.274-.365-.365-.365-.958 0-1.324L7.35 8.324v.35L.275 1.6C-.09 1.233-.09.64.274.274c.367-.365.96-.365 1.326 0l7.076 7.078h-.353L15.4.274c.366-.365.96-.365 1.326 0 .365.366.365.958 0 1.324L9.65 8.675v-.35l7.076 7.077z", fill: "#FFF", fillRule: "evenodd" }))));
|
package/dist/icons/Send.d.ts
DELETED
package/dist/icons/Send.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = __importDefault(require("react"));
|
|
7
|
-
exports.default = ({ height = 16, width = 16 }) => (react_1.default.createElement("svg", { width: width, height: height, xmlns: "http://www.w3.org/2000/svg" },
|
|
8
|
-
react_1.default.createElement("path", { d: "M15.398 9.01l-13.87 6.865c-.536.267-1.176.081-1.422-.427A.953.953 0 010 15v-4.838l8.67-2.168L0 5.923V1.001C0 .47.407 0 1.004 0c.169 0 .416.04.567.116L15.403 7.07a1.084 1.084 0 01-.005 1.939z", fill: "#000", fillRule: "evenodd" })));
|
package/dist/utils.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const isIE: boolean;
|
|
2
|
-
export declare const downloadFile: (name: string, blob: Blob) => void;
|
|
3
|
-
export declare const checkLocationOrigin: () => void;
|
|
4
|
-
export declare const initializeAnalytics: () => void;
|
|
5
|
-
export declare const trackMessage: (direction: 'sent' | 'received') => void;
|
|
6
|
-
export declare const trackWebchatState: (state: 'show' | 'hide' | 'toggle') => void;
|
|
7
|
-
export declare const renderUnsafeHTML: (message: string | undefined, escaped: boolean) => string;
|
|
8
|
-
export declare const isRTLLocale: (locale: string | undefined | null) => boolean;
|
package/dist/utils.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isRTLLocale = exports.renderUnsafeHTML = exports.trackWebchatState = exports.trackMessage = exports.initializeAnalytics = exports.checkLocationOrigin = exports.downloadFile = exports.isIE = void 0;
|
|
7
|
-
const react_ga_1 = __importDefault(require("react-ga"));
|
|
8
|
-
const snarkdown_1 = __importDefault(require("snarkdown"));
|
|
9
|
-
exports.isIE = window.navigator.userAgent.match(/MSIE|Trident/) !== null;
|
|
10
|
-
const downloadFile = (name, blob) => {
|
|
11
|
-
const url = window.URL.createObjectURL(blob);
|
|
12
|
-
const link = document.createElement('a');
|
|
13
|
-
link.href = url;
|
|
14
|
-
link.setAttribute('download', name);
|
|
15
|
-
document.body.appendChild(link);
|
|
16
|
-
link.click();
|
|
17
|
-
document.body.removeChild(link);
|
|
18
|
-
window.URL.revokeObjectURL(url);
|
|
19
|
-
};
|
|
20
|
-
exports.downloadFile = downloadFile;
|
|
21
|
-
const checkLocationOrigin = () => {
|
|
22
|
-
if (!window.location.origin) {
|
|
23
|
-
const { protocol, hostname, port } = window.location;
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
window.location.origin = `${protocol}//${hostname}${port && `:${port}`}`;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
exports.checkLocationOrigin = checkLocationOrigin;
|
|
29
|
-
// TODO: does analytics stil work?
|
|
30
|
-
const initializeAnalytics = () => {
|
|
31
|
-
if (window.SEND_USAGE_STATS) {
|
|
32
|
-
try {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
react_ga_1.default.initialize('UA-90044826-2', {
|
|
35
|
-
gaOptions: {
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
userId: window.UUID
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
react_ga_1.default.pageview(window.location.pathname + window.location.search);
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
console.error('Error init analytics', err);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
exports.initializeAnalytics = initializeAnalytics;
|
|
49
|
-
const trackMessage = (direction) => {
|
|
50
|
-
if (window.SEND_USAGE_STATS) {
|
|
51
|
-
try {
|
|
52
|
-
react_ga_1.default.event({ category: 'Interactions', action: `message ${direction}` });
|
|
53
|
-
}
|
|
54
|
-
finally {
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
exports.trackMessage = trackMessage;
|
|
59
|
-
const trackWebchatState = (state) => {
|
|
60
|
-
if (window.SEND_USAGE_STATS) {
|
|
61
|
-
try {
|
|
62
|
-
react_ga_1.default.event({ category: 'Display', action: state });
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
exports.trackWebchatState = trackWebchatState;
|
|
69
|
-
const renderUnsafeHTML = (message = '', escaped) => {
|
|
70
|
-
if (escaped) {
|
|
71
|
-
message = message.replace(/</g, '<').replace(/>/g, '>');
|
|
72
|
-
}
|
|
73
|
-
const html = (0, snarkdown_1.default)(message);
|
|
74
|
-
return html.replace(/<a href/gi, '<a target="_blank" href');
|
|
75
|
-
};
|
|
76
|
-
exports.renderUnsafeHTML = renderUnsafeHTML;
|
|
77
|
-
const rtlLocales = [
|
|
78
|
-
'ae' /* Avestan */,
|
|
79
|
-
'ar' /* 'العربية', Arabic */,
|
|
80
|
-
'arc' /* Aramaic */,
|
|
81
|
-
'bcc' /* 'بلوچی مکرانی', Southern Balochi */,
|
|
82
|
-
'bqi' /* 'بختياري', Bakthiari */,
|
|
83
|
-
'ckb' /* 'Soranî / کوردی', Sorani */,
|
|
84
|
-
'dv' /* Dhivehi */,
|
|
85
|
-
'fa' /* 'فارسی', Persian */,
|
|
86
|
-
'glk' /* 'گیلکی', Gilaki */,
|
|
87
|
-
'he' /* 'עברית', Hebrew */,
|
|
88
|
-
'ku' /* 'Kurdî / كوردی', Kurdish */,
|
|
89
|
-
'mzn' /* 'مازِرونی', Mazanderani */,
|
|
90
|
-
'nqo' /* N'Ko */,
|
|
91
|
-
'pnb' /* 'پنجابی', Western Punjabi */,
|
|
92
|
-
'ps' /* 'پښتو', Pashto, */,
|
|
93
|
-
'sd' /* 'سنڌي', Sindhi */,
|
|
94
|
-
'ug' /* 'Uyghurche / ئۇيغۇرچە', Uyghur */,
|
|
95
|
-
'ur' /* 'اردو', Urdu */,
|
|
96
|
-
'yi' /* 'ייִדיש', Yiddish */
|
|
97
|
-
];
|
|
98
|
-
// 'en-US' becomes ['en', '-us'] 'en' becomes ['en']
|
|
99
|
-
const localeRegex = /^([a-zA-Z]*)([_\-a-zA-Z]*)$/;
|
|
100
|
-
const isRTLLocale = (locale) => {
|
|
101
|
-
if (!locale) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
locale = locale.toLowerCase();
|
|
105
|
-
const matches = localeRegex.exec(locale);
|
|
106
|
-
if (!matches) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return rtlLocales.includes(matches[1]);
|
|
110
|
-
};
|
|
111
|
-
exports.isRTLLocale = isRTLLocale;
|