Skip to content

Commit d0a5f15

Browse files
committed
better version of the session id generator
1 parent 397e8ff commit d0a5f15

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.5
2+
3+
- better version of the session id generator
4+
15
## 0.3.4
26

37
- use new session id format

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aptabase/react-native",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"private": false,
55
"description": "React Native SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps",
66
"sideEffects": false,

src/session.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
export function newSessionId(): string {
2-
const epochInSeconds = BigInt(Math.floor(Date.now() / 1000));
3-
const random = BigInt(Math.floor(Math.random() * 100000000));
4-
return (epochInSeconds * 100000000n + random).toString();
2+
const epochInSeconds = Math.floor(Date.now() / 1000).toString();
3+
const random = Math.floor(Math.random() * 100000000)
4+
.toString()
5+
.padStart(8, "0");
6+
7+
return epochInSeconds + random;
58
}

0 commit comments

Comments
 (0)