📈 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
copyButton
ArtemRozzhivin17c61303a37f
diff --git a/.env.example b/.env.exampledeleted file mode 100644index aad8e1f1d..000000000--- a/.env.example+++ /dev/null@@ -1,4 +0,0 @@-REACT_APP_API_URL=https://api.swetrix.com/-REACT_APP_BLOG_URL=https://blog.swetrix.com/-CHOKIDAR_USEPOLLING=true-GENERATE_SOURCEMAP=falsediff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsxindex 9de73dd40..af8b42ad0 100644--- a/src/pages/UserSettings/UserSettings.jsx+++ b/src/pages/UserSettings/UserSettings.jsx@@ -1,6 +1,4 @@-import React, {- useState, useEffect, memo,-} from 'react'+import React, { useState, useEffect, memo } from 'react'import { useSelector } from 'react-redux'import cx from 'clsx'import _size from 'lodash/size'@@ -11,7 +9,11 @@ import _map from 'lodash/map'import _keys from 'lodash/keys'import _isString from 'lodash/isString'import {- EnvelopeIcon, ExclamationTriangleIcon, ArrowDownTrayIcon, CurrencyDollarIcon,+ EnvelopeIcon,+ ExclamationTriangleIcon,+ ArrowDownTrayIcon,+ CurrencyDollarIcon,+ ClipboardDocumentIcon,} from '@heroicons/react/24/outline'import QRCode from 'react-qr-code'import PropTypes from 'prop-types'@@ -26,9 +28,7 @@ import Beta from 'ui/Beta'import Select from 'ui/Select'import PaidFeature from 'modals/PaidFeature'import TimezonePicker from 'ui/TimezonePicker'-import {- isValidEmail, isValidPassword, MIN_PASSWORD_CHARS,-} from 'utils/validator'+import { isValidEmail, isValidPassword, MIN_PASSWORD_CHARS } from 'utils/validator'import { setAccessToken } from 'utils/accessToken'import {@@ -36,8 +36,15 @@ import {} from 'api'const ProjectList = ({- item, t, removeShareProject, removeProject, setProjectsShareData, setUserShareData,- language, userSharedUpdate, sharedProjectError,+ item,+ t,+ removeShareProject,+ removeProject,+ setProjectsShareData,+ setUserShareData,+ language,+ userSharedUpdate,+ sharedProjectError,}) => {const [showDeleteModal, setShowDeleteModal] = useState(false)const {@@ -147,8 +154,10 @@ const TwoFA = ({const [twoFARecovery, setTwoFARecovery] = useState(null)const { isTwoFactorAuthenticationEnabled } = user- const handle2FAInput = event => {- const { target: { value } } = event+ const handle2FAInput = (event) => {+ const {+ target: { value },+ } = eventsetTwoFACode(value)setTwoFACodeError(null)}@@ -181,7 +190,11 @@ const TwoFA = ({setIsTwoFaLoading(true)try {- const { twoFactorRecoveryCode, access_token: accessToken, user: updatedUser } = await enable2FA(twoFACode)+ const {+ twoFactorRecoveryCode,+ access_token: accessToken,+ user: updatedUser,+ } = await enable2FA(twoFACode)login(updatedUser)setAccessToken(accessToken, dontRemember)setTwoFARecovery(twoFactorRecoveryCode)@@ -234,16 +247,8 @@ const TwoFA = ({<p className='text-base text-gray-900 dark:text-gray-50'>{t('profileSettings.2faRecoveryNote')}</p>- <Input- type='text'- className='mt-4'- value={twoFARecovery}- />- <Button- onClick={recoverySaved}- primary- large- >+ <Input type='text' className='mt-4' value={twoFARecovery} />+ <Button onClick={recoverySaved} primary large>{t('profileSettings.2faRecoverySaved')}</Button></div>@@ -291,12 +296,7 @@ const TwoFA = ({<p className='max-w-prose text-base text-gray-900 dark:text-gray-50'>{t('profileSettings.2faEnabled')}</p>- <Button- className='mt-4'- onClick={() => setTwoFADisabling(true)}- danger- large- >+ <Button className='mt-4' onClick={() => setTwoFADisabling(true)} danger large>{t('profileSettings.2faDisableBtn')}</Button></>@@ -357,11 +357,26 @@ const TwoFA = ({}const UserSettings = ({- onDelete, onExport, onSubmit, onEmailConfirm, onDeleteProjectCache, t,- removeProject, removeShareProject, setUserShareData, setProjectsShareData, language,- userSharedUpdate, sharedProjectError, updateUserData, login, genericError, onApiKeyGenerate, onApiKeyDelete,+ onDelete,+ onExport,+ onSubmit,+ onEmailConfirm,+ onDeleteProjectCache,+ t,+ removeProject,+ removeShareProject,+ setUserShareData,+ setProjectsShareData,+ language,+ userSharedUpdate,+ sharedProjectError,+ updateUserData,+ login,+ genericError,+ onApiKeyGenerate,+ onApiKeyDelete,}) => {- const { user, dontRemember, isPaidTierUsed } = useSelector(state => state.auth)+ const { user, dontRemember, isPaidTierUsed } = useSelector((state) => state.auth)const [form, setForm] = useState({email: user.email || '',@@ -404,24 +419,24 @@ const UserSettings = ({useEffect(() => {validate()- }, [form]) // eslint-disable-line+ }, [form]); // eslint-disable-lineconst _setTimezone = (value) => {setTimezoneChanged(true)setTimezone(value)}- const handleInput = event => {+ const handleInput = (event) => {const { target } = eventconst value = target.type === 'checkbox' ? target.checked : target.value- setForm(prevForm => ({+ setForm((prevForm) => ({...prevForm,[target.name]: value,}))}- const handleSubmit = e => {+ const handleSubmit = (e) => {e.preventDefault()e.stopPropagation()setBeenSubmitted(true)@@ -469,14 +484,16 @@ const UserSettings = ({const reportIconExtractor = (_, index) => {if (!isPaidTierUsed && reportFrequencies[index] === WEEKLY_REPORT_FREQUENCY) {- return (- <CurrencyDollarIcon className='w-5 h-5 mr-1' />- )+ return <CurrencyDollarIcon className='w-5 h-5 mr-1' />}return null}+ const setToClickboard = (value) => {+ navigator.clipboard.writeText(value)+ }+return (<Title title={t('titles.profileSettings')}><div className='min-h-min-footer bg-gray-50 dark:bg-gray-800 flex flex-col py-6 px-4 sm:px-6 lg:px-8'>@@ -532,10 +549,7 @@ const UserSettings = ({</h3><div className='grid grid-cols-1 gap-y-6 gap-x-4 lg:grid-cols-2 mt-4'><div>- <TimezonePicker- value={timezone}- onChange={_setTimezone}- />+ <TimezonePicker value={timezone} onChange={_setTimezone} /></div></div><Button className='mt-4' onClick={handleTimezoneSave} primary large>@@ -553,7 +567,9 @@ const UserSettings = ({className='w-full'items={translatedFrequencies}iconExtractor={reportIconExtractor}- onSelect={(f) => _setReportFrequency(reportFrequencies[_findIndex(translatedFrequencies, freq => freq === f)])}+ onSelect={(f) => _setReportFrequency(+ reportFrequencies[_findIndex(translatedFrequencies, (freq) => freq === f)],+ )}/></div></div>@@ -568,23 +584,38 @@ const UserSettings = ({</div></h3>{user.apiKey ? (- <>+ <div><p className='max-w-prose text-base text-gray-900 dark:text-gray-50'>{t('profileSettings.apiKeyWarning')}</p>+ <p className='mt-4 max-w-prose text-base text-gray-900 dark:text-gray-50'>+ {t('profileSettings.apiKey')}+ </p><div className='grid grid-cols-1 gap-y-6 gap-x-4 lg:grid-cols-2'>- <Input- name='apiKey'- id='apiKey'- type='text'- label={t('profileSettings.apiKey')}- value={user.apiKey}- className='mt-4'- onChange={handleInput}- disabled- />+ <div className='relative group'>+ <Input+ name='apiKey'+ id='apiKey'+ type='text'+ className='pr-9'+ value={user.apiKey}+ onChange={handleInput}+ disabled+ />+ <div className='group'>+ <Button+ type='button'+ onClick={() => setToClickboard(user.apiKey)}+ className='group hover:opacity-1 sm:top-3 hidden absolute right-2 top-3 group-hover:block'+ noBorder+ >+ <ClipboardDocumentIcon className='w-6 h-6' />+ </Button>+ <div className='opacity-1 bg-black dark:bg-gray-700 rounded p-1 absolute bottom-0 right-8 text-xs hidden group-focus:block'>Copied</div>+ </div>+ </div></div>- </>+ </div>) : (<p className='max-w-prose text-base text-gray-900 dark:text-gray-50'>{t('profileSettings.noApiKey')}@@ -603,7 +634,14 @@ const UserSettings = ({<h3 className='flex items-center mt-2 text-lg font-bold text-gray-900 dark:text-gray-50'>{t('profileSettings.2fa')}</h3>- <TwoFA t={t} user={user} dontRemember={dontRemember} updateUserData={updateUserData} login={login} genericError={genericError} />+ <TwoFA+ t={t}+ user={user}+ dontRemember={dontRemember}+ updateUserData={updateUserData}+ login={login}+ genericError={genericError}+ /><hr className='mt-5 border-gray-200 dark:border-gray-600' /><h3 className='flex items-center mt-2 text-lg font-bold text-gray-900 dark:text-gray-50'>@@ -618,35 +656,42 @@ const UserSettings = ({<table className='min-w-full divide-y divide-gray-300 dark:divide-gray-600'><thead><tr className='dark:bg-gray-700'>- <th scope='col' className='py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 dark:text-white'>+ <th+ scope='col'+ className='py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 dark:text-white'+ >{t('profileSettings.sharedTable.project')}</th>- <th scope='col' className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white'>+ <th+ scope='col'+ className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white'+ >{t('profileSettings.sharedTable.role')}</th>- <th scope='col' className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white'>+ <th+ scope='col'+ className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-white'+ >{t('profileSettings.sharedTable.joinedOn')}</th><th scope='col' className='relative py-3.5 pl-3 pr-4 sm:pr-6' /></tr></thead><tbody className='divide-y divide-gray-300 dark:divide-gray-600'>- {- _map(user.sharedProjects, (item) => (- <ProjectList- key={item.id}- item={item}- language={language}- t={t}- removeProject={removeProject}- removeShareProject={removeShareProject}- setUserShareData={setUserShareData}- setProjectsShareData={setProjectsShareData}- userSharedUpdate={userSharedUpdate}- sharedProjectError={sharedProjectError}- />- ))- }+ {_map(user.sharedProjects, (item) => (+ <ProjectList+ key={item.id}+ item={item}+ language={language}+ t={t}+ removeProject={removeProject}+ removeShareProject={removeShareProject}+ setUserShareData={setUserShareData}+ setProjectsShareData={setProjectsShareData}+ userSharedUpdate={userSharedUpdate}+ sharedProjectError={sharedProjectError}+ />+ ))}</tbody></table></div>@@ -659,39 +704,34 @@ const UserSettings = ({</div><hr className='mt-5 border-gray-200 dark:border-gray-600' />{!user.isActive && (- <div href='#' className='flex cursor-pointer mt-4 pl-0 underline text-blue-600 hover:text-indigo-800' onClick={() => onEmailConfirm(setError)}>+ <div+ href='#'+ className='flex cursor-pointer mt-4 pl-0 underline text-blue-600 hover:text-indigo-800'+ onClick={() => onEmailConfirm(setError)}+ ><EnvelopeIcon className='mt-0.5 mr-2 w-6 h-6 text-blue-500' />{t('profileSettings.noLink')}</div>)}<div className='flex justify-between mt-4'>- <Button- onClick={() => setShowExportModal(true)}- semiSmall- primary- >+ <Button onClick={() => setShowExportModal(true)} semiSmall primary><ArrowDownTrayIcon className='w-5 h-5 mr-1' />{t('profileSettings.requestExport')}</Button>- <Button- className='ml-3'- onClick={() => setShowModal(true)}- semiSmall- danger- >+ <Button className='ml-3' onClick={() => setShowModal(true)} semiSmall danger><ExclamationTriangleIcon className='w-5 h-5 mr-1' />{t('profileSettings.delete')}</Button></div></form>- <PaidFeature- isOpened={isPaidFeatureOpened}- onClose={() => setIsPaidFeatureOpened(false)}- />+ <PaidFeature isOpened={isPaidFeatureOpened} onClose={() => setIsPaidFeatureOpened(false)} /><ModalonClose={() => setShowExportModal(false)}- onSubmit={() => { setShowExportModal(false); onExport(user.exportedAt) }}+ onSubmit={() => {+ setShowExportModal(false)+ onExport(user.exportedAt)+ }}submitText={t('common.continue')}closeText={t('common.close')}title={t('profileSettings.dataExport')}@@ -701,7 +741,10 @@ const UserSettings = ({/><ModalonClose={() => setShowModal(false)}- onSubmit={() => { setShowModal(false); onDelete() }}+ onSubmit={() => {+ setShowModal(false)+ onDelete()+ }}submitText={t('profileSettings.aDelete')}closeText={t('common.close')}title={t('profileSettings.qDelete')}@@ -712,7 +755,10 @@ const UserSettings = ({/><ModalonClose={() => setShowAPIDeleteModal(false)}- onSubmit={() => { setShowAPIDeleteModal(false); onApiKeyDelete() }}+ onSubmit={() => {+ setShowAPIDeleteModal(false)+ onApiKeyDelete()+ }}submitText={t('profileSettings.deleteApiKeyBtn')}closeText={t('common.close')}title={t('profileSettings.apiKeyDelete')}@@ -722,7 +768,9 @@ const UserSettings = ({isOpened={showAPIDeleteModal}/><Modal- onClose={() => { setError('') }}+ onClose={() => {+ setError('')+ }}closeText={t('common.gotIt')}type='error'title={t('common.error')}diff --git a/src/ui/Button.jsx b/src/ui/Button.jsxindex 91720648c..edb64cb00 100644--- a/src/ui/Button.jsx+++ b/src/ui/Button.jsx@@ -6,7 +6,7 @@ import PropTypes from 'prop-types'import Spin from './icons/Spin'const Button = ({- text, children, primary, secondary, danger, onClick, white, small, regular, large, giant, type, className, loading, semiSmall, semiDanger,+ text, children, primary, secondary, danger, onClick, white, small, regular, large, giant, type, className, loading, semiSmall, semiDanger, noBorder,}) => (<buttontype={type}@@ -17,6 +17,7 @@ const Button = ({'text-gray-700 bg-white hover:bg-gray-50 border-transparent': white,'text-white bg-red-500 hover:bg-red-600 border-transparent': danger,'text-red-500 hover:text-red-600 border-red-600 dark:text-red-300 dark:hover:text-red-400 dark:border-red-500 border-1': semiDanger,+ 'focus:border-none border-none text-gray-700 dark:text-white focus:ring-0 focus:ring-offset-0': noBorder,'px-2.5 py-1.5 text-xs': small,'px-2.5 py-1.5 text-sm': semiSmall,'px-4 py-2 text-sm': large,diff --git a/tailwind.config.js b/tailwind.config.jsindex 68a2e1fc8..448a0f55c 100644--- a/tailwind.config.js+++ b/tailwind.config.js@@ -23,6 +23,7 @@ module.exports = {},animation: {'ping-slow': 'ping-op 3s cubic-bezier(0, 0, 0.2, 1) infinite',+ 'copy-icon': 'copy-icon 0.5s cubic-bezier(0, 0, 0.2, 1) 2'},keyframes: {'ping-op': {@@ -34,6 +35,20 @@ module.exports = {opacity: 0,},},+ 'effect-dylan': {+ '50%': {+ transform: 'scale(1.5, 1.5)',+ opacity: 0,+ },+ '99%': {+ transform: 'scale(0.001, 0.001)',+ opacity: 0,+ },+ '100%': {+ transform: 'scale(0.001, 0.001)',+ opacity: 1,+ }+ }},},minHeight: {