Skip to content

Commit a33f54c

Browse files
committed
electron app start counter
1 parent 265d012 commit a33f54c

6 files changed

Lines changed: 117 additions & 25 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"mousetrap": "^1.6.5",
6262
"notistack": "^3.0.1",
6363
"postcss": "^8.4.35",
64+
"posthog-node": "^4.0.1",
6465
"react": "^18.2.0",
6566
"react-copy-to-clipboard": "^5.1.0",
6667
"react-custom-scrollbars": "^4.2.1",

pnpm-lock.yaml

Lines changed: 55 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/molecules/modals/SettingsModal.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const SettingsModal = ({ closeFn = () => null, open = false, initialTab = 0 }) =
2222
const [enabled, setEnabled] = useState(false);
2323
const [accessId, setAccessId] = useState('');
2424
const [accessKey, setAccessKey] = useState('');
25-
console.log(config);
2625

2726
// const {
2827
// register,

src/components/pages/Home.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ import HorizontalDivider from 'components/atoms/common/HorizontalDivider';
1111
import WithoutSplitPane from 'components/layouts/WithoutSplitPane';
1212
import useCollectionStore from 'stores/CollectionStore';
1313
import registerSettingsEventHandlers from 'ipc/settings';
14+
import useTelemetry from 'utils/useTelemetry';
1415

1516
const Home = () => {
1617
const collections = useCollectionStore((state) => state.collections);
1718
const showLoader = useCommonStore((state) => state.showLoader);
1819
registerMainEventHandlers();
1920
registerSettingsEventHandlers();
21+
useTelemetry();
2022
return (
21-
<div className='relative flex h-full flex-col font-openSans text-cyan-900'>
23+
<div className='relative flex flex-col h-full font-openSans text-cyan-900'>
2224
<MainHeader />
2325
<HorizontalDivider />
2426
{/* For some reason with this condition in SplitPane component, drag feature was not getting enabled thus putting this here

src/ipc/collection.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const registerMainEventHandlers = () => {
1818
const { ipcRenderer } = window;
1919

2020
ipcRenderer.on('main:collection-created', (id, name, pathname, nodes) => {
21-
console.log(`\n \n main:collection-created :: _createCollection \n \n `);
2221
_createCollection(id, name, pathname, nodes);
2322
});
2423

src/utils/useTelemetry.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Telemetry in FlowTestAI is just an anonymous visit counter (triggered once per day).
3+
* The only details shared are:
4+
* - OS (ex: mac, windows, linux)
5+
* - Version (ex: 1.3.0)
6+
* We don't track usage analytics / micro-interactions / crash logs / anything else.
7+
*/
8+
9+
import { useEffect } from 'react';
10+
import { v4 as uuidv4 } from 'uuid';
11+
// import getConfig from 'next/config';
12+
import { PostHog } from 'posthog-node';
13+
14+
const posthogApiKey = 'phc_NWEriNXcUcZ1QB3GDBHrM3NDzZj69P1npzZ9PY2A5tW';
15+
let posthogClient = null;
16+
17+
const getPosthogClient = () => {
18+
if (posthogClient) {
19+
return posthogClient;
20+
}
21+
22+
posthogClient = new PostHog(posthogApiKey);
23+
return posthogClient;
24+
};
25+
26+
const getAnonymousId = () => {
27+
let id = localStorage.getItem('flowtestai.anonymousId');
28+
29+
if (!id || !id.length || id.length !== 21) {
30+
id = uuidv4();
31+
localStorage.setItem('flowtestai.anonymousId', id);
32+
}
33+
34+
return id;
35+
};
36+
37+
const trackStart = () => {
38+
const { ipcRenderer } = window;
39+
const id = getAnonymousId();
40+
const client = getPosthogClient();
41+
client.capture({
42+
distinctId: id,
43+
event: 'start',
44+
properties: {
45+
os: ipcRenderer.isMacOs() ? 'darwin' : 'win32',
46+
version: '1.2.0',
47+
},
48+
});
49+
};
50+
51+
const useTelemetry = () => {
52+
useEffect(() => {
53+
trackStart();
54+
setInterval(trackStart, 24 * 60 * 60 * 1000);
55+
}, []);
56+
};
57+
58+
export default useTelemetry;

0 commit comments

Comments
 (0)