Skip to content

Commit 18d51fc

Browse files
authored
add retention and time to complete for tutorial (#9)
1 parent 6ec48b0 commit 18d51fc

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed

src/background.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { checkUrlForPhishing } from './services/phishing/phishingService';
1515
import { checkAllWalletsAndCreateAlerts } from './services/http/versionService';
1616
import { WgKeys } from './lib/helpers/chrome/localStorageKeys';
1717
import * as Sentry from '@sentry/react';
18-
import { posthog } from 'posthog-js';
1918

2019
const log = logger.child({ component: 'Background' });
2120

@@ -123,23 +122,10 @@ chrome.runtime.onInstalled.addListener(async (details) => {
123122

124123
await checkAllWalletsAndCreateAlerts();
125124

126-
posthog.init('phc_rb7Dd9nqkBMJYCCh7MQWpXtkNqIGUFdCZbUThgipNQD', {
127-
api_host: 'https://app.posthog.com',
128-
persistence: 'localStorage',
129-
autocapture: false,
130-
});
131-
132125
if (process.env.NODE_ENV === 'production' && details.reason === 'install') {
133-
posthog.capture('install');
134126
openDashboard();
135127
chrome.runtime.setUninstallURL('https://forms.gle/KzGYKYFzUpYtTn9i8');
136128
}
137-
138-
if (details.reason === 'update') {
139-
chrome.management.getSelf().then((res) => {
140-
posthog.capture('update', { version: res.version });
141-
});
142-
}
143129
});
144130

145131
// STARTUP

src/components/app-dashboard/tabs/dashboard/DashboardTab.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ export function DashboardTab() {
5252
const { isOpen, onOpen, onClose } = useDisclosure();
5353
const LAST_TUTORIAL_INDEX = 3;
5454

55-
function completeTutorial() {
56-
setTutorialComplete(true);
57-
chrome.storage.local.set({ [WgKeys.TutorialComplete]: true });
58-
}
59-
6055
useEffect(() => {
6156
getVersionFromLocalStorage();
6257

@@ -70,6 +65,7 @@ export function DashboardTab() {
7065
});
7166
localStorageHelpers.get<boolean>(WgKeys.TutorialComplete).then((res) => {
7267
if (res !== true) {
68+
posthog.capture('startTutorial');
7369
setTutorialComplete(false);
7470
} else {
7571
setTutorialComplete(true);
@@ -89,13 +85,22 @@ export function DashboardTab() {
8985

9086
function goToTutorialStep(index: number) {
9187
setTutorialStep(index);
88+
posthog.capture('updateTutorialStep', { step: index });
9289
}
9390

9491
function nextTutorialStep() {
9592
if (tutorialStep === LAST_TUTORIAL_INDEX) {
9693
completeTutorial();
94+
return;
9795
}
9896
setTutorialStep((step) => step + 1);
97+
posthog.capture('updateTutorialStep', { step: tutorialStep + 1 });
98+
}
99+
100+
function completeTutorial() {
101+
posthog.capture('completeTutorial');
102+
setTutorialComplete(true);
103+
chrome.storage.local.set({ [WgKeys.TutorialComplete]: true });
99104
}
100105

101106
function getTutorialText() {

src/lib/helpers/linkHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function openGuide() {
77
}
88

99
export function openDashboard(updateCurrentURL = false) {
10-
posthog.capture('open dashboard')
10+
posthog.capture('open dashboard');
1111
if (updateCurrentURL) {
1212
chrome.tabs.update({ url: 'chrome-extension://pdgbckgdncnhihllonhnjbdoighgpimk/dashboard.html' });
1313
} else {

0 commit comments

Comments
 (0)