wip(dev): Refactoring navigation
This commit is contained in:
parent
264e7a0b9d
commit
244f4524c4
20 changed files with 362 additions and 265 deletions
33
sites/dev/hooks/use-bugsnag.mjs
Normal file
33
sites/dev/hooks/use-bugsnag.mjs
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue