import FingerprintJS from '@fingerprintjs/fingerprintjs'

const VISITORID = 'VISITORID'

export async function getVisitorId() {
  let id = sessionStorage.getItem(VISITORID)
  if (!id) {
    const fp = await FingerprintJS.load()
    const result = await fp.get()
    id = result.visitorId
    sessionStorage.setItem(VISITORID, id)
  }
  return id
}
