-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
120 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { createUsageStatsClient } from '@anime-skip/usage-stats-client'; | ||
import { browser } from 'webextension-polyfill-ts'; | ||
import Browser from './Browser'; | ||
|
||
declare const EXTENSION_VERSION: string; | ||
|
||
export const USAGE_STATS_USER_ID_STORAGE_KEY = 'usage-stats-user-id'; | ||
|
||
const client = createUsageStatsClient({ | ||
app: 'Anime Skip Player', | ||
appVersion: EXTENSION_VERSION, | ||
browser: Browser.detect(), | ||
async getUserId() { | ||
const results = await browser.storage.local.get(USAGE_STATS_USER_ID_STORAGE_KEY); | ||
return results[USAGE_STATS_USER_ID_STORAGE_KEY]; | ||
}, | ||
log: console.log, | ||
async persistGuestUserId(userId) { | ||
browser.storage.local.set({ [USAGE_STATS_USER_ID_STORAGE_KEY]: userId }); | ||
}, | ||
send: import.meta.env.VITE_EXT_MODE === 'prod' || import.meta.env.VITE_EXT_MODE === 'beta', | ||
source: 'browser', | ||
}); | ||
|
||
export default { | ||
async setUserId(userId: string): Promise<void> { | ||
await browser.storage.local.set({ [USAGE_STATS_USER_ID_STORAGE_KEY]: userId }); | ||
}, | ||
async clearUserId(): Promise<void> { | ||
await browser.storage.local.remove(USAGE_STATS_USER_ID_STORAGE_KEY); | ||
}, | ||
...client, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useClearTokens } from '~/common/state/useAuth'; | ||
import { useResetPreferences } from '~/common/state/useGeneralPreferences'; | ||
import { sleep } from '~/common/utils/EventLoop'; | ||
import UsageStats from '~/common/utils/UsageStats'; | ||
|
||
export function useLogout() { | ||
const clearTokens = useClearTokens(); | ||
const resetPreferences = useResetPreferences(); | ||
|
||
return async () => { | ||
await sleep(500); | ||
clearTokens(); | ||
resetPreferences(); | ||
void UsageStats.saveEvent('logout').then(UsageStats.clearUserId); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters