wineater-bot 1.4.5 → 1.5.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.
@@ -289,59 +289,59 @@ function r(n) {
289
289
  if (e.length === 2)
290
290
  return e.pop().split(";").shift();
291
291
  }
292
- function y(n) {
293
- return Object.keys(n).map((t) => encodeURIComponent(t) + "=" + encodeURIComponent(n[t])).join("&");
294
- }
295
292
  function d(n, t) {
296
- fetch("https://api-eu.mixpanel.com/track", {
293
+ const e = "6f3d90d5b02720f58de3663e3ef675fe", o = "https://api-eu.mixpanel.com/track", i = {
294
+ event: n,
295
+ properties: {
296
+ token: e,
297
+ ...t
298
+ }
299
+ };
300
+ fetch(o, {
297
301
  method: "POST",
298
302
  headers: {
299
- "Content-Type": "application/x-www-form-urlencoded",
300
- Authentication: "6f3d90d5b02720f58de3663e3ef675fe"
303
+ "Content-Type": "application/json"
301
304
  },
302
- body: y({
303
- event: n,
304
- properties: t
305
- })
306
- }).then((a) => {
307
- a.ok || console.error("Mixpanel tracking failed", a);
308
- }).catch((a) => {
309
- console.error("Mixpanel tracking error", a);
305
+ body: JSON.stringify(i)
306
+ }).then((s) => {
307
+ s.ok || console.error("Mixpanel tracking failed", s);
308
+ }).catch((s) => {
309
+ console.error("Mixpanel tracking error", s);
310
310
  });
311
311
  }
312
- function h() {
312
+ function g() {
313
313
  d("Chatbot Opened", { distinct_id: r("chatbotToken") });
314
314
  }
315
- function g() {
315
+ function h() {
316
316
  d("Chatbot Closed", { distinct_id: r("chatbotToken") });
317
317
  }
318
- function w(n) {
318
+ function y(n) {
319
319
  d("Message Sent", { distinct_id: r("chatbotToken"), message_content: n });
320
320
  }
321
- function x(n) {
321
+ function w(n) {
322
322
  d("Message Sent", { distinct_id: r("chatbotToken"), products: n });
323
323
  }
324
- function v(n) {
324
+ function x(n) {
325
325
  d("Product Clicked", { distinct_id: r("chatbotToken"), product_id: n });
326
326
  }
327
327
  function u() {
328
328
  const n = document.getElementById("chat-window"), t = document.getElementById("chat-icon");
329
- n.classList.contains("visible") ? (g(), n.classList.remove("visible"), t.style.display = "flex") : (h(), n.classList.add("visible"), t.style.display = "none");
329
+ n.classList.contains("visible") ? (h(), n.classList.remove("visible"), t.style.display = "flex") : (g(), n.classList.add("visible"), t.style.display = "none");
330
330
  }
331
- function k() {
332
- g(), document.getElementById("chat-window").classList.remove("visible");
331
+ function v() {
332
+ h(), document.getElementById("chat-window").classList.remove("visible");
333
333
  }
334
- function C() {
335
- h(), document.getElementById("chat-window").classList.add("visible");
334
+ function k() {
335
+ g(), document.getElementById("chat-window").classList.add("visible");
336
336
  }
337
337
  document.addEventListener("DOMContentLoaded", () => {
338
338
  setupCloseButton(), setupOutsideClick();
339
339
  });
340
- const E = ["climats", "telckel", "biobio", "weinpoint"], I = "OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";
340
+ const C = ["climats", "telckel", "biobio", "weinpoint"], E = "OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";
341
341
  class m {
342
342
  constructor(t) {
343
343
  var e;
344
- this.baseURL = "https://api.wineater.com/", this.store = E.find((o) => window.location.href.includes(o)), this.token = ((e = window == null ? void 0 : window.wineaterData) == null ? void 0 : e.CLIENT_TOKEN) || I;
344
+ this.baseURL = "https://api.wineater.com/", this.store = C.find((o) => window.location.href.includes(o)), this.token = ((e = window == null ? void 0 : window.wineaterData) == null ? void 0 : e.CLIENT_TOKEN) || E;
345
345
  }
346
346
  async getStoreConfig(t) {
347
347
  console.log(t);
@@ -380,7 +380,7 @@ class m {
380
380
  }
381
381
  }
382
382
  }
383
- class T {
383
+ class I {
384
384
  constructor() {
385
385
  this.api = new m(), this.language = "en", this.translations = {
386
386
  fr: {
@@ -431,10 +431,10 @@ class T {
431
431
  return this.translations[this.language][t] || t;
432
432
  }
433
433
  }
434
- const s = new T();
435
- class B {
434
+ const a = new I();
435
+ class T {
436
436
  constructor() {
437
- this.api = new m(), this.displayFirstMessage(s.translate("welcomeMessage"));
437
+ this.api = new m(), this.displayFirstMessage(a.translate("welcomeMessage"));
438
438
  }
439
439
  initialize() {
440
440
  document.getElementById("send-button").addEventListener("click", () => this.handleUserInput()), document.getElementById("user-input").addEventListener("keypress", (o) => {
@@ -450,11 +450,11 @@ class B {
450
450
  if (e) {
451
451
  this.displayMessage(e, "user"), t.value = "", this.showTypingIndicator();
452
452
  try {
453
- w(e);
453
+ y(e);
454
454
  const o = await this.api.getWineRecommendations(e);
455
455
  this.hideTypingIndicator(), o && o.length ? this.displayResults(o) : this.displayMessage("No results found.", "api");
456
456
  } catch {
457
- this.hideTypingIndicator(), this.displayMessage(s.translate("somethingWentWrong"), "api");
457
+ this.hideTypingIndicator(), this.displayMessage(a.translate("somethingWentWrong"), "api");
458
458
  }
459
459
  }
460
460
  }
@@ -469,35 +469,35 @@ class B {
469
469
  i.textContent = t, i.className = "message " + e, o.appendChild(i), o.scrollTop = o.scrollHeight;
470
470
  }
471
471
  sendAnalytics(t) {
472
- v(t);
472
+ x(t);
473
473
  }
474
474
  displayResults(t) {
475
475
  const e = document.getElementById("message-container");
476
- x(t.map((o) => o.Title)), t.forEach((o) => {
476
+ w(t.map((o) => o.Title)), t.forEach((o) => {
477
477
  const i = document.createElement("div");
478
478
  i.className = "wine-item";
479
- const a = document.createElement("img");
480
- a.src = o.Image, i.appendChild(a);
479
+ const s = document.createElement("img");
480
+ s.src = o.Image, i.appendChild(s);
481
481
  const c = document.createElement("div");
482
482
  c.innerHTML = `
483
483
  <strong>${o.Title}</strong><br>
484
- ${s.translate("price")}: ${o.Price}<br>
485
- ${s.translate("region")}: ${o.Region}<br>
486
- ${s.translate("type")}: ${o.Type}<br>
487
- <a href="${o.Url}" onclick="sendAnalytics(${o.Title})" target="_blank">${s.translate("moreInfo")}</a>
484
+ ${a.translate("price")}: ${o.Price}<br>
485
+ ${a.translate("region")}: ${o.Region}<br>
486
+ ${a.translate("type")}: ${o.Type}<br>
487
+ <a href="${o.Url}" onclick="sendAnalytics(${o.Title})" target="_blank">${a.translate("moreInfo")}</a>
488
488
  `, i.appendChild(c), e.appendChild(i);
489
489
  }), e.scrollTop = e.scrollHeight;
490
490
  }
491
491
  }
492
492
  document.addEventListener("DOMContentLoaded", () => {
493
- window.toggleChatWindow = u, window.closeChatWindow = k, window.openChatWindow = C;
493
+ window.toggleChatWindow = u, window.closeChatWindow = v, window.openChatWindow = k;
494
494
  });
495
- function L() {
495
+ function B() {
496
496
  const n = `
497
497
  <div id="chatbot-container">
498
498
  <div id="chat-icon" onclick="toggleChatWindow()">
499
499
  <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon"> <!-- Update the path to your logo image -->
500
- <span>${s.translate("chatButton")}</span>
500
+ <span>${a.translate("chatButton")}</span>
501
501
  </div>
502
502
 
503
503
  <div id="chat-window" class="hidden">
@@ -514,24 +514,24 @@ function L() {
514
514
  <span></span><span></span><span></span>
515
515
  </div>
516
516
  <div id="input-container">
517
- <input type="text" id="user-input" placeholder="${s.translate("inputPlaceholder")}">
518
- <button id="send-button">${s.translate("sendButton")}</button>
517
+ <input type="text" id="user-input" placeholder="${a.translate("inputPlaceholder")}">
518
+ <button id="send-button">${a.translate("sendButton")}</button>
519
519
  </div>
520
520
  </div>
521
521
  </div>
522
522
  `;
523
523
  document.body.insertAdjacentHTML("beforeend", n);
524
524
  }
525
- function P() {
525
+ function L() {
526
526
  document.getElementById("close-btn").addEventListener("click", u);
527
527
  }
528
- function W() {
528
+ function P() {
529
529
  window.addEventListener("click", function(n) {
530
530
  const t = document.getElementById("chat-window"), e = document.getElementById("chat-icon");
531
531
  !t.contains(n.target) && !e.contains(n.target) && (t.classList.remove("visible"), e.style.display = "flex");
532
532
  });
533
533
  }
534
- function S(n) {
534
+ function W(n) {
535
535
  console.log(n);
536
536
  const t = document.getElementById("chat-icon"), e = document.getElementById("chat-window");
537
537
  t.className = "", e.className = "", n === "right-center" ? (t.classList.add("chat-icon-right-center"), e.classList.add("right-center-aligned")) : t.classList.add("chat-icon-bottom-right");
@@ -540,14 +540,14 @@ var l;
540
540
  if (typeof window < "u") {
541
541
  const n = ((l = window.wineaterData) == null ? void 0 : l.POSITION) || "bottom-right";
542
542
  window.addEventListener("DOMContentLoaded", async () => {
543
- var a;
543
+ var s;
544
544
  const e = ["climats", "telckel", "biobio", "weinpoint"].find((c) => window.location.href.includes(c)) || null;
545
545
  let o;
546
- e && (o = e.charAt(0).toUpperCase() + e.slice(1)), await s.fetchConfig(o || null), L(), P(), W(), S(n), b("chatbotToken", (a = window.wineaterData) == null ? void 0 : a.CLIENT_TOKEN, 365), new B().initialize();
546
+ e && (o = e.charAt(0).toUpperCase() + e.slice(1)), await a.fetchConfig(o || null), B(), L(), P(), W(n), b("chatbotToken", (s = window.wineaterData) == null ? void 0 : s.CLIENT_TOKEN, 365), new T().initialize();
547
547
  });
548
548
  }
549
549
  export {
550
- k as closeChatWindow,
551
- C as openChatWindow,
550
+ v as closeChatWindow,
551
+ k as openChatWindow,
552
552
  u as toggleChatWindow
553
553
  };
@@ -273,17 +273,17 @@
273
273
  .typing-indicator.visible {
274
274
  visibility: visible;
275
275
  height: 50px;
276
- }`,g=document.createElement("style");g.textContent=d,document.head.appendChild(g);function x(n,t,e){let o="";if(e){const i=new Date;i.setTime(i.getTime()+e*24*60*60*1e3),o="; expires="+i.toUTCString()}document.cookie=n+"="+(t||"")+o+"; path=/; secure; samesite=strict"}function c(n){const e=`; ${document.cookie}`.split(`; ${n}=`);if(e.length===2)return e.pop().split(";").shift()}function v(n){return Object.keys(n).map(t=>encodeURIComponent(t)+"="+encodeURIComponent(n[t])).join("&")}function l(n,t){fetch("https://api-eu.mixpanel.com/track",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authentication:"6f3d90d5b02720f58de3663e3ef675fe"},body:v({event:n,properties:t})}).then(s=>{s.ok||console.error("Mixpanel tracking failed",s)}).catch(s=>{console.error("Mixpanel tracking error",s)})}function u(){l("Chatbot Opened",{distinct_id:c("chatbotToken")})}function m(){l("Chatbot Closed",{distinct_id:c("chatbotToken")})}function k(n){l("Message Sent",{distinct_id:c("chatbotToken"),message_content:n})}function C(n){l("Message Sent",{distinct_id:c("chatbotToken"),products:n})}function E(n){l("Product Clicked",{distinct_id:c("chatbotToken"),product_id:n})}function h(){const n=document.getElementById("chat-window"),t=document.getElementById("chat-icon");n.classList.contains("visible")?(m(),n.classList.remove("visible"),t.style.display="flex"):(u(),n.classList.add("visible"),t.style.display="none")}function f(){m(),document.getElementById("chat-window").classList.remove("visible")}function b(){u(),document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const I=["climats","telckel","biobio","weinpoint"],T="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";class y{constructor(t){var e;this.baseURL="https://api.wineater.com/",this.store=I.find(o=>window.location.href.includes(o)),this.token=((e=window==null?void 0:window.wineaterData)==null?void 0:e.CLIENT_TOKEN)||T}async getStoreConfig(t){console.log(t);try{const e=await fetch(`${this.baseURL}stores/store`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:t})});if(!e.ok)throw new Error(`HTTP error! Status: ${e.status}`);return await e.json()}catch(e){throw console.error("Error fetching store configuration:",e),e}}async getWineRecommendations(t){console.log(window.location.href);try{const e=await fetch(`${this.baseURL}dish/recommendations`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:t,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),o=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${o.message||"No additional error information"}`);return o}catch(e){throw console.error("Fetching wine recommendations failed:",e.message),new Error(`Error in getWineRecommendations: ${e.message}`)}}}class B{constructor(){this.api=new y,this.language="en",this.translations={fr:{welcomeMessage:"Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton:"Accorder le vin au dîner",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",price:"Prix",region:"Région",type:"Type",moreInfo:"Plus d'infos"},es:{welcomeMessage:"Mejore su experiencia gastronómica. Solo proporcione los detalles de su plato y obtenga la recomendación de vino ideal. ¿Qué le gustaría comer?",noResultsFound:"No se encontraron resultados.",somethingWentWrong:"Lo sentimos, algo salió mal.",chatButton:"Maridar vino con cena",inputPlaceholder:"ej., Ensalada de atún",sendButton:"Maridar",price:"Precio",region:"Región",type:"Tipo",moreInfo:"Más info"},en:{welcomeMessage:"Enhance your dining experience. Just provide your dish details and get the ideal wine pairing. What would you like to eat?",noResultsFound:"No results found.",somethingWentWrong:"Sorry, something went wrong.",chatButton:"Pair wine with dinner",inputPlaceholder:"e.g., Tuna Salad",sendButton:"Pair",price:"Price",region:"Region",type:"Type",moreInfo:"More info"}}}async fetchConfig(t){if(t){const e=await this.api.getStoreConfig(t);this.language=e.lang}}translate(t){return this.translations[this.language][t]||t}}const a=new B;class L{constructor(){this.api=new y,this.displayFirstMessage(a.translate("welcomeMessage"))}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",o=>{o.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(t,e="api"){const o=document.getElementById("message-container"),i=document.createElement("div");i.className=`message ${e}`,i.textContent=t,o.appendChild(i),o.scrollTop=o.scrollHeight}async handleUserInput(){const t=document.getElementById("user-input"),e=t.value.trim();if(e){this.displayMessage(e,"user"),t.value="",this.showTypingIndicator();try{k(e);const o=await this.api.getWineRecommendations(e);this.hideTypingIndicator(),o&&o.length?this.displayResults(o):this.displayMessage("No results found.","api")}catch{this.hideTypingIndicator(),this.displayMessage(a.translate("somethingWentWrong"),"api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(t,e){const o=document.getElementById("message-container"),i=document.createElement("div");i.textContent=t,i.className="message "+e,o.appendChild(i),o.scrollTop=o.scrollHeight}sendAnalytics(t){E(t)}displayResults(t){const e=document.getElementById("message-container");C(t.map(o=>o.Title)),t.forEach(o=>{const i=document.createElement("div");i.className="wine-item";const s=document.createElement("img");s.src=o.Image,i.appendChild(s);const p=document.createElement("div");p.innerHTML=`
276
+ }`,g=document.createElement("style");g.textContent=d,document.head.appendChild(g);function x(n,t,e){let o="";if(e){const i=new Date;i.setTime(i.getTime()+e*24*60*60*1e3),o="; expires="+i.toUTCString()}document.cookie=n+"="+(t||"")+o+"; path=/; secure; samesite=strict"}function c(n){const e=`; ${document.cookie}`.split(`; ${n}=`);if(e.length===2)return e.pop().split(";").shift()}function l(n,t){const e="6f3d90d5b02720f58de3663e3ef675fe",o="https://api-eu.mixpanel.com/track",i={event:n,properties:{token:e,...t}};fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}).then(a=>{a.ok||console.error("Mixpanel tracking failed",a)}).catch(a=>{console.error("Mixpanel tracking error",a)})}function u(){l("Chatbot Opened",{distinct_id:c("chatbotToken")})}function m(){l("Chatbot Closed",{distinct_id:c("chatbotToken")})}function v(n){l("Message Sent",{distinct_id:c("chatbotToken"),message_content:n})}function k(n){l("Message Sent",{distinct_id:c("chatbotToken"),products:n})}function C(n){l("Product Clicked",{distinct_id:c("chatbotToken"),product_id:n})}function h(){const n=document.getElementById("chat-window"),t=document.getElementById("chat-icon");n.classList.contains("visible")?(m(),n.classList.remove("visible"),t.style.display="flex"):(u(),n.classList.add("visible"),t.style.display="none")}function f(){m(),document.getElementById("chat-window").classList.remove("visible")}function b(){u(),document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const E=["climats","telckel","biobio","weinpoint"],I="OuhXJRleF6sROjsQZPWx1yqjrL6APeJxmHswqyOBWbgIqtXcht3MDadvI9DtOOoL";class y{constructor(t){var e;this.baseURL="https://api.wineater.com/",this.store=E.find(o=>window.location.href.includes(o)),this.token=((e=window==null?void 0:window.wineaterData)==null?void 0:e.CLIENT_TOKEN)||I}async getStoreConfig(t){console.log(t);try{const e=await fetch(`${this.baseURL}stores/store`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({store:t})});if(!e.ok)throw new Error(`HTTP error! Status: ${e.status}`);return await e.json()}catch(e){throw console.error("Error fetching store configuration:",e),e}}async getWineRecommendations(t){console.log(window.location.href);try{const e=await fetch(`${this.baseURL}dish/recommendations`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`},body:JSON.stringify({text:t,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),o=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${o.message||"No additional error information"}`);return o}catch(e){throw console.error("Fetching wine recommendations failed:",e.message),new Error(`Error in getWineRecommendations: ${e.message}`)}}}class T{constructor(){this.api=new y,this.language="en",this.translations={fr:{welcomeMessage:"Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?",noResultsFound:"Aucun résultat trouvé.",somethingWentWrong:"Désolé, quelque chose a mal tourné.",chatButton:"Accorder le vin au dîner",inputPlaceholder:"ex., Salade de thon",sendButton:"Accorder",price:"Prix",region:"Région",type:"Type",moreInfo:"Plus d'infos"},es:{welcomeMessage:"Mejore su experiencia gastronómica. Solo proporcione los detalles de su plato y obtenga la recomendación de vino ideal. ¿Qué le gustaría comer?",noResultsFound:"No se encontraron resultados.",somethingWentWrong:"Lo sentimos, algo salió mal.",chatButton:"Maridar vino con cena",inputPlaceholder:"ej., Ensalada de atún",sendButton:"Maridar",price:"Precio",region:"Región",type:"Tipo",moreInfo:"Más info"},en:{welcomeMessage:"Enhance your dining experience. Just provide your dish details and get the ideal wine pairing. What would you like to eat?",noResultsFound:"No results found.",somethingWentWrong:"Sorry, something went wrong.",chatButton:"Pair wine with dinner",inputPlaceholder:"e.g., Tuna Salad",sendButton:"Pair",price:"Price",region:"Region",type:"Type",moreInfo:"More info"}}}async fetchConfig(t){if(t){const e=await this.api.getStoreConfig(t);this.language=e.lang}}translate(t){return this.translations[this.language][t]||t}}const s=new T;class B{constructor(){this.api=new y,this.displayFirstMessage(s.translate("welcomeMessage"))}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",o=>{o.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(t,e="api"){const o=document.getElementById("message-container"),i=document.createElement("div");i.className=`message ${e}`,i.textContent=t,o.appendChild(i),o.scrollTop=o.scrollHeight}async handleUserInput(){const t=document.getElementById("user-input"),e=t.value.trim();if(e){this.displayMessage(e,"user"),t.value="",this.showTypingIndicator();try{v(e);const o=await this.api.getWineRecommendations(e);this.hideTypingIndicator(),o&&o.length?this.displayResults(o):this.displayMessage("No results found.","api")}catch{this.hideTypingIndicator(),this.displayMessage(s.translate("somethingWentWrong"),"api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(t,e){const o=document.getElementById("message-container"),i=document.createElement("div");i.textContent=t,i.className="message "+e,o.appendChild(i),o.scrollTop=o.scrollHeight}sendAnalytics(t){C(t)}displayResults(t){const e=document.getElementById("message-container");k(t.map(o=>o.Title)),t.forEach(o=>{const i=document.createElement("div");i.className="wine-item";const a=document.createElement("img");a.src=o.Image,i.appendChild(a);const p=document.createElement("div");p.innerHTML=`
277
277
  <strong>${o.Title}</strong><br>
278
- ${a.translate("price")}: ${o.Price}<br>
279
- ${a.translate("region")}: ${o.Region}<br>
280
- ${a.translate("type")}: ${o.Type}<br>
281
- <a href="${o.Url}" onclick="sendAnalytics(${o.Title})" target="_blank">${a.translate("moreInfo")}</a>
282
- `,i.appendChild(p),e.appendChild(i)}),e.scrollTop=e.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=h,window.closeChatWindow=f,window.openChatWindow=b});function W(){const n=`
278
+ ${s.translate("price")}: ${o.Price}<br>
279
+ ${s.translate("region")}: ${o.Region}<br>
280
+ ${s.translate("type")}: ${o.Type}<br>
281
+ <a href="${o.Url}" onclick="sendAnalytics(${o.Title})" target="_blank">${s.translate("moreInfo")}</a>
282
+ `,i.appendChild(p),e.appendChild(i)}),e.scrollTop=e.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=h,window.closeChatWindow=f,window.openChatWindow=b});function L(){const n=`
283
283
  <div id="chatbot-container">
284
284
  <div id="chat-icon" onclick="toggleChatWindow()">
285
285
  <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon"> <!-- Update the path to your logo image -->
286
- <span>${a.translate("chatButton")}</span>
286
+ <span>${s.translate("chatButton")}</span>
287
287
  </div>
288
288
 
289
289
  <div id="chat-window" class="hidden">
@@ -300,9 +300,9 @@
300
300
  <span></span><span></span><span></span>
301
301
  </div>
302
302
  <div id="input-container">
303
- <input type="text" id="user-input" placeholder="${a.translate("inputPlaceholder")}">
304
- <button id="send-button">${a.translate("sendButton")}</button>
303
+ <input type="text" id="user-input" placeholder="${s.translate("inputPlaceholder")}">
304
+ <button id="send-button">${s.translate("sendButton")}</button>
305
305
  </div>
306
306
  </div>
307
307
  </div>
308
- `;document.body.insertAdjacentHTML("beforeend",n)}function P(){document.getElementById("close-btn").addEventListener("click",h)}function S(){window.addEventListener("click",function(n){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");!t.contains(n.target)&&!e.contains(n.target)&&(t.classList.remove("visible"),e.style.display="flex")})}function O(n){console.log(n);const t=document.getElementById("chat-icon"),e=document.getElementById("chat-window");t.className="",e.className="",n==="right-center"?(t.classList.add("chat-icon-right-center"),e.classList.add("right-center-aligned")):t.classList.add("chat-icon-bottom-right")}if(typeof window<"u"){const n=((w=window.wineaterData)==null?void 0:w.POSITION)||"bottom-right";window.addEventListener("DOMContentLoaded",async()=>{var s;const e=["climats","telckel","biobio","weinpoint"].find(p=>window.location.href.includes(p))||null;let o;e&&(o=e.charAt(0).toUpperCase()+e.slice(1)),await a.fetchConfig(o||null),W(),P(),S(),O(n),x("chatbotToken",(s=window.wineaterData)==null?void 0:s.CLIENT_TOKEN,365),new L().initialize()})}r.closeChatWindow=f,r.openChatWindow=b,r.toggleChatWindow=h,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
308
+ `;document.body.insertAdjacentHTML("beforeend",n)}function W(){document.getElementById("close-btn").addEventListener("click",h)}function P(){window.addEventListener("click",function(n){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");!t.contains(n.target)&&!e.contains(n.target)&&(t.classList.remove("visible"),e.style.display="flex")})}function S(n){console.log(n);const t=document.getElementById("chat-icon"),e=document.getElementById("chat-window");t.className="",e.className="",n==="right-center"?(t.classList.add("chat-icon-right-center"),e.classList.add("right-center-aligned")):t.classList.add("chat-icon-bottom-right")}if(typeof window<"u"){const n=((w=window.wineaterData)==null?void 0:w.POSITION)||"bottom-right";window.addEventListener("DOMContentLoaded",async()=>{var a;const e=["climats","telckel","biobio","weinpoint"].find(p=>window.location.href.includes(p))||null;let o;e&&(o=e.charAt(0).toUpperCase()+e.slice(1)),await s.fetchConfig(o||null),L(),W(),P(),S(n),x("chatbotToken",(a=window.wineaterData)==null?void 0:a.CLIENT_TOKEN,365),new B().initialize()})}r.closeChatWindow=f,r.openChatWindow=b,r.toggleChatWindow=h,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "1.4.5",
3
+ "version": "1.5.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
@@ -15,13 +15,6 @@ function setCookie(name, value, days) {
15
15
  const parts = value.split(`; ${name}=`);
16
16
  if (parts.length === 2) return parts.pop().split(';').shift();
17
17
  }
18
-
19
- // Function to URL encode the data
20
- function urlEncodeData(data) {
21
- return Object.keys(data)
22
- .map(key => encodeURIComponent(key) + '=' + encodeURIComponent(data[key]))
23
- .join('&');
24
- }
25
18
 
26
19
  // Функция для отправки событий в Mixpanel
27
20
  function trackEvent(event, properties) {
@@ -29,16 +22,18 @@ function urlEncodeData(data) {
29
22
  const endpoint = 'https://api-eu.mixpanel.com/track';
30
23
  const data = {
31
24
  event: event,
32
- properties: properties
25
+ properties: {
26
+ token: token,
27
+ ...properties
28
+ }
33
29
  };
34
30
 
35
31
  fetch(endpoint, {
36
32
  method: 'POST',
37
33
  headers: {
38
- 'Content-Type': 'application/x-www-form-urlencoded',
39
- 'Authentication': token
34
+ 'Content-Type': 'application/json'
40
35
  },
41
- body: urlEncodeData(data)
36
+ body: JSON.stringify(data)
42
37
  }).then(response => {
43
38
  if (!response.ok) {
44
39
  console.error('Mixpanel tracking failed', response);