Skip to content

Commit

Permalink
Update analytics and sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jul 9, 2024
1 parent 3b34c0f commit 19b8b5c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 20 deletions.
15 changes: 10 additions & 5 deletions interface/layout/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { dev, version } from "../../build.json"
import { optionalAnalyticsPayload } from "interface/utils/analytics"
import { checkForUpdate } from "interface/utils/update"
import logger from "interface/utils/logger"
import { init, trackEvent } from "@aptabase/web"
import posthog from "posthog-js"

const settings = getSettings()
const state = getState()
Expand All @@ -20,9 +20,6 @@ const app = new App({

export default app

// Setup analytics
init("A-EU-1557095726", { appVersion: version, isDebug: false })

// Set background color if vibrancy not supported
const setBackground = async () => {

Check warning on line 24 in interface/layout/app.ts

View workflow job for this annotation

GitHub Actions / build

'setBackground' is assigned a value but never used
const system = await os.type()
Expand Down Expand Up @@ -104,7 +101,15 @@ const optionalAnalytics = async () => {
const payload = await optionalAnalyticsPayload()

try {
trackEvent("app_start", { version: payload.version, build: payload.build, os: payload.os, lang: payload.lang, date: payload.date.toISOString().split("T")[0] })
posthog.init("phc_QYxqnCtHIrREhZ47S6ZVPaksY8jO2j7YZCPQjbPgF09", {
api_host: "https://eu.i.posthog.com",
capture_pageview: false,
capture_pageleave: false,
persistence: "localStorage",
autocapture: false,
})

posthog.capture("app_start", { version: payload.version, build: payload.build, os: payload.os, lang: payload.lang, date: payload.date.toISOString().split("T")[0] })
} catch (error) {
logger.error(`Failed to send analytics: ${error}`)
}
Expand Down
8 changes: 5 additions & 3 deletions interface/utils/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export const textConverter = (text: string, sortNumber: number): LibImportFile =
secret,
}).generate()
} catch (error) {
dialog.message("Failed to generate TOTP code from secret. \n\nMake sure you import file is correct!", { type: "error" })
logger.error("Failed to generate TOTP code from secret")
dialog.message("Failed to generate TOTP code from secret. \n\nMake sure your import file is correct!", { type: "error" })
logger.error(`Failed to generate TOTP code from secret: ${error} - ${secret}`)

state.importData = null
setState(state)
Expand Down Expand Up @@ -112,6 +112,8 @@ export const textConverter = (text: string, sortNumber: number): LibImportFile =
sortedMap = new Map([...codesMap.entries()].sort((a, b) => a[1].issuer.localeCompare(b[1].issuer)))
} else if (sortNumber === 2) {
sortedMap = new Map([...codesMap.entries()].sort((a, b) => b[1].issuer.localeCompare(a[1].issuer)))
} else {
sortedMap = codesMap
}

const sortedUniqIds = []
Expand All @@ -123,7 +125,7 @@ export const textConverter = (text: string, sortNumber: number): LibImportFile =
sortedUniqIds.push(key)
sortedNames.push(value.name)
sortedSecrets.push(value.secret)
sortedIssuers.push(value)
sortedIssuers.push(value.issuer)
sortedTypes.push(value.type)
})

Expand Down
66 changes: 55 additions & 11 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@aptabase/web": "^0.4.2",
"@undecaf/barcode-detector-polyfill": "^0.9.16",
"@undecaf/zbar-wasm": "^0.9.13",
"otpauth": "^8.0.3",
"posthog-js": "^1.145.0",
"qrcode-generator": "^1.4.4",
"ua-parser-js": "^1.0.37"
}
Expand Down

0 comments on commit 19b8b5c

Please sign in to comment.