1
0
Fork 0

wip(dev): Refactoring navigation

This commit is contained in:
Joost De Cock 2023-03-26 06:50:59 +02:00
parent 264e7a0b9d
commit 244f4524c4
20 changed files with 362 additions and 265 deletions

View file

@ -0,0 +1,33 @@
/*
* Dumb method to generate a unique (enough) ID for submissions to bugsnag
*/
function createErrorId() {
let result = ''
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789'
const charactersLength = characters.length
for (let s = 0; s < 3; s++) {
for (let i = 0; i < 4; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength))
}
if (s < 2) result += '-'
}
return result
}
/*
* The hook
*/
export function useBugsnag(bugsnag) {
const reportError = (err) => {
const id = createErrorId()
bugsnag.notify(err, (evt) => {
evt.setUser(account.username ? account.username : '__visitor')
evt.context = id
})
return id
}
return reportError
}