Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
aa53111
add deduplicate function
ABTastyAdel Jul 7, 2025
a4ceda6
wip
ABTastyAdel Jul 8, 2025
3424206
clean code and clean deduplication
ABTastyAdel Jul 8, 2025
f2bcdf6
clean code
ABTastyAdel Jul 8, 2025
60e58d2
add unit test
ABTastyAdel Jul 9, 2025
bc0b685
clean code
ABTastyAdel Jul 11, 2025
845dcf5
clean code
ABTastyAdel Jul 11, 2025
304e631
increment version
ABTastyAdel Jul 11, 2025
c8a8745
update version
ABTastyAdel Jul 28, 2025
3721121
post review
ABTastyAdel Jul 28, 2025
c1c38e3
clean
ABTastyAdel Oct 16, 2025
9f90059
manage lookup visitor
ABTastyAdel Oct 16, 2025
fec269b
Update lib/visitor.dart
ABTastyAdel Oct 16, 2025
e3ece89
Update lib/Storage/database_management.dart
ABTastyAdel Oct 16, 2025
4e5e276
manage cache in bucketing mode to handle the xcp
ABTastyAdel Oct 17, 2025
54a9674
Update lib/visitor.dart
ABTastyAdel Oct 17, 2025
5bfc9a1
unlock xpc for buckting mode
ABTastyAdel Oct 20, 2025
865e0b4
fix bux post QA
ABTastyAdel Oct 21, 2025
861e220
fix unit test
ABTastyAdel Nov 3, 2025
6f37262
fix unit test
ABTastyAdel Nov 3, 2025
721da60
fix build demo apk
ABTastyAdel Nov 3, 2025
cf99fd3
Merge pull request #56 from flagship-io/xpcBucketing
ABTastyAdel Nov 3, 2025
0afcfaf
Update lib/visitor/strategy/default_strategy.dart
ABTastyAdel Nov 3, 2025
957aaff
Update lib/cache/default_cache.dart
ABTastyAdel Nov 3, 2025
851f83c
Update test/activate_test.dart
ABTastyAdel Nov 3, 2025
def16af
Update example/lib/widgets/configuration.dart
ABTastyAdel Nov 3, 2025
508039d
Update lib/visitor/strategy/default_strategy.dart
ABTastyAdel Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

15 changes: 15 additions & 0 deletions example/ios/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
</dict>
</plist>
32 changes: 32 additions & 0 deletions example/ios/Flutter/ephemeral/flutter_lldb_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Generated file, do not edit.
#

import lldb

def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict):
"""Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages."""
base = frame.register["x0"].GetValueAsAddress()
page_len = frame.register["x1"].GetValueAsUnsigned()

# Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the
# first page to see if handled it correctly. This makes diagnosing
# misconfiguration (e.g. missing breakpoint) easier.
data = bytearray(page_len)
data[0:8] = b'IHELPED!'

error = lldb.SBError()
frame.GetThread().GetProcess().WriteMemory(base, data, error)
if not error.Success():
print(f'Failed to write into {base}[+{page_len}]', error)
return

def __lldb_init_module(debugger: lldb.SBDebugger, _):
target = debugger.GetDummyTarget()
# Caveat: must use BreakpointCreateByRegEx here and not
# BreakpointCreateByName. For some reasons callback function does not
# get carried over from dummy target for the later.
bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$")
bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__))
bp.SetAutoContinue(True)
print("-- LLDB integration loaded --")
5 changes: 5 additions & 0 deletions example/ios/Flutter/ephemeral/flutter_lldbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Generated file, do not edit.
#

command script import --relative-to-command-file flutter_lldb_helper.py
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
platform :ios, '12.0'
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0

PODFILE CHECKSUM: ce13d36744da294d67f8e460dbb7aed7c09bd7f4
PODFILE CHECKSUM: 30517025a2fecca2d72dac25f08abb5b9a8f1a56

COCOAPODS: 1.16.2
6 changes: 3 additions & 3 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -423,7 +423,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -472,7 +472,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -45,11 +46,13 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
6 changes: 2 additions & 4 deletions example/lib/Providers/fs_data.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import 'dart:math';

import 'package:flagship/tracking/tracking_manager_config.dart';
import 'package:flagship/utils/constants.dart';
import 'package:flutter/material.dart';

class FSData extends ChangeNotifier {
// Apikey
String _apiKey = "apiKey"; //
String _apiKey = "DxAcxlnRB9yFBZYtLDue1q01dcXZCw6aM49CQB23"; //
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the key

// EnvId
String _envId = "bkk9glocmjcg0vtmdlng"; //
// Mode
Expand Down Expand Up @@ -65,7 +63,7 @@ class FSData extends ChangeNotifier {
}

class UserData extends ChangeNotifier {
String _visitorId = "flutter_user" + Random().nextInt(10000).toString();
String _visitorId = "anonymousId"; //+ Random().nextInt(10000).toString();

Map<String, Object> context = {
"testing_tracking_manager": true,
Expand Down
3 changes: 1 addition & 2 deletions example/lib/widgets/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,7 @@ class _ConfigurationState extends State<Configuration> with ShowDialog {
GestureBinding.instance.pointerRouter
.addGlobalRoute(_emotionAIGlobalPointerRoute);
} catch (e) {
// Todo later add flagship logger
print(e);
Flagship.logger(Level.ERROR, e.toString());
}

Flagship.sharedInstance()
Expand Down
60 changes: 30 additions & 30 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ packages:
dependency: transitive
description:
name: characters
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.4.0"
clock:
dependency: transitive
description:
name: clock
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
url: "https://pub.dev"
source: hosted
version: "1.1.1"
version: "1.1.2"
collection:
dependency: transitive
description:
name: collection
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
url: "https://pub.dev"
source: hosted
version: "1.19.0"
version: "1.19.1"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -77,10 +77,10 @@ packages:
dependency: transitive
description:
name: fake_async
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.dev"
source: hosted
version: "1.3.1"
version: "1.3.3"
ffi:
dependency: transitive
description:
Expand All @@ -103,7 +103,7 @@ packages:
path: ".."
relative: true
source: path
version: "4.1.1-beta"
version: "4.2.0-beta"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -163,34 +163,34 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.dev"
source: hosted
version: "10.0.7"
version: "11.0.2"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev"
source: hosted
version: "3.0.8"
version: "3.0.10"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "3.0.2"
matcher:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
version: "0.12.17"
material_color_utilities:
dependency: transitive
description:
Expand All @@ -203,10 +203,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
version: "1.15.0"
version: "1.16.0"
murmurhash:
dependency: transitive
description:
Expand All @@ -227,10 +227,10 @@ packages:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.9.1"
path_provider:
dependency: transitive
description:
Expand Down Expand Up @@ -424,18 +424,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.12.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.4"
string_scanner:
dependency: transitive
description:
Expand Down Expand Up @@ -464,10 +464,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
url: "https://pub.dev"
source: hosted
version: "0.7.3"
version: "0.7.6"
typed_data:
dependency: transitive
description:
Expand All @@ -488,10 +488,10 @@ packages:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.2.0"
vm_service:
dependency: transitive
description:
Expand Down Expand Up @@ -533,5 +533,5 @@ packages:
source: hosted
version: "1.1.0"
sdks:
dart: ">=3.6.0 <4.0.0"
dart: ">=3.8.0-0 <4.0.0"
flutter: ">=3.27.0"
18 changes: 18 additions & 0 deletions lib/Storage/database_management.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,22 @@ class DatabaseManagement {
return '';
}
}

// Check if visitor exists in database
Future<bool> visitorExists(String visitorId, String nameTable) async {
try {
final db = _visitorDatabase;
if (db == null) return false;

List<Map> result = await db.rawQuery(
'SELECT COUNT(*) as count FROM $nameTable WHERE id = ?', [visitorId]);

int count = result.isNotEmpty ? (result.first['count'] ?? 0) : 0;
return count > 0;
} on Exception catch (e) {
Flagship.logger(Level.EXCEPTIONS,
"Error checking if visitor exists: ${e.toString()}");
return false;
}
}
}
12 changes: 12 additions & 0 deletions lib/cache/default_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,16 @@ class DefaultCacheVisitorImp with IVisitorCacheImplementation {
await _checkDatabase();
return dbMgt.readVisitor(visitoId, 'table_visitors');
}

@override
Future<bool> visitorExists(String visitorId) async {
// Reject empty strings
if (visitorId.isEmpty) {
return false;
}
Flagship.logger(
Level.DEBUG, "visitorExists from default cache Implementation");
await _checkDatabase();
return dbMgt.visitorExists(visitorId, 'table_visitors');
}
}
Loading