Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ABTastyAdel committed Jul 10, 2024
2 parents 73c03b6 + 03c9e57 commit bfb39e1
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 51 deletions.
22 changes: 16 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ PODS:
- device_information (0.0.1):
- Flutter
- Flutter (1.0.0)
- FMDB (2.7.12):
- FMDB/standard (= 2.7.12)
- FMDB/Core (2.7.12)
- FMDB/standard (2.7.12):
- FMDB/Core
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand All @@ -12,15 +17,19 @@ PODS:
- FlutterMacOS
- sqflite (0.0.3):
- Flutter
- FlutterMacOS
- FMDB (>= 2.7.5)

DEPENDENCIES:
- device_info (from `.symlinks/plugins/device_info/ios`)
- device_information (from `.symlinks/plugins/device_information/ios`)
- Flutter (from `Flutter`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)

SPEC REPOS:
trunk:
- FMDB

EXTERNAL SOURCES:
device_info:
Expand All @@ -34,15 +43,16 @@ EXTERNAL SOURCES:
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite:
:path: ".symlinks/plugins/sqflite/darwin"
:path: ".symlinks/plugins/sqflite/ios"

SPEC CHECKSUMS:
device_info: d7d233b645a32c40dfdc212de5cf646ca482f175
device_information: d652f6dcea86bdc5300ffd495486de1d5047bf4f
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
FMDB: 728731dd336af3936ce00f91d9d8495f5718a0e6
path_provider_foundation: eaf5b3e458fc0e5fbb9940fb09980e853fe058b8
shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a

PODFILE CHECKSUM: ce13d36744da294d67f8e460dbb7aed7c09bd7f4

Expand Down
12 changes: 6 additions & 6 deletions example/lib/widgets/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ class _ConfigurationState extends State<Configuration> with ShowDialog {
UserData fsUser = Provider.of<UserData>(context, listen: false);
visitorIdController.text = fsUser.visitorId;
var newVisitor;
newVisitor = Flagship.newVisitor(fsUser.visitorId)
.withContext(fsUser.context)
.hasConsented(fsUser.hasConsented)
.isAuthenticated(fsUser.isAuthenticated)
.build();
newVisitor =
Flagship.newVisitor(visitorId: "", hasConsented: fsUser.hasConsented)
.withContext(fsUser.context)
.isAuthenticated(fsUser.isAuthenticated)
.build();
// Set current visitor singleton instance for future use
Flagship.setCurrentVisitor(newVisitor);
}
Expand Down Expand Up @@ -381,7 +381,7 @@ class _ConfigurationState extends State<Configuration> with ShowDialog {

_customTest() async {
for (int i = 0; i < 50; i++) {
Visitor vA = Flagship.newVisitor("visitor_A$i")
Visitor vA = Flagship.newVisitor(visitorId: "user", hasConsented: true)
.withContext({"condition1": "test"})
.isAuthenticated(false)
.build();
Expand Down
9 changes: 9 additions & 0 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.1"
win32:
dependency: transitive
description:
name: win32
sha256: "1414f27dd781737e51afa9711f2ac2ace6ab4498ee98e20863fa5505aa00c58c"
url: "https://pub.dev"
source: hosted
version: "5.0.4"
xdg_directories:
dependency: transitive
description:
Expand All @@ -503,3 +511,4 @@ packages:
sdks:
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"

8 changes: 5 additions & 3 deletions lib/flagship.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ class Flagship with FlagshipDelegate {
}

/// Create new visitor
static VisitorBuilder newVisitor(String visitorId,
{Instance instanceType = Instance.SINGLE_INSTANCE}) {
return VisitorBuilder(visitorId, instanceType: instanceType);
static VisitorBuilder newVisitor(
{required String visitorId,
required bool hasConsented,
Instance instanceType = Instance.SINGLE_INSTANCE}) {
return VisitorBuilder(visitorId, hasConsented, instanceType: instanceType);
}

// Set the current visitor singleton
Expand Down
10 changes: 5 additions & 5 deletions lib/visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class VisitorBuilder {
// Xpc by default false
bool _isAuthenticated = false;

VisitorBuilder(this.visitorId,
VisitorBuilder(this.visitorId, this._hasConsented,
{this.instanceType = Instance.SINGLE_INSTANCE});

// Context
Expand All @@ -344,10 +344,10 @@ class VisitorBuilder {
return this;
}

VisitorBuilder hasConsented(bool hasConsented) {
_hasConsented = hasConsented;
return this;
}
// VisitorBuilder hasConsented(bool hasConsented) {
// _hasConsented = hasConsented;
// return this;
// }

isAuthenticated(bool authenticated) {
_isAuthenticated = authenticated;
Expand Down
6 changes: 6 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@ packages:
sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b
url: "https://pub.dev"
source: hosted
<<<<<<< HEAD
version: "6.8.0"
=======
version: "6.7.0"
>>>>>>> hasConsentedBis
leak_tracker:
dependency: transitive
description:
Expand Down Expand Up @@ -797,6 +801,7 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.5"

web_socket_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -824,3 +829,4 @@ packages:
sdks:
dart: ">=3.4.0 <4.0.0"
flutter: ">=3.22.0"

3 changes: 2 additions & 1 deletion test/callback_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ void main() {
Flagship.sharedInstance().onUpdateState(Status.NOT_INITIALIZED);
Flagship.start("bkk9glocmjcg0vtmdlrr", "apiKey", config: config);

var v1 = Flagship.newVisitor("visitorId").withContext({}).build();
var v1 = Flagship.newVisitor(visitorId: "visitorId", hasConsented: true)
.withContext({}).build();
Flagship.setCurrentVisitor(v1);

// ignore: deprecated_member_use_from_same_package
Expand Down
9 changes: 6 additions & 3 deletions test/default_strategy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ void main() {
Flagship.setLoggerLevel(Level.WARNING);
PathProviderPlatform.instance = FakePathProviderPlatform();

var v1 = Flagship.newVisitor("visitorId").withContext({}).build();
var v1 = Flagship.newVisitor(visitorId: "visitorId", hasConsented: true)
.withContext({}).build();

v1.config.decisionManager = fakeApi;

Expand Down Expand Up @@ -136,7 +137,8 @@ void main() {

await Flagship.start("bkk9glocmjcg0vtmdlrr", "apiKey", config: config);
PathProviderPlatform.instance = FakePathProviderPlatform();
var v1 = Flagship.newVisitor("visitorId").build();
var v1 =
Flagship.newVisitor(visitorId: "visitorId", hasConsented: true).build();
Flagship.setCurrentVisitor(v1);
expect(v1.getConsent(), true);

Expand Down Expand Up @@ -178,7 +180,8 @@ void main() {

Flagship.start("bkk9glocmjcg0vtmdlrr", "apiKey", config: config);
PathProviderPlatform.instance = FakePathProviderPlatform();
var v1 = Flagship.newVisitor("visitorId").build();
var v1 =
Flagship.newVisitor(visitorId: "visitorId", hasConsented: true).build();
Flagship.setCurrentVisitor(v1);
expect(v1.getConsent(), true);
});
Expand Down
21 changes: 14 additions & 7 deletions test/flag_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ void main() async {

await Flagship.start("bkk9glocmjcg0vtmdlrr", "apiKey", config: config);
PathProviderPlatform.instance = FakePathProviderPlatform();
var v1 = Flagship.newVisitor("flagVisitor").build();
var v1 =
Flagship.newVisitor(visitorId: "flagVisitor", hasConsented: true).build();
v1.config.decisionManager = fakeApi;

test("Test Flag class", (() async {
// PathProviderPlatform.instance = FakePathProviderPlatform();
var v1 = Flagship.newVisitor("flagVisitor").build();
var v1 = Flagship.newVisitor(visitorId: "flagVisitor", hasConsented: true)
.build();

v1.trackingManager = fakeTracking;
v1.fetchFlags().whenComplete(() async {
Expand Down Expand Up @@ -208,7 +210,8 @@ void main() async {

test("Flag with bad type", () {
// PathProviderPlatform.instance = FakePathProviderPlatform();
var v2 = Flagship.newVisitor("flagVisitor").build();
var v2 = Flagship.newVisitor(visitorId: "flagVisitor", hasConsented: true)
.build();
v2.fetchFlags().whenComplete(() {
Flag myFlag = v2.getFlag("key_A", 3.14);
expect(myFlag.value(), 3.14);
Expand All @@ -228,7 +231,8 @@ void main() async {
});

test("Flag with null as value", () {
var v3 = Flagship.newVisitor("flagVisitor").build();
var v3 = Flagship.newVisitor(visitorId: "flagVisitor", hasConsented: true)
.build();
v3.fetchFlags().whenComplete(() {
// String as default value
Flag myFlag = v3.getFlag("keyNull", "nullValue");
Expand Down Expand Up @@ -257,7 +261,8 @@ void main() async {

test("Flag value & default value = null", () {
//PathProviderPlatform.instance = FakePathProviderPlatform();
var v4 = Flagship.newVisitor("flagVisitor").build();
var v4 = Flagship.newVisitor(visitorId: "flagVisitor", hasConsented: true)
.build();
v4.fetchFlags().whenComplete(() {
Flag myFlag = v4.getFlag("keyNull", null);
expect(myFlag.value(), null);
Expand All @@ -274,7 +279,8 @@ void main() async {

test("Flag with default value = null", () {
//PathProviderPlatform.instance = FakePathProviderPlatform();
var v4 = Flagship.newVisitor("flagVisitor").build();
var v4 = Flagship.newVisitor(visitorId: "flagVisitor", hasConsented: true)
.build();
v4.fetchFlags().whenComplete(() {
Flag myFlag = v4.getFlag("key_A", null);
expect(myFlag.value(), "val_A");
Expand All @@ -296,7 +302,8 @@ void main() async {
.thenAnswer((_) async {
return http.Response("fakeResponse", 400);
});
var v5 = Flagship.newVisitor("flagVisitor").build();
var v5 = Flagship.newVisitor(visitorId: "flagVisitor", hasConsented: true)
.build();
v5.fetchFlags().whenComplete(() async {
Flag myFlag = v5.getFlag("key_A", "12");
myFlag.visitorExposed();
Expand Down
12 changes: 6 additions & 6 deletions test/flagship_flutter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ void main() {
test('Start Client ', () {
Flagship.start("envId", "apiKey");

Flagship.setCurrentVisitor(Flagship.newVisitor("user1").withContext(
{"key1": "val1", "key2": 2, "key3": true, "key4": 12.01}).build());
Flagship.setCurrentVisitor(
Flagship.newVisitor(visitorId: "user1", hasConsented: true).withContext(
{"key1": "val1", "key2": 2, "key3": true, "key4": 12.01}).build());
var v1 = Flagship.getCurrentVisitor();

// Check the user id
Expand All @@ -24,10 +25,9 @@ void main() {
expect(v1?.getConsent(), true);

// Create visitor v2
var v2 = Flagship.newVisitor("user2")
.withContext({"key1": "val1", "key2": 2, "key3": true, "key4": 12.01})
.hasConsented(false)
.build();
var v2 = Flagship.newVisitor(visitorId: "user2", hasConsented: false)
.withContext(
{"key1": "val1", "key2": 2, "key3": true, "key4": 12.01}).build();
expect(v2.visitorId, "user2");
expect(v2.getConsent(), false);
v2.setConsent(true);
Expand Down
3 changes: 2 additions & 1 deletion test/notConsent_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void main() {
//config.decisionManager = fakeApi;
await Flagship.start("bkk9glocmjcg0vtmdlrr", "apiKey", config: config);

var v1 = Flagship.newVisitor("visitorId").hasConsented(false).build();
var v1 = Flagship.newVisitor(visitorId: "visitorId", hasConsented: false)
.build();
v1.config.decisionManager = fakeApi;
expect(v1.getConsent(), false);
// ignore: deprecated_member_use_from_same_package
Expand Down
3 changes: 2 additions & 1 deletion test/notReady_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ void main() {
test('Test API with bad envId format', () async {
Flagship.start("bkk9g", "apiKey");

var v1 = Flagship.newVisitor("visitorId").build();
var v1 =
Flagship.newVisitor(visitorId: "visitorId", hasConsented: true).build();

expect(Flagship.getStatus(), Status.NOT_INITIALIZED);

Expand Down
3 changes: 2 additions & 1 deletion test/panic_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ void main() {
Flagship.sharedInstance().onUpdateState(Status.NOT_INITIALIZED);
await Flagship.start("bkk9glocmjcg0vtmdlrr", "apiKey", config: config);

var v1 = Flagship.newVisitor("panicUser").build();
var v1 =
Flagship.newVisitor(visitorId: "panicUser", hasConsented: true).build();
v1.config.decisionManager = fakePanicApi;

Flagship.setCurrentVisitor(v1);
Expand Down
8 changes: 6 additions & 2 deletions test/tracking_manager_no_strategy_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ Future<void> main() async {
.build());
// create new visitor
PathProviderPlatform.instance = FakePathProviderPlatform();
var user = Flagship.newVisitor("userWithHidden").build();
var user =
Flagship.newVisitor(visitorId: "userWithHidden", hasConsented: true)
.build();
// Set the mocks
user.trackingManager = fakeTrackingMgr;
user.config.decisionManager = fakeApi;
Expand Down Expand Up @@ -133,7 +135,9 @@ Future<void> main() async {

PathProviderPlatform.instance = FakePathProviderPlatform();
// create new visitor
var user = Flagship.newVisitor("userWithHidden").build();
var user =
Flagship.newVisitor(visitorId: "userWithHidden", hasConsented: true)
.build();
// Set the mocks
user.trackingManager = fakeTrackingMgr;
user.config.decisionManager = fakeApi;
Expand Down
2 changes: 1 addition & 1 deletion test/tracking_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Future<void> main() async {
});
test("Test activate ", () async {
await Flagship.start("bkk9glocmjcg0vtmdlrr", "apiKey");
Visitor vMock = VisitorBuilder("visitorId").build();
Visitor vMock = VisitorBuilder("visitorId", true).build();
vMock.trackingManager = fakeTrackingMgr;
vMock.config.decisionManager = fakeApi;

Expand Down
11 changes: 8 additions & 3 deletions test/trouble_shooting_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,23 @@ void main() {
});

test("TS Fetching", () {
Visitor testVisitor = Flagship.newVisitor("TSVisitor").build();
Visitor testVisitor =
Flagship.newVisitor(visitorId: "TSVisitor", hasConsented: true).build();
dataUsageTest.processTSFetching(testVisitor);
});

test("Data Usage Fetching", () {
Visitor testVisitor = Flagship.newVisitor("dataUsageVisitor").build();
Visitor testVisitor =
Flagship.newVisitor(visitorId: "dataUsageVisitor", hasConsented: true)
.build();
dataUsageTest.dataUsageTrackingReportAllowed = true;
dataUsageTest.processDataUsageTracking(testVisitor);
});

test("Data Usage Fetching on Buckeitng", () {
Visitor testVisitor = Flagship.newVisitor("dataUsageVisitor").build();
Visitor testVisitor =
Flagship.newVisitor(visitorId: "dataUsageVisitor", hasConsented: true)
.build();

dataUsageTest.configureDataUsage(null, "visitorId", true,
ConfigBuilder().withMode(Mode.BUCKETING).build());
Expand Down
Loading

0 comments on commit bfb39e1

Please sign in to comment.