diff --git a/package.json b/package.json index 8e20df3..ec996ff 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "@emotion/styled": "^11.11.0", "@headlessui/react": "^1.7.18", "@heroicons/react": "^2.1.1", - "@hookform/resolvers": "^3.7.0", "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", @@ -62,12 +61,12 @@ "mousetrap": "^1.6.5", "notistack": "^3.0.1", "postcss": "^8.4.35", + "posthog-node": "^4.0.1", "react": "^18.2.0", "react-copy-to-clipboard": "^5.1.0", "react-custom-scrollbars": "^4.2.1", "react-dom": "^18.2.0", "react-edit-text": "^5.1.1", - "react-hook-form": "^7.52.0", "react-icons": "^5.0.1", "react-json-view-lite": "^1.4.0", "react-perfect-scrollbar": "^1.5.8", @@ -82,12 +81,10 @@ "tailwindcss": "^3.4.1", "typescript": "4", "web-vitals": "^2.1.4", - "zod": "^3.23.8", "zustand": "^4.5.2" }, "devDependencies": { "@changesets/cli": "^2.27.1", - "@tailwindcss/forms": "^0.5.7", "@tailwindcss/typography": "^0.5.10", "@types/node": "20.11.5", "daisyui": "^4.7.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e04f2ee..10a5ca0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35,9 +35,6 @@ importers: '@heroicons/react': specifier: ^2.1.1 version: 2.1.3(react@18.3.1) - '@hookform/resolvers': - specifier: ^3.7.0 - version: 3.7.0(react-hook-form@7.52.0(react@18.3.1)) '@testing-library/jest-dom': specifier: ^5.17.0 version: 5.17.0 @@ -86,6 +83,9 @@ importers: postcss: specifier: ^8.4.35 version: 8.4.38 + posthog-node: + specifier: ^4.0.1 + version: 4.0.1 react: specifier: ^18.2.0 version: 18.3.1 @@ -101,9 +101,6 @@ importers: react-edit-text: specifier: ^5.1.1 version: 5.1.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - react-hook-form: - specifier: ^7.52.0 - version: 7.52.0(react@18.3.1) react-icons: specifier: ^5.0.1 version: 5.2.1(react@18.3.1) @@ -146,9 +143,6 @@ importers: web-vitals: specifier: ^2.1.4 version: 2.1.4 - zod: - specifier: ^3.23.8 - version: 3.23.8 zustand: specifier: ^4.5.2 version: 4.5.2(@types/react@18.3.3)(immer@10.1.1)(react@18.3.1) @@ -156,9 +150,6 @@ importers: '@changesets/cli': specifier: ^2.27.1 version: 2.27.5 - '@tailwindcss/forms': - specifier: ^0.5.7 - version: 0.5.7(tailwindcss@3.4.3) '@tailwindcss/typography': specifier: ^0.5.10 version: 0.5.13(tailwindcss@3.4.3) @@ -1508,11 +1499,6 @@ packages: peerDependencies: react: '>= 16' - '@hookform/resolvers@3.7.0': - resolution: {integrity: sha512-42p5X18noBV3xqOpTlf2V5qJZwzNgO4eLzHzmKGh/w7z4+4XqRw5AsESVkqE+qwAuRRlg2QG12EVEjPkrRIbeg==} - peerDependencies: - react-hook-form: ^7.0.0 - '@humanwhocodes/config-array@0.11.14': resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==} engines: {node: '>=10.10.0'} @@ -2421,11 +2407,6 @@ packages: resolution: {integrity: sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==} engines: {node: '>=10'} - '@tailwindcss/forms@0.5.7': - resolution: {integrity: sha512-QE7X69iQI+ZXwldE+rzasvbJiyV/ju1FGHH0Qn2W3FKbuYtqp8LKcy6iSw79fVUT5/Vvf+0XgLCeYVG+UV6hOw==} - peerDependencies: - tailwindcss: '>=3.0.0 || >= 3.0.0-alpha.1' - '@tailwindcss/typography@0.5.13': resolution: {integrity: sha512-ADGcJ8dX21dVVHIwTRgzrcunY6YY9uSlAHHGVKvkA+vLc5qLwEszvKts40lx7z0qc4clpjclwLeK5rVCV2P/uw==} peerDependencies: @@ -6183,10 +6164,6 @@ packages: peerDependencies: webpack: ^5.0.0 - mini-svg-data-uri@1.4.4: - resolution: {integrity: sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==} - hasBin: true - minimalistic-assert@1.0.1: resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} @@ -7045,6 +7022,10 @@ packages: resolution: {integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==} engines: {node: ^10 || ^12 || >=14} + posthog-node@4.0.1: + resolution: {integrity: sha512-rtqm2h22QxLGBrW2bLYzbRhliIrqgZ0k+gF0LkQ1SNdeD06YE5eilV0MxZppFSxC8TfH0+B0cWCuebEnreIDgQ==} + engines: {node: '>=15.0.0'} + preferred-pm@3.1.3: resolution: {integrity: sha512-MkXsENfftWSRpzCzImcp4FRsCc3y1opwB73CfCNWyzMqArju2CrlMHlqB7VexKiPEOjGMbttv1r9fSCn5S610w==} engines: {node: '>=10'} @@ -7277,12 +7258,6 @@ packages: react-error-overlay@6.0.11: resolution: {integrity: sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg==} - react-hook-form@7.52.0: - resolution: {integrity: sha512-mJX506Xc6mirzLsmXUJyqlAI3Kj9Ph2RhplYhUVffeOQSnubK2uVqBFOBJmvKikvbFV91pxVXmDiR+QMF19x6A==} - engines: {node: '>=12.22.0'} - peerDependencies: - react: ^16.8.0 || ^17 || ^18 || ^19 - react-icons@5.2.1: resolution: {integrity: sha512-zdbW5GstTzXaVKvGSyTaBalt7HSfuK5ovrzlpyiWHAFXndXTdd/1hdDHI4xBM1Mn7YriT6aqESucFl9kEXzrdw==} peerDependencies: @@ -7554,6 +7529,9 @@ packages: run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} + rusha@0.8.14: + resolution: {integrity: sha512-cLgakCUf6PedEu15t8kbsjnwIFFR2D4RfL+W3iWFJ4iac7z4B0ZI8fxy4R3J956kAI68HclCFGL8MPoUVC3qVA==} + safe-array-concat@1.1.2: resolution: {integrity: sha512-vj6RsCsWBCf19jIeHEfkRMw8DPiBb+DMXklQ/1SGDHOMlHdPUkZXFQ2YdplS23zESTijAcurb1aSgJA3AgMu1Q==} engines: {node: '>=0.4'} @@ -8952,9 +8930,9 @@ snapshots: dependencies: '@aws-crypto/sha256-browser': 3.0.0 '@aws-crypto/sha256-js': 3.0.0 - '@aws-sdk/client-sts': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0) + '@aws-sdk/client-sts': 3.583.0 '@aws-sdk/core': 3.582.0 - '@aws-sdk/credential-provider-node': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0)(@aws-sdk/client-sts@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)) + '@aws-sdk/credential-provider-node': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0)(@aws-sdk/client-sts@3.583.0) '@aws-sdk/middleware-host-header': 3.577.0 '@aws-sdk/middleware-logger': 3.577.0 '@aws-sdk/middleware-recursion-detection': 3.577.0 @@ -8993,11 +8971,13 @@ snapshots: transitivePeerDependencies: - aws-crt - '@aws-sdk/client-sso@3.583.0': + '@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0)': dependencies: '@aws-crypto/sha256-browser': 3.0.0 '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.583.0 '@aws-sdk/core': 3.582.0 + '@aws-sdk/credential-provider-node': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0))(@aws-sdk/client-sts@3.583.0) '@aws-sdk/middleware-host-header': 3.577.0 '@aws-sdk/middleware-logger': 3.577.0 '@aws-sdk/middleware-recursion-detection': 3.577.0 @@ -9034,15 +9014,14 @@ snapshots: '@smithy/util-utf8': 3.0.0 tslib: 2.6.2 transitivePeerDependencies: + - '@aws-sdk/client-sts' - aws-crt - '@aws-sdk/client-sts@3.583.0': + '@aws-sdk/client-sso@3.583.0': dependencies: '@aws-crypto/sha256-browser': 3.0.0 '@aws-crypto/sha256-js': 3.0.0 - '@aws-sdk/client-sso-oidc': 3.583.0 '@aws-sdk/core': 3.582.0 - '@aws-sdk/credential-provider-node': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0)(@aws-sdk/client-sts@3.583.0) '@aws-sdk/middleware-host-header': 3.577.0 '@aws-sdk/middleware-logger': 3.577.0 '@aws-sdk/middleware-recursion-detection': 3.577.0 @@ -9081,13 +9060,13 @@ snapshots: transitivePeerDependencies: - aws-crt - '@aws-sdk/client-sts@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)': + '@aws-sdk/client-sts@3.583.0': dependencies: '@aws-crypto/sha256-browser': 3.0.0 '@aws-crypto/sha256-js': 3.0.0 - '@aws-sdk/client-sso-oidc': 3.583.0 + '@aws-sdk/client-sso-oidc': 3.583.0(@aws-sdk/client-sts@3.583.0) '@aws-sdk/core': 3.582.0 - '@aws-sdk/credential-provider-node': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0)(@aws-sdk/client-sts@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)) + '@aws-sdk/credential-provider-node': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0))(@aws-sdk/client-sts@3.583.0) '@aws-sdk/middleware-host-header': 3.577.0 '@aws-sdk/middleware-logger': 3.577.0 '@aws-sdk/middleware-recursion-detection': 3.577.0 @@ -9124,7 +9103,6 @@ snapshots: '@smithy/util-utf8': 3.0.0 tslib: 2.6.2 transitivePeerDependencies: - - '@aws-sdk/client-sso-oidc' - aws-crt '@aws-sdk/core@3.582.0': @@ -9156,13 +9134,13 @@ snapshots: '@smithy/util-stream': 3.0.1 tslib: 2.6.2 - '@aws-sdk/credential-provider-ini@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)(@aws-sdk/client-sts@3.583.0(@aws-sdk/client-sso-oidc@3.583.0))': + '@aws-sdk/credential-provider-ini@3.583.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0))(@aws-sdk/client-sts@3.583.0)': dependencies: - '@aws-sdk/client-sts': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0) + '@aws-sdk/client-sts': 3.583.0 '@aws-sdk/credential-provider-env': 3.577.0 '@aws-sdk/credential-provider-process': 3.577.0 - '@aws-sdk/credential-provider-sso': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0) - '@aws-sdk/credential-provider-web-identity': 3.577.0(@aws-sdk/client-sts@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)) + '@aws-sdk/credential-provider-sso': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0)) + '@aws-sdk/credential-provider-web-identity': 3.577.0(@aws-sdk/client-sts@3.583.0) '@aws-sdk/types': 3.577.0 '@smithy/credential-provider-imds': 3.0.0 '@smithy/property-provider': 3.0.0 @@ -9190,14 +9168,14 @@ snapshots: - '@aws-sdk/client-sso-oidc' - aws-crt - '@aws-sdk/credential-provider-node@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)(@aws-sdk/client-sts@3.583.0(@aws-sdk/client-sso-oidc@3.583.0))': + '@aws-sdk/credential-provider-node@3.583.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0))(@aws-sdk/client-sts@3.583.0)': dependencies: '@aws-sdk/credential-provider-env': 3.577.0 '@aws-sdk/credential-provider-http': 3.582.0 - '@aws-sdk/credential-provider-ini': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0)(@aws-sdk/client-sts@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)) + '@aws-sdk/credential-provider-ini': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0))(@aws-sdk/client-sts@3.583.0) '@aws-sdk/credential-provider-process': 3.577.0 - '@aws-sdk/credential-provider-sso': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0) - '@aws-sdk/credential-provider-web-identity': 3.577.0(@aws-sdk/client-sts@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)) + '@aws-sdk/credential-provider-sso': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0)) + '@aws-sdk/credential-provider-web-identity': 3.577.0(@aws-sdk/client-sts@3.583.0) '@aws-sdk/types': 3.577.0 '@smithy/credential-provider-imds': 3.0.0 '@smithy/property-provider': 3.0.0 @@ -9236,10 +9214,10 @@ snapshots: '@smithy/types': 3.0.0 tslib: 2.6.2 - '@aws-sdk/credential-provider-sso@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)': + '@aws-sdk/credential-provider-sso@3.583.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0))': dependencies: '@aws-sdk/client-sso': 3.583.0 - '@aws-sdk/token-providers': 3.577.0(@aws-sdk/client-sso-oidc@3.583.0) + '@aws-sdk/token-providers': 3.577.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0)) '@aws-sdk/types': 3.577.0 '@smithy/property-provider': 3.0.0 '@smithy/shared-ini-file-loader': 3.0.0 @@ -9249,13 +9227,18 @@ snapshots: - '@aws-sdk/client-sso-oidc' - aws-crt - '@aws-sdk/credential-provider-web-identity@3.577.0(@aws-sdk/client-sts@3.583.0(@aws-sdk/client-sso-oidc@3.583.0))': + '@aws-sdk/credential-provider-sso@3.583.0(@aws-sdk/client-sso-oidc@3.583.0)': dependencies: - '@aws-sdk/client-sts': 3.583.0(@aws-sdk/client-sso-oidc@3.583.0) + '@aws-sdk/client-sso': 3.583.0 + '@aws-sdk/token-providers': 3.577.0(@aws-sdk/client-sso-oidc@3.583.0) '@aws-sdk/types': 3.577.0 '@smithy/property-provider': 3.0.0 + '@smithy/shared-ini-file-loader': 3.0.0 '@smithy/types': 3.0.0 tslib: 2.6.2 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt '@aws-sdk/credential-provider-web-identity@3.577.0(@aws-sdk/client-sts@3.583.0)': dependencies: @@ -9302,6 +9285,15 @@ snapshots: '@smithy/util-middleware': 3.0.0 tslib: 2.6.2 + '@aws-sdk/token-providers@3.577.0(@aws-sdk/client-sso-oidc@3.583.0(@aws-sdk/client-sts@3.583.0))': + dependencies: + '@aws-sdk/client-sso-oidc': 3.583.0(@aws-sdk/client-sts@3.583.0) + '@aws-sdk/types': 3.577.0 + '@smithy/property-provider': 3.0.0 + '@smithy/shared-ini-file-loader': 3.0.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + '@aws-sdk/token-providers@3.577.0(@aws-sdk/client-sso-oidc@3.583.0)': dependencies: '@aws-sdk/client-sso-oidc': 3.583.0 @@ -10678,10 +10670,6 @@ snapshots: dependencies: react: 18.3.1 - '@hookform/resolvers@3.7.0(react-hook-form@7.52.0(react@18.3.1))': - dependencies: - react-hook-form: 7.52.0(react@18.3.1) - '@humanwhocodes/config-array@0.11.14': dependencies: '@humanwhocodes/object-schema': 2.0.3 @@ -11736,11 +11724,6 @@ snapshots: dependencies: defer-to-connect: 2.0.1 - '@tailwindcss/forms@0.5.7(tailwindcss@3.4.3)': - dependencies: - mini-svg-data-uri: 1.4.4 - tailwindcss: 3.4.3 - '@tailwindcss/typography@0.5.13(tailwindcss@3.4.3)': dependencies: lodash.castarray: 4.4.0 @@ -16409,8 +16392,6 @@ snapshots: tapable: 2.2.1 webpack: 5.91.0 - mini-svg-data-uri@1.4.4: {} - minimalistic-assert@1.0.1: {} minimatch@3.1.2: @@ -17253,6 +17234,13 @@ snapshots: picocolors: 1.0.1 source-map-js: 1.2.0 + posthog-node@4.0.1: + dependencies: + axios: 1.7.2 + rusha: 0.8.14 + transitivePeerDependencies: + - debug + preferred-pm@3.1.3: dependencies: find-up: 5.0.0 @@ -17457,10 +17445,6 @@ snapshots: react-error-overlay@6.0.11: {} - react-hook-form@7.52.0(react@18.3.1): - dependencies: - react: 18.3.1 - react-icons@5.2.1(react@18.3.1): dependencies: react: 18.3.1 @@ -17836,6 +17820,8 @@ snapshots: dependencies: queue-microtask: 1.2.3 + rusha@0.8.14: {} + safe-array-concat@1.1.2: dependencies: call-bind: 1.0.7 diff --git a/src/components/molecules/modals/SettingsModal.js b/src/components/molecules/modals/SettingsModal.js index a165735..14dfae9 100644 --- a/src/components/molecules/modals/SettingsModal.js +++ b/src/components/molecules/modals/SettingsModal.js @@ -1,54 +1,58 @@ import React, { Fragment, useState, useEffect } from 'react'; import { Dialog, Transition, Tab } from '@headlessui/react'; -import { useForm } from 'react-hook-form'; -import { z } from 'zod'; -import { zodResolver } from '@hookform/resolvers/zod'; +// import { useForm } from 'react-hook-form'; +// import { z } from 'zod'; +// import { zodResolver } from '@hookform/resolvers/zod'; import { XCircleIcon } from '@heroicons/react/20/solid'; import Button from 'components/atoms/common/Button'; import { BUTTON_INTENT_TYPES, BUTTON_TYPES } from 'constants/Common'; import { addLogSyncConfig } from 'service/settings'; import useSettingsStore from 'stores/SettingsStore'; -const schema = z.object({ - enabled: z.boolean(), - accessId: z.string(), - accessKey: z.string(), -}); +// const schema = z.object({ +// enabled: z.boolean(), +// accessId: z.string(), +// accessKey: z.string(), +// }); const SettingsModal = ({ closeFn = () => null, open = false, initialTab = 0 }) => { const [successFullSubmissionMessage, showSuccessFullSubmissionMessage] = useState(false); + const [failureFullSubmissionMessage, showFailureFullSubmissionMessage] = useState(false); const config = useSettingsStore((state) => state.logSyncConfig); + const [enabled, setEnabled] = useState(false); + const [accessId, setAccessId] = useState(''); + const [accessKey, setAccessKey] = useState(''); - const { - register, - handleSubmit, - setValue, - setError, - formState: { errors, isSubmitting }, - } = useForm({ - defaultValues: { - enabled: false, - accessId: '', - accessKey: '', - }, - resolver: zodResolver(schema), - }); + // const { + // register, + // handleSubmit, + // setValue, + // setError, + // formState: { errors, isSubmitting }, + // } = useForm({ + // defaultValues: { + // enabled: false, + // accessId: '', + // accessKey: '', + // }, + // resolver: zodResolver(schema), + // }); useEffect(() => { - setValue('enabled', config?.enabled || false); - setValue('accessId', config?.accessId || ''); - setValue('accessKey', config?.accessKey || ''); + setEnabled(config?.enabled || false); + setAccessId(config?.accessId || ''); + setAccessKey(config?.accessKey || ''); }, [config]); - const onFormSubmit = async (data) => { + const onFormSubmit = async () => { try { - await addLogSyncConfig(data.enabled, 'https://flowtest-ai.vercel.app', data.accessId, data.accessKey); + await addLogSyncConfig(enabled, 'https://flowtest-ai.vercel.app', accessId, accessKey); // send the form data as a request showSuccessFullSubmissionMessage(true); closeFn(); } catch (error) { // To show error message from the request handler - setError('root', { message: error }); + showFailureFullSubmissionMessage(true); } }; @@ -59,6 +63,9 @@ const SettingsModal = ({ closeFn = () => null, open = false, initialTab = 0 }) = as='div' className='relative z-10' onClose={() => { + setEnabled(config?.enabled || false); + setAccessId(config?.accessId || ''); + setAccessKey(config?.accessKey || ''); closeFn(); }} > @@ -114,65 +121,74 @@ const SettingsModal = ({ closeFn = () => null, open = false, initialTab = 0 }) = {/* Scans Content */} -
-
-
-

- Scans aim to provide anayltics and observability for your flows.
- - Get Access Keys - -

-
-
- - - {errors.enabled &&
{errors.enabled.message}
} -
-
- - - {errors.accessId &&
{errors.accessId.message}
} -
-
- - - {errors.accessKey &&
{errors.accessKey.message}
} -
-
- {errors.root &&
{errors.root.message}
}{' '} - {successFullSubmissionMessage && ( -
Successfully saved settings
- )} -
+
+
+

+ Scans aim to provide anayltics and observability for your flows.
+ + Get Access Keys + +

-
- +
+ + setEnabled(!enabled)} + id='enabled' + className='block' + />
- +
+ + setAccessId(e.target.value)} + type='text' + placeholder='Access Id' + className='mb-2 block w-full rounded border border-slate-700 bg-background-light p-2.5 text-sm text-slate-900 outline-none' + /> +
+
+ + setAccessKey(e.target.value)} + type='text' + placeholder='Access Key' + className='mb-2 block w-full rounded border border-slate-700 bg-background-light p-2.5 text-sm text-slate-900 outline-none' + /> +
+
+ {failureFullSubmissionMessage && ( +
Failed to saved settings
+ )} + {successFullSubmissionMessage && ( +
Successfully saved settings
+ )} +
+
+
+ +
{/* Theme Content */} diff --git a/src/components/pages/Home.js b/src/components/pages/Home.js index bc9c331..282473b 100644 --- a/src/components/pages/Home.js +++ b/src/components/pages/Home.js @@ -11,14 +11,16 @@ import HorizontalDivider from 'components/atoms/common/HorizontalDivider'; import WithoutSplitPane from 'components/layouts/WithoutSplitPane'; import useCollectionStore from 'stores/CollectionStore'; import registerSettingsEventHandlers from 'ipc/settings'; +import useTelemetry from 'utils/useTelemetry'; const Home = () => { const collections = useCollectionStore((state) => state.collections); const showLoader = useCommonStore((state) => state.showLoader); registerMainEventHandlers(); registerSettingsEventHandlers(); + useTelemetry(); return ( -
+
{/* For some reason with this condition in SplitPane component, drag feature was not getting enabled thus putting this here diff --git a/src/ipc/collection.js b/src/ipc/collection.js index c998df0..43a13fe 100644 --- a/src/ipc/collection.js +++ b/src/ipc/collection.js @@ -18,7 +18,6 @@ const registerMainEventHandlers = () => { const { ipcRenderer } = window; ipcRenderer.on('main:collection-created', (id, name, pathname, nodes) => { - console.log(`\n \n main:collection-created :: _createCollection \n \n `); _createCollection(id, name, pathname, nodes); }); diff --git a/src/utils/useTelemetry.js b/src/utils/useTelemetry.js new file mode 100644 index 0000000..a599314 --- /dev/null +++ b/src/utils/useTelemetry.js @@ -0,0 +1,58 @@ +/** + * Telemetry in FlowTestAI is just an anonymous visit counter (triggered once per day). + * The only details shared are: + * - OS (ex: mac, windows, linux) + * - Version (ex: 1.3.0) + * We don't track usage analytics / micro-interactions / crash logs / anything else. + */ + +import { useEffect } from 'react'; +import { v4 as uuidv4 } from 'uuid'; +// import getConfig from 'next/config'; +import { PostHog } from 'posthog-node'; + +const posthogApiKey = 'phc_NWEriNXcUcZ1QB3GDBHrM3NDzZj69P1npzZ9PY2A5tW'; +let posthogClient = null; + +const getPosthogClient = () => { + if (posthogClient) { + return posthogClient; + } + + posthogClient = new PostHog(posthogApiKey); + return posthogClient; +}; + +const getAnonymousId = () => { + let id = localStorage.getItem('flowtestai.anonymousId'); + + if (!id || !id.length || id.length !== 21) { + id = uuidv4(); + localStorage.setItem('flowtestai.anonymousId', id); + } + + return id; +}; + +const trackStart = () => { + const { ipcRenderer } = window; + const id = getAnonymousId(); + const client = getPosthogClient(); + client.capture({ + distinctId: id, + event: 'start', + properties: { + os: ipcRenderer.isMacOs() ? 'darwin' : 'win32', + version: '1.2.0', + }, + }); +}; + +const useTelemetry = () => { + useEffect(() => { + trackStart(); + setInterval(trackStart, 24 * 60 * 60 * 1000); + }, []); +}; + +export default useTelemetry; diff --git a/tailwind.config.js b/tailwind.config.js index eaa690a..0b5c8fa 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -70,7 +70,7 @@ module.exports = { montserrat: ['Montserrat', 'sans-serif'], }, }, - plugins: [require('daisyui'), require('@tailwindcss/forms')], + plugins: [require('daisyui')], daisyui: { // themes: false, themes: [],