Skip to content

Commit 59918e8

Browse files
committed
use new session id format
1 parent 93aabf6 commit 59918e8

7 files changed

Lines changed: 26 additions & 31 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.1.1
2+
3+
* use new session id format
4+
15
## 0.1.0
26

37
* Update dependencies

example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@
363363
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
364364
ENABLE_BITCODE = NO;
365365
INFOPLIST_FILE = Runner/Info.plist;
366-
LD_RUNPATH_SEARCH_PATHS = (
366+
TOOLCHAIN_DIR = (
367367
"$(inherited)",
368368
"@executable_path/Frameworks",
369369
);
@@ -541,7 +541,7 @@
541541
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
542542
ENABLE_BITCODE = NO;
543543
INFOPLIST_FILE = Runner/Info.plist;
544-
LD_RUNPATH_SEARCH_PATHS = (
544+
TOOLCHAIN_DIR = (
545545
"$(inherited)",
546546
"@executable_path/Frameworks",
547547
);
@@ -563,7 +563,7 @@
563563
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
564564
ENABLE_BITCODE = NO;
565565
INFOPLIST_FILE = Runner/Info.plist;
566-
LD_RUNPATH_SEARCH_PATHS = (
566+
TOOLCHAIN_DIR = (
567567
"$(inherited)",
568568
"@executable_path/Frameworks",
569569
);

example/macos/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ SPEC CHECKSUMS:
2525

2626
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
2727

28-
COCOAPODS: 1.12.1
28+
COCOAPODS: 1.14.2

example/macos/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@
571571
CODE_SIGN_STYLE = Automatic;
572572
COMBINE_HIDPI_IMAGES = YES;
573573
INFOPLIST_FILE = Runner/Info.plist;
574-
LD_RUNPATH_SEARCH_PATHS = (
574+
TOOLCHAIN_DIR = (
575575
"$(inherited)",
576576
"@executable_path/../Frameworks",
577577
);
@@ -697,7 +697,7 @@
697697
CODE_SIGN_STYLE = Automatic;
698698
COMBINE_HIDPI_IMAGES = YES;
699699
INFOPLIST_FILE = Runner/Info.plist;
700-
LD_RUNPATH_SEARCH_PATHS = (
700+
TOOLCHAIN_DIR = (
701701
"$(inherited)",
702702
"@executable_path/../Frameworks",
703703
);
@@ -717,7 +717,7 @@
717717
CODE_SIGN_STYLE = Automatic;
718718
COMBINE_HIDPI_IMAGES = YES;
719719
INFOPLIST_FILE = Runner/Info.plist;
720-
LD_RUNPATH_SEARCH_PATHS = (
720+
TOOLCHAIN_DIR = (
721721
"$(inherited)",
722722
"@executable_path/../Frameworks",
723723
);

example/pubspec.lock

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
path: ".."
88
relative: true
99
source: path
10-
version: "0.1.0"
10+
version: "0.1.1"
1111
async:
1212
dependency: transitive
1313
description:
@@ -48,14 +48,6 @@ packages:
4848
url: "https://pub.dev"
4949
source: hosted
5050
version: "1.17.2"
51-
crypto:
52-
dependency: transitive
53-
description:
54-
name: crypto
55-
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
56-
url: "https://pub.dev"
57-
source: hosted
58-
version: "3.0.3"
5951
cupertino_icons:
6052
dependency: "direct main"
6153
description:
@@ -276,14 +268,6 @@ packages:
276268
url: "https://pub.dev"
277269
source: hosted
278270
version: "2.2.2"
279-
uuid:
280-
dependency: transitive
281-
description:
282-
name: uuid
283-
sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313"
284-
url: "https://pub.dev"
285-
source: hosted
286-
version: "3.0.7"
287271
vector_math:
288272
dependency: transitive
289273
description:

lib/aptabase_flutter.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// The Flutter SDK for Aptabase, a privacy-first and simple analytics platform for apps.
22
library aptabase_flutter;
33

4+
import 'dart:math';
45
import 'package:aptabase_flutter/sys_info.dart';
56
import 'package:flutter/foundation.dart';
67
import 'package:universal_io/io.dart';
78
import 'dart:convert';
89
import 'dart:developer' as developer;
9-
import 'package:uuid/uuid.dart';
1010

1111
/// Additional options for initializing the Aptabase SDK.
1212
class InitOptions {
@@ -19,7 +19,7 @@ class InitOptions {
1919
///
2020
/// Initialize the client with `Aptabase.init(appKey)` and then use `Aptabase.instance.trackEvent(eventName, props)` to record events.
2121
class Aptabase {
22-
static const String _sdkVersion = "aptabase_flutter@0.1.0";
22+
static const String _sdkVersion = "aptabase_flutter@0.1.1";
2323
static const Duration _sessionTimeout = Duration(hours: 1);
2424

2525
static const Map<String, String> _hosts = {
@@ -30,11 +30,11 @@ class Aptabase {
3030
};
3131

3232
static final http = newUniversalHttpClient();
33-
static const uuid = Uuid();
33+
static final rnd = Random();
3434
static SystemInfo? _sysInfo;
3535
static String _appKey = "";
3636
static Uri? _apiUrl;
37-
static String _sessionId = uuid.v4();
37+
static String _sessionId = newSessionId();
3838
static DateTime _lastTouchTs = DateTime.now().toUtc();
3939

4040
Aptabase._();
@@ -68,7 +68,7 @@ class Aptabase {
6868
final now = DateTime.now().toUtc();
6969
final elapsed = now.difference(_lastTouchTs);
7070
if (elapsed > _sessionTimeout) {
71-
_sessionId = uuid.v4();
71+
_sessionId = newSessionId();
7272
}
7373

7474
_lastTouchTs = now;
@@ -141,4 +141,12 @@ class Aptabase {
141141

142142
return Uri.parse('$baseUrl/api/v0/event');
143143
}
144+
145+
/// Returns a new session id.
146+
static String newSessionId() {
147+
String epochInSeconds = (DateTime.now().millisecondsSinceEpoch ~/ 1000).toString();
148+
String random = (rnd.nextInt(100000000)).toString().padLeft(8, '0');
149+
150+
return epochInSeconds + random;
151+
}
144152
}

pubspec.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: aptabase_flutter
22
description: "Flutter SDK for Aptabase: Open Source Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps"
3-
version: 0.1.0
3+
version: 0.1.1
44
homepage: https://aptabase.com
55
repository: https://github.com/aptabase/aptabase_flutter
66
issue_tracker: https://github.com/aptabase/aptabase_flutter/issues
@@ -14,7 +14,6 @@ dependencies:
1414
sdk: flutter
1515
package_info_plus: ^4.0.0
1616
device_info_plus: ^9.0.0
17-
uuid: ^3.0.0
1817
universal_io: ^2.2.0
1918

2019
dev_dependencies:

0 commit comments

Comments
 (0)