@diplodoc/client 5.5.3 → 5.5.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.
@@ -3270,6 +3270,10 @@ var Loader = __webpack_require__(83129);
3270
3270
  var es = __webpack_require__(53054);
3271
3271
  // EXTERNAL MODULE: ./node_modules/bem-cn-lite/lib/index.js
3272
3272
  var lib = __webpack_require__(23614);
3273
+ // EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/shared/libs/analytics/react/analytics-provider.js
3274
+ var analytics_provider = __webpack_require__(56701);
3275
+ // EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/shared/libs/analytics/constant.js
3276
+ var constant = __webpack_require__(27039);
3273
3277
  // EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/components/SearchSuggest/AiIcon.js
3274
3278
  var AiIcon = __webpack_require__(78564);
3275
3279
  ;// CONCATENATED MODULE: ./node_modules/@diplodoc/components/build/esm/components/NeuroExpertModal/NeuroExpertModal.css
@@ -3282,32 +3286,54 @@ var AiIcon = __webpack_require__(78564);
3282
3286
 
3283
3287
 
3284
3288
 
3289
+
3285
3290
  var b = (0,lib["default"])("dc-neuro-expert-modal");
3286
3291
  var IFRAME_BASE_URL = "https://expert.yandex.ru/expert/projects";
3292
+ var IFRAME_ORIGIN = "https://expert.yandex.ru";
3293
+ var IFRAME_ACTION_MAP = {
3294
+ "message-sent": "message"
3295
+ };
3287
3296
  var HeaderCaption = () => {
3288
3297
  const { t } = (0,es/* .useTranslation */.Bd)("search-suggest");
3289
3298
  return /* @__PURE__ */ react.createElement("div", { className: b("header-caption") }, /* @__PURE__ */ react.createElement(AiIcon/* .AiIcon */.K, null), /* @__PURE__ */ react.createElement(Text/* .Text */.E, { variant: "subheader-2" }, t("search-suggest_ai-chat")));
3290
3299
  };
3291
3300
  var NeuroExpertModal = ({ open, query, projectId, onClose }) => {
3301
+ const analytics = (0,analytics_provider/* .useAnalytics */.s)();
3292
3302
  const [loaded, setLoaded] = (0,react.useState)(false);
3293
3303
  const iframeRef = (0,react.useRef)(null);
3294
3304
  const iframeSrc = `${IFRAME_BASE_URL}/${projectId}/iframe`;
3305
+ const trackAction = (0,react.useCallback)(
3306
+ (action) => {
3307
+ analytics.track(constant/* .CommonAnalyticsEvent.DOCS_NEUROEXPERT_ACTION */.Q.DOCS_NEUROEXPERT_ACTION, {
3308
+ action,
3309
+ initType: "search"
3310
+ });
3311
+ },
3312
+ [analytics]
3313
+ );
3295
3314
  (0,react.useEffect)(() => {
3296
- if (loaded) {
3297
- return;
3298
- }
3299
3315
  const handleMessage = (event) => {
3300
3316
  var _a, _b;
3301
3317
  if (event.source !== ((_a = iframeRef.current) == null ? void 0 : _a.contentWindow)) {
3302
3318
  return;
3303
3319
  }
3304
- if (((_b = event.data) == null ? void 0 : _b.type) === "chat-mounted") {
3320
+ const type = (_b = event.data) == null ? void 0 : _b.type;
3321
+ if (type === "chat-mounted" && !loaded) {
3305
3322
  setLoaded(true);
3306
3323
  }
3324
+ const mappedAction = IFRAME_ACTION_MAP[type];
3325
+ if (mappedAction) {
3326
+ trackAction(mappedAction);
3327
+ }
3307
3328
  };
3308
3329
  window.addEventListener("message", handleMessage);
3309
3330
  return () => window.removeEventListener("message", handleMessage);
3310
- }, [loaded]);
3331
+ }, [loaded, trackAction]);
3332
+ (0,react.useEffect)(() => {
3333
+ if (open) {
3334
+ trackAction("open");
3335
+ }
3336
+ }, [open, trackAction]);
3311
3337
  (0,react.useEffect)(() => {
3312
3338
  var _a, _b;
3313
3339
  if (!open || !loaded) {
@@ -3315,7 +3341,7 @@ var NeuroExpertModal = ({ open, query, projectId, onClose }) => {
3315
3341
  }
3316
3342
  (_b = (_a = iframeRef.current) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage(
3317
3343
  { type: "send-message", payload: { text: query } },
3318
- "*"
3344
+ IFRAME_ORIGIN
3319
3345
  );
3320
3346
  }, [open, loaded, query]);
3321
3347
  return /* @__PURE__ */ react.createElement(
@@ -9862,6 +9888,7 @@ var CommonAnalyticsEvent = /* @__PURE__ */ ((CommonAnalyticsEvent2) => {
9862
9888
  CommonAnalyticsEvent2["DOCS_WIDESCREEN_MODE_CLICK"] = "DOCS_WIDESCREEN-MODE_CLICK";
9863
9889
  CommonAnalyticsEvent2["DOCS_HIDE_PAGE_NAV_CLICK"] = "DOCS_HIDE-PAGE-NAV_CLICK";
9864
9890
  CommonAnalyticsEvent2["DOCS_FONTSIZE_MODE_CLICK"] = "DOCS_FONTSIZE-MODE_CLICK";
9891
+ CommonAnalyticsEvent2["DOCS_NEUROEXPERT_ACTION"] = "DOCS_NEUROEXPERT_ACTION";
9865
9892
  return CommonAnalyticsEvent2;
9866
9893
  })(CommonAnalyticsEvent || {});
9867
9894