📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fixed custom events table; added custom events documentation
Blue Mouse2ccab57017a2
diff --git a/src/pages/Docs/Docs.jsx b/src/pages/Docs/Docs.jsxindex 8c507c7df..7df24b6ce 100644--- a/src/pages/Docs/Docs.jsx+++ b/src/pages/Docs/Docs.jsx@@ -5,7 +5,7 @@ import Prism from 'prismjs'import Title from 'components/Title'import Code from 'ui/Code'import {- umdBuildExample, trackPageView, init, trackViews,+ umdBuildExample, trackPageView, init, trackViews, track, trackExample,} from './examples'const contents = [{@@ -100,6 +100,14 @@ const Docs = () => {</p><Code text={trackPageView} language='javascript' />+ <CSection id='docs-ce' name='Track custom events' />+ <p className='text-lg text-gray-900 tracking-tight'>+ In addition to tracking pageviews we provide an ability to track custom events. <br />+ For example, if you want to track an event like 'Sign up' or 'Newsletter subscription', this feature would be very useful.<br />+ Under the screen, the principle of this function is similar to trackViews.+ </p>+ <Code text={trackExample} language='javascript' />+<CHeader id='docs-api' name='API' /><CSection id='docs-init' name='init' />@@ -111,8 +119,10 @@ const Docs = () => {<CSection id='docs-tr' name='track' /><p className='text-lg text-gray-900 tracking-tight'>- This section is not ready yet..+ With this function you are able to track any custom events you want.<br />+ You should never send any identifiable data (like User ID, email, session cookie, etc.) as an event name.</p>+ <Code text={track} language='javascript' /><CSection id='docs-tv' name='trackViews' /><p className='text-lg text-gray-900 tracking-tight'>diff --git a/src/pages/Docs/examples.js b/src/pages/Docs/examples.jsindex dffa1a129..0152cf001 100644--- a/src/pages/Docs/examples.js+++ b/src/pages/Docs/examples.js@@ -14,6 +14,25 @@ export const umdBuildExample = `<script src="./analytics_script/dist/analytics.uexport const trackPageView = `analytics.trackViews()`+export const track = `analytics.track({+ // The event identifier you want to track.+ // This has to be a string, which:+ // - only contains English letters (a-Z A-Z), numbers (0-9), underscores (_),+ // dashes (-) and dots (.).+ // - is fewer than 64 characters.+ ev: 'YOUR_EVENT_NAME',++ // If true, only 1 event with the same ID will be saved per user session.+ // The principle of this parameter is similar to page views and unique views.+ unique: false,+})+`++export const trackExample = `analytics.track({+ ev: 'USER_SIGN_UP',+})+`+export const init = `analytics.init('YOUR_PROJECT_ID', {// When set to true, all tracking logs will be// printed to console and localhost events will be sent to server.diff --git a/src/pages/Project/View/Panels.jsx b/src/pages/Project/View/Panels.jsxindex 4c8dda128..e9e03e776 100644--- a/src/pages/Project/View/Panels.jsx+++ b/src/pages/Project/View/Panels.jsx@@ -21,9 +21,9 @@ const ENTRIES_PER_PANEL = 5const PanelContainer = ({name, children,}) => (- <div className='relative bg-white pt-5 px-4 pb-12 h-72 sm:pt-6 sm:px-6 shadow rounded-lg overflow-hidden'>+ <div className='relative bg-white pt-5 px-4 pb-12 min-h-72 sm:pt-6 sm:px-6 shadow rounded-lg overflow-hidden'><h3 className='text-lg leading-6 font-semibold mb-2 text-gray-900'>{name}</h3>- <div className='flex flex-col h-full'>+ <div className='flex flex-col h-full scroll-auto'>{children}</div></div>@@ -138,27 +138,26 @@ const CustomEvents = ({const keys = _keys(customs)const uniques = _sum(chartData.uniques)- // TODO: Fix col layoutreturn (<PanelContainer name='Custom events'>- <div className='flex justify-between'>- <span className='font-semibold text-lg w-4/6'>Event</span>- <div className='flex justify-between w-2/6'>- <span className='font-semibold text-lg'>Quantity</span>- <span className='font-semibold text-lg'>Conversion</span>- </div>- </div>- {_map(keys, (ev) => (- <div key={ev} className='flex justify-between'>- <span className='text-lg w-4/6'>{ev}</span>- <div className='flex justify-between w-2/6'>- <div className='text-right w-1/2'>- <span className='text-gray-900 text-xl'>{customs[ev]}</span>- </div>- <span className='text-gray-900 text-xl'>{(customs[ev] / uniques) * 100}%</span>- </div>- </div>- ))}+ <table className='table-fixed'>+ <thead>+ <tr>+ <th className='w-4/6 text-left text-gray-900'>Event</th>+ <th className='w-1/6 text-right text-gray-900'>Quantity </th>+ <th className='w-1/6 text-right text-gray-900'>Conversion</th>+ </tr>+ </thead>+ <tbody>+ {_map(keys, (ev) => (+ <tr key={ev}>+ <td className='text-left'>{ev}</td>+ <td className='text-right'>{customs[ev]} </td>+ <td className='text-right'>{_round((customs[ev] / uniques) * 100, 2)}%</td>+ </tr>+ ))}+ </tbody>+ </table></PanelContainer>)}@@ -194,7 +193,7 @@ const Panel = ({return (<PanelContainer name={name}>{_isEmpty(data) ? (- <p className="mt-1 text-base text-gray-700">There's currently no data for this parameter</p>+ <p className='mt-1 text-base text-gray-700'>No data for this parameter yet</p>) : _map(keysToDisplay, key => {const perc = _round(data[key] / total * 100, 2)const rowData = _isFunction(rowMapper) ? rowMapper(key) : key@@ -222,29 +221,29 @@ const Panel = ({)})}{_size(keys) > 5 && (- <div className="absolute bottom-0 w-card-toggle">+ <div className='absolute bottom-0 w-card-toggle'><div className='flex justify-between select-none mb-2'>- <span- className={cx('text-gray-500 font-light', {- hoverable: canGoPrev(),- disabled: !canGoPrev(),- })}- role='button'- onClick={onPrevious}- >- < Previous+ <span+ className={cx('text-gray-500 font-light', {+ hoverable: canGoPrev(),+ disabled: !canGoPrev(),+ })}+ role='button'+ onClick={onPrevious}+ >+ < Previous</span>- <span- className={cx('text-gray-500 font-light', {- hoverable: canGoNext(),- disabled: !canGoNext(),- })}- role='button'- onClick={onNext}- >- Next >+ <span+ className={cx('text-gray-500 font-light', {+ hoverable: canGoNext(),+ disabled: !canGoNext(),+ })}+ role='button'+ onClick={onNext}+ >+ Next ></span>- </div>+ </div></div>)}</PanelContainer>diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsxindex 1b160fc03..42493b8e3 100644--- a/src/pages/Project/View/ViewProject.jsx+++ b/src/pages/Project/View/ViewProject.jsx@@ -321,7 +321,20 @@ const ViewProject = ({if (type === 'ref') {return (- <Panel key={type} name={typeNameMapping[type]} data={panelsData.data[type]} linkContent />+ <Panel key={type} name={typeNameMapping[type]} data={panelsData.data[type]} rowMapper={(name) => {+ const url = new URL(name)+ console.log(url)++ return (+ <a className='flex label hover:underline text-blue-600' href={name} target='_blank' rel='noopener noreferrer'>+ {!_isEmpty(url.hostname) && (+ <img className='w-5 h-5 mr-1.5' src={`https://icons.duckduckgo.com/ip3/${url.hostname}.ico`} alt='' />+ )}+ {name}+ </a>+ )+ }}+ />)}