- better version of the session id generator
This commit is contained in:
parent
febfbaa379
commit
8e99cbd02b
3 changed files with 11 additions and 4 deletions
|
@ -1,3 +1,7 @@
|
|||
## 0.3.2
|
||||
|
||||
- better version of the session id generator
|
||||
|
||||
## 0.3.1
|
||||
|
||||
- use new session id format
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@aptabase/web",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"type": "module",
|
||||
"description": "JavaScript SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps",
|
||||
"main": "./dist/index.cjs",
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
export function newSessionId(): string {
|
||||
const epochInSeconds = BigInt(Math.floor(Date.now() / 1000));
|
||||
const random = BigInt(Math.floor(Math.random() * 100000000));
|
||||
return (epochInSeconds * 100000000n + random).toString();
|
||||
const epochInSeconds = Math.floor(Date.now() / 1000).toString();
|
||||
const random = Math.floor(Math.random() * 100000000)
|
||||
.toString()
|
||||
.padStart(8, '0');
|
||||
|
||||
return epochInSeconds + random;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue