@ably/ui 16.0.0-dev.f34cb058 → 16.1.0-dev.d9810f04
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 -1
- package/core/.DS_Store +0 -0
- package/core/Flyout.js +1 -1
- package/core/Flyout.js.map +1 -1
- package/core/Footer/data.js +2 -0
- package/core/Footer/data.js.map +1 -0
- package/core/Footer.js +1 -1
- package/core/Footer.js.map +1 -1
- package/core/Header/HeaderLinks.js.map +1 -1
- package/core/Header.js +1 -1
- package/core/Header.js.map +1 -1
- package/core/LegacyFooter/LegacyFooter.js +2 -0
- package/core/LegacyFooter/LegacyFooter.js.map +1 -0
- package/core/Meganav/.DS_Store +0 -0
- package/core/Meganav/component.js +2 -0
- package/core/{LegacyMeganav → Meganav}/component.js.map +1 -1
- package/core/Meganav.js +2 -0
- package/core/Meganav.js.map +1 -0
- package/core/MeganavBlogPostsList/component.js +2 -0
- package/core/MeganavBlogPostsList/component.js.map +1 -0
- package/core/MeganavBlogPostsList.js.map +1 -1
- package/core/MeganavContentCompany.js.map +1 -1
- package/core/MeganavContentDevelopers.js.map +1 -1
- package/core/MeganavContentProducts.js.map +1 -1
- package/core/MeganavContentUseCases.js.map +1 -1
- package/core/MeganavControl/component.js +2 -0
- package/core/MeganavControl/component.js.map +1 -0
- package/core/MeganavControl.js.map +1 -1
- package/core/MeganavControlMobileDropdown/component.js +2 -0
- package/core/MeganavControlMobileDropdown/component.js.map +1 -0
- package/core/MeganavControlMobileDropdown.js.map +1 -1
- package/core/MeganavControlMobilePanelClose/component.js +2 -0
- package/core/MeganavControlMobilePanelClose/component.js.map +1 -0
- package/core/MeganavControlMobilePanelOpen/component.js +2 -0
- package/core/MeganavControlMobilePanelOpen/component.js.map +1 -0
- package/core/MeganavItemsDesktop.js +1 -1
- package/core/MeganavItemsDesktop.js.map +1 -1
- package/core/MeganavItemsMobile.js +1 -1
- package/core/MeganavItemsMobile.js.map +1 -1
- package/core/MeganavItemsSignedIn.js.map +1 -1
- package/core/MeganavSearch.js.map +1 -1
- package/core/MeganavSearchAutocomplete/component.js +2 -0
- package/core/MeganavSearchAutocomplete/component.js.map +1 -0
- package/core/MeganavSearchPanel.js.map +1 -1
- package/core/MeganavSearchSuggestions/component.js +2 -0
- package/core/MeganavSearchSuggestions/component.js.map +1 -0
- package/core/MeganavSearchSuggestions.js.map +1 -1
- package/core/Notice/component.js +1 -1
- package/core/Notice/component.js.map +1 -1
- package/core/SegmentedControl.js +2 -0
- package/core/SegmentedControl.js.map +1 -0
- package/core/SignOutLink.js.map +1 -1
- package/core/insights/command-queue.js +2 -0
- package/core/insights/command-queue.js.map +1 -0
- package/core/insights/datalayer.js +2 -0
- package/core/insights/datalayer.js.map +1 -0
- package/core/insights/index.js +1 -1
- package/core/insights/index.js.map +1 -1
- package/core/insights/index.test.js +2 -0
- package/core/insights/index.test.js.map +1 -0
- package/core/insights/logger.js +2 -0
- package/core/insights/logger.js.map +1 -0
- package/core/insights/mixpanel.js +1 -1
- package/core/insights/mixpanel.js.map +1 -1
- package/core/insights/posthog.js +1 -1
- package/core/insights/posthog.js.map +1 -1
- package/core/insights/service.js +2 -0
- package/core/insights/service.js.map +1 -0
- package/core/insights/types.js.map +1 -1
- package/core/scripts.js +1 -1
- package/core/scripts.js.map +1 -1
- package/index.d.ts +177 -221
- package/package.json +10 -6
- package/core/ContactFooter/component.css +0 -11
- package/core/ContactFooter/component.js +0 -2
- package/core/ContactFooter/component.js.map +0 -1
- package/core/ContactFooter.js +0 -2
- package/core/ContactFooter.js.map +0 -1
- package/core/LegacyMeganav/MeganavBlogPostsList/component.js +0 -2
- package/core/LegacyMeganav/MeganavBlogPostsList/component.js.map +0 -1
- package/core/LegacyMeganav/MeganavControl/component.js +0 -2
- package/core/LegacyMeganav/MeganavControl/component.js.map +0 -1
- package/core/LegacyMeganav/MeganavControlMobileDropdown/component.js +0 -2
- package/core/LegacyMeganav/MeganavControlMobileDropdown/component.js.map +0 -1
- package/core/LegacyMeganav/MeganavControlMobilePanelClose/component.js +0 -2
- package/core/LegacyMeganav/MeganavControlMobilePanelClose/component.js.map +0 -1
- package/core/LegacyMeganav/MeganavControlMobilePanelOpen/component.js +0 -2
- package/core/LegacyMeganav/MeganavControlMobilePanelOpen/component.js.map +0 -1
- package/core/LegacyMeganav/MeganavSearchAutocomplete/component.js +0 -2
- package/core/LegacyMeganav/MeganavSearchAutocomplete/component.js.map +0 -1
- package/core/LegacyMeganav/MeganavSearchSuggestions/component.js +0 -2
- package/core/LegacyMeganav/MeganavSearchSuggestions/component.js.map +0 -1
- package/core/LegacyMeganav/component.js +0 -2
- package/core/LegacyMeganav.js +0 -2
- package/core/LegacyMeganav.js.map +0 -1
- package/core/Meganav/Meganav.js +0 -2
- package/core/Meganav/Meganav.js.map +0 -1
- package/core/Meganav/MeganavMobile.js +0 -2
- package/core/Meganav/MeganavMobile.js.map +0 -1
- package/core/Meganav/MeganavPanel.js +0 -2
- package/core/Meganav/MeganavPanel.js.map +0 -1
- package/core/Meganav/data.js +0 -2
- package/core/Meganav/data.js.map +0 -1
- package/core/Meganav/images/fan-engagement-nav-image.png +0 -0
- package/core/Meganav/images/founders-nav-image.png +0 -0
- package/core/hubspot-chat-toggle.js +0 -2
- package/core/hubspot-chat-toggle.js.map +0 -1
- /package/core/{Footer → LegacyFooter}/component.css +0 -0
- /package/core/{LegacyMeganav → Meganav}/component.css +0 -0
- /package/core/{LegacyMeganav → Meganav}/component.json +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{queryId}from"../dom-query";import AddSearchClient from"addsearch-js-client";const init=({input,container,listContainer,clear,client})=>{client.setAnalyticsTag("Meganav autocomplete");client.setThrottleTime(400);const clearResults=()=>{container.classList.add("hidden");listContainer.innerHTML=""};const toggleClearBtn=query=>{if((query||"").length>0&&clear){clear.classList.remove("invisible")}else if(clear){clear.classList.add("invisible")}};const markQueryInSuggestion=(suggestionValue,query)=>{return suggestionValue.replace(query.toLowerCase(),`<span class="font-light">${query}</span>`)};const navigateToUrl=q=>window.location=`/search?q=${q}`;const focusNext=index=>{const nextSuggestion=listContainer.querySelector(`[data-suggestion-index="${index+1}"]`);if(!nextSuggestion)return;nextSuggestion.focus()};const focusPrevious=index=>{const previousIndex=index-1;const previousSuggestion=listContainer.querySelector(`[data-suggestion-index="${previousIndex}"]`);if(!previousSuggestion)return;previousSuggestion.focus()};const renderResults=query=>(results={})=>{toggleClearBtn(query);if(!Array.isArray(results.suggestions)){clearResults();return}if(results.suggestions.length===0){clearResults();return}const items=results.suggestions.map((suggestion,index)=>{const li=document.createElement("li");const button=document.createElement("button");button.type="button";button.classList.add("ui-text-menu2","font-medium","p-8","w-full","text-left","rounded","hover:text-gui-hover","focus:outline-gui-focus","hover:bg-light-grey");button.innerHTML=markQueryInSuggestion(suggestion.value,query);button.dataset.suggestionIndex=index;button.addEventListener("click",()=>{navigateToUrl(suggestion.value)});button.addEventListener("keydown",e=>{const key=e.key;if(key==="ArrowDown"){focusNext(index)}else if(key==="ArrowUp"&&index-1<0){input.focus()}else if(key==="ArrowUp"&&index-1>=0){focusPrevious(index)}else if(key==="Enter"||key==="Space"){navigateToUrl(suggestion.value)}});li.appendChild(button);return li});listContainer.innerHTML="";items.forEach(item=>listContainer.appendChild(item));container.classList.remove("hidden")};const keyupHandler=e=>{const query=e.target.value;const key=e.key;if(key==="ArrowDown"){focusNext(0);return}if(!query){clearResults()}else{client.suggestions(query,renderResults(query))}};let clearHandler;if(clear){clearHandler=()=>{input.value="";clear.classList.add("invisible");clearResults()};clear.addEventListener("click",clearHandler)}input.addEventListener("keyup",keyupHandler);return{teardown:()=>{input.removeEventListener("keyup",keyupHandler);if(clear)clear.removeEventListener("click",clearHandler)},clear:()=>{input.value="";clearResults()}}};export default(apiKey=>{if(!apiKey){console.log(`No AddSearch API key provided, skipping search suggestions.`);return[]}const client=new AddSearchClient(apiKey);return[queryId("meganav-search-input"),queryId("meganav-mobile-search-input")].filter(i=>i).map(input=>{const parent=input.parentNode;const container=queryId("meganav-search-autocomplete-container",parent);const listContainer=queryId("meganav-search-autocomplete-list",parent);const clear=queryId("meganav-search-input-clear",parent);return init({input,container,listContainer,client,clear})})});
|
|
2
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/MeganavSearchAutocomplete/component.js"],"sourcesContent":["import { queryId } from \"../dom-query\";\nimport AddSearchClient from \"addsearch-js-client\";\n\nconst init = ({ input, container, listContainer, clear, client }) => {\n client.setAnalyticsTag(\"Meganav autocomplete\");\n client.setThrottleTime(400);\n\n const clearResults = () => {\n container.classList.add(\"hidden\");\n listContainer.innerHTML = \"\";\n };\n\n const toggleClearBtn = (query) => {\n if ((query || \"\").length > 0 && clear) {\n clear.classList.remove(\"invisible\");\n } else if (clear) {\n clear.classList.add(\"invisible\");\n }\n };\n\n const markQueryInSuggestion = (suggestionValue, query) => {\n return suggestionValue.replace(\n query.toLowerCase(),\n `<span class=\"font-light\">${query}</span>`,\n );\n };\n\n const navigateToUrl = (q) => (window.location = `/search?q=${q}`);\n\n const focusNext = (index) => {\n const nextSuggestion = listContainer.querySelector(\n `[data-suggestion-index=\"${index + 1}\"]`,\n );\n if (!nextSuggestion) return;\n nextSuggestion.focus();\n };\n\n const focusPrevious = (index) => {\n const previousIndex = index - 1;\n\n const previousSuggestion = listContainer.querySelector(\n `[data-suggestion-index=\"${previousIndex}\"]`,\n );\n if (!previousSuggestion) return;\n previousSuggestion.focus();\n };\n\n const renderResults =\n (query) =>\n (results = {}) => {\n toggleClearBtn(query);\n\n // Prevent invalid access error when key is invalid\n if (!Array.isArray(results.suggestions)) {\n clearResults();\n return;\n }\n\n // Prevent key error from invalid key\n if (results.suggestions.length === 0) {\n clearResults();\n return;\n }\n\n const items = results.suggestions.map((suggestion, index) => {\n const li = document.createElement(\"li\");\n const button = document.createElement(\"button\");\n button.type = \"button\";\n\n button.classList.add(\n \"ui-text-menu2\",\n \"font-medium\",\n \"p-8\",\n \"w-full\",\n \"text-left\",\n \"rounded\",\n \"hover:text-gui-hover\",\n \"focus:outline-gui-focus\",\n \"hover:bg-light-grey\",\n );\n\n button.innerHTML = markQueryInSuggestion(suggestion.value, query);\n\n button.dataset.suggestionIndex = index;\n\n button.addEventListener(\"click\", () => {\n navigateToUrl(suggestion.value);\n });\n\n button.addEventListener(\"keydown\", (e) => {\n const key = e.key;\n\n if (key === \"ArrowDown\") {\n focusNext(index);\n } else if (key === \"ArrowUp\" && index - 1 < 0) {\n input.focus();\n } else if (key === \"ArrowUp\" && index - 1 >= 0) {\n focusPrevious(index);\n } else if (key === \"Enter\" || key === \"Space\") {\n navigateToUrl(suggestion.value);\n }\n });\n\n li.appendChild(button);\n return li;\n });\n\n listContainer.innerHTML = \"\";\n items.forEach((item) => listContainer.appendChild(item));\n container.classList.remove(\"hidden\");\n };\n\n const keyupHandler = (e) => {\n const query = e.target.value;\n const key = e.key;\n\n if (key === \"ArrowDown\") {\n focusNext(0);\n return;\n }\n\n if (!query) {\n clearResults();\n } else {\n client.suggestions(query, renderResults(query));\n }\n };\n\n let clearHandler;\n if (clear) {\n clearHandler = () => {\n input.value = \"\";\n clear.classList.add(\"invisible\");\n clearResults();\n };\n clear.addEventListener(\"click\", clearHandler);\n }\n\n input.addEventListener(\"keyup\", keyupHandler);\n\n return {\n teardown: () => {\n input.removeEventListener(\"keyup\", keyupHandler);\n if (clear) clear.removeEventListener(\"click\", clearHandler);\n },\n clear: () => {\n input.value = \"\";\n clearResults();\n },\n };\n};\n\nexport default (apiKey) => {\n if (!apiKey) {\n console.log(`No AddSearch API key provided, skipping search suggestions.`);\n return [];\n }\n\n const client = new AddSearchClient(apiKey);\n\n return [\n queryId(\"meganav-search-input\"),\n queryId(\"meganav-mobile-search-input\"),\n ]\n .filter((i) => i)\n .map((input) => {\n const parent = input.parentNode;\n const container = queryId(\n \"meganav-search-autocomplete-container\",\n parent,\n );\n const listContainer = queryId(\"meganav-search-autocomplete-list\", parent);\n const clear = queryId(\"meganav-search-input-clear\", parent);\n\n return init({ input, container, listContainer, client, clear });\n });\n};\n"],"names":["queryId","AddSearchClient","init","input","container","listContainer","clear","client","setAnalyticsTag","setThrottleTime","clearResults","classList","add","innerHTML","toggleClearBtn","query","length","remove","markQueryInSuggestion","suggestionValue","replace","toLowerCase","navigateToUrl","q","window","location","focusNext","index","nextSuggestion","querySelector","focus","focusPrevious","previousIndex","previousSuggestion","renderResults","results","Array","isArray","suggestions","items","map","suggestion","li","document","createElement","button","type","value","dataset","suggestionIndex","addEventListener","e","key","appendChild","forEach","item","keyupHandler","target","clearHandler","teardown","removeEventListener","apiKey","console","log","filter","i","parent","parentNode"],"mappings":"AAAA,OAASA,OAAO,KAAQ,cAAe,AACvC,QAAOC,oBAAqB,qBAAsB,CAElD,MAAMC,KAAO,CAAC,CAAEC,KAAK,CAAEC,SAAS,CAAEC,aAAa,CAAEC,KAAK,CAAEC,MAAM,CAAE,IAC9DA,OAAOC,eAAe,CAAC,wBACvBD,OAAOE,eAAe,CAAC,KAEvB,MAAMC,aAAe,KACnBN,UAAUO,SAAS,CAACC,GAAG,CAAC,SACxBP,CAAAA,cAAcQ,SAAS,CAAG,EAC5B,EAEA,MAAMC,eAAiB,AAACC,QACtB,GAAI,AAACA,CAAAA,OAAS,EAAC,EAAGC,MAAM,CAAG,GAAKV,MAAO,CACrCA,MAAMK,SAAS,CAACM,MAAM,CAAC,YACzB,MAAO,GAAIX,MAAO,CAChBA,MAAMK,SAAS,CAACC,GAAG,CAAC,YACtB,CACF,EAEA,MAAMM,sBAAwB,CAACC,gBAAiBJ,SAC9C,OAAOI,gBAAgBC,OAAO,CAC5BL,MAAMM,WAAW,GACjB,CAAC,yBAAyB,EAAEN,MAAM,OAAO,CAAC,CAE9C,EAEA,MAAMO,cAAgB,AAACC,GAAOC,OAAOC,QAAQ,CAAG,CAAC,UAAU,EAAEF,EAAE,CAAC,CAEhE,MAAMG,UAAY,AAACC,QACjB,MAAMC,eAAiBvB,c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MAAMgE,UAAU,CAC/B,MAAM/D,UAAYJ,QAChB,wCACAkE,QAEF,MAAM7D,cAAgBL,QAAQ,mCAAoCkE,QAClE,MAAM5D,MAAQN,QAAQ,6BAA8BkE,QAEpD,OAAOhE,KAAK,CAAEC,MAAOC,UAAWC,cAAeE,OAAQD,KAAM,EAC/D,EACJ,CAAA,CAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/MeganavSearchPanel.tsx"],"sourcesContent":["import React from \"react\";\n\nimport Icon from \"./Icon\";\nimport MeganavSearchSuggestions from \"./MeganavSearchSuggestions\";\nimport MeganavSearchAutocomplete from \"./MeganavSearchAutocomplete\";\nimport { AbsUrl } from \"./
|
|
1
|
+
{"version":3,"sources":["../../src/core/MeganavSearchPanel.tsx"],"sourcesContent":["import React from \"react\";\n\nimport Icon from \"./Icon\";\nimport MeganavSearchSuggestions from \"./MeganavSearchSuggestions\";\nimport MeganavSearchAutocomplete from \"./MeganavSearchAutocomplete\";\nimport { AbsUrl } from \"./Meganav\";\n\nconst MeganavSearchPanel = ({ absUrl }: { absUrl: AbsUrl }) => (\n <section className=\"ui-meganav-content grid-cols-12\">\n <div className=\"col-span-8\">\n <div className=\"mb-32\">\n <form\n className=\"flex items-start\"\n action={absUrl(\"/search\")}\n method=\"get\"\n >\n <div className=\"relative w-full\">\n <Icon\n name=\"icon-gui-magnifying-glass-outline\"\n color=\"text-cool-black\"\n size=\"1.5rem\"\n additionalCSS=\"absolute top-12 left-16\"\n />\n <input\n type=\"search\"\n name=\"q\"\n className=\"ui-input pl-48 h-48\"\n placeholder=\"Search\"\n autoComplete=\"off\"\n data-id=\"meganav-search-input\"\n />\n\n <MeganavSearchAutocomplete />\n </div>\n\n <button\n type=\"submit\"\n className=\"ui-btn-secondary flex-shrink-0 ml-8 sm:ml-16 md:ml-24 xl:ml-32\"\n >\n Search\n </button>\n </form>\n </div>\n </div>\n\n <div className=\"col-span-12\">\n <MeganavSearchSuggestions displaySupportLink={true} absUrl={absUrl} />\n </div>\n </section>\n);\n\nexport default MeganavSearchPanel;\n"],"names":["React","Icon","MeganavSearchSuggestions","MeganavSearchAutocomplete","MeganavSearchPanel","absUrl","section","className","div","form","action","method","name","color","size","additionalCSS","input","type","placeholder","autoComplete","data-id","button","displaySupportLink"],"mappings":"AAAA,OAAOA,UAAW,OAAQ,AAE1B,QAAOC,SAAU,QAAS,AAC1B,QAAOC,6BAA8B,4BAA6B,AAClE,QAAOC,8BAA+B,6BAA8B,CAGpE,MAAMC,mBAAqB,CAAC,CAAEC,MAAM,CAAsB,GACxD,oBAACC,WAAQC,UAAU,mCACjB,oBAACC,OAAID,UAAU,cACb,oBAACC,OAAID,UAAU,SACb,oBAACE,QACCF,UAAU,mBACVG,OAAQL,OAAO,WACfM,OAAO,OAEP,oBAACH,OAAID,UAAU,mBACb,oBAACN,MACCW,KAAK,oCACLC,MAAM,kBACNC,KAAK,SACLC,cAAc,4BAEhB,oBAACC,SACCC,KAAK,SACLL,KAAK,IACLL,UAAU,sBACVW,YAAY,SACZC,aAAa,MACbC,UAAQ,yBAGV,oBAACjB,iCAGH,oBAACkB,UACCJ,KAAK,SACLV,UAAU,kEACX,aAOP,oBAACC,OAAID,UAAU,eACb,oBAACL,0BAAyBoB,mBAAoB,KAAMjB,OAAQA,UAKlE,gBAAeD,kBAAmB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{queryId}from"../dom-query";const DRAG_BUFFER=5;const getTranslateX=node=>new DOMMatrix(window.getComputedStyle(node).transform).e;const updateTranslateX=(node,value)=>node.style.transform=`translateX(${value}px)`;const dragLeftBoundary=(translateX,threshold)=>translateX>=threshold;const dragRightBoundary=(translateX,itemsWidth,windowWidth,threshold)=>Math.abs(translateX-windowWidth+threshold)>itemsWidth;const getDistance=(e,touchStartX)=>e.changedTouches[0]?.clientX-touchStartX;const withinBuffer=distance=>Math.abs(distance)<DRAG_BUFFER;const getItemsTotalWidth=nodes=>nodes.map(item=>item.getBoundingClientRect().width).reduce((acc,val)=>acc+val,0);const MeganavSearchSuggestions=()=>{const suggestionsToggle=queryId("meganav-mobile-search-input");const suggestions=queryId("meganav-mobile-search-suggestions");const list=suggestions.querySelector("ul");const listItems=Array.from(list.querySelectorAll("li"));const dragLeft=(distance,threshold)=>{const currentTranslateX=getTranslateX(list);const translateX=Math.round(currentTranslateX+distance);if(dragLeftBoundary(translateX,threshold))return;updateTranslateX(list,translateX)};const dragLeftEnd=(distance,threshold)=>{const currentTranslateX=getTranslateX(list);let translateX=Math.round(currentTranslateX+distance);if(dragLeftBoundary(translateX,threshold)){translateX=0}updateTranslateX(list,translateX)};const dragRight=(distance,threshold)=>{const listWidth=list.getBoundingClientRect().width;const currentTranslateX=getTranslateX(list);const translateX=Math.round(currentTranslateX+distance);const itemsTotalWidth=getItemsTotalWidth(listItems);if(dragRightBoundary(translateX,itemsTotalWidth,listWidth,threshold)){return}updateTranslateX(list,translateX)};const dragRightEnd=(distance,threshold)=>{const listWidth=list.getBoundingClientRect().width;const currentTranslateX=getTranslateX(list);const itemsTotalWidth=getItemsTotalWidth(listItems);let translateX=Math.round(currentTranslateX+distance);if(dragRightBoundary(translateX,itemsTotalWidth,listWidth,threshold)){translateX=-(itemsTotalWidth-listWidth+threshold)}updateTranslateX(list,translateX)};let touchStartX;const touchstartHandler=e=>{touchStartX=e.touches[0]?.clientX};const touchmoveHandler=e=>{const distance=getDistance(e,touchStartX);if(withinBuffer(distance))return;distance>0?dragLeft(distance,24):dragRight(distance,96)};const touchendHandler=e=>{const distance=getDistance(e,touchStartX);if(withinBuffer(distance))return;distance>0?dragLeftEnd(distance,24):dragRightEnd(distance,48)};const focusSuggestionsHandler=()=>{suggestions.classList.add("max-h-96")};const blurSuggestionsHandler=e=>{if(e.relatedTarget===suggestions.querySelectorAll("a")[0]){return}suggestions.classList.remove("max-h-96")};const wheelHandler=e=>{const distance=e.deltaY*4;if(withinBuffer(distance))return;distance>0?dragLeftEnd(distance,24):dragRightEnd(distance,48)};suggestionsToggle?.addEventListener("focus",focusSuggestionsHandler);suggestionsToggle?.addEventListener("blur",blurSuggestionsHandler);suggestions.addEventListener("touchstart",touchstartHandler);suggestions.addEventListener("touchmove",touchmoveHandler);suggestions.addEventListener("touchend",touchendHandler);suggestions.addEventListener("wheel",wheelHandler);return{teardown:()=>{suggestionsToggle?.removeEventListener("focus",focusSuggestionsHandler);suggestionsToggle?.removeEventListener("blur",blurSuggestionsHandler);suggestions.removeEventListener("touchstart",touchstartHandler);suggestions.removeEventListener("touchmove",touchmoveHandler);suggestions.removeEventListener("touchend",touchendHandler)},clear:()=>{suggestions.classList.remove("max-h-96");list.style.transform=`translateX(0px)`}}};export default MeganavSearchSuggestions;
|
|
2
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/MeganavSearchSuggestions/component.js"],"sourcesContent":["import { queryId } from \"../dom-query\";\n\nconst DRAG_BUFFER = 5;\n\nconst getTranslateX = (node) =>\n new DOMMatrix(window.getComputedStyle(node).transform).e;\n\nconst updateTranslateX = (node, value) =>\n (node.style.transform = `translateX(${value}px)`);\n\nconst dragLeftBoundary = (translateX, threshold) => translateX >= threshold;\n\nconst dragRightBoundary = (translateX, itemsWidth, windowWidth, threshold) =>\n Math.abs(translateX - windowWidth + threshold) > itemsWidth;\n\nconst getDistance = (e, touchStartX) =>\n e.changedTouches[0]?.clientX - touchStartX;\n\nconst withinBuffer = (distance) => Math.abs(distance) < DRAG_BUFFER;\n\nconst getItemsTotalWidth = (nodes) =>\n nodes\n .map((item) => item.getBoundingClientRect().width)\n .reduce((acc, val) => acc + val, 0);\n\nconst MeganavSearchSuggestions = () => {\n const suggestionsToggle = queryId(\"meganav-mobile-search-input\");\n const suggestions = queryId(\"meganav-mobile-search-suggestions\");\n const list = suggestions.querySelector(\"ul\");\n const listItems = Array.from(list.querySelectorAll(\"li\"));\n\n const dragLeft = (distance, threshold) => {\n const currentTranslateX = getTranslateX(list);\n const translateX = Math.round(currentTranslateX + distance);\n if (dragLeftBoundary(translateX, threshold)) return;\n updateTranslateX(list, translateX);\n };\n\n const dragLeftEnd = (distance, threshold) => {\n const currentTranslateX = getTranslateX(list);\n let translateX = Math.round(currentTranslateX + distance);\n\n if (dragLeftBoundary(translateX, threshold)) {\n translateX = 0;\n }\n\n updateTranslateX(list, translateX);\n };\n\n const dragRight = (distance, threshold) => {\n const listWidth = list.getBoundingClientRect().width;\n const currentTranslateX = getTranslateX(list);\n const translateX = Math.round(currentTranslateX + distance);\n const itemsTotalWidth = getItemsTotalWidth(listItems);\n\n if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {\n return;\n }\n\n updateTranslateX(list, translateX);\n };\n\n const dragRightEnd = (distance, threshold) => {\n const listWidth = list.getBoundingClientRect().width;\n const currentTranslateX = getTranslateX(list);\n const itemsTotalWidth = getItemsTotalWidth(listItems);\n let translateX = Math.round(currentTranslateX + distance);\n\n if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {\n translateX = -(itemsTotalWidth - listWidth + threshold);\n }\n\n updateTranslateX(list, translateX);\n };\n\n let touchStartX;\n\n const touchstartHandler = (e) => {\n touchStartX = e.touches[0]?.clientX;\n };\n\n const touchmoveHandler = (e) => {\n const distance = getDistance(e, touchStartX);\n if (withinBuffer(distance)) return;\n distance > 0 ? dragLeft(distance, 24) : dragRight(distance, 96);\n };\n\n const touchendHandler = (e) => {\n const distance = getDistance(e, touchStartX);\n if (withinBuffer(distance)) return;\n distance > 0 ? dragLeftEnd(distance, 24) : dragRightEnd(distance, 48);\n };\n\n const focusSuggestionsHandler = () => {\n suggestions.classList.add(\"max-h-96\");\n };\n\n const blurSuggestionsHandler = (e) => {\n if (e.relatedTarget === suggestions.querySelectorAll(\"a\")[0]) {\n return;\n }\n suggestions.classList.remove(\"max-h-96\");\n };\n\n const wheelHandler = (e) => {\n const distance = e.deltaY * 4;\n if (withinBuffer(distance)) return;\n distance > 0 ? dragLeftEnd(distance, 24) : dragRightEnd(distance, 48);\n };\n\n suggestionsToggle?.addEventListener(\"focus\", focusSuggestionsHandler);\n suggestionsToggle?.addEventListener(\"blur\", blurSuggestionsHandler);\n suggestions.addEventListener(\"touchstart\", touchstartHandler);\n suggestions.addEventListener(\"touchmove\", touchmoveHandler);\n suggestions.addEventListener(\"touchend\", touchendHandler);\n suggestions.addEventListener(\"wheel\", wheelHandler);\n\n return {\n teardown: () => {\n suggestionsToggle?.removeEventListener(\"focus\", focusSuggestionsHandler);\n suggestionsToggle?.removeEventListener(\"blur\", blurSuggestionsHandler);\n suggestions.removeEventListener(\"touchstart\", touchstartHandler);\n suggestions.removeEventListener(\"touchmove\", touchmoveHandler);\n suggestions.removeEventListener(\"touchend\", touchendHandler);\n },\n clear: () => {\n suggestions.classList.remove(\"max-h-96\");\n list.style.transform = `translateX(0px)`;\n },\n };\n};\n\nexport default MeganavSearchSuggestions;\n"],"names":["queryId","DRAG_BUFFER","getTranslateX","node","DOMMatrix","window","getComputedStyle","transform","e","updateTranslateX","value","style","dragLeftBoundary","translateX","threshold","dragRightBoundary","itemsWidth","windowWidth","Math","abs","getDistance","touchStartX","changedTouches","clientX","withinBuffer","distance","getItemsTotalWidth","nodes","map","item","getBoundingClientRect","width","reduce","acc","val","MeganavSearchSuggestions","suggestionsToggle","suggestions","list","querySelector","listItems","Array","from","querySelectorAll","dragLeft","currentTranslateX","round","dragLeftEnd","dragRight","listWidth","itemsTotalWidth","dragRightEnd","touchstartHandler","touches","touchmoveHandler","touchendHandler","focusSuggestionsHandler","classList","add","blurSuggestionsHandler","relatedTarget","remove","wheelHandler","deltaY","addEventListener","teardown","removeEventListener","clear"],"mappings":"AAAA,OAASA,OAAO,KAAQ,cAAe,CAEvC,MAAMC,YAAc,EAEpB,MAAMC,cAAgB,AAACC,MACrB,IAAIC,UAAUC,OAAOC,gBAAgB,CAACH,MAAMI,SAAS,EAAEC,CAAC,CAE1D,MAAMC,iBAAmB,CAACN,KAAMO,QAC7BP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C,aAAe,AAACtD,IACpB,MAAMiB,SAAWjB,EAAEuD,MAAM,CAAG,EAC5B,GAAIvC,aAAaC,UAAW,MAC5BA,CAAAA,SAAW,EAAIsB,YAAYtB,SAAU,IAAM0B,aAAa1B,SAAU,GACpE,EAEAW,mBAAmB4B,iBAAiB,QAASR,yBAC7CpB,mBAAmB4B,iBAAiB,OAAQL,wBAC5CtB,YAAY2B,gBAAgB,CAAC,aAAcZ,mBAC3Cf,YAAY2B,gBAAgB,CAAC,YAAaV,kBAC1CjB,YAAY2B,gBAAgB,CAAC,WAAYT,iBACzClB,YAAY2B,gBAAgB,CAAC,QAASF,cAEtC,MAAO,CACLG,SAAU,KACR7B,mBAAmB8B,oBAAoB,QAASV,yBAChDpB,mBAAmB8B,oBAAoB,OAAQP,wBAC/CtB,YAAY6B,mBAAmB,CAAC,aAAcd,mBAC9Cf,YAAY6B,mBAAmB,CAAC,YAAaZ,kBAC7CjB,YAAY6B,mBAAmB,CAAC,WAAYX,gBAC9C,EACAY,MAAO,KACL9B,YAAYoB,SAAS,CAACI,MAAM,CAAC,WAC7BvB,CAAAA,KAAK3B,KAAK,CAACJ,SAAS,CAAG,CAAC,eAAe,CAAC,AAC1C,CACF,CACF,CAEA,gBAAe4B,wBAAyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/MeganavSearchSuggestions.tsx"],"sourcesContent":["import React from \"react\";\n\nimport FeaturedLink from \"./FeaturedLink\";\nimport { AbsUrl } from \"./
|
|
1
|
+
{"version":3,"sources":["../../src/core/MeganavSearchSuggestions.tsx"],"sourcesContent":["import React from \"react\";\n\nimport FeaturedLink from \"./FeaturedLink\";\nimport { AbsUrl } from \"./Meganav\";\n\ntype MeganavSearchSuggestionsProps = {\n absUrl: AbsUrl;\n displaySupportLink: boolean;\n};\n\nconst MeganavSearchSuggestions = ({\n absUrl,\n displaySupportLink,\n}: MeganavSearchSuggestionsProps) => (\n <>\n <p className=\"ui-text-overline2 text-cool-black py-12\">Popular pages</p>\n\n <div className=\"flex justify-between items-center overflow-hidden\">\n <ul className=\"flex transition-transform\">\n <li className=\"py-12 pr-8 flex-shrink-0\">\n <a\n href={absUrl(\"/docs/how-ably-works\")}\n className=\"ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus\"\n >\n How does Ably work?\n </a>\n </li>\n <li className=\"py-12 px-8 flex-shrink-0\">\n <a\n href={absUrl(\"/docs/quick-start-guide\")}\n className=\"ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus\"\n >\n Quickstart guide\n </a>\n </li>\n <li className=\"py-12 px-8 flex-shrink-0\">\n <a\n href={absUrl(\"/docs/core-features/pubsub\")}\n className=\"ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus\"\n >\n Publish/Subscribe Messaging\n </a>\n </li>\n <li className=\"py-12 pl-8 flex-shrink-0\">\n <a\n href={absUrl(\"/platform\")}\n className=\"ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus\"\n >\n Platform\n </a>\n </li>\n </ul>\n {displaySupportLink ? (\n <FeaturedLink url={absUrl(\"/support\")} textSize=\"text-p2\">\n Support\n </FeaturedLink>\n ) : null}\n </div>\n </>\n);\n\nexport default MeganavSearchSuggestions;\n"],"names":["React","FeaturedLink","MeganavSearchSuggestions","absUrl","displaySupportLink","p","className","div","ul","li","a","href","url","textSize"],"mappings":"AAAA,OAAOA,UAAW,OAAQ,AAE1B,QAAOC,iBAAkB,gBAAiB,CAQ1C,MAAMC,yBAA2B,CAAC,CAChCC,MAAM,CACNC,kBAAkB,CACY,GAC9B,wCACE,oBAACC,KAAEC,UAAU,2CAA0C,iBAEvD,oBAACC,OAAID,UAAU,qDACb,oBAACE,MAAGF,UAAU,6BACZ,oBAACG,MAAGH,UAAU,4BACZ,oBAACI,KACCC,KAAMR,OAAO,wBACbG,UAAU,+EACX,wBAIH,oBAACG,MAAGH,UAAU,4BACZ,oBAACI,KACCC,KAAMR,OAAO,2BACbG,UAAU,+EACX,qBAIH,oBAACG,MAAGH,UAAU,4BACZ,oBAACI,KACCC,KAAMR,OAAO,8BACbG,UAAU,+EACX,gCAIH,oBAACG,MAAGH,UAAU,4BACZ,oBAACI,KACCC,KAAMR,OAAO,aACbG,UAAU,+EACX,cAKJF,mBACC,oBAACH,cAAaW,IAAKT,OAAO,YAAaU,SAAS,WAAU,WAGxD,MAKV,gBAAeX,wBAAyB"}
|
package/core/Notice/component.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Cookie from"js-cookie";import throttle from"lodash.throttle";import{queryId}from"../dom-query";import{FLASH_DATA_ID}from"../Flash";const COOKIE_EXPIRY=90;
|
|
1
|
+
import Cookie from"js-cookie";import throttle from"lodash.throttle";import{queryId}from"../dom-query";import{FLASH_DATA_ID}from"../Flash";const COOKIE_EXPIRY=90;const COLLAPSE_TRIGGER_DISTANCE=5;const SCROLL_LISTENER_THROTTLE=100;const RESIZE_LISTENER_THROTTLE=100;const isMdViewport=()=>!window.matchMedia(`(min-width: 65rem)`).matches;const adjustFlashMargin=open=>{const flash=queryId(FLASH_DATA_ID);if(flash){flash.style.marginTop=open?`4rem`:null}};const hideOnMobile=bannerContainer=>{if(isMdViewport()){bannerContainer.style.display="none"}else{bannerContainer.style.display=null}};const hideNotice=bannerContainer=>{bannerContainer.style.maxHeight=0;bannerContainer.style.overflow="hidden";adjustFlashMargin(false)};const showNotice=bannerContainer=>{bannerContainer.style.maxHeight=null;bannerContainer.style.overflow=null;adjustFlashMargin(true)};const setupRememberClosed=(cookieId,noticeId)=>{const cookie=Cookie.get(cookieId)||"";Cookie.set(cookieId,`${cookie.replace(`${noticeId},`,"")+noticeId},`,{expires:COOKIE_EXPIRY})};const hasBeenClosedBefore=(cookieId,noticeId)=>(Cookie.get(cookieId)||"").includes(noticeId);const setupNoticeCollapse=bannerContainer=>{const scrollTop=window.scrollY;if(scrollTop>COLLAPSE_TRIGGER_DISTANCE){hideNotice(bannerContainer)}const listener=throttle(()=>{const scrollTop=window.scrollY;if(scrollTop>COLLAPSE_TRIGGER_DISTANCE){hideNotice(bannerContainer)}else if(bannerContainer.style.overflow){showNotice(bannerContainer)}},SCROLL_LISTENER_THROTTLE);document.addEventListener("scroll",listener);return()=>document.removeEventListener("scroll",listener)};const setupCloseBtn=(bannerContainer,cookieId,noticeId,collapseUnmountListeners)=>{const closeBtn=bannerContainer.querySelector("button");if(!closeBtn)return()=>{};const listener=()=>{if(cookieId&¬iceId)setupRememberClosed(cookieId,noticeId);hideNotice(bannerContainer);collapseUnmountListeners()};closeBtn.addEventListener("click",listener);return()=>document.removeEventListener("click",listener)};const resizeHandler=bannerContainer=>{const handler=throttle(()=>{hideOnMobile(bannerContainer)},RESIZE_LISTENER_THROTTLE);window.addEventListener("resize",handler);return()=>window.removeEventListener("resize",handler)};const Notice=({bannerContainer,cookieId,noticeId,options})=>{if(typeof window==="undefined")return()=>{};if(!bannerContainer){console.warn("A Notice component was initited but no notice container was found.");return()=>{}}if(hasBeenClosedBefore(cookieId,noticeId))return()=>{};hideOnMobile(bannerContainer);showNotice(bannerContainer);const opts={collapse:true,...options};const collapseUnmountListeners=opts.collapse?setupNoticeCollapse(bannerContainer):()=>{};const closeBtnUnmountListeners=setupCloseBtn(bannerContainer,cookieId,noticeId,collapseUnmountListeners);const resizeUnmountListener=resizeHandler(bannerContainer);return()=>{[closeBtnUnmountListeners,collapseUnmountListeners,resizeUnmountListener].forEach(unmount=>unmount())}};export default Notice;
|
|
2
2
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/Notice/component.js"],"sourcesContent":["import Cookie from \"js-cookie\";\nimport throttle from \"lodash.throttle\";\n\nimport { queryId } from \"../dom-query\";\nimport { FLASH_DATA_ID } from \"../Flash\";\n\nconst COOKIE_EXPIRY = 90;\
|
|
1
|
+
{"version":3,"sources":["../../../src/core/Notice/component.js"],"sourcesContent":["import Cookie from \"js-cookie\";\nimport throttle from \"lodash.throttle\";\n\nimport { queryId } from \"../dom-query\";\nimport { FLASH_DATA_ID } from \"../Flash\";\n\nconst COOKIE_EXPIRY = 90;\nconst COLLAPSE_TRIGGER_DISTANCE = 5;\nconst SCROLL_LISTENER_THROTTLE = 100;\nconst RESIZE_LISTENER_THROTTLE = 100;\n\nconst isMdViewport = () => !window.matchMedia(`(min-width: 65rem)`).matches;\n\nconst adjustFlashMargin = (open) => {\n // HACK ALERT\n // Add margin to flashes when opening the notice.\n // Flashes are react components and this notice needs to work as a view-component and react component.\n // We could do this with redux but then we potentially update state on every scroll event, which\n // even with debounce will deplate our frame budget.\n\n const flash = queryId(FLASH_DATA_ID);\n\n if (flash) {\n flash.style.marginTop = open ? `4rem` : null;\n }\n};\n\nconst hideOnMobile = (bannerContainer) => {\n if (isMdViewport()) {\n bannerContainer.style.display = \"none\";\n } else {\n bannerContainer.style.display = null;\n }\n};\n\nconst hideNotice = (bannerContainer) => {\n bannerContainer.style.maxHeight = 0;\n bannerContainer.style.overflow = \"hidden\";\n\n adjustFlashMargin(false);\n};\n\nconst showNotice = (bannerContainer) => {\n bannerContainer.style.maxHeight = null;\n bannerContainer.style.overflow = null;\n\n adjustFlashMargin(true);\n};\n\nconst setupRememberClosed = (cookieId, noticeId) => {\n const cookie = Cookie.get(cookieId) || \"\";\n\n Cookie.set(cookieId, `${cookie.replace(`${noticeId},`, \"\") + noticeId},`, {\n expires: COOKIE_EXPIRY,\n });\n};\n\nconst hasBeenClosedBefore = (cookieId, noticeId) =>\n (Cookie.get(cookieId) || \"\").includes(noticeId);\n\nconst setupNoticeCollapse = (bannerContainer) => {\n const scrollTop = window.scrollY;\n\n if (scrollTop > COLLAPSE_TRIGGER_DISTANCE) {\n hideNotice(bannerContainer);\n }\n\n const listener = throttle(() => {\n const scrollTop = window.scrollY;\n\n if (scrollTop > COLLAPSE_TRIGGER_DISTANCE) {\n hideNotice(bannerContainer);\n } else if (bannerContainer.style.overflow) {\n showNotice(bannerContainer);\n }\n }, SCROLL_LISTENER_THROTTLE);\n\n document.addEventListener(\"scroll\", listener);\n\n return () => document.removeEventListener(\"scroll\", listener);\n};\n\nconst setupCloseBtn = (\n bannerContainer,\n cookieId,\n noticeId,\n collapseUnmountListeners,\n) => {\n const closeBtn = bannerContainer.querySelector(\"button\");\n\n if (!closeBtn) return () => {};\n\n const listener = () => {\n if (cookieId && noticeId) setupRememberClosed(cookieId, noticeId);\n\n hideNotice(bannerContainer);\n collapseUnmountListeners();\n };\n\n closeBtn.addEventListener(\"click\", listener);\n\n return () => document.removeEventListener(\"click\", listener);\n};\n\nconst resizeHandler = (bannerContainer) => {\n const handler = throttle(() => {\n hideOnMobile(bannerContainer);\n }, RESIZE_LISTENER_THROTTLE);\n\n window.addEventListener(\"resize\", handler);\n\n return () => window.removeEventListener(\"resize\", handler);\n};\n\nconst Notice = ({ bannerContainer, cookieId, noticeId, options }) => {\n if (typeof window === \"undefined\") return () => {};\n\n if (!bannerContainer) {\n console.warn(\n \"A Notice component was initited but no notice container was found.\",\n );\n return () => {};\n }\n\n if (hasBeenClosedBefore(cookieId, noticeId)) return () => {};\n\n hideOnMobile(bannerContainer);\n showNotice(bannerContainer);\n\n const opts = { collapse: true, ...options };\n\n const collapseUnmountListeners = opts.collapse\n ? setupNoticeCollapse(bannerContainer)\n : () => {};\n\n const closeBtnUnmountListeners = setupCloseBtn(\n bannerContainer,\n cookieId,\n noticeId,\n collapseUnmountListeners,\n );\n\n const resizeUnmountListener = resizeHandler(bannerContainer);\n\n return () => {\n [\n closeBtnUnmountListeners,\n collapseUnmountListeners,\n resizeUnmountListener,\n ].forEach((unmount) => unmount());\n };\n};\n\nexport default Notice;\n"],"names":["Cookie","throttle","queryId","FLASH_DATA_ID","COOKIE_EXPIRY","COLLAPSE_TRIGGER_DISTANCE","SCROLL_LISTENER_THROTTLE","RESIZE_LISTENER_THROTTLE","isMdViewport","window","matchMedia","matches","adjustFlashMargin","open","flash","style","marginTop","hideOnMobile","bannerContainer","display","hideNotice","maxHeight","overflow","showNotice","setupRememberClosed","cookieId","noticeId","cookie","get","set","replace","expires","hasBeenClosedBefore","includes","setupNoticeCollapse","scrollTop","scrollY","listener","document","addEventListener","removeEventListener","setupCloseBtn","collapseUnmountListeners","closeBtn","querySelector","resizeHandler","handler","Notice","options","console","warn","opts","collapse","closeBtnUnmountListeners","resizeUnmountListener","forEach","unmount"],"mappings":"AAAA,OAAOA,WAAY,WAAY,AAC/B,QAAOC,aAAc,iBAAkB,AAEvC,QAASC,OAAO,KAAQ,cAAe,AACvC,QAASC,aAAa,KAAQ,UAAW,CAEzC,MAAMC,cAAgB,GACtB,MAAMC,0BAA4B,EAClC,MAAMC,yBAA2B,IACjC,MAAMC,yBAA2B,IAEjC,MAAMC,aAAe,IAAM,CAACC,OAAOC,UAAU,CAAC,CAAC,kBAAkB,CAAC,EAAEC,OAAO,CAE3E,MAAMC,kBAAoB,AAACC,OAOzB,MAAMC,MAAQZ,QAAQC,eAEtB,GAAIW,MAAO,CACTA,MAAMC,KAAK,CAACC,SAAS,CAAGH,KAAO,CAAC,IAAI,CAAC,CAAG,IAC1C,CACF,EAEA,MAAMI,aAAe,AAACC,kBACpB,GAAIV,eAAgB,CAClBU,gBAAgBH,KAAK,CAACI,OAAO,CAAG,MAClC,KAAO,CACLD,gBAAgBH,KAAK,CAACI,OAAO,CAAG,IAClC,CACF,EAEA,MAAMC,WAAa,AAACF,kBAClBA,gBAAgBH,KAAK,CAACM,SAAS,CAAG,CAClCH,CAAAA,gBAAgBH,KAAK,CAACO,QAAQ,CAAG,SAEjCV,kBAAkB,MACpB,EAEA,MAAMW,WAAa,AAACL,kBAClBA,gBAAgBH,KAAK,CAACM,SAAS,CAAG,IAClCH,CAAAA,gBAAgBH,KAAK,CAACO,QAAQ,CAAG,KAEjCV,kBAAkB,KACpB,EAEA,MAAMY,oBAAsB,CAACC,SAAUC,YACrC,MAAMC,OAAS3B,OAAO4B,GAAG,CAACH,WAAa,GAEvCzB,OAAO6B,GAAG,CAACJ,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AAO,CAAE,IAC9D,GAAI,OAAOvC,SAAW,YAAa,MAAO,KAAO,EAEjD,GAAI,CAACS,gBAAiB,CACpB+B,QAAQC,IAAI,CACV,sEAEF,MAAO,KAAO,CAChB,CAEA,GAAIlB,oBAAoBP,SAAUC,UAAW,MAAO,KAAO,EAE3DT,aAAaC,iBACbK,WAAWL,iBAEX,MAAMiC,KAAO,CAAEC,SAAU,KAAM,GAAGJ,OAAO,AAAC,EAE1C,MAAMN,yBAA2BS,KAAKC,QAAQ,CAC1ClB,oBAAoBhB,iBACpB,KAAO,EAEX,MAAMmC,yBAA2BZ,cAC/BvB,gBACAO,SACAC,SACAgB,0BAGF,MAAMY,sBAAwBT,cAAc3B,iBAE5C,MAAO,KACL,CACEmC,yBACAX,yBACAY,sBACD,CAACC,OAAO,CAAC,AAACC,SAAYA,UACzB,CACF,CAEA,gBAAeT,MAAO"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import React from"react";import cn from"./utils/cn";import Icon from"./Icon";const SegmentedControl=({className,rounded=false,leftIcon,rightIcon,active=false,variant="default",size="md",children,onClick,disabled})=>{const colorStyles={default:{active:"bg-neutral-200 dark:bg-neutral-1100",inactive:"bg-neutral-000 dark:bg-neutral-1300 hover:bg-neutral-100 dark:hover:bg-neutral-1200 active:bg-neutral-100 dark:active:bg-neutral-1200"},subtle:{active:"bg-neutral-000 dark:bg-neutral-1000",inactive:"bg-neutral-100 dark:bg-neutral-1200 hover:bg-neutral-200 dark:hover:bg-neutral-1100 active:bg-neutral-200 dark:active:bg-neutral-1100"},strong:{active:"bg-neutral-1000 dark:bg-neutral-300",inactive:"bg-neutral-100 dark:bg-neutral-1200 hover:bg-neutral-200 dark:hover:bg-neutral-1100 active:bg-neutral-200 dark:active:bg-neutral-1100"}};const contentColorStyles={default:{active:"text-neutral-1300 dark:text-neutral-000",inactive:"text-neutral-1000 dark:text-neutral-300 hover:text-neutral-1300 dark:hover:text-neutral-000"},subtle:{active:"text-neutral-1300 dark:text-neutral-000",inactive:"text-neutral-1000 dark:text-neutral-300 hover:text-neutral-1300 dark:hover:text-neutral-000"},strong:{active:"text-neutral-000 dark:text-neutral-1300",inactive:"text-neutral-1000 dark:text-neutral-300 hover:text-neutral-1300 dark:hover:text-neutral-000"}};const sizeStyles={md:cn("h-48 p-12 gap-[10px]",rounded&&"px-[18px]"),sm:cn("h-40 p-[9px] gap-[9px]",rounded&&"px-[14px]"),xs:cn("h-36 p-8 gap-8",rounded&&"px-12")};const textStyles={md:"ui-text-menu2",sm:"ui-text-menu3",xs:"ui-text-menu4"};const iconSizes={md:"23px",sm:"22px",xs:"20px"};const activeKey=active?"active":"inactive";return React.createElement("div",{onClick:!disabled?onClick:undefined,onKeyDown:e=>{if((e.key==="Enter"||e.key===" ")&&!disabled&&onClick){e.preventDefault();onClick()}},className:cn("focus-base flex items-center justify-center cursor-pointer select-none transition-colors",colorStyles[variant][activeKey],contentColorStyles[variant][activeKey],sizeStyles[size],textStyles[size],disabled&&"cursor-not-allowed hover:bg-inherit dark:hover:bg-inherit active:bg-inherit dark:active:bg-inherit",rounded?"rounded-full":"rounded-lg",className),tabIndex:disabled?-1:0,role:"button","aria-pressed":active,"aria-disabled":disabled},leftIcon&&React.createElement(Icon,{name:leftIcon,size:iconSizes[size],"aria-hidden":"true"}),React.createElement("span",{className:cn("font-semibold transition-colors",contentColorStyles[variant][activeKey],disabled&&"text-gui-unavailable dark:text-gui-unavailable-dark hover:text-gui-unavailable dark:hover:text-gui-unavailable-dark")},children),rightIcon&&React.createElement(Icon,{name:rightIcon,size:iconSizes[size],"aria-hidden":"true"}))};export default SegmentedControl;
|
|
2
|
+
//# sourceMappingURL=SegmentedControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/SegmentedControl.tsx"],"sourcesContent":["import React, { PropsWithChildren } from \"react\";\nimport cn from \"./utils/cn\";\nimport Icon from \"./Icon\";\nimport type { IconName, IconSize } from \"./Icon/types\";\n\nexport type SegmentedControlSize = \"md\" | \"sm\" | \"xs\";\n\nexport type SegmentedControlProps = {\n className?: string;\n rounded?: boolean;\n leftIcon?: IconName;\n rightIcon?: IconName;\n active?: boolean;\n variant?: \"default\" | \"subtle\" | \"strong\";\n size?: SegmentedControlSize;\n onClick?: () => void;\n disabled?: boolean;\n};\n\nconst SegmentedControl: React.FC<PropsWithChildren<SegmentedControlProps>> = ({\n className,\n rounded = false,\n leftIcon,\n rightIcon,\n active = false,\n variant = \"default\",\n size = \"md\",\n children,\n onClick,\n disabled,\n}) => {\n const colorStyles = {\n default: {\n active: \"bg-neutral-200 dark:bg-neutral-1100\",\n inactive:\n \"bg-neutral-000 dark:bg-neutral-1300 hover:bg-neutral-100 dark:hover:bg-neutral-1200 active:bg-neutral-100 dark:active:bg-neutral-1200\",\n },\n subtle: {\n active: \"bg-neutral-000 dark:bg-neutral-1000\",\n inactive:\n \"bg-neutral-100 dark:bg-neutral-1200 hover:bg-neutral-200 dark:hover:bg-neutral-1100 active:bg-neutral-200 dark:active:bg-neutral-1100\",\n },\n strong: {\n active: \"bg-neutral-1000 dark:bg-neutral-300\",\n inactive:\n \"bg-neutral-100 dark:bg-neutral-1200 hover:bg-neutral-200 dark:hover:bg-neutral-1100 active:bg-neutral-200 dark:active:bg-neutral-1100\",\n },\n };\n\n const contentColorStyles = {\n default: {\n active: \"text-neutral-1300 dark:text-neutral-000\",\n inactive:\n \"text-neutral-1000 dark:text-neutral-300 hover:text-neutral-1300 dark:hover:text-neutral-000\",\n },\n subtle: {\n active: \"text-neutral-1300 dark:text-neutral-000\",\n inactive:\n \"text-neutral-1000 dark:text-neutral-300 hover:text-neutral-1300 dark:hover:text-neutral-000\",\n },\n strong: {\n active: \"text-neutral-000 dark:text-neutral-1300\",\n inactive:\n \"text-neutral-1000 dark:text-neutral-300 hover:text-neutral-1300 dark:hover:text-neutral-000\",\n },\n };\n\n const sizeStyles = {\n md: cn(\"h-48 p-12 gap-[10px]\", rounded && \"px-[18px]\"),\n sm: cn(\"h-40 p-[9px] gap-[9px]\", rounded && \"px-[14px]\"),\n xs: cn(\"h-36 p-8 gap-8\", rounded && \"px-12\"),\n };\n\n const textStyles = {\n md: \"ui-text-menu2\",\n sm: \"ui-text-menu3\",\n xs: \"ui-text-menu4\",\n };\n\n const iconSizes: Record<SegmentedControlSize, IconSize> = {\n md: \"23px\",\n sm: \"22px\",\n xs: \"20px\",\n };\n\n const activeKey = active ? \"active\" : \"inactive\";\n\n return (\n <div\n onClick={!disabled ? onClick : undefined}\n onKeyDown={(e) => {\n if ((e.key === \"Enter\" || e.key === \" \") && !disabled && onClick) {\n e.preventDefault();\n onClick();\n }\n }}\n className={cn(\n \"focus-base flex items-center justify-center cursor-pointer select-none transition-colors\",\n colorStyles[variant][activeKey],\n contentColorStyles[variant][activeKey],\n sizeStyles[size],\n textStyles[size],\n disabled &&\n \"cursor-not-allowed hover:bg-inherit dark:hover:bg-inherit active:bg-inherit dark:active:bg-inherit\",\n rounded ? \"rounded-full\" : \"rounded-lg\",\n className,\n )}\n tabIndex={disabled ? -1 : 0}\n role=\"button\"\n aria-pressed={active}\n aria-disabled={disabled}\n >\n {leftIcon && (\n <Icon name={leftIcon} size={iconSizes[size]} aria-hidden=\"true\" />\n )}\n <span\n className={cn(\n \"font-semibold transition-colors\",\n contentColorStyles[variant][activeKey],\n disabled &&\n \"text-gui-unavailable dark:text-gui-unavailable-dark hover:text-gui-unavailable dark:hover:text-gui-unavailable-dark\",\n )}\n >\n {children}\n </span>\n {rightIcon && (\n <Icon name={rightIcon} size={iconSizes[size]} aria-hidden=\"true\" />\n )}\n </div>\n );\n};\n\nexport default SegmentedControl;\n"],"names":["React","cn","Icon","SegmentedControl","className","rounded","leftIcon","rightIcon","active","variant","size","children","onClick","disabled","colorStyles","default","inactive","subtle","strong","contentColorStyles","sizeStyles","md","sm","xs","textStyles","iconSizes","activeKey","div","undefined","onKeyDown","e","key","preventDefault","tabIndex","role","aria-pressed","aria-disabled","name","aria-hidden","span"],"mappings":"A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AACV,KAAK,CAChBc,UAAU,CAACd,KAAK,CAChBG,UACE,qGACFR,QAAU,eAAiB,aAC3BD,WAEF6B,SAAUpB,SAAW,CAAC,EAAI,EAC1BqB,KAAK,SACLC,eAAc3B,OACd4B,gBAAevB,UAEdP,UACC,oBAACJ,MAAKmC,KAAM/B,SAAUI,KAAMe,SAAS,CAACf,KAAK,CAAE4B,cAAY,SAE3D,oBAACC,QACCnC,UAAWH,GACT,kCACAkB,kBAAkB,CAACV,QAAQ,CAACiB,UAAU,CACtCb,UACE,wHAGHF,UAEFJ,WACC,oBAACL,MAAKmC,KAAM9B,UAAWG,KAAMe,SAAS,CAACf,KAAK,CAAE4B,cAAY,SAIlE,CAEA,gBAAenC,gBAAiB"}
|
package/core/SignOutLink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/SignOutLink.tsx"],"sourcesContent":["import React, { MouseEvent, MouseEventHandler, ReactNode, useRef } from \"react\";\nimport { AbsUrl } from \"./
|
|
1
|
+
{"version":3,"sources":["../../src/core/SignOutLink.tsx"],"sourcesContent":["import React, { MouseEvent, MouseEventHandler, ReactNode, useRef } from \"react\";\nimport { AbsUrl } from \"./Meganav\";\n\ntype SignOutLinkProps = {\n token: string;\n href: string;\n text: string;\n children: ({\n href,\n text,\n onClick,\n }: {\n href: string;\n text: string;\n onClick: MouseEventHandler<HTMLAnchorElement>;\n }) => ReactNode;\n absUrl: AbsUrl;\n};\n\nconst SignOutLink = ({\n token,\n href,\n text,\n children,\n absUrl,\n}: SignOutLinkProps) => {\n const formRef = useRef<HTMLFormElement>(null);\n\n const onClick = (e: MouseEvent) => {\n formRef.current?.submit();\n e.preventDefault();\n };\n\n return (\n <>\n <form\n ref={formRef}\n method=\"post\"\n action={absUrl(href)}\n className=\"hidden\"\n >\n <input name=\"_method\" value=\"delete\" type=\"hidden\" />\n <input name=\"authenticity_token\" value={token} type=\"hidden\" />\n </form>\n\n {children({ href, text, onClick })}\n </>\n );\n};\n\nexport default SignOutLink;\n"],"names":["React","useRef","SignOutLink","token","href","text","children","absUrl","formRef","onClick","e","current","submit","preventDefault","form","ref","method","action","className","input","name","value","type"],"mappings":"AAAA,OAAOA,OAAmDC,MAAM,KAAQ,OAAQ,CAmBhF,MAAMC,YAAc,CAAC,CACnBC,KAAK,CACLC,IAAI,CACJC,IAAI,CACJC,QAAQ,CACRC,MAAM,CACW,IACjB,MAAMC,QAAUP,OAAwB,MAExC,MAAMQ,QAAU,AAACC,IACfF,QAAQG,OAAO,EAAEC,SACjBF,EAAEG,cAAc,EAClB,EAEA,OACE,wCACE,oBAACC,QACCC,IAAKP,QACLQ,OAAO,OACPC,OAAQV,OAAOH,MACfc,UAAU,UAEV,oBAACC,SAAMC,KAAK,UAAUC,MAAM,SAASC,KAAK,WAC1C,oBAACH,SAAMC,KAAK,qBAAqBC,MAAOlB,MAAOmB,KAAK,YAGrDhB,SAAS,CAAEF,KAAMC,KAAMI,OAAQ,GAGtC,CAEA,gBAAeP,WAAY"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}import{InsightsService}from"./service";import*as logger from"./logger";export class InsightsCommandQueue{executeInitInsights(config){this.debugMode=!!config.debug;if(this.debugMode){logger.debug("Initializing insights")}this.realImplementation=new InsightsService;this.realImplementation.initInsights(config);this.isInitialized=true;this.processQueue()}processQueue(){if(this.debugMode){logger.debug(`Processing ${this.queue.length} queued commands`)}while(this.queue.length>0){const cmd=this.queue.shift();if(cmd&&this.realImplementation&&typeof this.realImplementation[cmd.methodName]==="function"){try{if(this.debugMode){logger.debug(`Executing queued command: ${cmd.methodName}`,cmd.args)}const fn=this.realImplementation[cmd.methodName];fn.apply(this.realImplementation,cmd.args)}catch(e){if(this.debugMode){logger.error(`Error executing queued command: ${cmd.methodName}`,e)}}}}}initInsights(_config){}enableDebugMode(){}disableDebugMode(){}identify(_identity){}trackPageView(){}track(_event,_properties){}startSessionRecording(){}stopSessionRecording(){}setupObserver(){return()=>{}}constructor(){_define_property(this,"isInitialized",false);_define_property(this,"queue",[]);_define_property(this,"debugMode",false);_define_property(this,"realImplementation",null);return new Proxy(this,{get:(target,prop)=>{if(prop in target&&typeof target[prop]!=="function"){return target[prop]}return(...args)=>{if(!target.isInitialized||!target.realImplementation){if(prop==="initInsights"){target.executeInitInsights(args[0]);return}if(target.debugMode){logger.debug(`Queuing method call: ${String(prop)}`,args)}target.queue.push({methodName:prop,args});return}if(typeof target.realImplementation[prop]==="function"){return target.realImplementation[prop](...args)}}}})}}
|
|
2
|
+
//# sourceMappingURL=command-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/insights/command-queue.ts"],"sourcesContent":["import {\n AnalyticsService,\n Command,\n InsightsConfig,\n InsightsIdentity,\n} from \"./types\";\nimport { InsightsService } from \"./service\";\nimport * as logger from \"./logger\";\n\n// Queue handler that will collect commands before initialization\nexport class InsightsCommandQueue implements AnalyticsService {\n private isInitialized: boolean = false;\n private queue: Command[] = [];\n private debugMode: boolean = false;\n private realImplementation: InsightsService | null = null;\n\n constructor() {\n // Create a proxy that will either queue commands or execute them directly\n return new Proxy(this, {\n get: (target: InsightsCommandQueue, prop: string) => {\n // Return actual properties of the queue\n if (prop in target && typeof target[prop] !== \"function\") {\n return target[prop];\n }\n\n // Return a function that either queues or executes the method call\n return (...args: unknown[]) => {\n if (!target.isInitialized || !target.realImplementation) {\n // Queue the command for later execution\n if (prop === \"initInsights\") {\n // Special handling for initInsights - execute it right away\n target.executeInitInsights(args[0] as InsightsConfig);\n return;\n }\n\n // For debug logging\n if (target.debugMode) {\n logger.debug(`Queuing method call: ${String(prop)}`, args);\n }\n\n target.queue.push({\n methodName: prop as keyof AnalyticsService,\n args,\n });\n\n return;\n }\n\n // Execute the command immediately on the real implementation\n if (typeof target.realImplementation[prop] === \"function\") {\n return target.realImplementation[prop](...args);\n }\n };\n },\n });\n }\n\n // Special handling for init since it needs to happen right away\n private executeInitInsights(config: InsightsConfig): void {\n this.debugMode = !!config.debug;\n\n if (this.debugMode) {\n logger.debug(\"Initializing insights\");\n }\n\n // Create and initialize the real implementation\n this.realImplementation = new InsightsService();\n this.realImplementation.initInsights(config);\n\n // Mark as initialized and process the queue\n this.isInitialized = true;\n this.processQueue();\n }\n\n // Process all queued commands\n private processQueue(): void {\n if (this.debugMode) {\n logger.debug(`Processing ${this.queue.length} queued commands`);\n }\n\n while (this.queue.length > 0) {\n const cmd = this.queue.shift();\n if (\n cmd &&\n this.realImplementation &&\n typeof this.realImplementation[cmd.methodName] === \"function\"\n ) {\n try {\n if (this.debugMode) {\n logger.debug(\n `Executing queued command: ${cmd.methodName}`,\n cmd.args,\n );\n }\n\n const fn = this.realImplementation[cmd.methodName] as (\n ...args: unknown[]\n ) => unknown;\n\n // Execute the command with the real implementation\n fn.apply(this.realImplementation, cmd.args as unknown[]);\n } catch (e) {\n if (this.debugMode) {\n logger.error(\n `Error executing queued command: ${cmd.methodName}`,\n e,\n );\n }\n }\n }\n }\n }\n\n // Implement all methods required by AnalyticsService to satisfy TypeScript\n // (These won't be called directly due to the proxy)\n initInsights(_config: InsightsConfig): void {}\n enableDebugMode(): void {}\n disableDebugMode(): void {}\n identify(_identity: InsightsIdentity): void {}\n trackPageView(): void {}\n track(_event: string, _properties?: Record<string, unknown>): void {}\n startSessionRecording(): void {}\n stopSessionRecording(): void {}\n setupObserver(): () => void {\n return () => {};\n }\n}\n"],"names":["InsightsService","logger","InsightsCommandQueue","executeInitInsights","config","debugMode","debug","realImplementation","initInsights","isInitialized","processQueue","queue","length","cmd","shift","methodName","args","fn","apply","e","error","_config","enableDebugMode","disableDebugMode","identify","_identity","trackPageView","track","_event","_properties","startSessionRecording","stopSessionRecording","setupObserver","constructor","Proxy","get","target","prop","String","push"],"mappings":"oLAMA,OAASA,eAAe,KAAQ,WAAY,AAC5C,WAAYC,WAAY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zBC,kBAAyB,CAAC,CAC1BC,SAASC,SAA2B,CAAQ,CAAC,CAC7CC,eAAsB,CAAC,CACvBC,MAAMC,MAAc,CAAEC,WAAqC,CAAQ,CAAC,CACpEC,uBAA8B,CAAC,CAC/BC,sBAA6B,CAAC,CAC9BC,eAA4B,CAC1B,MAAO,KAAO,CAChB,CA7GAC,aAAc,CALd,sBAAQxB,gBAAyB,OACjC,sBAAQE,QAAmB,EAAE,EAC7B,sBAAQN,YAAqB,OAC7B,sBAAQE,qBAA6C,MAInD,OAAO,IAAI2B,MAAM,IAAI,CAAE,CACrBC,IAAK,CAACC,OAA8BC,QAElC,GAAIA,QAAQD,QAAU,OAAOA,MAAM,CAACC,KAAK,GAAK,WAAY,CACxD,OAAOD,MAAM,CAACC,KAAK,AACrB,CAGA,MAAO,CAAC,GAAGrB,QACT,GAAI,CAACoB,OAAO3B,aAAa,EAAI,CAAC2B,OAAO7B,kBAAkB,CAAE,CAEvD,GAAI8B,OAAS,eAAgB,CAE3BD,OAAOjC,mBAAmB,CAACa,IAAI,CAAC,EAAE,EAClC,MACF,CAGA,GAAIoB,OAAO/B,SAAS,CAAE,CACpBJ,OAAOK,KAAK,CAAC,CAAC,qBAAqB,EAAEgC,OAAOD,MAAM,CAAC,CAAErB,KACvD,CAEAoB,OAAOzB,KAAK,CAAC4B,IAAI,CAAC,CAChBxB,WAAYsB,KACZrB,IACF,GAEA,MACF,CAGA,GAAI,OAAOoB,OAAO7B,kBAAkB,CAAC8B,KAAK,GAAK,WAAY,CACzD,OAAOD,OAAO7B,kBAAkB,CAAC8B,KAAK,IAAIrB,KAC5C,CACF,CACF,CACF,EACF,CAuEF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/insights/datalayer.ts"],"sourcesContent":["declare global {\n interface Window {\n dataLayer: unknown[];\n }\n}\n\nexport const track = (event: string, properties?: Record<string, unknown>) => {\n if (typeof window === \"undefined\") {\n return;\n }\n\n const dataLayer = window.dataLayer || [];\n window.dataLayer = dataLayer;\n\n window.dataLayer.push({\n event,\n ...properties,\n });\n};\n"],"names":["track","event","properties","window","dataLayer","push"],"mappings":"AAMA,OAAO,MAAMA,MAAQ,CAACC,MAAeC,cACnC,GAAI,OAAOC,SAAW,YAAa,CACjC,MACF,CAEA,MAAMC,UAAYD,OAAOC,SAAS,EAAI,EAAE,AACxCD,CAAAA,OAAOC,SAAS,CAAGA,UAEnBD,OAAOC,SAAS,CAACC,IAAI,CAAC,CACpBJ,MACA,GAAGC,UAAU,AACf,EACF,CAAE"}
|
package/core/insights/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{InsightsCommandQueue}from"./command-queue";const insights=new InsightsCommandQueue;export const initInsights=config=>insights.initInsights(config);export const enableDebugMode=()=>insights.enableDebugMode();export const disableDebugMode=()=>insights.disableDebugMode();export const identify=identity=>insights.identify(identity);export const trackPageView=()=>insights.trackPageView();export const track=(event,properties)=>insights.track(event,properties);export const startSessionRecording=()=>insights.startSessionRecording();export const stopSessionRecording=()=>insights.stopSessionRecording();export const setupObserver=()=>insights.setupObserver();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/insights/index.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/core/insights/index.ts"],"sourcesContent":["import { InsightsConfig, InsightsIdentity } from \"./types\";\nimport { InsightsCommandQueue } from \"./command-queue\";\nexport type { InsightsConfig };\n\n// Hi and welcome 👋\n//\n// The insights code is written using a Command Queue, or Deferred Execution pattern.\n// This pattern is useful when you need to queue up actions that should wait until\n// some initialization is complete. In this case, we want to queue up all the analytics\n// commands until the analytics service is initialized. This way, we can ensure that\n// no analytics events are lost during the initialization process. It looks wildly\n// different than other parts of Ably UI, but if you squint you realise it looks very\n// much like the services it's wrapping.\n//\n// There are three pieces working together here:\n// - The `AnalyticsService` interface, which defines the public methods that the insights\n// service will expose.\n// - The `InsightsCommandQueue` class, which is the main entry point for the insights\n// service. It acts as a proxy that will either queue up commands or execute\n// them directly on the real implementation.\n// - The `InsightsService` class, which is the real implementation that will be used\n// after initialization. It's responsible for initializing the underlying analytics\n// services (Mixpanel, Posthog & the data layer) and executing the queued commands.\n\n// Create the singleton instance with the command queue pattern\nconst insights = new InsightsCommandQueue();\n\n// Export the methods with the same interface as before\nexport const initInsights = (config: InsightsConfig) =>\n insights.initInsights(config);\nexport const enableDebugMode = () => insights.enableDebugMode();\nexport const disableDebugMode = () => insights.disableDebugMode();\nexport const identify = (identity: InsightsIdentity) =>\n insights.identify(identity);\nexport const trackPageView = () => insights.trackPageView();\nexport const track = (event: string, properties?: Record<string, unknown>) =>\n insights.track(event, properties);\nexport const startSessionRecording = () => insights.startSessionRecording();\nexport const stopSessionRecording = () => insights.stopSessionRecording();\nexport const setupObserver = () => insights.setupObserver();\n"],"names":["InsightsCommandQueue","insights","initInsights","config","enableDebugMode","disableDebugMode","identify","identity","trackPageView","track","event","properties","startSessionRecording","stopSessionRecording","setupObserver"],"mappings":"AACA,OAASA,oBAAoB,KAAQ,iBAAkB,CAwBvD,MAAMC,SAAW,IAAID,oBAGrB,QAAO,MAAME,aAAe,AAACC,QAC3BF,SAASC,YAAY,CAACC,OAAQ,AAChC,QAAO,MAAMC,gBAAkB,IAAMH,SAASG,eAAe,EAAG,AAChE,QAAO,MAAMC,iBAAmB,IAAMJ,SAASI,gBAAgB,EAAG,AAClE,QAAO,MAAMC,SAAW,AAACC,UACvBN,SAASK,QAAQ,CAACC,SAAU,AAC9B,QAAO,MAAMC,cAAgB,IAAMP,SAASO,aAAa,EAAG,AAC5D,QAAO,MAAMC,MAAQ,CAACC,MAAeC,aACnCV,SAASQ,KAAK,CAACC,MAAOC,WAAY,AACpC,QAAO,MAAMC,sBAAwB,IAAMX,SAASW,qBAAqB,EAAG,AAC5E,QAAO,MAAMC,qBAAuB,IAAMZ,SAASY,oBAAoB,EAAG,AAC1E,QAAO,MAAMC,cAAgB,IAAMb,SAASa,aAAa,EAAG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{describe,expect,beforeEach,afterEach,it,vi}from"vitest";import*as datalayer from"./datalayer";import*as mixpanel from"./mixpanel";import*as posthog from"./posthog";import*as logger from"./logger";import*as insights from"./index";vi.mock("./datalayer",()=>({track:vi.fn()}));vi.mock("./mixpanel",()=>({initMixpanel:vi.fn(),enableDebugMode:vi.fn(),disableDebugMode:vi.fn(),identify:vi.fn(),trackPageView:vi.fn(),track:vi.fn(),startSessionRecording:vi.fn(),stopSessionRecording:vi.fn()}));vi.mock("./posthog",()=>({initPosthog:vi.fn(),enableDebugMode:vi.fn(),disableDebugMode:vi.fn(),identify:vi.fn(),trackPageView:vi.fn(),track:vi.fn(),startSessionRecording:vi.fn(),stopSessionRecording:vi.fn()}));vi.mock("./logger",()=>({debug:vi.fn(),info:vi.fn(),warn:vi.fn(),error:vi.fn()}));describe("Insights Command Queue",()=>{const testConfig={debug:true,mixpanelToken:"test-token",mixpanelAutoCapture:false,mixpanelRecordSessionsPercent:10,posthogApiKey:"test-key",posthogApiHost:"test-host"};const testIdentity={userId:"user-123",accountId:"account-456",organisationId:"org-789",email:"test@example.com",name:"Test User"};beforeEach(()=>{vi.clearAllMocks();vi.resetModules()});afterEach(()=>{document.body.replaceWith(document.body.cloneNode(true))});describe("Pre-initialization Queueing",()=>{it("should queue methods called before initialization",async()=>{insights.track("early_event",{early:true});insights.identify(testIdentity);insights.trackPageView();expect(mixpanel.track).not.toHaveBeenCalled();expect(posthog.track).not.toHaveBeenCalled();expect(datalayer.track).not.toHaveBeenCalled();expect(mixpanel.identify).not.toHaveBeenCalled();expect(posthog.identify).not.toHaveBeenCalled();expect(mixpanel.trackPageView).not.toHaveBeenCalled();expect(posthog.trackPageView).not.toHaveBeenCalled();insights.initInsights(testConfig);expect(mixpanel.initMixpanel).toHaveBeenCalledWith(testConfig.mixpanelToken,testConfig.mixpanelAutoCapture,testConfig.debug,testConfig.mixpanelRecordSessionsPercent);expect(posthog.initPosthog).toHaveBeenCalledWith(testConfig.posthogApiKey,testConfig.posthogApiHost);expect(mixpanel.track).toHaveBeenCalledWith("early_event",{early:true});expect(posthog.track).toHaveBeenCalledWith("early_event",{early:true});expect(datalayer.track).toHaveBeenCalledWith("early_event",{early:true});expect(mixpanel.identify).toHaveBeenCalledWith(testIdentity);expect(posthog.identify).toHaveBeenCalledWith(testIdentity);expect(mixpanel.trackPageView).toHaveBeenCalled();expect(posthog.trackPageView).toHaveBeenCalled()});it("should handle errors in queued methods gracefully",async()=>{mixpanel.track.mockImplementationOnce(()=>{throw new Error("Mixpanel error")});insights.track("error_event",{error:true});insights.trackPageView();insights.initInsights(testConfig);expect(logger.error).toHaveBeenCalledWith(expect.stringContaining("Failed to track event in Mixpanel"),expect.any(Error));expect(posthog.track).toHaveBeenCalledWith("error_event",{error:true});expect(datalayer.track).toHaveBeenCalledWith("error_event",{error:true});expect(mixpanel.trackPageView).toHaveBeenCalled();expect(posthog.trackPageView).toHaveBeenCalled()})});describe("Post-initialization Direct Execution",()=>{beforeEach(()=>{insights.initInsights(testConfig);vi.clearAllMocks()});it("should directly call methods after initialization",()=>{insights.track("post_init_event",{post:true});expect(mixpanel.track).toHaveBeenCalledWith("post_init_event",{post:true});expect(posthog.track).toHaveBeenCalledWith("post_init_event",{post:true});expect(datalayer.track).toHaveBeenCalledWith("post_init_event",{post:true})});it("should handle all exported methods correctly",()=>{insights.identify(testIdentity);expect(mixpanel.identify).toHaveBeenCalledWith(testIdentity);expect(posthog.identify).toHaveBeenCalledWith(testIdentity);insights.trackPageView();expect(mixpanel.trackPageView).toHaveBeenCalled();expect(posthog.trackPageView).toHaveBeenCalled();insights.startSessionRecording();expect(mixpanel.startSessionRecording).toHaveBeenCalled();expect(posthog.startSessionRecording).toHaveBeenCalled();insights.stopSessionRecording();expect(mixpanel.stopSessionRecording).toHaveBeenCalled();expect(posthog.stopSessionRecording).toHaveBeenCalled();insights.enableDebugMode();expect(mixpanel.enableDebugMode).toHaveBeenCalled();expect(posthog.enableDebugMode).toHaveBeenCalled();insights.disableDebugMode();expect(mixpanel.disableDebugMode).toHaveBeenCalled();expect(posthog.disableDebugMode).toHaveBeenCalled()})});describe("Observer Setup",()=>{beforeEach(()=>{insights.initInsights(testConfig);vi.clearAllMocks()});it("should set up click event observer and track clicks",()=>{const cleanup=insights.setupObserver();const testElement=document.createElement("button");testElement.setAttribute("data-insight-event","button_clicked");testElement.setAttribute("data-insight-button-id","test-123");document.body.appendChild(testElement);testElement.click();expect(mixpanel.track).toHaveBeenCalledWith("button_clicked",{buttonId:"test-123"});expect(posthog.track).toHaveBeenCalledWith("button_clicked",{buttonId:"test-123"});expect(datalayer.track).toHaveBeenCalledWith("button_clicked",{buttonId:"test-123"});cleanup();vi.clearAllMocks();testElement.click();expect(mixpanel.track).not.toHaveBeenCalled()});it("should handle nested elements correctly",()=>{insights.setupObserver();const parentElement=document.createElement("div");parentElement.setAttribute("data-insight-event","container_clicked");parentElement.setAttribute("data-insight-container-id","parent-container");const childElement=document.createElement("span");childElement.textContent="Click me";parentElement.appendChild(childElement);document.body.appendChild(parentElement);childElement.click();expect(mixpanel.track).toHaveBeenCalledWith("container_clicked",{containerId:"parent-container"})})});describe("Error Handling",()=>{it("should handle initialization errors gracefully",()=>{mixpanel.initMixpanel.mockImplementationOnce(()=>{throw new Error("Mixpanel init error")});expect(()=>{insights.initInsights(testConfig)}).not.toThrow();expect(logger.error).toHaveBeenCalledWith(expect.stringContaining("Failed to initialize Mixpanel"),expect.any(Error))});it("should handle runtime errors in methods",()=>{insights.initInsights(testConfig);vi.clearAllMocks();mixpanel.track.mockImplementationOnce(()=>{throw new Error("Mixpanel track error")});posthog.track.mockImplementationOnce(()=>{throw new Error("Posthog track error")});expect(()=>{insights.track("error_test",{test:true})}).not.toThrow();expect(logger.error).toHaveBeenCalledWith(expect.stringContaining("Failed to track event in Mixpanel"),expect.any(Error));expect(logger.error).toHaveBeenCalledWith(expect.stringContaining("Failed to track event in Posthog"),expect.any(Error));expect(datalayer.track).toHaveBeenCalledWith("error_test",{test:true})})});describe("Debug Mode",()=>{it("should respect debug flag in config",()=>{insights.initInsights(testConfig);expect(logger.debug).toHaveBeenCalledWith(expect.stringContaining("Initializing insights"));vi.clearAllMocks();insights.track("debug_test",{debug:true});expect(logger.info).toHaveBeenCalledWith(expect.stringContaining("Tracking event"),expect.objectContaining({event:"debug_test",properties:{debug:true}}))});it("should not log debug info when debug is false",()=>{insights.initInsights({...testConfig,debug:false});vi.clearAllMocks();insights.track("no_debug_test",{debug:false});expect(logger.info).not.toHaveBeenCalled()})})});
|
|
2
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/insights/index.test.ts"],"sourcesContent":["/**\n * @vitest-environment jsdom\n */\n\nimport { describe, expect, beforeEach, afterEach, it, vi } from \"vitest\";\n\nimport * as datalayer from \"./datalayer\";\nimport * as mixpanel from \"./mixpanel\";\nimport * as posthog from \"./posthog\";\nimport * as logger from \"./logger\";\nimport * as insights from \"./index\";\n\n// Mock the dependencies\nvi.mock(\"./datalayer\", () => ({\n track: vi.fn(),\n}));\n\nvi.mock(\"./mixpanel\", () => ({\n initMixpanel: vi.fn(),\n enableDebugMode: vi.fn(),\n disableDebugMode: vi.fn(),\n identify: vi.fn(),\n trackPageView: vi.fn(),\n track: vi.fn(),\n startSessionRecording: vi.fn(),\n stopSessionRecording: vi.fn(),\n}));\n\nvi.mock(\"./posthog\", () => ({\n initPosthog: vi.fn(),\n enableDebugMode: vi.fn(),\n disableDebugMode: vi.fn(),\n identify: vi.fn(),\n trackPageView: vi.fn(),\n track: vi.fn(),\n startSessionRecording: vi.fn(),\n stopSessionRecording: vi.fn(),\n}));\n\nvi.mock(\"./logger\", () => ({\n debug: vi.fn(),\n info: vi.fn(),\n warn: vi.fn(),\n error: vi.fn(),\n}));\n\ndescribe(\"Insights Command Queue\", () => {\n const testConfig = {\n debug: true,\n mixpanelToken: \"test-token\",\n mixpanelAutoCapture: false,\n mixpanelRecordSessionsPercent: 10,\n posthogApiKey: \"test-key\",\n posthogApiHost: \"test-host\",\n };\n\n const testIdentity = {\n userId: \"user-123\",\n accountId: \"account-456\",\n organisationId: \"org-789\",\n email: \"test@example.com\",\n name: \"Test User\",\n };\n\n beforeEach(() => {\n // Clear all mocks before each test\n vi.clearAllMocks();\n\n // Reset the module to clear any internal state\n vi.resetModules();\n });\n\n afterEach(() => {\n // Cleanup document event listeners\n document.body.replaceWith(document.body.cloneNode(true));\n });\n\n describe(\"Pre-initialization Queueing\", () => {\n it(\"should queue methods called before initialization\", async () => {\n // Call methods before initialization\n insights.track(\"early_event\", { early: true });\n insights.identify(testIdentity);\n insights.trackPageView();\n\n // Verify nothing has been called yet on the underlying services\n expect(mixpanel.track).not.toHaveBeenCalled();\n expect(posthog.track).not.toHaveBeenCalled();\n expect(datalayer.track).not.toHaveBeenCalled();\n expect(mixpanel.identify).not.toHaveBeenCalled();\n expect(posthog.identify).not.toHaveBeenCalled();\n expect(mixpanel.trackPageView).not.toHaveBeenCalled();\n expect(posthog.trackPageView).not.toHaveBeenCalled();\n\n // Now initialize\n insights.initInsights(testConfig);\n\n // Initialize should be called immediately\n expect(mixpanel.initMixpanel).toHaveBeenCalledWith(\n testConfig.mixpanelToken,\n testConfig.mixpanelAutoCapture,\n testConfig.debug,\n testConfig.mixpanelRecordSessionsPercent,\n );\n expect(posthog.initPosthog).toHaveBeenCalledWith(\n testConfig.posthogApiKey,\n testConfig.posthogApiHost,\n );\n\n // Queued methods should now be called in the correct order\n expect(mixpanel.track).toHaveBeenCalledWith(\"early_event\", {\n early: true,\n });\n expect(posthog.track).toHaveBeenCalledWith(\"early_event\", {\n early: true,\n });\n expect(datalayer.track).toHaveBeenCalledWith(\"early_event\", {\n early: true,\n });\n\n expect(mixpanel.identify).toHaveBeenCalledWith(testIdentity);\n expect(posthog.identify).toHaveBeenCalledWith(testIdentity);\n\n expect(mixpanel.trackPageView).toHaveBeenCalled();\n expect(posthog.trackPageView).toHaveBeenCalled();\n });\n\n it(\"should handle errors in queued methods gracefully\", async () => {\n // Setup an error for one of the methods\n mixpanel.track.mockImplementationOnce(() => {\n throw new Error(\"Mixpanel error\");\n });\n\n // Call methods before initialization\n insights.track(\"error_event\", { error: true });\n insights.trackPageView();\n\n // Now initialize\n insights.initInsights(testConfig);\n\n // Should have logged the error but continued processing the queue\n expect(logger.error).toHaveBeenCalledWith(\n expect.stringContaining(\"Failed to track event in Mixpanel\"),\n expect.any(Error),\n );\n\n // The other methods should still be called\n expect(posthog.track).toHaveBeenCalledWith(\"error_event\", {\n error: true,\n });\n expect(datalayer.track).toHaveBeenCalledWith(\"error_event\", {\n error: true,\n });\n expect(mixpanel.trackPageView).toHaveBeenCalled();\n expect(posthog.trackPageView).toHaveBeenCalled();\n });\n });\n\n describe(\"Post-initialization Direct Execution\", () => {\n beforeEach(() => {\n // Initialize first\n insights.initInsights(testConfig);\n // Clear the mocks to focus on post-init behavior\n vi.clearAllMocks();\n });\n\n it(\"should directly call methods after initialization\", () => {\n // Call methods after initialization\n insights.track(\"post_init_event\", { post: true });\n\n // Should be called immediately\n expect(mixpanel.track).toHaveBeenCalledWith(\"post_init_event\", {\n post: true,\n });\n expect(posthog.track).toHaveBeenCalledWith(\"post_init_event\", {\n post: true,\n });\n expect(datalayer.track).toHaveBeenCalledWith(\"post_init_event\", {\n post: true,\n });\n });\n\n it(\"should handle all exported methods correctly\", () => {\n // Test each exported method\n insights.identify(testIdentity);\n expect(mixpanel.identify).toHaveBeenCalledWith(testIdentity);\n expect(posthog.identify).toHaveBeenCalledWith(testIdentity);\n\n insights.trackPageView();\n expect(mixpanel.trackPageView).toHaveBeenCalled();\n expect(posthog.trackPageView).toHaveBeenCalled();\n\n insights.startSessionRecording();\n expect(mixpanel.startSessionRecording).toHaveBeenCalled();\n expect(posthog.startSessionRecording).toHaveBeenCalled();\n\n insights.stopSessionRecording();\n expect(mixpanel.stopSessionRecording).toHaveBeenCalled();\n expect(posthog.stopSessionRecording).toHaveBeenCalled();\n\n insights.enableDebugMode();\n expect(mixpanel.enableDebugMode).toHaveBeenCalled();\n expect(posthog.enableDebugMode).toHaveBeenCalled();\n\n insights.disableDebugMode();\n expect(mixpanel.disableDebugMode).toHaveBeenCalled();\n expect(posthog.disableDebugMode).toHaveBeenCalled();\n });\n });\n\n describe(\"Observer Setup\", () => {\n beforeEach(() => {\n insights.initInsights(testConfig);\n vi.clearAllMocks();\n });\n\n it(\"should set up click event observer and track clicks\", () => {\n // Setup observer\n const cleanup = insights.setupObserver();\n\n // Create a test element with insight attributes\n const testElement = document.createElement(\"button\");\n testElement.setAttribute(\"data-insight-event\", \"button_clicked\");\n testElement.setAttribute(\"data-insight-button-id\", \"test-123\");\n document.body.appendChild(testElement);\n\n // Simulate click\n testElement.click();\n\n // Should track the event\n expect(mixpanel.track).toHaveBeenCalledWith(\"button_clicked\", {\n buttonId: \"test-123\",\n });\n expect(posthog.track).toHaveBeenCalledWith(\"button_clicked\", {\n buttonId: \"test-123\",\n });\n expect(datalayer.track).toHaveBeenCalledWith(\"button_clicked\", {\n buttonId: \"test-123\",\n });\n\n // Test cleanup\n cleanup();\n\n // Reset tracking mocks\n vi.clearAllMocks();\n\n // Click again - should not track\n testElement.click();\n expect(mixpanel.track).not.toHaveBeenCalled();\n });\n\n it(\"should handle nested elements correctly\", () => {\n // Setup observer\n insights.setupObserver();\n\n // Create parent element with insight attributes\n const parentElement = document.createElement(\"div\");\n parentElement.setAttribute(\"data-insight-event\", \"container_clicked\");\n parentElement.setAttribute(\n \"data-insight-container-id\",\n \"parent-container\",\n );\n\n // Create child element without insights\n const childElement = document.createElement(\"span\");\n childElement.textContent = \"Click me\";\n\n // Nest elements\n parentElement.appendChild(childElement);\n document.body.appendChild(parentElement);\n\n // Click the child element\n childElement.click();\n\n // Should find and use the parent's insight attributes\n expect(mixpanel.track).toHaveBeenCalledWith(\"container_clicked\", {\n containerId: \"parent-container\",\n });\n });\n });\n\n describe(\"Error Handling\", () => {\n it(\"should handle initialization errors gracefully\", () => {\n // Setup an error in initialization\n mixpanel.initMixpanel.mockImplementationOnce(() => {\n throw new Error(\"Mixpanel init error\");\n });\n\n // Should not throw when initializing\n expect(() => {\n insights.initInsights(testConfig);\n }).not.toThrow();\n\n // Should log the error\n expect(logger.error).toHaveBeenCalledWith(\n expect.stringContaining(\"Failed to initialize Mixpanel\"),\n expect.any(Error),\n );\n });\n\n it(\"should handle runtime errors in methods\", () => {\n // Initialize first\n insights.initInsights(testConfig);\n vi.clearAllMocks();\n\n // Setup errors in tracking\n mixpanel.track.mockImplementationOnce(() => {\n throw new Error(\"Mixpanel track error\");\n });\n\n posthog.track.mockImplementationOnce(() => {\n throw new Error(\"Posthog track error\");\n });\n\n // Should not throw when tracking\n expect(() => {\n insights.track(\"error_test\", { test: true });\n }).not.toThrow();\n\n // Should log the errors\n expect(logger.error).toHaveBeenCalledWith(\n expect.stringContaining(\"Failed to track event in Mixpanel\"),\n expect.any(Error),\n );\n\n expect(logger.error).toHaveBeenCalledWith(\n expect.stringContaining(\"Failed to track event in Posthog\"),\n expect.any(Error),\n );\n\n // Should still try to track with datalayer\n expect(datalayer.track).toHaveBeenCalledWith(\"error_test\", {\n test: true,\n });\n });\n });\n\n describe(\"Debug Mode\", () => {\n it(\"should respect debug flag in config\", () => {\n // Initialize with debug: true\n insights.initInsights(testConfig);\n\n // Should log debug messages\n expect(logger.debug).toHaveBeenCalledWith(\n expect.stringContaining(\"Initializing insights\"),\n );\n\n // Clear mocks and test tracking\n vi.clearAllMocks();\n insights.track(\"debug_test\", { debug: true });\n\n // Should log info about tracking\n expect(logger.info).toHaveBeenCalledWith(\n expect.stringContaining(\"Tracking event\"),\n expect.objectContaining({\n event: \"debug_test\",\n properties: { debug: true },\n }),\n );\n });\n\n it(\"should not log debug info when debug is false\", () => {\n // Initialize with debug: false\n insights.initInsights({\n ...testConfig,\n debug: false,\n });\n\n // Clear mocks and test tracking\n vi.clearAllMocks();\n insights.track(\"no_debug_test\", { debug: false });\n\n // Should not log info about tracking\n expect(logger.info).not.toHaveBeenCalled();\n });\n });\n});\n"],"names":["describe","expect","beforeEach","afterEach","it","vi","datalayer","mixpanel","posthog","logger","insights","mock","track","fn","initMixpanel","enableDebugMode","disableDebugMode","identify","trackPageView","startSessionRecording","stopSessionRecording","initPosthog","debug","info","warn","error","testConfig","mixpanelToken","mixpanelAutoCapture","mixpanelRecordSessionsPercent","posthogApiKey","posthogApiHost","testIdentity","userId","accountId","organisationId","email","name","clearAllMocks","resetModules","document","body","replaceWith","cloneNode","early","not","toHaveBeenCalled","initInsights","toHaveBeenCalledWith","mockImplementationOnce","Error","stringContaining","any","post","cleanup","setupObserver","testElement","createElement","setAttribute","appendChild","click","buttonId","parentElement","childElement","textContent","containerId","toThrow","test","objectContaining","event","properties"],"mappings":"AAIA,OAASA,QAAQ,CAAEC,MAAM,CAAEC,UAAU,CAAEC,SAAS,CAAEC,EAAE,CAAEC,EAAE,KAAQ,QAAS,AAEzE,WAAYC,cAAe,aAAc,AACzC,WAAYC,aAAc,YAAa,AACvC,WAAYC,YAAa,WAAY,AACrC,WAAYC,WAAY,UAAW,AACnC,WAAYC,aAAc,SAAU,CAGpCL,GAAGM,IAAI,CAAC,cAAe,IAAO,CAAA,CAC5BC,MAAOP,GAAGQ,EAAE,EACd,CAAA,GAEAR,GAAGM,IAAI,CAAC,aAAc,IAAO,CAAA,CAC3BG,aAAcT,GAAGQ,EAAE,GACnBE,gBAAiBV,GAAGQ,EAAE,GACtBG,iBAAkBX,GAAGQ,EAAE,GACvBI,SAAUZ,GAAGQ,EAAE,GACfK,cAAeb,GAAGQ,EAAE,GACpBD,MAAOP,GAAGQ,EAAE,GACZM,sBAAuBd,GAAGQ,EAAE,GAC5BO,qBAAsBf,GAAGQ,EAAE,EAC7B,CAAA,GAEAR,GAAGM,IAAI,CAAC,YAAa,IAAO,CAAA,CAC1BU,YAAahB,GAAGQ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aACPC,WAAY,CAAEhD,MAAO,IAAK,CAC5B,GAEJ,GAEAlB,GAAG,gDAAiD,KAElDM,SAASqC,YAAY,CAAC,CACpB,GAAGrB,UAAU,CACbJ,MAAO,KACT,GAGAjB,GAAGiC,aAAa,GAChB5B,SAASE,KAAK,CAAC,gBAAiB,CAAEU,MAAO,KAAM,GAG/CrB,OAAOQ,OAAOc,IAAI,EAAEsB,GAAG,CAACC,gBAAgB,EAC1C,EACF,EACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const styles=[`background: #ff5416`,`border-radius: 0.5em`,`color: white`,`font-weight: bold`,`padding: 2px 0.5em`].join(";");export const debug=(...args)=>{console.debug(`%cinsights`,styles,...args)};export const info=(...args)=>{console.info(`%cinsights`,styles,...args)};export const warn=(...args)=>{console.warn(`%cinsights`,styles,...args)};export const error=(...args)=>{console.error(`%cinsights`,styles,...args)};
|
|
2
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/insights/logger.ts"],"sourcesContent":["// Inspired by Gatsby's logging\n\nconst styles = [\n `background: #ff5416`, // orange-600\n `border-radius: 0.5em`,\n `color: white`,\n `font-weight: bold`,\n `padding: 2px 0.5em`,\n].join(\";\");\n\nexport const debug = (...args: unknown[]) => {\n console.debug(`%cinsights`, styles, ...args);\n};\n\nexport const info = (...args: unknown[]) => {\n console.info(`%cinsights`, styles, ...args);\n};\n\nexport const warn = (...args: unknown[]) => {\n console.warn(`%cinsights`, styles, ...args);\n};\n\nexport const error = (...args: unknown[]) => {\n console.error(`%cinsights`, styles, ...args);\n};\n"],"names":["styles","join","debug","args","console","info","warn","error"],"mappings":"AAEA,MAAMA,OAAS,CACb,CAAC,mBAAmB,CAAC,CACrB,CAAC,oBAAoB,CAAC,CACtB,CAAC,YAAY,CAAC,CACd,CAAC,iBAAiB,CAAC,CACnB,CAAC,kBAAkB,CAAC,CACrB,CAACC,IAAI,CAAC,IAEP,QAAO,MAAMC,MAAQ,CAAC,GAAGC,QACvBC,QAAQF,KAAK,CAAC,CAAC,UAAU,CAAC,CAAEF,UAAWG,KACzC,CAAE,AAEF,QAAO,MAAME,KAAO,CAAC,GAAGF,QACtBC,QAAQC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAEL,UAAWG,KACxC,CAAE,AAEF,QAAO,MAAMG,KAAO,CAAC,GAAGH,QACtBC,QAAQE,IAAI,CAAC,CAAC,UAAU,CAAC,CAAEN,UAAWG,KACxC,CAAE,AAEF,QAAO,MAAMI,MAAQ,CAAC,GAAGJ,QACvBC,QAAQG,KAAK,CAAC,CAAC,UAAU,CAAC,CAAEP,UAAWG,KACzC,CAAE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import mixpanel from"mixpanel-browser";export const initMixpanel=(token,autoCapture=false,debug=false)=>{const blockSelectors=["[ph-no-capture]",'[data-sl="mask"]'];if(!token){console.warn("Mixpanel token not provided, skipping initialization");return}mixpanel.init(token,{debug:debug,persistence:"localStorage",autocapture:autoCapture?{block_selectors:blockSelectors}:false,track_pageview:false})};export const enableDebugMode=()=>{mixpanel.set_config({debug:true})};export const disableDebugMode=()=>{mixpanel.set_config({debug:false})};export const identify=({userId,accountId,organisationId,email,name})=>{if(!userId){return}mixpanel.identify(userId);if(email||name){mixpanel.people.set({$email:email,$name:name})}if(accountId){mixpanel.people.union({
|
|
1
|
+
import mixpanel from"mixpanel-browser";export const initMixpanel=(token,autoCapture=false,debug=false,recordSessionsPercent=1)=>{const blockSelectors=["[ph-no-capture]",'[data-sl="mask"]'];if(!token){console.warn("Mixpanel token not provided, skipping initialization");return}mixpanel.init(token,{debug:debug,persistence:"localStorage",autocapture:autoCapture?{block_selectors:blockSelectors,capture_text_content:true}:false,track_pageview:false,record_sessions_percent:recordSessionsPercent,record_mask_text_selector:null})};export const enableDebugMode=()=>{mixpanel.set_config({debug:true})};export const disableDebugMode=()=>{mixpanel.set_config({debug:false})};export const identify=({userId,accountId,organisationId,email,name})=>{if(!userId){return}mixpanel.identify(userId.toString());if(email||name){mixpanel.people.set({$email:email,$name:name})}if(accountId){mixpanel.people.union({accounts:[accountId.toString()]})}if(organisationId){mixpanel.people.set({organization_id:[organisationId.toString()]})}};const redactUrlSegments=()=>{const pathSegments=window.location.pathname.split("/");const redactedSegments=pathSegments.map(segment=>{return/^\d+$/.test(segment)?"{redacted}":segment});const url=new URL(window.location.href);url.pathname=redactedSegments.join("/");return decodeURI(url.toString()).toLowerCase()};export const trackPageView=()=>{mixpanel.track_pageview({redacted_path:redactUrlSegments()})};export const track=(event,properties)=>{mixpanel.track(event,properties)};export const startSessionRecording=()=>{mixpanel.start_session_recording()};export const stopSessionRecording=()=>{mixpanel.stop_session_recording()};
|
|
2
2
|
//# sourceMappingURL=mixpanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/insights/mixpanel.ts"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nimport { InsightsIdentity } from \"./types\";\n\nexport const initMixpanel = (\n token: string,\n autoCapture: boolean = false,\n debug: boolean = false,\n) => {\n const blockSelectors = [\"[ph-no-capture]\", '[data-sl=\"mask\"]'];\n if (!token) {\n console.warn(\"Mixpanel token not provided, skipping initialization\");\n return;\n }\n\n mixpanel.init(token, {\n debug: debug,\n persistence: \"localStorage\",\n autocapture: autoCapture\n ? {\n block_selectors: blockSelectors,\n }\n : false,\n track_pageview: false, // We'll track page views manually\n });\n};\n\nexport const enableDebugMode = () => {\n mixpanel.set_config({ debug: true });\n};\n\nexport const disableDebugMode = () => {\n mixpanel.set_config({ debug: false });\n};\n\nexport const identify = ({\n userId,\n accountId,\n organisationId,\n email,\n name,\n}: InsightsIdentity) => {\n // In very rare cases we might have a user without an account, so we'll\n // let null/undefined/blank strings through on that one\n if (!userId) {\n return;\n }\n\n mixpanel.identify(userId);\n\n if (email || name) {\n mixpanel.people.set({ $email: email, $name: name });\n }\n\n if (accountId) {\n mixpanel.people.union({
|
|
1
|
+
{"version":3,"sources":["../../../src/core/insights/mixpanel.ts"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nimport { InsightsIdentity } from \"./types\";\n\nexport const initMixpanel = (\n token: string,\n autoCapture: boolean = false,\n debug: boolean = false,\n recordSessionsPercent = 1,\n) => {\n const blockSelectors = [\"[ph-no-capture]\", '[data-sl=\"mask\"]'];\n if (!token) {\n console.warn(\"Mixpanel token not provided, skipping initialization\");\n return;\n }\n\n mixpanel.init(token, {\n debug: debug,\n persistence: \"localStorage\",\n autocapture: autoCapture\n ? {\n block_selectors: blockSelectors,\n capture_text_content: true,\n }\n : false,\n track_pageview: false, // We'll track page views manually\n record_sessions_percent: recordSessionsPercent,\n record_mask_text_selector: null, // Prevents all text from being masked - we have other masking configured/enabled\n });\n};\n\nexport const enableDebugMode = () => {\n mixpanel.set_config({ debug: true });\n};\n\nexport const disableDebugMode = () => {\n mixpanel.set_config({ debug: false });\n};\n\nexport const identify = ({\n userId,\n accountId,\n organisationId,\n email,\n name,\n}: InsightsIdentity) => {\n // In very rare cases we might have a user without an account, so we'll\n // let null/undefined/blank strings through on that one\n if (!userId) {\n return;\n }\n\n mixpanel.identify(userId.toString());\n\n if (email || name) {\n mixpanel.people.set({ $email: email, $name: name });\n }\n\n if (accountId) {\n mixpanel.people.union({ accounts: [accountId.toString()] });\n }\n\n if (organisationId) {\n mixpanel.people.set({ organization_id: [organisationId.toString()] });\n }\n};\n\n// Simple function to replace all digits in a URL path with {redacted},\n// purely to make reporting based on aggregates easier\nconst redactUrlSegments = () => {\n const pathSegments = window.location.pathname.split(\"/\");\n\n const redactedSegments = pathSegments.map((segment) => {\n // Check if the segment contains only digits\n return /^\\d+$/.test(segment) ? \"{redacted}\" : segment;\n });\n\n // Join the segments back together\n const url = new URL(window.location.href);\n url.pathname = redactedSegments.join(\"/\");\n\n return decodeURI(url.toString()).toLowerCase();\n};\n\nexport const trackPageView = () => {\n // Add the redacted URL to the page view event for reporting\n mixpanel.track_pageview({\n redacted_path: redactUrlSegments(),\n });\n};\n\nexport const track = (event: string, properties?: Record<string, unknown>) => {\n mixpanel.track(event, properties);\n};\n\nexport const startSessionRecording = () => {\n mixpanel.start_session_recording();\n};\n\nexport const stopSessionRecording = () => {\n mixpanel.stop_session_recording();\n};\n"],"names":["mixpanel","initMixpanel","token","autoCapture","debug","recordSessionsPercent","blockSelectors","console","warn","init","persistence","autocapture","block_selectors","capture_text_content","track_pageview","record_sessions_percent","record_mask_text_selector","enableDebugMode","set_config","disableDebugMode","identify","userId","accountId","organisationId","email","name","toString","people","set","$email","$name","union","accounts","organization_id","redactUrlSegments","pathSegments","window","location","pathname","split","redactedSegments","map","segment","test","url","URL","href","join","decodeURI","toLowerCase","trackPageView","redacted_path","track","event","properties","startSessionRecording","start_session_recording","stopSessionRecording","stop_session_recording"],"mappings":"AAAA,OAAOA,aAAc,kBAAmB,AAIxC,QAAO,MAAMC,aAAe,CAC1BC,MACAC,YAAuB,KAAK,CAC5BC,MAAiB,KAAK,CACtBC,sBAAwB,CAAC,IAEzB,MAAMC,eAAiB,CAAC,kBAAmB,mBAAmB,CAC9D,GAAI,CAACJ,MAAO,CACVK,QAAQC,IAAI,CAAC,wDACb,MACF,CAEAR,SAASS,IAAI,CAACP,MAAO,CACnBE,MAAOA,MACPM,YAAa,eACbC,YAAaR,YACT,CACES,gBAAiBN,eACjBO,qBAAsB,IACxB,EACA,MACJC,eAAgB,MAChBC,wBAAyBV,sBACzBW,0BAA2B,IAC7B,EACF,CAAE,AAEF,QAAO,MAAMC,gBAAkB,KAC7BjB,SAASkB,UAAU,CAAC,CAAEd,MAAO,IAAK,EACpC,CAAE,AAEF,QAAO,MAAMe,iBAAmB,KAC9BnB,SAASkB,UAAU,CAAC,CAAEd,MAAO,KAAM,EACrC,CAAE,AAEF,QAAO,MAAMgB,SAAW,CAAC,CACvBC,MAAM,CACNC,SAAS,CACTC,cAAc,CACdC,KAAK,CACLC,IAAI,CACa,IAGjB,GAAI,CAACJ,OAAQ,CACX,MACF,CAEArB,SAASoB,QAAQ,CAACC,OAAOK,QAAQ,IAEjC,GAAIF,OAASC,KAAM,CACjBzB,SAAS2B,MAAM,CAACC,GAAG,CAAC,CAAEC,OAAQL,MAAOM,MAAOL,IAAK,EACnD,CAEA,GAAIH,UAAW,CACbtB,SAAS2B,MAAM,CAACI,KAAK,CAAC,CAAEC,SAAU,CAACV,UAAUI,QAAQ,GAAG,AAAC,EAC3D,CAEA,GAAIH,eAAgB,CAClBvB,SAAS2B,MAAM,CAACC,GAAG,CAAC,CAAEK,gBAAiB,CAACV,eAAeG,QAAQ,GAAG,AAAC,EACrE,CACF,CAAE,CAIF,MAAMQ,kBAAoB,KACxB,MAAMC,aAAeC,OAAOC,QAAQ,CAACC,QAAQ,CAACC,KAAK,CAAC,KAEpD,MAAMC,iBAAmBL,aAAaM,GAAG,CAAC,AAACC,UAEzC,MAAO,QAAQC,IAAI,CAACD,SAAW,aAAeA,OAChD,GAGA,MAAME,IAAM,IAAIC,IAAIT,OAAOC,QAAQ,CAACS,IAAI,CACxCF,CAAAA,IAAIN,QAAQ,CAAGE,iBAAiBO,IAAI,CAAC,KAErC,OAAOC,UAAUJ,IAAIlB,QAAQ,IAAIuB,WAAW,EAC9C,CAEA,QAAO,MAAMC,cAAgB,KAE3BlD,SAASc,cAAc,CAAC,CACtBqC,cAAejB,mBACjB,EACF,CAAE,AAEF,QAAO,MAAMkB,MAAQ,CAACC,MAAeC,cACnCtD,SAASoD,KAAK,CAACC,MAAOC,WACxB,CAAE,AAEF,QAAO,MAAMC,sBAAwB,KACnCvD,SAASwD,uBAAuB,EAClC,CAAE,AAEF,QAAO,MAAMC,qBAAuB,KAClCzD,SAAS0D,sBAAsB,EACjC,CAAE"}
|
package/core/insights/posthog.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import posthog from"posthog-js";export const initPosthog=(apiKey,apiHost)=>{posthog.init(apiKey,{api_host:apiHost,capture_pageview:false})};export const enableDebugMode=()=>{posthog.debug()};export const disableDebugMode=()=>{posthog.debug(false)};export const identify=({userId,accountId,organisationId,email,name})=>{if(!userId){return}if(userId!==posthog.get_distinct_id()){posthog.identify(userId,{email,name})}if(accountId){posthog.group("account",accountId)}if(organisationId){posthog.group("organisation",organisationId)}};export const trackPageView=()=>{posthog.capture("$pageview")};export const track=(event,properties)=>{posthog.capture(event,properties)};
|
|
1
|
+
import posthog from"posthog-js";export const initPosthog=(apiKey,apiHost)=>{posthog.init(apiKey,{api_host:apiHost,capture_pageview:false})};export const enableDebugMode=()=>{posthog.debug()};export const disableDebugMode=()=>{posthog.debug(false)};export const identify=({userId,accountId,organisationId,email,name})=>{if(!userId){return}if(userId!==posthog.get_distinct_id()){posthog.identify(userId,{email,name})}if(accountId){posthog.group("account",accountId)}if(organisationId){posthog.group("organisation",organisationId)}};export const trackPageView=()=>{posthog.capture("$pageview")};export const track=(event,properties)=>{posthog.capture(event,properties)};export const startSessionRecording=()=>{posthog.startSessionRecording()};export const stopSessionRecording=()=>{posthog.stopSessionRecording()};
|
|
2
2
|
//# sourceMappingURL=posthog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/insights/posthog.ts"],"sourcesContent":["import posthog from \"posthog-js\";\n\nimport { InsightsIdentity } from \"./types\";\n\nexport const initPosthog = (apiKey: string, apiHost: string) => {\n posthog.init(apiKey, {\n api_host: apiHost,\n capture_pageview: false,\n });\n};\n\nexport const enableDebugMode = () => {\n posthog.debug();\n};\n\nexport const disableDebugMode = () => {\n posthog.debug(false);\n};\n\nexport const identify = ({\n userId,\n accountId,\n organisationId,\n email,\n name,\n}: InsightsIdentity) => {\n // In very rare cases we might have a user without an account, so we'll\n // let null/undefined/blank strings through on that one\n if (!userId) {\n return;\n }\n\n if (userId !== posthog.get_distinct_id()) {\n posthog.identify(userId, { email, name });\n }\n\n // Associate all events in this session with this account\n if (accountId) {\n posthog.group(\"account\", accountId);\n }\n\n // Associate all events in this session with this organisation (if available)\n if (organisationId) {\n posthog.group(\"organisation\", organisationId);\n }\n};\n\nexport const trackPageView = () => {\n posthog.capture(\"$pageview\");\n};\n\nexport const track = (event: string, properties?: Record<string, unknown>) => {\n posthog.capture(event, properties);\n};\n"],"names":["posthog","initPosthog","apiKey","apiHost","init","api_host","capture_pageview","enableDebugMode","debug","disableDebugMode","identify","userId","accountId","organisationId","email","name","get_distinct_id","group","trackPageView","capture","track","event","properties"],"mappings":"AAAA,OAAOA,YAAa,YAAa,AAIjC,QAAO,MAAMC,YAAc,CAACC,OAAgBC,WAC1CH,QAAQI,IAAI,CAACF,OAAQ,CACnBG,SAAUF,QACVG,iBAAkB,KACpB,EACF,CAAE,AAEF,QAAO,MAAMC,gBAAkB,KAC7BP,QAAQQ,KAAK,EACf,CAAE,AAEF,QAAO,MAAMC,iBAAmB,KAC9BT,QAAQQ,KAAK,CAAC,MAChB,CAAE,AAEF,QAAO,MAAME,SAAW,CAAC,CACvBC,MAAM,CACNC,SAAS,CACTC,cAAc,CACdC,KAAK,CACLC,IAAI,CACa,IAGjB,GAAI,CAACJ,OAAQ,CACX,MACF,CAEA,GAAIA,SAAWX,QAAQgB,eAAe,GAAI,CACxChB,QAAQU,QAAQ,CAACC,OAAQ,CAAEG,MAAOC,IAAK,EACzC,CAGA,GAAIH,UAAW,CACbZ,QAAQiB,KAAK,CAAC,UAAWL,UAC3B,CAGA,GAAIC,eAAgB,CAClBb,QAAQiB,KAAK,CAAC,eAAgBJ,eAChC,CACF,CAAE,AAEF,QAAO,MAAMK,cAAgB,KAC3BlB,QAAQmB,OAAO,CAAC,YAClB,CAAE,AAEF,QAAO,MAAMC,MAAQ,CAACC,MAAeC,cACnCtB,QAAQmB,OAAO,CAACE,MAAOC,WACzB,CAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/insights/posthog.ts"],"sourcesContent":["import posthog from \"posthog-js\";\n\nimport { InsightsIdentity } from \"./types\";\n\nexport const initPosthog = (apiKey: string, apiHost: string) => {\n posthog.init(apiKey, {\n api_host: apiHost,\n capture_pageview: false,\n });\n};\n\nexport const enableDebugMode = () => {\n posthog.debug();\n};\n\nexport const disableDebugMode = () => {\n posthog.debug(false);\n};\n\nexport const identify = ({\n userId,\n accountId,\n organisationId,\n email,\n name,\n}: InsightsIdentity) => {\n // In very rare cases we might have a user without an account, so we'll\n // let null/undefined/blank strings through on that one\n if (!userId) {\n return;\n }\n\n if (userId !== posthog.get_distinct_id()) {\n posthog.identify(userId, { email, name });\n }\n\n // Associate all events in this session with this account\n if (accountId) {\n posthog.group(\"account\", accountId);\n }\n\n // Associate all events in this session with this organisation (if available)\n if (organisationId) {\n posthog.group(\"organisation\", organisationId);\n }\n};\n\nexport const trackPageView = () => {\n posthog.capture(\"$pageview\");\n};\n\nexport const track = (event: string, properties?: Record<string, unknown>) => {\n posthog.capture(event, properties);\n};\n\nexport const startSessionRecording = () => {\n posthog.startSessionRecording();\n};\n\nexport const stopSessionRecording = () => {\n posthog.stopSessionRecording();\n};\n"],"names":["posthog","initPosthog","apiKey","apiHost","init","api_host","capture_pageview","enableDebugMode","debug","disableDebugMode","identify","userId","accountId","organisationId","email","name","get_distinct_id","group","trackPageView","capture","track","event","properties","startSessionRecording","stopSessionRecording"],"mappings":"AAAA,OAAOA,YAAa,YAAa,AAIjC,QAAO,MAAMC,YAAc,CAACC,OAAgBC,WAC1CH,QAAQI,IAAI,CAACF,OAAQ,CACnBG,SAAUF,QACVG,iBAAkB,KACpB,EACF,CAAE,AAEF,QAAO,MAAMC,gBAAkB,KAC7BP,QAAQQ,KAAK,EACf,CAAE,AAEF,QAAO,MAAMC,iBAAmB,KAC9BT,QAAQQ,KAAK,CAAC,MAChB,CAAE,AAEF,QAAO,MAAME,SAAW,CAAC,CACvBC,MAAM,CACNC,SAAS,CACTC,cAAc,CACdC,KAAK,CACLC,IAAI,CACa,IAGjB,GAAI,CAACJ,OAAQ,CACX,MACF,CAEA,GAAIA,SAAWX,QAAQgB,eAAe,GAAI,CACxChB,QAAQU,QAAQ,CAACC,OAAQ,CAAEG,MAAOC,IAAK,EACzC,CAGA,GAAIH,UAAW,CACbZ,QAAQiB,KAAK,CAAC,UAAWL,UAC3B,CAGA,GAAIC,eAAgB,CAClBb,QAAQiB,KAAK,CAAC,eAAgBJ,eAChC,CACF,CAAE,AAEF,QAAO,MAAMK,cAAgB,KAC3BlB,QAAQmB,OAAO,CAAC,YAClB,CAAE,AAEF,QAAO,MAAMC,MAAQ,CAACC,MAAeC,cACnCtB,QAAQmB,OAAO,CAACE,MAAOC,WACzB,CAAE,AAEF,QAAO,MAAMC,sBAAwB,KACnCvB,QAAQuB,qBAAqB,EAC/B,CAAE,AAEF,QAAO,MAAMC,qBAAuB,KAClCxB,QAAQwB,oBAAoB,EAC9B,CAAE"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}import*as datalayer from"./datalayer";import*as mixpanel from"./mixpanel";import*as posthog from"./posthog";import*as logger from"./logger";export class InsightsService{initInsights({mixpanelToken,mixpanelAutoCapture,mixpanelRecordSessionsPercent=1,posthogApiKey,posthogApiHost,debug=false}){this.debugMode=!!debug;if(this.debugMode){logger.debug("InsightService: Initializing insights")}try{mixpanel.initMixpanel(mixpanelToken,mixpanelAutoCapture,this.debugMode,mixpanelRecordSessionsPercent)}catch(e){if(this.debugMode){logger.error("Failed to initialize Mixpanel",e)}}try{posthog.initPosthog(posthogApiKey,posthogApiHost)}catch(e){if(this.debugMode){logger.error("Failed to initialize Posthog",e)}}}enableDebugMode(){this.debugMode=true;logger.debug("Enabling debug mode");try{mixpanel.enableDebugMode();posthog.enableDebugMode()}catch(e){logger.error("Failed to enable debug mode",e)}}disableDebugMode(){this.debugMode=false;logger.debug("Disabling debug mode");try{mixpanel.disableDebugMode();posthog.disableDebugMode()}catch(e){logger.error("Failed to disable debug mode",e)}}identify(identity){const{userId,accountId,organisationId,email,name}=identity;if(!userId){if(this.debugMode){logger.warn("User ID not provided, skipping identify")}return}if(this.debugMode){logger.info("Identifying user",{userId,accountId,organisationId,email,name})}try{mixpanel.identify({userId,accountId,organisationId,email,name})}catch(e){if(this.debugMode){logger.error("Failed to identify user in Mixpanel",e)}}try{posthog.identify({userId,accountId,organisationId,email,name})}catch(e){if(this.debugMode){logger.error("Failed to identify user in Posthog",e)}}}trackPageView(){if(this.debugMode){logger.info("Tracking page view")}try{mixpanel.trackPageView()}catch(e){if(this.debugMode){logger.error("Failed to track page view in Mixpanel",e)}}try{posthog.trackPageView()}catch(e){if(this.debugMode){logger.error("Failed to track page view in Posthog",e)}}}track(event,properties){if(this.debugMode){logger.info("Tracking event",{event,properties})}try{mixpanel.track(event,properties)}catch(e){if(this.debugMode){logger.error("Failed to track event in Mixpanel",e)}}try{posthog.track(event,properties)}catch(e){if(this.debugMode){logger.error("Failed to track event in Posthog",e)}}try{datalayer.track(event,properties)}catch(e){if(this.debugMode){logger.error("Failed to track event in Datalayer",e)}}}startSessionRecording(){if(this.debugMode){logger.info("Starting session recording")}try{mixpanel.startSessionRecording()}catch(e){if(this.debugMode){logger.error("Failed to start session recording in Mixpanel",e)}}try{posthog.startSessionRecording()}catch(e){if(this.debugMode){logger.error("Failed to start session recording in Posthog",e)}}}stopSessionRecording(){if(this.debugMode){logger.info("Stopping session recording")}try{mixpanel.stopSessionRecording()}catch(e){if(this.debugMode){logger.error("Failed to stop session recording in Mixpanel",e)}}try{posthog.stopSessionRecording()}catch(e){if(this.debugMode){logger.error("Failed to stop session recording in Posthog",e)}}}setupObserver(){const getInsightAttributes=element=>{const MAX_ATTRIBUTES=10;let count=0;const attributes={};for(const attr of element.attributes){if(count>=MAX_ATTRIBUTES)break;if(attr.name.startsWith("data-insight-")){if(!/^data-insight-[a-zA-Z0-9-]+$/.test(attr.name))continue;if(typeof attr.value!=="string"||attr.value.length>100)continue;const key=attr.name.replace("data-insight-","").split("-").map((part,index)=>index===0?part:part.charAt(0).toUpperCase()+part.slice(1)).join("");attributes[key]=attr.value;count++}}return attributes};const findClosestElementWithInsights=element=>{let current=element;while(current&¤t!==document.body){const insights=getInsightAttributes(current);if(Object.keys(insights).length>0){return insights}current=current.parentElement}return null};const handleClick=event=>{if(!(event.target instanceof HTMLElement))return;const insights=findClosestElementWithInsights(event.target);if(insights){const{event:eventName,...properties}=insights;this.track(eventName||"element_clicked",properties)}};document.body.addEventListener("click",handleClick);return()=>{document.body.removeEventListener("click",handleClick)}}constructor(){_define_property(this,"debugMode",false)}}
|
|
2
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/insights/service.ts"],"sourcesContent":["import type {\n AnalyticsService,\n InsightsConfig,\n InsightsIdentity,\n} from \"./types\";\nimport * as datalayer from \"./datalayer\";\nimport * as mixpanel from \"./mixpanel\";\nimport * as posthog from \"./posthog\";\nimport * as logger from \"./logger\";\n\n// The real implementation that will be used after initialization\nexport class InsightsService implements AnalyticsService {\n private debugMode: boolean = false;\n\n initInsights({\n mixpanelToken,\n mixpanelAutoCapture,\n mixpanelRecordSessionsPercent = 1,\n posthogApiKey,\n posthogApiHost,\n debug = false,\n }: InsightsConfig): void {\n this.debugMode = !!debug;\n\n if (this.debugMode) {\n logger.debug(\"InsightService: Initializing insights\");\n }\n\n try {\n mixpanel.initMixpanel(\n mixpanelToken,\n mixpanelAutoCapture,\n this.debugMode,\n mixpanelRecordSessionsPercent,\n );\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to initialize Mixpanel\", e);\n }\n }\n\n try {\n posthog.initPosthog(posthogApiKey, posthogApiHost);\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to initialize Posthog\", e);\n }\n }\n }\n\n enableDebugMode(): void {\n this.debugMode = true;\n logger.debug(\"Enabling debug mode\");\n\n try {\n mixpanel.enableDebugMode();\n posthog.enableDebugMode();\n } catch (e) {\n logger.error(\"Failed to enable debug mode\", e);\n }\n }\n\n disableDebugMode(): void {\n this.debugMode = false;\n logger.debug(\"Disabling debug mode\");\n\n try {\n mixpanel.disableDebugMode();\n posthog.disableDebugMode();\n } catch (e) {\n logger.error(\"Failed to disable debug mode\", e);\n }\n }\n\n identify(identity: InsightsIdentity): void {\n const { userId, accountId, organisationId, email, name } = identity;\n\n // In very rare cases we might have a user without an account, so we'll\n // let null/undefined/blank strings through on that one\n if (!userId) {\n if (this.debugMode) {\n logger.warn(\"User ID not provided, skipping identify\");\n }\n return;\n }\n\n if (this.debugMode) {\n logger.info(\"Identifying user\", {\n userId,\n accountId,\n organisationId,\n email,\n name,\n });\n }\n\n try {\n mixpanel.identify({ userId, accountId, organisationId, email, name });\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to identify user in Mixpanel\", e);\n }\n }\n\n try {\n posthog.identify({ userId, accountId, organisationId, email, name });\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to identify user in Posthog\", e);\n }\n }\n }\n\n trackPageView(): void {\n if (this.debugMode) {\n logger.info(\"Tracking page view\");\n }\n\n try {\n mixpanel.trackPageView();\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to track page view in Mixpanel\", e);\n }\n }\n\n try {\n posthog.trackPageView();\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to track page view in Posthog\", e);\n }\n }\n }\n\n track(event: string, properties?: Record<string, unknown>): void {\n if (this.debugMode) {\n logger.info(\"Tracking event\", { event, properties });\n }\n\n try {\n mixpanel.track(event, properties);\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to track event in Mixpanel\", e);\n }\n }\n\n try {\n posthog.track(event, properties);\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to track event in Posthog\", e);\n }\n }\n\n try {\n datalayer.track(event, properties);\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to track event in Datalayer\", e);\n }\n }\n }\n\n startSessionRecording(): void {\n if (this.debugMode) {\n logger.info(\"Starting session recording\");\n }\n\n try {\n mixpanel.startSessionRecording();\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to start session recording in Mixpanel\", e);\n }\n }\n\n try {\n posthog.startSessionRecording();\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to start session recording in Posthog\", e);\n }\n }\n }\n\n stopSessionRecording(): void {\n if (this.debugMode) {\n logger.info(\"Stopping session recording\");\n }\n\n try {\n mixpanel.stopSessionRecording();\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to stop session recording in Mixpanel\", e);\n }\n }\n\n try {\n posthog.stopSessionRecording();\n } catch (e) {\n if (this.debugMode) {\n logger.error(\"Failed to stop session recording in Posthog\", e);\n }\n }\n }\n\n setupObserver(): () => void {\n // Helper to get all data-insight-* attributes from an element\n const getInsightAttributes = (\n element,\n ): { event?: string; [key: string]: string | undefined } => {\n // limit how many data attributes we'll process\n const MAX_ATTRIBUTES = 10;\n let count = 0;\n\n const attributes: { event?: string; [key: string]: string | undefined } =\n {};\n\n for (const attr of element.attributes) {\n if (count >= MAX_ATTRIBUTES) break;\n if (attr.name.startsWith(\"data-insight-\")) {\n // Validate attribute name format\n if (!/^data-insight-[a-zA-Z0-9-]+$/.test(attr.name)) continue;\n\n // Sanitize attribute value\n if (typeof attr.value !== \"string\" || attr.value.length > 100)\n continue;\n\n // Convert data-insight-event-name to eventName\n const key = attr.name\n .replace(\"data-insight-\", \"\")\n .split(\"-\")\n .map((part, index) =>\n index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1),\n )\n .join(\"\");\n attributes[key] = attr.value;\n count++;\n }\n }\n return attributes;\n };\n\n // Helper to find closest element with data-insight attributes\n const findClosestElementWithInsights = (element) => {\n let current = element;\n while (current && current !== document.body) {\n const insights = getInsightAttributes(current);\n if (Object.keys(insights).length > 0) {\n return insights;\n }\n current = current.parentElement;\n }\n return null;\n };\n\n // Global click handler\n const handleClick = (event: MouseEvent): void => {\n if (!(event.target instanceof HTMLElement)) return;\n const insights = findClosestElementWithInsights(event.target);\n if (insights) {\n // Extract special properties if they exist\n const { event: eventName, ...properties } = insights;\n this.track(eventName || \"element_clicked\", properties);\n }\n };\n\n // Add listener to document body to catch all clicks\n document.body.addEventListener(\"click\", handleClick);\n\n // Return cleanup function in case it's needed\n return () => {\n document.body.removeEventListener(\"click\", handleClick);\n };\n }\n}\n"],"names":["datalayer","mixpanel","posthog","logger","InsightsService","initInsights","mixpanelToken","mixpanelAutoCapture","mixpanelRecordSessionsPercent","posthogApiKey","posthogApiHost","debug","debugMode","initMixpanel","e","error","initPosthog","enableDebugMode","disableDebugMode","identify","identity","userId","accountId","organisationId","email","name","warn","info","trackPageView","track","event","properties","startSessionRecording","stopSessionRecording","setupObserver","getInsightAttributes","element","MAX_ATTRIBUTES","count","attributes","attr","startsWith","test","value","length","key","replace","split","map","part","index","charAt","toUpperCase","slice","join","findClosestElementWithInsights","current","document","body","insights","Object","keys","parentElement","handleClick","target","HTMLElement","eventName","addEventListener","removeEventListener"],"mappings":"oLAKA,UAAYA,cAAe,aAAc,AACzC,WAAYC,aAAc,YAAa,AACvC,WAAYC,YAAa,WAAY,AACrC,WAAYC,WAAY,UAAW,AAGnC,QAAO,MAAMC,gBAGXC,aAAa,CACXC,aAAa,CACbC,mBAAmB,CACnBC,8BAAgC,CAAC,CACjCC,aAAa,CACbC,cAAc,CACdC,MAAQ,KAAK,CACE,CAAQ,CACvB,IAAI,CAACC,SAAS,CAAG,CAAC,CAACD,MAEnB,GAAI,IAAI,CAACC,SAAS,CAAE,CAClBT,OAAOQ,KAAK,CAAC,wCACf,CAEA,GAAI,CACFV,SAASY,YAAY,CACnBP,cACAC,oBACA,IAAI,CAACK,SAAS,CACdJ,8BAEJ,CAAE,MAAOM,EAAG,CACV,GAAI,IAAI,CAACF,SAAS,CAAE,CAClBT,OAAOY,KAAK,CAAC,gCAAiCD,EAChD,CACF,CAEA,GAAI,CACFZ,QAAQc,WAAW,CAACP,cAAeC,eACrC,CAAE,MAAOI,EAAG,CACV,GAAI,IAAI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IAAIoB,QAAUpB,QACd,MAAOoB,SAAWA,UAAYC,SAASC,IAAI,CAAE,CAC3C,MAAMC,SAAWxB,qBAAqBqB,SACtC,GAAII,OAAOC,IAAI,CAACF,UAAUf,MAAM,CAAG,EAAG,CACpC,OAAOe,QACT,CACAH,QAAUA,QAAQM,aAAa,AACjC,CACA,OAAO,IACT,EAGA,MAAMC,YAAc,AAACjC,QACnB,GAAI,CAAEA,CAAAA,MAAMkC,MAAM,YAAYC,WAAU,EAAI,OAC5C,MAAMN,SAAWJ,+BAA+BzB,MAAMkC,MAAM,EAC5D,GAAIL,SAAU,CAEZ,KAAM,CAAE7B,MAAOoC,SAAS,CAAE,GAAGnC,WAAY,CAAG4B,SAC5C,IAAI,CAAC9B,KAAK,CAACqC,WAAa,kBAAmBnC,WAC7C,CACF,EAGA0B,SAASC,IAAI,CAACS,gBAAgB,CAAC,QAASJ,aAGxC,MAAO,KACLN,SAASC,IAAI,CAACU,mBAAmB,CAAC,QAASL,YAC7C,CACF,eAzQA,sBAAQnD,YAAqB,OA0Q/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/insights/types.ts"],"sourcesContent":["export type InsightsIdentity = {\n userId: string;\n accountId: string;\n organisationId?: string;\n email?: string;\n name?: string;\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/core/insights/types.ts"],"sourcesContent":["export type InsightsConfig = {\n debug: boolean;\n mixpanelToken: string;\n mixpanelAutoCapture: boolean;\n mixpanelRecordSessionsPercent: number;\n posthogApiKey: string;\n posthogApiHost: string;\n};\n\n// Define the interface for our analytics service\nexport interface AnalyticsService {\n initInsights: (config: InsightsConfig) => void;\n enableDebugMode: () => void;\n disableDebugMode: () => void;\n identify: (identity: InsightsIdentity) => void;\n trackPageView: () => void;\n track: (event: string, properties?: Record<string, unknown>) => void;\n startSessionRecording: () => void;\n stopSessionRecording: () => void;\n setupObserver: () => () => void;\n}\n\n// Command type for our queue\nexport type Command = {\n methodName: keyof AnalyticsService;\n args: unknown[];\n};\n\nexport type InsightsIdentity = {\n userId: string;\n accountId: string;\n organisationId?: string;\n email?: string;\n name?: string;\n};\n"],"names":[],"mappings":"AA4BA,QAME"}
|
package/core/scripts.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"array-flat-polyfill";export{default as reactRenderer,renderComponent}from"./react-renderer";export{default as loadSprites}from"./load-sprites";export
|
|
1
|
+
import"array-flat-polyfill";export{default as reactRenderer,renderComponent}from"./react-renderer";export{default as loadSprites}from"./load-sprites";export*from"./remote-data-store";export*from"./remote-blogs-posts";export*from"./remote-session-data";export*from"./dom-query";
|
|
2
2
|
//# sourceMappingURL=scripts.js.map
|
package/core/scripts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/scripts.js"],"sourcesContent":["import \"array-flat-polyfill\";\n\nexport { default as reactRenderer, renderComponent } from \"./react-renderer\";\nexport { default as loadSprites } from \"./load-sprites\";\
|
|
1
|
+
{"version":3,"sources":["../../src/core/scripts.js"],"sourcesContent":["import \"array-flat-polyfill\";\n\nexport { default as reactRenderer, renderComponent } from \"./react-renderer\";\nexport { default as loadSprites } from \"./load-sprites\";\n\nexport * from \"./remote-data-store\";\nexport * from \"./remote-blogs-posts\";\nexport * from \"./remote-session-data\";\nexport * from \"./dom-query\";\n"],"names":["default","reactRenderer","renderComponent","loadSprites"],"mappings":"AAAA,MAAO,qBAAsB,AAE7B,QAASA,WAAWC,aAAa,CAAEC,eAAe,KAAQ,kBAAmB,AAC7E,QAASF,WAAWG,WAAW,KAAQ,gBAAiB,AAExD,YAAc,qBAAsB,AACpC,YAAc,sBAAuB,AACrC,YAAc,uBAAwB,AACtC,YAAc,aAAc"}
|