diff --git a/.af-e2e/test-plan.json b/.af-e2e/test-plan.json index ac286ee5..b0c7c9b5 100644 --- a/.af-e2e/test-plan.json +++ b/.af-e2e/test-plan.json @@ -3,10 +3,10 @@ "plan_id": "unity-e2e", "plugin": "unity", "version": "1.0.0", - "description": "End-to-end test plan for the AppsFlyer Unity plugin. CI imports the generated appsflyer-unity-plugin-.unitypackage into test-app/ before building, so E2E validates the same regular customer artifact that RC publish attaches. Covers seven scenarios: cold launch, background deep link, foreground deep link, custom event with parameters, identity APIs round-trip, consent / SDK stop toggle, and (iOS-only) Universal Link re-open through the scene delegate's scene:continueUserActivity:. NOTE: the scene delegate's true cold-launch path (scene:willConnectToSession:options:, DELIVERY-115275's original trigger) is NOT exercised by phase_7 or any other automation here - UISceneConnectionOptions has no public initializer, so the QA harness cannot fabricate that event and can only drive the warm re-open swizzle. That branch remains manually/E2E-unverified. Mapped to E2E-001..E2E-007 in appsflyer-mobile-plugin-tooling/contracts/e2e-test-contract.md.", + "description": "End-to-end test plan for the AppsFlyer Unity plugin. CI imports the generated appsflyer-unity-plugin-.unitypackage into test-app/ before building, so E2E validates the same regular customer artifact that RC publish attaches. Covers nine scenarios: cold launch, background deep link, foreground deep link, custom event with parameters, identity APIs round-trip, consent / SDK stop toggle, (iOS-only) Universal Link re-open through the scene delegate's scene:continueUserActivity:, and Purchase Connector integration (Android-only phase_8, iOS-only phase_9). NOTE: the scene delegate's true cold-launch path (scene:willConnectToSession:options:, DELIVERY-115275's original trigger) is NOT exercised by phase_7 or any other automation here - UISceneConnectionOptions has no public initializer, so the QA harness cannot fabricate that event and can only drive the warm re-open swizzle. That branch remains manually/E2E-unverified. Mapped to E2E-001..E2E-009 in appsflyer-mobile-plugin-tooling/contracts/e2e-test-contract.md.", "platforms": ["android", "ios"], "schema_version": "1.0.0", - "tooling_contract_ref": "E2E-001, E2E-002, E2E-003, E2E-004, E2E-005, E2E-006, E2E-007" + "tooling_contract_ref": "E2E-001, E2E-002, E2E-003, E2E-004, E2E-005, E2E-006, E2E-007, E2E-008, E2E-009" }, "config": { @@ -435,6 +435,91 @@ "fail_action": "fail" } ] + }, + { + "id": "phase_8", + "name": "Purchase Connector integration (Android)", + "scenario_ref": "E2E-008", + "description": "Android-only. Fresh install. The test app calls AppsFlyerPurchaseConnector init/build/startObservingTransactions before start(). Verifies com.appsflyer:purchase-connector is in the APK and actually starts: the native SDK logs Start Observing Transactions and the Play Billing connection callback, and the C# guard did not fall back to no-ops. Regression guard for DELIVERY-137580, where the dependency was commented out of AppsFlyerDependencies.xml and Purchase Connector silently did nothing. No purchase is made; the CI emulator has no Google account, so onBillingSetupFinished reports billing unavailable, which is expected.", + "platforms": ["android"], + "requires_fresh_install": true, + "wait_after_launch_sec": 240, + "checks": [ + { + "id": "pc_csharp_calls_done", + "description": "Test app ran the Purchase Connector setup calls", + "type": "log_contains", + "pattern": "[AF_QA][PurchaseConnector] init+build+startObservingTransactions done", + "fail_action": "fail" + }, + { + "id": "pc_native_observing", + "description": "Native Purchase Connector started observing transactions (proves purchase-connector is in the APK)", + "type": "log_contains", + "pattern": "[PurchaseConnector]: Start Observing Transactions", + "fail_action": "fail" + }, + { + "id": "pc_billing_setup_finished", + "description": "Purchase Connector connected to Play Billing (the callback fires even when billing is unavailable)", + "type": "log_contains", + "pattern": "[PurchaseConnector]: onBillingSetupFinished", + "fail_action": "fail" + }, + { + "id": "pc_not_missing", + "description": "C# guard did not fall back to no-ops (its warning carries the [AppsFlyer] tag, so it passes the runner's logcat filter; the native-log checks above are the primary guard)", + "type": "absent", + "patterns": ["Purchase Connector is unavailable on Android"], + "fail_action": "fail" + }, + { + "id": "no_fatal_errors", + "description": "No fatal exceptions", + "type": "absent", + "patterns": ["Fatal Exception", "FATAL"], + "fail_action": "fail" + } + ] + }, + { + "id": "phase_9", + "name": "Purchase Connector integration (iOS)", + "scenario_ref": "E2E-009", + "description": "iOS-only. Fresh install. The test app calls AppsFlyerPurchaseConnector init, setStoreKitVersion(SK2), setIsSandbox(true), build and startObservingTransactions before start(). Verifies the PurchaseConnector framework is linked and actually runs: when it is not linked, AppsFlyeriOSWrapper.mm compiles silent no-op stubs, so the native [PurchaseConnector] logs are the only proof. No purchase is made; the simulator has no App Store account, so StoreKit reports 'No active account', which is expected.", + "platforms": ["ios"], + "requires_fresh_install": true, + "wait_after_launch_sec": 240, + "checks": [ + { + "id": "pc_csharp_calls_done", + "description": "Test app ran the Purchase Connector setup calls", + "type": "log_contains", + "pattern": "[AF_QA][PurchaseConnector] init+build+startObservingTransactions done", + "fail_action": "fail" + }, + { + "id": "pc_native_sandbox", + "description": "Native PurchaseConnector received setIsSandbox(true) (proves the real framework, not the wrapper stubs, ran)", + "type": "log_contains", + "pattern": "[PurchaseConnector] AppsFlyerARS has been set to Sandbox environment", + "fail_action": "fail" + }, + { + "id": "pc_native_cache_resolved", + "description": "Native PurchaseConnector initialised its purchase event cache", + "type": "log_contains", + "pattern": "[PurchaseConnector] Resolved cached PurchaseConnectorEvents", + "fail_action": "fail" + }, + { + "id": "no_fatal_errors", + "description": "No fatal exceptions", + "type": "absent", + "patterns": ["Fatal Exception", "FATAL"], + "fail_action": "fail" + } + ] } ], diff --git a/.github/workflows/rc-e2e-android.yml b/.github/workflows/rc-e2e-android.yml index b00bad9f..a9cd126a 100644 --- a/.github/workflows/rc-e2e-android.yml +++ b/.github/workflows/rc-e2e-android.yml @@ -147,6 +147,13 @@ jobs: echo "::error::AppsFlyerRpcHandler class missing from built APK (af-android-plugin-bridge dependency likely dropped from mainTemplate.gradle)" exit 1 fi + echo "--- Purchase Connector PurchaseClient class present in dex? ---" + if strings "$WORKDIR"/classes*.dex | grep -q 'Lcom/appsflyer/api/PurchaseClient;'; then + echo "FOUND" + else + echo "::error::PurchaseClient class missing from built APK (com.appsflyer:purchase-connector dropped from AppsFlyerDependencies.xml or not resolved by EDM4U)" + exit 1 + fi echo "--- distinct com.appsflyer.* package roots baked into dex ---" strings "$WORKDIR"/classes*.dex | grep -oE '^Lcom/appsflyer/[a-zA-Z_]+' | sort -u diff --git a/.github/workflows/rc-e2e-ios.yml b/.github/workflows/rc-e2e-ios.yml index 80a93478..25c9e783 100644 --- a/.github/workflows/rc-e2e-ios.yml +++ b/.github/workflows/rc-e2e-ios.yml @@ -274,6 +274,29 @@ jobs: rm -rf test-app/Build/iOS-Simulator/UnityQATest.app cp -R "$APP" test-app/Build/iOS-Simulator/UnityQATest.app + - name: Verify Purchase Connector is linked into the .app + run: | + APP=test-app/Build/iOS-Simulator/UnityQATest.app + UF="$APP/Frameworks/UnityFramework.framework/UnityFramework" + # AppsFlyeriOSWrapper.mm compiles silent no-op stubs when PurchaseConnector-Swift.h is + # not found, so the real bridge is proven by UnityFramework referencing the @objc + # PurchaseConnector class (verified with nm on a real build: "(undefined) external + # _OBJC_CLASS_$_PurchaseConnector (from PurchaseConnector)"). Undefined = dynamically + # linked (SPM PurchaseConnector-Dynamic), so the framework must also be embedded; + # defined = statically linked into UnityFramework, nothing to embed. + # (No grep -q: it closes the pipe early and nm's SIGPIPE would fail under pipefail.) + SYMBOLS=$(nm -m "$UF" | grep -E '_OBJC_CLASS_\$_PurchaseConnector( |$)' || true) + echo "$SYMBOLS" + if [[ -z "$SYMBOLS" ]]; then + echo "::error::UnityFramework does not reference the PurchaseConnector class - AppsFlyeriOSWrapper.mm was compiled with the no-op stubs (PurchaseConnector pod/SPM package not resolved)" + exit 1 + fi + if echo "$SYMBOLS" | grep '(undefined)' >/dev/null && [[ ! -d "$APP/Frameworks/PurchaseConnector.framework" ]]; then + echo "::error::UnityFramework links PurchaseConnector dynamically but PurchaseConnector.framework is not embedded in UnityQATest.app (dyld would fail at launch)" + exit 1 + fi + echo "PurchaseConnector bridge linked into UnityFramework" + - name: Upload xcodebuild log if: always() uses: actions/upload-artifact@v4 diff --git a/Assets/AppsFlyer/AppsFlyer.cs b/Assets/AppsFlyer/AppsFlyer.cs index 756396dd..6760d4f1 100644 --- a/Assets/AppsFlyer/AppsFlyer.cs +++ b/Assets/AppsFlyer/AppsFlyer.cs @@ -17,7 +17,7 @@ namespace AppsFlyerSDK #pragma warning disable CS1998 public class AppsFlyer : MonoBehaviour { - public static readonly string kAppsFlyerPluginVersion = "7.0.41"; + public static readonly string kAppsFlyerPluginVersion = "7.0.42"; public static string CallBackObjectName = null; private static EventHandler onSessionReady; private static Action onConversionDataSuccessCallback; diff --git a/Assets/AppsFlyer/AppsFlyerPurchaseConnector.cs b/Assets/AppsFlyer/AppsFlyerPurchaseConnector.cs index 3ccb744e..486f1b36 100644 --- a/Assets/AppsFlyer/AppsFlyerPurchaseConnector.cs +++ b/Assets/AppsFlyer/AppsFlyerPurchaseConnector.cs @@ -246,12 +246,11 @@ private void Awake() private static bool _connectorUnavailableWarned; private static bool _connectorLookupFailed; - // purchase-connector is currently disabled in AppsFlyerDependencies.xml (AGP 8 namespace - // collision with af-android-sdk - see review_processed.md #16), but AppsFlyerAndroidWrapper - // still directly imports its types. That turns every Purchase Connector call below into an - // unguarded NoClassDefFoundError/ClassNotFoundException at the point of first use instead of - // a build-time failure. Resolve/call through here so integrators who don't use Purchase - // Connector are unaffected, and those who do get one clear logged warning instead of a crash. + // AppsFlyerAndroidWrapper imports purchase-connector types, but the wrapper only has a + // compileOnly dependency on it. If the app ends up without purchase-connector (e.g. the + // dependency was excluded or EDM4U resolution was skipped), every call below would throw + // NoClassDefFoundError/ClassNotFoundException at first use. Resolve/call through here so the + // app gets one clear logged warning instead of a crash. private static bool TryGetConnector(out AndroidJavaClass connector) { if (_connectorLookupFailed) @@ -294,10 +293,12 @@ private static void WarnConnectorUnavailable(Exception e) { if (_connectorUnavailableWarned) return; _connectorUnavailableWarned = true; - Debug.LogWarning("[AppsFlyer] Purchase Connector is unavailable on Android (the " + - "purchase-connector dependency is currently disabled due to an AGP 8 namespace " + - "collision with af-android-sdk - see Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml). " + - "Purchase Connector calls will be no-ops until this is resolved upstream. " + e); + Debug.LogWarning("[AppsFlyer] Purchase Connector is unavailable on Android. Possible causes: " + + "(1) com.appsflyer:purchase-connector is missing from the build - make sure External " + + "Dependency Manager resolved Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml; " + + "(2) Google Play Billing Library 8 is missing or older - Purchase Connector requires the " + + "app to provide com.android.billingclient:billing 8.x (e.g. Unity IAP 5.x). " + + "Purchase Connector calls will be no-ops. " + e); } #endif diff --git a/Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml b/Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml index 87eb7baa..823208cb 100644 --- a/Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml +++ b/Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml @@ -10,9 +10,10 @@ itself is installed on the device, surfacing as a ClassNotFoundException in the "gaidError" field of outgoing SDK requests. --> - - + + + + + diff --git a/test-app/Assets/Editor/TestAppDependencies.xml.meta b/test-app/Assets/Editor/TestAppDependencies.xml.meta new file mode 100644 index 00000000..8c18f493 --- /dev/null +++ b/test-app/Assets/Editor/TestAppDependencies.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0e01d4c5fa71e48f2a47ef124380b97a +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/test-app/Assets/Plugins/Android/gradleTemplate.properties b/test-app/Assets/Plugins/Android/gradleTemplate.properties index dfb43623..c8a36b4e 100644 --- a/test-app/Assets/Plugins/Android/gradleTemplate.properties +++ b/test-app/Assets/Plugins/Android/gradleTemplate.properties @@ -3,12 +3,3 @@ org.gradle.jvmargs=-Xmx4096M android.useAndroidX=true android.enableJetifier=true **ADDITIONAL_PROPERTIES** - -# NOTE: com.appsflyer:purchase-connector:2.3.0 and com.appsflyer:af-android-sdk:7.0.1 share the -# manifest package "com.appsflyer", which AGP 8's mandatory namespace-uniqueness check hard-fails -# on. `android.uniquePackageNames` does NOT fix this (it's an older, unrelated naming-convention -# flag, not a namespace-uniqueness override) - there is currently no known consumer-side Gradle -# property that resolves this collision. Until AppsFlyer publishes these two artifacts with -# distinct namespaces upstream, purchase-connector is disabled in this project's dependencies -# (see Assets/AppsFlyer/Editor/AppsFlyerDependencies.xml) rather than shipped with a non-working -# workaround. diff --git a/test-app/Assets/Scripts/QATestScript.cs b/test-app/Assets/Scripts/QATestScript.cs index f16ce896..ef2aa555 100644 --- a/test-app/Assets/Scripts/QATestScript.cs +++ b/test-app/Assets/Scripts/QATestScript.cs @@ -8,7 +8,7 @@ using AppsFlyerSDK; using System.Text; -public class QATestScript : MonoBehaviour, IAppsFlyerConversionData +public class QATestScript : MonoBehaviour, IAppsFlyerConversionData, IAppsFlyerPurchaseValidation { [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] static void AutoInit() @@ -294,9 +294,49 @@ void RunPreStartApis() AppsFlyer.setAdditionalData(additionalData); AFQALogger.Log("[AF_QA][setAdditionalData] tenant=qa_eu experiment=rc_pipeline_v1"); + SetupPurchaseConnector(); + AFQALogger.Log("[AF_QA][AUTO_APIS] --- Pre-start auto APIs complete ---"); } + // ── Purchase Connector ──────────────────────────────────────────────────── + + // Must run before AppsFlyer.start(). + // Android: Billing comes from Assets/Editor/TestAppDependencies.xml. E2E phase_8 checks the + // native "[PurchaseConnector]: Start Observing Transactions" log; if purchase-connector is + // missing from the APK the C# guard turns these calls into no-ops and logs + // "Purchase Connector is unavailable on Android" instead. + // iOS: E2E phase_9 checks the native "[PurchaseConnector] AppsFlyerARS has been set to Sandbox + // environment" log. If PurchaseConnector isn't linked, AppsFlyeriOSWrapper.mm compiles silent + // stubs, so that log is the only sign the real framework ran. + void SetupPurchaseConnector() + { +#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR + AppsFlyerPurchaseConnector.init(this, Store.GOOGLE); +#if UNITY_IOS + AppsFlyerPurchaseConnector.setStoreKitVersion(StoreKitVersion.SK2); +#endif + AppsFlyerPurchaseConnector.setIsSandbox(true); + AppsFlyerPurchaseConnector.setAutoLogPurchaseRevenue( + AppsFlyerAutoLogPurchaseRevenueOptions.AppsFlyerAutoLogPurchaseRevenueOptionsAutoRenewableSubscriptions, + AppsFlyerAutoLogPurchaseRevenueOptions.AppsFlyerAutoLogPurchaseRevenueOptionsInAppPurchases); + AppsFlyerPurchaseConnector.setPurchaseRevenueValidationListeners(true); + AppsFlyerPurchaseConnector.build(); + AppsFlyerPurchaseConnector.startObservingTransactions(); + AFQALogger.Log("[AF_QA][PurchaseConnector] init+build+startObservingTransactions done"); +#endif + } + + public void didReceivePurchaseRevenueValidationInfo(string validationInfo) + { + AFQALogger.Log("[AF_QA][PurchaseConnector] validation info: " + validationInfo); + } + + public void didReceivePurchaseRevenueError(string error) + { + AFQALogger.Log("[AF_QA][PurchaseConnector] validation error: " + error); + } + // ── Post-start APIs ─────────────────────────────────────────────────────── async void LogSdkVersion() diff --git a/test-app/ProjectSettings/ProjectSettings.asset b/test-app/ProjectSettings/ProjectSettings.asset index b7132624..f8f0aab0 100644 --- a/test-app/ProjectSettings/ProjectSettings.asset +++ b/test-app/ProjectSettings/ProjectSettings.asset @@ -268,7 +268,7 @@ PlayerSettings: useCustomMainGradleTemplate: 0 useCustomLauncherGradleManifest: 0 useCustomBaseGradleTemplate: 0 - useCustomGradlePropertiesTemplate: 0 + useCustomGradlePropertiesTemplate: 1 useCustomGradleSettingsTemplate: 0 useCustomProguardFile: 0 AndroidTargetArchitectures: 10