Skip to content

Commit

Permalink
2.19.0: chore: remove 100% analytics #45
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Jun 3, 2023
1 parent 8f40638 commit 041111e
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 131 deletions.
58 changes: 2 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"dependencies": {
"@heroicons/react": "^2.0.13",
"lodash": "^4.17.21",
"posthog-js": "^1.37.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.42.1",
Expand Down
15 changes: 0 additions & 15 deletions src/LegacySettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Notice, TFolder } from 'obsidian';
import posthog from 'posthog-js';
import * as React from 'react';
import { PrimaryButton, SecondaryButton } from './Button';
import AvaPlugin from './main';
Expand Down Expand Up @@ -78,9 +77,6 @@ export function AdvancedSettings({ plugin }: { plugin: AvaPlugin }) {
}, []);

const handleClearIndex = () => {
posthog.capture('settings', {
action: 'clearIndex',
});
setIsLoading(true);
new Notice('Clearing 🧙 Links index', 5000);
plugin
Expand All @@ -98,10 +94,6 @@ export function AdvancedSettings({ plugin }: { plugin: AvaPlugin }) {
};
const enableLinks = (value: boolean) => {
console.log('enableLinks', value);
posthog.capture('settings', {
action: 'useLinks',
value: value,
});
plugin.settings.useLinks = value;
plugin.saveSettings();
setUseLinks(value);
Expand All @@ -125,10 +117,6 @@ export function AdvancedSettings({ plugin }: { plugin: AvaPlugin }) {
};
const handleDebug = (event: React.ChangeEvent<HTMLInputElement>) => {
const checked = event.target.checked;
posthog.capture('settings', {
action: 'debug',
value: checked,
});
plugin.settings.debug = checked;
plugin.saveSettings();
setDebug(checked);
Expand All @@ -141,9 +129,6 @@ export function AdvancedSettings({ plugin }: { plugin: AvaPlugin }) {
};
// this will not refresh the ui but it will clear the cache
const handleDeleteCache = () => {
posthog.capture('settings', {
action: 'deleteCache',
});
plugin.settings.token = undefined;
plugin.settings.vaultId = undefined;
plugin.saveSettings();
Expand Down
13 changes: 0 additions & 13 deletions src/LinkComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ChevronDownIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
import { Notice } from 'obsidian';
import { posthog } from 'posthog-js';
import * as React from 'react';
import { useForm } from 'react-hook-form';
import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
Expand Down Expand Up @@ -99,10 +98,6 @@ const ControlForm = () => {
new Notice('🧙 You need to login to use this feature', 3000);
return;
}
posthog.capture('use-feature', {
feature: 'search',
limit: data.limit,
});
state.setEmbedsLoading(true);
const query: any = {
content: state.currentFileContent,
Expand Down Expand Up @@ -195,12 +190,6 @@ export function LinkComponent() {
const embeds = state.embeds;
const threshold = 0.5;

const trackCopy = () => {
posthog.capture('copy-links');
};
const trackInsert = () => {
posthog.capture('insert-links');
};

React.useEffect(() => {
if (!embeds) {
Expand Down Expand Up @@ -241,13 +230,11 @@ export function LinkComponent() {
<CopyToClipboardButton
disabled={disableButtons}
text={textToInsert}
extraOnClick={trackCopy}
/>
<InsertButton
disabled={disableButtons}
text={textToInsert}
editorContext={state.editorContext}
extraOnClick={trackInsert}
/>
</div>
<div className="text-sm text-[var(--text-faint)]">
Expand Down
7 changes: 0 additions & 7 deletions src/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { posthog } from 'posthog-js';
import * as React from 'react';
import { PrimaryButton } from './Button';
import useRetryUntilResolved from './hooks';
Expand Down Expand Up @@ -32,10 +31,6 @@ const Connect = ({ plugin }: { plugin: AvaPlugin }) => {
plugin.settings.token = linkData?.token;
plugin.settings.userId = linkData?.userId;

posthog.identify(linkData.userId, {
vaultId: vaultId,
version: plugin.manifest.version,
});
plugin.saveSettings();
setAttemptingToConnect(false);

Expand All @@ -46,14 +41,12 @@ const Connect = ({ plugin }: { plugin: AvaPlugin }) => {
}, 2000);

const handleConnect = async () => {
posthog.capture('ava-connect');
const vaultId = getVaultId(plugin);
setAttemptingToConnect(true);
openApp(vaultId);
};

const handleDisconnect = () => {
posthog.capture('ava-disconnect');
plugin.settings.token = '';
plugin.unlistenToNoteEvents();
setAttemptingToConnect(false);
Expand Down
14 changes: 0 additions & 14 deletions src/WriteComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Notice } from 'obsidian';
import posthog from 'posthog-js';
import * as React from 'react';
import { useForm } from 'react-hook-form';
import { CopyToClipboardButton } from './CopyToClipboard';
Expand Down Expand Up @@ -27,10 +26,6 @@ export const WriteComponent = () => {
return;
}
if (data.content.length > REWRITE_CHAR_LIMIT) {
posthog.capture('too-long-selection', {
length: data.content.length,
action: 'rewrite',
});
new Notice(
'🧙 AVA - Text is too long, please reduce to less than 5800 characters ~1200 words'
);
Expand All @@ -45,7 +40,6 @@ export const WriteComponent = () => {
};
// only capture short prompt as it's more data privacy wise
if (prompt.length < 100) d.prompt = prompt;
posthog.capture('use-feature', d);
store.setState({ loadingContent: true });

try {
Expand Down Expand Up @@ -115,12 +109,6 @@ export const WriteComponent = () => {
React.useEffect(() => {
setValue('content', state.content);
}, [state.content, setValue]);
const trackCopy = () => {
posthog.capture('copy-write');
};
const trackInsert = () => {
posthog.capture('insert-write');
};

const handleOnChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
store.getState().replaceContentToRewrite(e.target.value);
Expand All @@ -135,13 +123,11 @@ export const WriteComponent = () => {
<CopyToClipboardButton
disabled={disableButtons}
text={state.content}
extraOnClick={trackCopy}
/>
<InsertButton
disabled={disableButtons}
editorContext={state.editorContext}
text={state.content}
extraOnClick={trackInsert}
/>
</div>

Expand Down
Loading

0 comments on commit 041111e

Please sign in to comment.