@ably/ui 15.6.0 → 15.7.0-dev.a9daaf05

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.
@@ -0,0 +1,2 @@
1
+ export const initDatalayer=()=>{const dataLayer=window.dataLayer||[];window.dataLayer=dataLayer};export const track=(event,properties)=>{window.dataLayer.push({event,...properties})};
2
+ //# sourceMappingURL=datalayer.js.map
@@ -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 initDatalayer = () => {\n const dataLayer = window.dataLayer || [];\n window.dataLayer = dataLayer;\n};\n\nexport const track = (event: string, properties?: Record<string, unknown>) => {\n window.dataLayer.push({\n event,\n ...properties,\n });\n};\n"],"names":["initDatalayer","dataLayer","window","track","event","properties","push"],"mappings":"AAMA,OAAO,MAAMA,cAAgB,KAC3B,MAAMC,UAAYC,OAAOD,SAAS,EAAI,EAAE,AACxCC,CAAAA,OAAOD,SAAS,CAAGA,SACrB,CAAE,AAEF,QAAO,MAAME,MAAQ,CAACC,MAAeC,cACnCH,OAAOD,SAAS,CAACK,IAAI,CAAC,CACpBF,MACA,GAAGC,UAAU,AACf,EACF,CAAE"}
@@ -1,2 +1,2 @@
1
- import*as mixpanel from"./mixpanel";import*as posthog from"./posthog";let debugMode=false;export const initInsights=({mixpanelToken,mixpanelAutoCapture,posthogApiKey,posthogApiHost,debug=false})=>{debugMode=!!debug;try{mixpanel.initMixpanel(mixpanelToken,mixpanelAutoCapture,debugMode)}catch(e){if(debugMode){console.error("Failed to initialize Mixpanel",e)}}try{posthog.initPosthog(posthogApiKey,posthogApiHost)}catch(e){if(debugMode){console.error("Failed to initialize Posthog",e)}}};export const enableDebugMode=()=>{debugMode=true;try{mixpanel.enableDebugMode();posthog.enableDebugMode()}catch(e){console.error("Failed to enable debug mode",e)}};export const disableDebugMode=()=>{debugMode=false;try{mixpanel.disableDebugMode();posthog.disableDebugMode()}catch(e){console.error("Failed to disable debug mode",e)}};export const identify=({userId,accountId,organisationId,email,name})=>{if(!userId){if(debugMode){console.warn("User ID not provided, skipping identify")}return}try{mixpanel.identify({userId,accountId,organisationId,email,name})}catch(e){if(debugMode){console.error("Failed to identify user in Mixpanel",e)}}try{posthog.identify({userId,accountId,organisationId,email,name})}catch(e){if(debugMode){console.error("Failed to identify user in Posthog",e)}}};export const trackPageView=()=>{try{mixpanel.trackPageView()}catch(e){if(debugMode){console.error("Failed to track page view in Mixpanel",e)}}try{posthog.trackPageView()}catch(e){if(debugMode){console.error("Failed to track page view in Posthog",e)}}};export const track=(event,properties)=>{try{mixpanel.track(event,properties)}catch(e){if(debugMode){console.error("Failed to track event in Mixpanel",e)}}try{posthog.track(event,properties)}catch(e){if(debugMode){console.error("Failed to track event in Posthog",e)}}};export const 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&&current!==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;track(eventName||"element_clicked",properties)}};document.body.addEventListener("click",handleClick);return()=>{document.body.removeEventListener("click",handleClick)}};
1
+ import*as datalayer from"./datalayer";import*as mixpanel from"./mixpanel";import*as posthog from"./posthog";let debugMode=false;export const initInsights=({mixpanelToken,mixpanelAutoCapture,mixpanelRecordSessionsPercent=1,posthogApiKey,posthogApiHost,debug=false})=>{debugMode=!!debug;try{mixpanel.initMixpanel(mixpanelToken,mixpanelAutoCapture,debugMode,mixpanelRecordSessionsPercent)}catch(e){if(debugMode){console.error("Failed to initialize Mixpanel",e)}}try{posthog.initPosthog(posthogApiKey,posthogApiHost)}catch(e){if(debugMode){console.error("Failed to initialize Posthog",e)}}try{datalayer.initDatalayer()}catch(e){if(debugMode){console.error("Failed to initialize Datalayer",e)}}};export const enableDebugMode=()=>{debugMode=true;try{mixpanel.enableDebugMode();posthog.enableDebugMode()}catch(e){console.error("Failed to enable debug mode",e)}};export const disableDebugMode=()=>{debugMode=false;try{mixpanel.disableDebugMode();posthog.disableDebugMode()}catch(e){console.error("Failed to disable debug mode",e)}};export const identify=({userId,accountId,organisationId,email,name})=>{if(!userId){if(debugMode){console.warn("User ID not provided, skipping identify")}return}try{mixpanel.identify({userId,accountId,organisationId,email,name})}catch(e){if(debugMode){console.error("Failed to identify user in Mixpanel",e)}}try{posthog.identify({userId,accountId,organisationId,email,name})}catch(e){if(debugMode){console.error("Failed to identify user in Posthog",e)}}};export const trackPageView=()=>{try{mixpanel.trackPageView()}catch(e){if(debugMode){console.error("Failed to track page view in Mixpanel",e)}}try{posthog.trackPageView()}catch(e){if(debugMode){console.error("Failed to track page view in Posthog",e)}}};export const track=(event,properties)=>{try{mixpanel.track(event,properties)}catch(e){if(debugMode){console.error("Failed to track event in Mixpanel",e)}}try{posthog.track(event,properties)}catch(e){if(debugMode){console.error("Failed to track event in Posthog",e)}}try{datalayer.track(event,properties)}catch(e){if(debugMode){console.error("Failed to track event in Datalayer",e)}}};export const startSessionRecording=()=>{try{mixpanel.startSessionRecording()}catch(e){if(debugMode){console.error("Failed to start session recording in Mixpanel",e)}}try{posthog.startSessionRecording()}catch(e){if(debugMode){console.error("Failed to start session recording in Posthog",e)}}};export const stopSessionRecording=()=>{try{mixpanel.stopSessionRecording()}catch(e){if(debugMode){console.error("Failed to stop session recording in Mixpanel",e)}}try{posthog.stopSessionRecording()}catch(e){if(debugMode){console.error("Failed to stop session recording in Posthog",e)}}};export const 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&&current!==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;track(eventName||"element_clicked",properties)}};document.body.addEventListener("click",handleClick);return()=>{document.body.removeEventListener("click",handleClick)}};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/insights/index.ts"],"sourcesContent":["import * as mixpanel from \"./mixpanel\";\nimport * as posthog from \"./posthog\";\nimport { InsightsIdentity } from \"./types\";\n\nexport type InsightsConfig = {\n debug: boolean;\n mixpanelToken: string;\n mixpanelAutoCapture: boolean;\n posthogApiKey: string;\n posthogApiHost: string;\n};\n\nlet debugMode = false;\n\nexport const initInsights = ({\n mixpanelToken,\n mixpanelAutoCapture,\n posthogApiKey,\n posthogApiHost,\n debug = false,\n}: InsightsConfig) => {\n debugMode = !!debug;\n\n try {\n mixpanel.initMixpanel(mixpanelToken, mixpanelAutoCapture, debugMode);\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to initialize Mixpanel\", e);\n }\n }\n\n try {\n posthog.initPosthog(posthogApiKey, posthogApiHost);\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to initialize Posthog\", e);\n }\n }\n};\n\nexport const enableDebugMode = () => {\n debugMode = true;\n try {\n mixpanel.enableDebugMode();\n posthog.enableDebugMode();\n } catch (e) {\n console.error(\"Failed to enable debug mode\", e);\n }\n};\n\nexport const disableDebugMode = () => {\n debugMode = false;\n try {\n mixpanel.disableDebugMode();\n posthog.disableDebugMode();\n } catch (e) {\n console.error(\"Failed to disable debug mode\", e);\n }\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 if (debugMode) {\n console.warn(\"User ID not provided, skipping identify\");\n }\n return;\n }\n\n try {\n mixpanel.identify({ userId, accountId, organisationId, email, name });\n } catch (e) {\n if (debugMode) {\n console.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 (debugMode) {\n console.error(\"Failed to identify user in Posthog\", e);\n }\n }\n};\n\nexport const trackPageView = () => {\n try {\n mixpanel.trackPageView();\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to track page view in Mixpanel\", e);\n }\n }\n\n try {\n posthog.trackPageView();\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to track page view in Posthog\", e);\n }\n }\n};\n\nexport const track = (event: string, properties?: Record<string, unknown>) => {\n try {\n mixpanel.track(event, properties);\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to track event in Mixpanel\", e);\n }\n }\n\n try {\n posthog.track(event, properties);\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to track event in Posthog\", e);\n }\n }\n};\n\ntype InsightAttributes = {\n event?: string;\n [key: string]: string | undefined;\n};\n\nexport const setupObserver = () => {\n // Helper to get all data-insight-* attributes from an element\n const getInsightAttributes = (element): InsightAttributes => {\n // limit how many data attributes we'll process\n const MAX_ATTRIBUTES = 10;\n let count = 0;\n\n const attributes: InsightAttributes = {};\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) 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 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"],"names":["mixpanel","posthog","debugMode","initInsights","mixpanelToken","mixpanelAutoCapture","posthogApiKey","posthogApiHost","debug","initMixpanel","e","console","error","initPosthog","enableDebugMode","disableDebugMode","identify","userId","accountId","organisationId","email","name","warn","trackPageView","track","event","properties","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":"AAAA,UAAYA,aAAc,YAAa,AACvC,WAAYC,YAAa,WAAY,CAWrC,IAAIC,UAAY,KAEhB,QAAO,MAAMC,aAAe,CAAC,CAC3BC,aAAa,CACbC,mBAAmB,CACnBC,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C,GACRf,CAAAA,UAAU,CAACM,IAAI,CAAGL,KAAKG,KAAK,AAC5BL,CAAAA,OACF,CACF,CACA,OAAOC,UACT,EAGA,MAAMgB,+BAAiC,AAACnB,UACtC,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,AAAC/B,QACnB,GAAI,CAAEA,CAAAA,MAAMgC,MAAM,YAAYC,WAAU,EAAI,OAC5C,MAAMN,SAAWJ,+BAA+BvB,MAAMgC,MAAM,EAC5D,GAAIL,SAAU,CAEZ,KAAM,CAAE3B,MAAOkC,SAAS,CAAE,GAAGjC,WAAY,CAAG0B,SAC5C5B,MAAMmC,WAAa,kBAAmBjC,WACxC,CACF,EAGAwB,SAASC,IAAI,CAACS,gBAAgB,CAAC,QAASJ,aAGxC,MAAO,KACLN,SAASC,IAAI,CAACU,mBAAmB,CAAC,QAASL,YAC7C,CACF,CAAE"}
1
+ {"version":3,"sources":["../../../src/core/insights/index.ts"],"sourcesContent":["import * as datalayer from \"./datalayer\";\nimport * as mixpanel from \"./mixpanel\";\nimport * as posthog from \"./posthog\";\nimport { InsightsIdentity } from \"./types\";\n\nexport type InsightsConfig = {\n debug: boolean;\n mixpanelToken: string;\n mixpanelAutoCapture: boolean;\n mixpanelRecordSessionsPercent: number;\n posthogApiKey: string;\n posthogApiHost: string;\n};\n\nlet debugMode = false;\n\nexport const initInsights = ({\n mixpanelToken,\n mixpanelAutoCapture,\n mixpanelRecordSessionsPercent = 1,\n posthogApiKey,\n posthogApiHost,\n debug = false,\n}: InsightsConfig) => {\n debugMode = !!debug;\n\n try {\n mixpanel.initMixpanel(\n mixpanelToken,\n mixpanelAutoCapture,\n debugMode,\n mixpanelRecordSessionsPercent,\n );\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to initialize Mixpanel\", e);\n }\n }\n\n try {\n posthog.initPosthog(posthogApiKey, posthogApiHost);\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to initialize Posthog\", e);\n }\n }\n\n try {\n datalayer.initDatalayer();\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to initialize Datalayer\", e);\n }\n }\n};\n\nexport const enableDebugMode = () => {\n debugMode = true;\n try {\n mixpanel.enableDebugMode();\n posthog.enableDebugMode();\n } catch (e) {\n console.error(\"Failed to enable debug mode\", e);\n }\n};\n\nexport const disableDebugMode = () => {\n debugMode = false;\n try {\n mixpanel.disableDebugMode();\n posthog.disableDebugMode();\n } catch (e) {\n console.error(\"Failed to disable debug mode\", e);\n }\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 if (debugMode) {\n console.warn(\"User ID not provided, skipping identify\");\n }\n return;\n }\n\n try {\n mixpanel.identify({ userId, accountId, organisationId, email, name });\n } catch (e) {\n if (debugMode) {\n console.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 (debugMode) {\n console.error(\"Failed to identify user in Posthog\", e);\n }\n }\n};\n\nexport const trackPageView = () => {\n try {\n mixpanel.trackPageView();\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to track page view in Mixpanel\", e);\n }\n }\n\n try {\n posthog.trackPageView();\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to track page view in Posthog\", e);\n }\n }\n};\n\nexport const track = (event: string, properties?: Record<string, unknown>) => {\n try {\n mixpanel.track(event, properties);\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to track event in Mixpanel\", e);\n }\n }\n\n try {\n posthog.track(event, properties);\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to track event in Posthog\", e);\n }\n }\n\n try {\n datalayer.track(event, properties);\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to track event in Datalayer\", e);\n }\n }\n};\n\nexport const startSessionRecording = () => {\n try {\n mixpanel.startSessionRecording();\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to start session recording in Mixpanel\", e);\n }\n }\n\n try {\n posthog.startSessionRecording();\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to start session recording in Posthog\", e);\n }\n }\n};\n\nexport const stopSessionRecording = () => {\n try {\n mixpanel.stopSessionRecording();\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to stop session recording in Mixpanel\", e);\n }\n }\n\n try {\n posthog.stopSessionRecording();\n } catch (e) {\n if (debugMode) {\n console.error(\"Failed to stop session recording in Posthog\", e);\n }\n }\n};\n\ntype InsightAttributes = {\n event?: string;\n [key: string]: string | undefined;\n};\n\nexport const setupObserver = () => {\n // Helper to get all data-insight-* attributes from an element\n const getInsightAttributes = (element): InsightAttributes => {\n // limit how many data attributes we'll process\n const MAX_ATTRIBUTES = 10;\n let count = 0;\n\n const attributes: InsightAttributes = {};\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) 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 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"],"names":["datalayer","mixpanel","posthog","debugMode","initInsights","mixpanelToken","mixpanelAutoCapture","mixpanelRecordSessionsPercent","posthogApiKey","posthogApiHost","debug","initMixpanel","e","console","error","initPosthog","initDatalayer","enableDebugMode","disableDebugMode","identify","userId","accountId","organisationId","email","name","warn","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":"AAAA,UAAYA,cAAe,aAAc,AACzC,WAAYC,aAAc,YAAa,AACvC,WAAYC,YAAa,WAAY,CAYrC,IAAIC,UAAY,KAEhB,QAAO,MAAMC,aAAe,CAAC,CAC3BC,aAAa,CACbC,mBAAmB,CACnBC,8BAAgC,CAAC,CACjCC,aAAa,CACbC,cAAc,CACdC,MAAQ,KAAK,CACE,IACfP,UAAY,CAAC,CAACO,MAEd,GAAI,CACFT,SAASU,YAAY,CACnBN,cACAC,oBACAH,UACAI,8BAEJ,CAAE,MAAOK,EAAG,CACV,GAAIT,UAAW,CACbU,QAAQC,KAAK,CAAC,gCAAiCF,EACjD,CACF,CAEA,GAAI,CACFV,QAAQa,WAAW,CAACP,cAAeC,eACrC,CAAE,MAAOG,EAAG,CACV,GAAIT,UAAW,CACbU,QAAQC,KAAK,CAAC,+BAAgCF,EAChD,CACF,CAEA,G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C,CACF,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({account_id:[accountId]})}if(organisationId){mixpanel.people.set({organisation_id:[organisationId]})}};export const trackPageView=mixpanel.track_pageview;export const track=mixpanel.track;
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}:false,track_pageview:false,record_sessions_percent:recordSessionsPercent})};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({account_id:[accountId]})}if(organisationId){mixpanel.people.set({organisation_id:[organisationId]})}};export const trackPageView=mixpanel.track_pageview;export const track=mixpanel.track;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({ account_id: [accountId] });\n }\n\n if (organisationId) {\n mixpanel.people.set({ organisation_id: [organisationId] });\n }\n};\n\nexport const trackPageView = mixpanel.track_pageview;\n\nexport const track = mixpanel.track;\n"],"names":["mixpanel","initMixpanel","token","autoCapture","debug","blockSelectors","console","warn","init","persistence","autocapture","block_selectors","track_pageview","enableDebugMode","set_config","disableDebugMode","identify","userId","accountId","organisationId","email","name","people","set","$email","$name","union","account_id","organisation_id","trackPageView","track"],"mappings":"AAAA,OAAOA,aAAc,kBAAmB,AAIxC,QAAO,MAAMC,aAAe,CAC1BC,MACAC,YAAuB,KAAK,CAC5BC,MAAiB,KAAK,IAEtB,MAAMC,eAAiB,CAAC,kBAAmB,mBAAmB,CAC9D,GAAI,CAACH,MAAO,CACVI,QAAQC,IAAI,CAAC,wDACb,MACF,CAEAP,SAASQ,IAAI,CAACN,MAAO,CACnBE,MAAOA,MACPK,YAAa,eACbC,YAAaP,YACT,CACEQ,gBAAiBN,cACnB,EACA,MACJO,eAAgB,KAClB,EACF,CAAE,AAEF,QAAO,MAAMC,gBAAkB,KAC7Bb,SAASc,UAAU,CAAC,CAAEV,MAAO,IAAK,EACpC,CAAE,AAEF,QAAO,MAAMW,iBAAmB,KAC9Bf,SAASc,UAAU,CAAC,CAAEV,MAAO,KAAM,EACrC,CAAE,AAEF,QAAO,MAAMY,SAAW,CAAC,CACvBC,MAAM,CACNC,SAAS,CACTC,cAAc,CACdC,KAAK,CACLC,IAAI,CACa,IAGjB,GAAI,CAACJ,OAAQ,CACX,MACF,CAEAjB,SAASgB,QAAQ,CAACC,QAElB,GAAIG,OAASC,KAAM,CACjBrB,SAASsB,MAAM,CAACC,GAAG,CAAC,CAAEC,OAAQJ,MAAOK,MAAOJ,IAAK,EACnD,CAEA,GAAIH,UAAW,CACblB,SAASsB,MAAM,CAACI,KAAK,CAAC,CAAEC,WAAY,CAACT,UAAU,AAAC,EAClD,CAEA,GAAIC,eAAgB,CAClBnB,SAASsB,MAAM,CAACC,GAAG,CAAC,CAAEK,gBAAiB,CAACT,eAAe,AAAC,EAC1D,CACF,CAAE,AAEF,QAAO,MAAMU,cAAgB7B,SAASY,cAAc,AAAC,AAErD,QAAO,MAAMkB,MAAQ9B,SAAS8B,KAAK,AAAC"}
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: number = 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 }\n : false,\n track_pageview: false, // We'll track page views manually\n record_sessions_percent: recordSessionsPercent,\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({ account_id: [accountId] });\n }\n\n if (organisationId) {\n mixpanel.people.set({ organisation_id: [organisationId] });\n }\n};\n\nexport const trackPageView = mixpanel.track_pageview;\n\nexport const track = mixpanel.track;\n\nexport const startSessionRecording = mixpanel.start_session_recording;\n\nexport const stopSessionRecording = mixpanel.stop_session_recording;\n"],"names":["mixpanel","initMixpanel","token","autoCapture","debug","recordSessionsPercent","blockSelectors","console","warn","init","persistence","autocapture","block_selectors","track_pageview","record_sessions_percent","enableDebugMode","set_config","disableDebugMode","identify","userId","accountId","organisationId","email","name","people","set","$email","$name","union","account_id","organisation_id","trackPageView","track","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,sBAAgC,CAAC,IAEjC,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,cACnB,EACA,MACJO,eAAgB,MAChBC,wBAAyBT,qBAC3B,EACF,CAAE,AAEF,QAAO,MAAMU,gBAAkB,KAC7Bf,SAASgB,UAAU,CAAC,CAAEZ,MAAO,IAAK,EACpC,CAAE,AAEF,QAAO,MAAMa,iBAAmB,KAC9BjB,SAASgB,UAAU,CAAC,CAAEZ,MAAO,KAAM,EACrC,CAAE,AAEF,QAAO,MAAMc,SAAW,CAAC,CACvBC,MAAM,CACNC,SAAS,CACTC,cAAc,CACdC,KAAK,CACLC,IAAI,CACa,IAGjB,GAAI,CAACJ,OAAQ,CACX,MACF,CAEAnB,SAASkB,QAAQ,CAACC,QAElB,GAAIG,OAASC,KAAM,CACjBvB,SAASwB,MAAM,CAACC,GAAG,CAAC,CAAEC,OAAQJ,MAAOK,MAAOJ,IAAK,EACnD,CAEA,GAAIH,UAAW,CACbpB,SAASwB,MAAM,CAACI,KAAK,CAAC,CAAEC,WAAY,CAACT,UAAU,AAAC,EAClD,CAEA,GAAIC,eAAgB,CAClBrB,SAASwB,MAAM,CAACC,GAAG,CAAC,CAAEK,gBAAiB,CAACT,eAAe,AAAC,EAC1D,CACF,CAAE,AAEF,QAAO,MAAMU,cAAgB/B,SAASa,cAAc,AAAC,AAErD,QAAO,MAAMmB,MAAQhC,SAASgC,KAAK,AAAC,AAEpC,QAAO,MAAMC,sBAAwBjC,SAASkC,uBAAuB,AAAC,AAEtE,QAAO,MAAMC,qBAAuBnC,SAASoC,sBAAsB,AAAC"}
@@ -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 = posthog.startSessionRecording;\n\nexport const stopSessionRecording = posthog.stopSessionRecording;\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,sBAAwBvB,QAAQuB,qBAAqB,AAAC,AAEnE,QAAO,MAAMC,qBAAuBxB,QAAQwB,oBAAoB,AAAC"}
@@ -0,0 +1 @@
1
+ ["bg-blue-400","bg-blue-100","bg-neutral-1300","bg-neutral-300","bg-neutral-200","bg-neutral-100","bg-neutral-000","bg-neutral-600","bg-orange-900","bg-orange-600","border-blue-400","border-neutral-200","border-neutral-600","border-neutral-500","border-orange-600","from-neutral-400","group-hover:bg-neutral-100","text-blue-600","text-blue-200","text-neutral-1300","text-neutral-300","text-neutral-000","text-neutral-1100","text-neutral-1000","text-neutral-800","text-neutral-700","text-neutral-600","text-neutral-500","text-orange-200","text-orange-600"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ably/ui",
3
- "version": "15.6.0",
3
+ "version": "15.7.0-dev.a9daaf05",
4
4
  "description": "Home of the Ably design system library ([design.ably.com](https://design.ably.com)). It provides a showcase, development/test environment and a publishing pipeline for different distributables.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,19 +19,17 @@
19
19
  "workerDirectory": "./public"
20
20
  },
21
21
  "devDependencies": {
22
- "@storybook/addon-a11y": "^8.6.0",
23
- "@storybook/addon-essentials": "^8.6.0",
24
- "@storybook/addon-interactions": "^8.6.0",
25
- "@storybook/addon-links": "^8.6.0",
26
- "@storybook/blocks": "^8.6.0",
27
- "@storybook/react-vite": "^8.6.0",
28
- "@storybook/test": "^8.6.0",
29
- "@storybook/test-runner": "^0.21.3",
22
+ "@storybook/addon-essentials": "^8.6.4",
23
+ "@storybook/react-vite": "^8.6.4",
24
+ "@storybook/test": "^8.6.4",
25
+ "@storybook/test-runner": "^0.22.0",
30
26
  "@swc/cli": "^0.6.0",
31
27
  "@swc/core": "^1.4.11",
32
28
  "@tailwindcss/container-queries": "^0.1.1",
33
29
  "@types/js-cookie": "^3.0.6",
34
30
  "@types/lodash.throttle": "^4.1.9",
31
+ "@types/node": "^20",
32
+ "@types/react": "^18.3.1",
35
33
  "@types/react-dom": "^18.3.0",
36
34
  "@types/svg-sprite": "^0.0.39",
37
35
  "@typescript-eslint/eslint-plugin": "^8.25.0",
@@ -42,7 +40,7 @@
42
40
  "eslint": "^8.57.0",
43
41
  "eslint-config-prettier": "^10.0.1",
44
42
  "eslint-plugin-react": "^7.34.3",
45
- "eslint-plugin-storybook": "^0.11.3",
43
+ "eslint-plugin-storybook": "^0.11.4",
46
44
  "heroicons": "^2.2.0",
47
45
  "http-server": "14.1.1",
48
46
  "mixpanel-browser": "^2.60.0",
@@ -52,7 +50,7 @@
52
50
  "posthog-js": "^1.217.4",
53
51
  "prettier": "^3.2.5",
54
52
  "react-syntax-highlighter": "^15.6.1",
55
- "storybook": "^8.6.0",
53
+ "storybook": "^8.6.4",
56
54
  "storybook-dark-mode": "^4.0.2",
57
55
  "svg-sprite": "^2.0.4",
58
56
  "tailwindcss": "^3.3.6",