1 line
1.7 KiB
Plaintext
1 line
1.7 KiB
Plaintext
|
{"version":3,"file":"getInstallationIdAsync.web.js","sourceRoot":"","sources":["../../src/environment/getInstallationIdAsync.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAE7C,IAAI,cAAc,GAAkB,IAAI,CAAC;AAEzC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,sBAAsB;IAClD,uBAAuB;IACvB,IAAI,cAAc,EAAE;QAClB,OAAO,cAAc,CAAC;KACvB;IAED,IAAI;QACF,gDAAgD;QAChD,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAC3D,IAAI,cAAc,EAAE;YAClB,OAAO,cAAc,CAAC;SACvB;KACF;IAAC,OAAO,KAAK,EAAE;QACd,wDAAwD;QACxD,0BAA0B;KAC3B;IAED,8CAA8C;IAC9C,cAAc,GAAG,MAAM,EAAE,CAAC;IAC1B,+CAA+C;IAC/C,IAAI;QACF,YAAY,CAAC,OAAO,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;KAC3D;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,yEAAyE,EAAE,KAAK,CAAC,CAAC;KACjG;IAED,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nconst INSTALLATION_ID_KEY = 'installationId';\n\nlet installationId: string | null = null;\n\nexport default async function getInstallationIdAsync() {\n // Already cached value\n if (installationId) {\n return installationId;\n }\n\n try {\n // No cached value, fetch from persisted storage\n installationId = localStorage.getItem(INSTALLATION_ID_KEY);\n if (installationId) {\n return installationId;\n }\n } catch (error) {\n // If we weren't able to fetch one (for whatever reason)\n // let's create a new one.\n }\n\n // No persisted value, set the cached value...\n installationId = uuidv4();\n // ...and try to persist it. Ignore the errors.\n try {\n localStorage.setItem(INSTALLATION_ID_KEY, installationId);\n } catch (error) {\n console.debug('Could not save installation ID in persisted storage, it will get reset.', error);\n }\n\n return installationId;\n}\n"]}
|