diff options
author | Eric Bailey <git@esb.lol> | 2023-11-27 18:39:53 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-27 16:39:53 -0800 |
commit | 26bbe0706897d3b00f35e77da9131d0305b633ef (patch) | |
tree | 901628c2a4c8295f947eb647d97bbba0a77f782b | |
parent | 5fd2d36273c2e603084bdd58af43023e9622fb46 (diff) | |
download | voidsky-26bbe0706897d3b00f35e77da9131d0305b633ef.tar.zst |
Add more debugging to auth (#2009)
-rw-r--r-- | src/state/persisted/legacy.ts | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/state/persisted/legacy.ts b/src/state/persisted/legacy.ts index 170401723..025877529 100644 --- a/src/state/persisted/legacy.ts +++ b/src/state/persisted/legacy.ts @@ -122,7 +122,35 @@ export async function migrate() { const rawLegacyData = await AsyncStorage.getItem( DEPRECATED_ROOT_STATE_STORAGE_KEY, ) - const alreadyMigrated = Boolean(await read()) + const newData = await read() + const alreadyMigrated = Boolean(newData) + + try { + if (rawLegacyData) { + const legacy = JSON.parse(rawLegacyData) as Partial<LegacySchema> + logger.info(`persisted state: debug legacy data`, { + hasExistingLoggedInAccount: Boolean(legacy?.session?.data), + numberOfExistingAccounts: legacy?.session?.accounts?.length, + foundExistingCurrentAccount: Boolean( + legacy.session?.accounts?.find( + a => a.did === legacy.session?.data?.did, + ), + ), + }) + logger.info(`persisted state: debug new data`, { + hasExistingLoggedInAccount: Boolean(newData?.session?.currentAccount), + numberOfExistingAccounts: newData?.session?.accounts?.length, + existingAccountMatchesLegacy: Boolean( + newData?.session?.currentAccount?.did === + legacy?.session?.data?.did, + ), + }) + } else { + logger.info(`persisted state: no legacy to debug, fresh install`) + } + } catch (e) { + logger.error(`persisted state: legacy debugging failed`, {error: e}) + } if (!alreadyMigrated && rawLegacyData) { logger.info('persisted state: migrating legacy storage') |