- 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
|
## 0.3.1
|
||||||
|
|
||||||
- use new session id format
|
- use new session id format
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@aptabase/web",
|
"name": "@aptabase/web",
|
||||||
"version": "0.3.1",
|
"version": "0.3.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "JavaScript SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps",
|
"description": "JavaScript SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps",
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.cjs",
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
export function newSessionId(): string {
|
export function newSessionId(): string {
|
||||||
const epochInSeconds = BigInt(Math.floor(Date.now() / 1000));
|
const epochInSeconds = Math.floor(Date.now() / 1000).toString();
|
||||||
const random = BigInt(Math.floor(Math.random() * 100000000));
|
const random = Math.floor(Math.random() * 100000000)
|
||||||
return (epochInSeconds * 100000000n + random).toString();
|
.toString()
|
||||||
|
.padStart(8, '0');
|
||||||
|
|
||||||
|
return epochInSeconds + random;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue