Skip to content

Commit e09d86e

Browse files
committed
use new session id format
1 parent 2e6675f commit e09d86e

File tree

7 files changed

+797
-632
lines changed

7 files changed

+797
-632
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.4
2+
3+
- use new session id format
4+
15
## 0.3.3
26

37
- Changes the way we flush events when app state changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { getDefaultConfig } = require("expo/metro-config");
2+
const path = require("path");
3+
4+
// Find the project and workspace directories
5+
const projectRoot = __dirname;
6+
// This can be replaced with `find-yarn-workspace-root`
7+
const workspaceRoot = path.resolve(projectRoot, "../..");
8+
9+
const config = getDefaultConfig(projectRoot);
10+
11+
// 1. Watch all files within the monorepo
12+
config.watchFolders = [workspaceRoot];
13+
// 2. Let Metro know where to resolve packages and in what order
14+
config.resolver.nodeModulesPaths = [
15+
path.resolve(projectRoot, "node_modules"),
16+
path.resolve(workspaceRoot, "node_modules"),
17+
];
18+
// 3. Force Metro to resolve (sub)dependencies only from the `nodeModulesPaths`
19+
config.resolver.disableHierarchicalLookup = true;
20+
21+
module.exports = config;

examples/HelloWorldExpo/package-lock.json

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

examples/HelloWorldExpo/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
"version": "1.0.0",
44
"main": "node_modules/expo/AppEntry.js",
55
"scripts": {
6-
"start": "expo start",
6+
"start": "expo start --clear",
77
"android": "expo start --android",
88
"ios": "expo start --ios",
99
"web": "expo start --web"
1010
},
1111
"dependencies": {
12-
"@aptabase/react-native": "file:../..",
13-
"expo": "~49.0.7",
14-
"expo-status-bar": "~1.6.0",
12+
"expo": "49.0.16",
13+
"expo-status-bar": "1.7.1",
1514
"react": "18.2.0",
16-
"react-native": "0.72.3"
15+
"react-native": "0.72.6"
1716
},
1817
"devDependencies": {
1918
"@babel/core": "^7.20.0"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"compilerOptions": {},
3+
"extends": "expo/tsconfig.base"
4+
}

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.3",
3+
"version": "0.3.4",
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: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
1-
export function newSessionId() {
2-
return [
3-
randomStr(8),
4-
randomStr(4),
5-
randomStr(4),
6-
randomStr(4),
7-
randomStr(12),
8-
].join("-");
9-
}
10-
11-
const characters = "abcdefghijklmnopqrstuvwxyz0123456789";
12-
const charactersLength = characters.length;
13-
function randomStr(len: number) {
14-
let result = "";
15-
for (let i = 0; i < len; i++) {
16-
result += characters.charAt(Math.floor(Math.random() * charactersLength));
17-
}
18-
return result;
1+
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();
195
}

0 commit comments

Comments
 (0)