-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds country, accounts count and profile count in analytics (#2658
) * feat: adds country_code in analytics * fix: getCountryCode (window not defined) issue * refactor: move getDataFromApp to a separate function * feat: adds profile_count and account_count in analytics * fix: country field * fix: try catch getCountryCode * enhancement: add more amplitude specific properties to identify Co-authored-by: Jean Ribeiro <[email protected]> --------- Co-authored-by: Nicole O'Brien <[email protected]>
- Loading branch information
1 parent
b1edadb
commit c5d56d3
Showing
7 changed files
with
141 additions
and
44 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
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,36 @@ | ||
import { KeyValue } from '@ui/types' | ||
import { ClassicLevel } from 'classic-level' | ||
import path from 'path' | ||
import fs from 'fs' | ||
|
||
export async function getDataFromApp( | ||
appName: string, | ||
userDataPath: string | ||
): Promise<Record<number, KeyValue<string>> | undefined> { | ||
const levelDBPath = path.resolve(userDataPath, '..', appName, 'Local Storage/leveldb') | ||
// check if the path exists | ||
if (!fs.existsSync(levelDBPath)) { | ||
return | ||
} | ||
|
||
const data: Record<string, KeyValue<string>> = {} | ||
|
||
try { | ||
const db = new ClassicLevel(levelDBPath) | ||
let i = 0 | ||
for await (const [key, value] of db.iterator()) { | ||
data[i] = { key: key.toString(), value: value.substring(1) } | ||
i++ | ||
} | ||
await db.close() | ||
return data | ||
} catch (err) { | ||
// https://github.com/Level/abstract-level#errors | ||
const _err = err as Error & { code?: string } | ||
if (_err?.code) { | ||
throw new Error(_err.code) | ||
} else { | ||
console.error(err) | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
packages/shared/src/lib/auxiliary/country/actions/getAndUpdateCountryCode.ts
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { CountryApi } from '../api' | ||
import { IpApi } from '../api' | ||
import { updateCountryCode } from '../stores' | ||
|
||
export async function getAndUpdateCountryCode(): Promise<void> { | ||
const api = new CountryApi() | ||
const api = new IpApi() | ||
const countryCode = await api.getCountryCode() | ||
updateCountryCode(countryCode) | ||
} |
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