diff --git a/.github/workflows/build-kits.yml b/.github/workflows/build-kits.yml index 77e136597..1bbae817c 100644 --- a/.github/workflows/build-kits.yml +++ b/.github/workflows/build-kits.yml @@ -46,10 +46,14 @@ jobs: sed -i '' 's/s\.version[[:space:]]*=.*/s.version = "9.0.0"/' mParticle-Apple-SDK-Swift/mParticle-Apple-SDK-Swift.podspec echo "Linting: ${{ matrix.kit.podspec }}" - pod lib lint "${{ matrix.kit.podspec }}" \ - --allow-warnings \ - --skip-import-validation \ - --include-podspecs="{mParticle-Apple-SDK.podspec,mParticle-Apple-SDK-Swift/mParticle-Apple-SDK-Swift.podspec,mParticle-Apple-Media-SDK.podspec}" + for attempt in 1 2 3; do + pod lib lint "${{ matrix.kit.podspec }}" \ + --allow-warnings \ + --skip-import-validation \ + --include-podspecs="{mParticle-Apple-SDK.podspec,mParticle-Apple-SDK-Swift/mParticle-Apple-SDK-Swift.podspec,mParticle-Apple-Media-SDK.podspec}" \ + && break + [ $attempt -lt 3 ] && echo "Attempt $attempt failed, retrying in 60s..." && sleep 60 || exit 1 + done build-kits: name: Build ${{ matrix.kit.name }} diff --git a/Kits/appsflyer/appsflyer-6/Sources/mParticle-AppsFlyer/MPKitAppsFlyer.m b/Kits/appsflyer/appsflyer-6/Sources/mParticle-AppsFlyer/MPKitAppsFlyer.m index a37ba2949..f6806d1f0 100644 --- a/Kits/appsflyer/appsflyer-6/Sources/mParticle-AppsFlyer/MPKitAppsFlyer.m +++ b/Kits/appsflyer/appsflyer-6/Sources/mParticle-AppsFlyer/MPKitAppsFlyer.m @@ -18,7 +18,7 @@ NSString *const afAppleAppId = @"appleAppId"; NSString *const afDevKey = @"devKey"; -NSString *const afSharingFilterForPartners = @"sharingFilterForPartners"; +NSString *const afManualStart = @"manualStart"; NSString *const afAppsFlyerIdIntegrationKey = @"appsflyer_id_integration_setting"; NSString *const kMPKAFCustomerUserId = @"af_customer_user_id"; @@ -112,12 +112,7 @@ - (MPKitExecStatus *)didFinishLaunchingWithConfiguration:(NSDictionary *)configu appsFlyerTracker.deepLinkDelegate = self; _configuration = configuration; - - NSArray *sharingFilter = [self sharingFilterForPartnersFromConfiguration:configuration]; - if (sharingFilter.count > 0) { - [appsFlyerTracker setSharingFilterForPartners:sharingFilter]; - } - + [self updateConsent]; [appsFlyerTracker waitForATTUserAuthorizationWithTimeoutInterval:60]; [self start]; @@ -151,7 +146,10 @@ - (void)start { } - (nonnull MPKitExecStatus *)didBecomeActive { - [appsFlyerTracker start]; + BOOL manualStart = [_configuration[afManualStart] boolValue]; + if (!manualStart) { + [appsFlyerTracker start]; + } MPKitExecStatus *execStatus = [[MPKitExecStatus alloc] initWithSDKCode:@(MPKitInstanceAppsFlyer) returnCode:MPKitReturnCodeSuccess]; return execStatus; } @@ -543,35 +541,6 @@ - (NSNumber * _Nullable)resolvedConsentForMappingKey:(NSString *)mappingKey return [value isGranted]; } -- (NSArray *)sharingFilterForPartnersFromConfiguration:(NSDictionary *)configuration { - id value = configuration[afSharingFilterForPartners]; - if (!value) { - return nil; - } - - NSArray *partnerIds = nil; - if ([value isKindOfClass:[NSArray class]]) { - partnerIds = value; - } else if ([value isKindOfClass:[NSString class]]) { - NSData *jsonData = [value dataUsingEncoding:NSUTF8StringEncoding]; - NSError *error; - partnerIds = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; - if (error || ![partnerIds isKindOfClass:[NSArray class]]) { - return nil; - } - } else { - return nil; - } - - NSMutableArray *result = [NSMutableArray arrayWithCapacity:partnerIds.count]; - for (id item in partnerIds) { - if ([item isKindOfClass:[NSString class]] && ((NSString *)item).length > 0) { - [result addObject:item]; - } - } - return result.count > 0 ? [result copy] : nil; -} - - (NSArray*)mappingForKey:(NSString*)key { NSString *mappingJson = _configuration[key]; if (![mappingJson isKindOfClass:[NSString class]]) { diff --git a/Kits/appsflyer/appsflyer-6/Sources/mParticle-AppsFlyer/include/MPKitAppsFlyer.h b/Kits/appsflyer/appsflyer-6/Sources/mParticle-AppsFlyer/include/MPKitAppsFlyer.h index 2edd097d2..a8dd398c9 100644 --- a/Kits/appsflyer/appsflyer-6/Sources/mParticle-AppsFlyer/include/MPKitAppsFlyer.h +++ b/Kits/appsflyer/appsflyer-6/Sources/mParticle-AppsFlyer/include/MPKitAppsFlyer.h @@ -28,8 +28,6 @@ extern NSString * _Nonnull const MPKitAppsFlyerErrorDomain; - (nullable NSArray*)mappingForKey:(NSString* _Nonnull)key; -- (nullable NSArray *)sharingFilterForPartnersFromConfiguration:(NSDictionary * _Nonnull)configuration; - - (nonnull NSDictionary*)convertToKeyValuePairs: (NSArray * _Nonnull)mappings; - (nonnull MPKitExecStatus *)routeCommerceEvent:(nonnull MPCommerceEvent *)commerceEvent; diff --git a/Kits/appsflyer/appsflyer-6/Tests/mParticle-AppsFlyerTests/AppsFlyerLibMock.swift b/Kits/appsflyer/appsflyer-6/Tests/mParticle-AppsFlyerTests/AppsFlyerLibMock.swift index 7654fe993..f6bdbc0e5 100644 --- a/Kits/appsflyer/appsflyer-6/Tests/mParticle-AppsFlyerTests/AppsFlyerLibMock.swift +++ b/Kits/appsflyer/appsflyer-6/Tests/mParticle-AppsFlyerTests/AppsFlyerLibMock.swift @@ -11,6 +11,11 @@ class AppsFlyerLibMock: AppsFlyerLib { var logEventCalled = false var logEventEventName: String? var logEventValues: [AnyHashable: Any]? + var startCallCount = 0 + + override func start() { + startCallCount += 1 + } override func logEvent(_ eventName: String, withValues values: [AnyHashable: Any]?) { logEventCalled = true diff --git a/Kits/appsflyer/appsflyer-6/Tests/mParticle-AppsFlyerTests/MPKitAppsFlyerTests.swift b/Kits/appsflyer/appsflyer-6/Tests/mParticle-AppsFlyerTests/MPKitAppsFlyerTests.swift index 39b8ad26b..43e521934 100644 --- a/Kits/appsflyer/appsflyer-6/Tests/mParticle-AppsFlyerTests/MPKitAppsFlyerTests.swift +++ b/Kits/appsflyer/appsflyer-6/Tests/mParticle-AppsFlyerTests/MPKitAppsFlyerTests.swift @@ -67,30 +67,33 @@ final class MPKitAppsFlyerTests: XCTestCase { XCTAssertNil(result) } - // MARK: - sharingFilterForPartnersFromConfiguration + // MARK: - didBecomeActive / manualStart - func test_sharingFilterForPartners_validJSON_returnsList() { - kit.configuration["sharingFilterForPartners"] = #"["partner_1", "partner_2"]"# - let result = kit.sharingFilterForPartners(fromConfiguration: kit.configuration) - XCTAssertEqual(result, ["partner_1", "partner_2"]) - } + func test_didBecomeActive_manualStartTrue_doesNotCallAppsFlyerStart() { + kit.configuration = ["manualStart": true] + kit.providerKitInstance = mock + + _ = kit.didBecomeActive() - func test_sharingFilterForPartners_emptyOrMissing_returnsNil() { - XCTAssertNil(kit.sharingFilterForPartners(fromConfiguration: [:])) - kit.configuration["sharingFilterForPartners"] = "" - XCTAssertNil(kit.sharingFilterForPartners(fromConfiguration: kit.configuration)) + XCTAssertEqual(mock.startCallCount, 0) } - func test_sharingFilterForPartners_invalidJSON_returnsNil() { - kit.configuration["sharingFilterForPartners"] = "not a json array" - let result = kit.sharingFilterForPartners(fromConfiguration: kit.configuration) - XCTAssertNil(result) + func test_didBecomeActive_manualStartFalse_callsAppsFlyerStart() { + kit.configuration = ["manualStart": false] + kit.providerKitInstance = mock + + _ = kit.didBecomeActive() + + XCTAssertEqual(mock.startCallCount, 1) } - func test_sharingFilterForPartners_invalidEscapedJSON_returnsNil() { - kit.configuration["sharingFilterForPartners"] = #"[\"test_1\", \"test_2\"]"# - let result = kit.sharingFilterForPartners(fromConfiguration: kit.configuration) - XCTAssertNil(result) + func test_didBecomeActive_manualStartOmitted_callsAppsFlyerStart() { + kit.configuration = [:] + kit.providerKitInstance = mock + + _ = kit.didBecomeActive() + + XCTAssertEqual(mock.startCallCount, 1) } // MARK: - resolvedConsentForMappingKey