-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathQATestScript.cs
More file actions
541 lines (441 loc) · 25.7 KB
/
Copy pathQATestScript.cs
File metadata and controls
541 lines (441 loc) · 25.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.Networking;
using AppsFlyerSDK;
using System.Text;
public class QATestScript : MonoBehaviour, IAppsFlyerConversionData
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
static void AutoInit()
{
var go = new GameObject("QATestObject");
DontDestroyOnLoad(go);
go.AddComponent<AppsFlyer>();
go.AddComponent<QATestScript>();
go.AddComponent<AppsFlyerAPITester>();
}
#if UNITY_IOS
[DllImport("__Internal")]
private static extern void _afqaRequestTrackingAuthorization();
#endif
private string _devKey;
private string _iosAppId;
private string _androidAppId;
// Defaults to skipping the ATT system prompt: CI simulators have no one to answer it, and
// once it's shown the whole app - including AppsFlyer's own network requests - is suspended
// at the OS level until it's dismissed, which it never is. Opt in via .env (REQUEST_ATT=true)
// to exercise the real ATT flow on a real device/manual run.
private bool _requestATT = false;
private bool _conversionDataReceived = false;
private bool _sessionReadySignaled = false;
void Start()
{
// CI's headless Android emulator (-gpu swiftshader_indirect, -no-window) has been seen
// disabling its Choreographer callback after an Activity pause/resume (e.g. from
// triggerLifecycleNudge) and never re-enabling it - with vSyncCount>0, Choreographer is
// the engine's only frame clock, so the player loop stalls permanently when that happens.
// targetFrameRate gives it an independent timer to pace off instead (requires vSyncCount
// == 0 in QualitySettings, set for Android's quality level).
Application.targetFrameRate = 60;
InitAsync();
}
// Invoked by ATTPermissionRequest.mm via UnitySendMessage once the user has answered the
// ATT system prompt (or the OS reports it can't be shown at all, on iOS < 14).
void OnATTAuthorizationDetermined(string status)
{
AFQALogger.Log("[AF_QA][ATT] authorization determined status=" + status);
}
void OnDestroy()
{
// [REPRO] InitAsync/RequestATTThenStart are async Awaitable methods, not coroutines -
// unlike StartCoroutine, Unity does NOT cancel an in-flight async Awaitable when this
// component is destroyed, so this marker firing mid-run no longer explains a silently
// abandoned start() the way it did when these ran as coroutines. Kept as a timing marker
// for RunPostStartApis/RunRPCCoverageApis, which are still coroutines and ARE killed here.
AFQALogger.Log($"[AF_QA][REPRO] QATestScript.OnDestroy t={Time.realtimeSinceStartup:F3} frame={Time.frameCount}");
AppsFlyer.OnSessionReady -= OnSessionReadyHandler;
}
void OnDisable()
{
// [REPRO] same caveat as OnDestroy above: only affects the still-coroutine-based
// RunPostStartApis/RunRPCCoverageApis, not the async Awaitable init/start chain.
AFQALogger.Log($"[AF_QA][REPRO] QATestScript.OnDisable t={Time.realtimeSinceStartup:F3} frame={Time.frameCount}");
}
// ── Initialisation ────────────────────────────────────────────────────────
async Awaitable InitAsync()
{
await LoadConfig();
if (string.IsNullOrEmpty(_devKey))
return;
// Subscribed before registerSessionReadyListener() below so the event can't fire
// before we're listening. start() is called from inside OnSessionReadyHandler,
// matching the native contract: call start inside the session-ready block, not
// unconditionally right after registering it.
AppsFlyer.OnSessionReady += OnSessionReadyHandler;
string appId = Application.platform == RuntimePlatform.IPhonePlayer ? _iosAppId : _androidAppId;
// Awaited (rather than fired-and-forgotten) so each RPC's native round trip actually
// completes, in order, before the next one is dispatched - narrowed to this init
// sequence since it's the one the CI GCD-timing investigation cares about; the bulk
// RPC-coverage calls further down stay fire-and-forget.
await AppsFlyer.registerDeepLinkListener(OnDeepLinkReceived);
// Must be set before init(): registerConversionListener assigns the local delegate
// synchronously before its own RPC round trip, but native can fire onInstallConversionData
// as soon as init()'s "initialize" RPC call lands - registering after init() left a window
// where the event arrived with no delegate to route to and was silently dropped.
await AppsFlyer.registerConversionListener(onConversionDataSuccess, onConversionDataFail);
await AppsFlyer.init(_devKey, appId, GetComponent<AppsFlyer>() ?? this as MonoBehaviour);
await AppsFlyer.enableDebug(true);
AFQALogger.Log("[AF_QA][registerDeepLinkListener] registered");
// SDK 7 flow: session readiness gates start().
AwaitSessionReadyRegistration();
#if UNITY_ANDROID
// AppsFlyerLib registers its own ActivityLifecycleCallbacks as a side effect of the
// init() call above, but that registration only happens once Unity's managed layer has
// booted - which is always after Android's real, launch-triggering onResume() already
// fired. Left alone, session readiness/start() would never be (re-)evaluated until the
// user backgrounds/foregrounds the app for real. This forces that missed resume signal
// via a momentary translucent Activity - no AppsFlyerLib/RPC call involved.
using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
using (var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
{
activity.Call("triggerLifecycleNudge");
}
AFQALogger.Log("[AF_QA][lifecycleNudge] triggered");
#endif
RunPreStartApis();
AFQALogger.Log("[AF_QA][registerSessionReadyListener] registered");
}
// ── Config loading ────────────────────────────────────────────────────────
async Awaitable LoadConfig()
{
string content = null;
#if UNITY_ANDROID && !UNITY_EDITOR
// On Android, StreamingAssets are inside the APK — use UnityWebRequest.
// The CI workflow bakes .env into StreamingAssets before calling unity-builder.
string url = Path.Combine(Application.streamingAssetsPath, ".env");
using var req = UnityWebRequest.Get(url);
var op = req.SendWebRequest();
while (!op.isDone)
await Awaitable.NextFrameAsync();
if (req.result == UnityWebRequest.Result.Success)
content = req.downloadHandler.text;
else
AFQALogger.Log("[AF_QA][CONFIG] .env read failed: " + req.error);
#else
// iOS / Editor: StreamingAssets are on the regular filesystem.
string envPath = Path.Combine(Application.streamingAssetsPath, ".env");
if (File.Exists(envPath))
content = File.ReadAllText(envPath);
else
{
string editorEnv = Path.Combine(Application.dataPath, "../.env");
if (File.Exists(editorEnv))
content = File.ReadAllText(editorEnv);
}
await Awaitable.NextFrameAsync();
#endif
if (string.IsNullOrEmpty(content))
{
AFQALogger.Log("[AF_QA][CONFIG] DEV_KEY missing");
return;
}
foreach (var line in content.Split('\n'))
{
string trimmed = line.Trim();
if (trimmed.StartsWith("DEV_KEY=")) _devKey = trimmed.Substring("DEV_KEY=".Length);
else if (trimmed.StartsWith("IOS_APP_ID=")) _iosAppId = trimmed.Substring("IOS_APP_ID=".Length);
else if (trimmed.StartsWith("ANDROID_APP_ID=")) _androidAppId = trimmed.Substring("ANDROID_APP_ID=".Length);
else if (trimmed.StartsWith("REQUEST_ATT=")) _requestATT = trimmed.Substring("REQUEST_ATT=".Length).Trim().ToLowerInvariant() == "true";
}
if (string.IsNullOrEmpty(_devKey))
{
AFQALogger.Log("[AF_QA][CONFIG] DEV_KEY missing");
return;
}
AFQALogger.Log("[AF_QA][CONFIG] loaded");
}
// ── Session ready handler (SDK 7) ─────────────────────────────────────────
void OnSessionReadyHandler(object sender, EventArgs args)
{
HandleSessionReady("event");
}
// registerSessionReadyListener() streams a one-shot onSessionReady event to whichever
// listener is registered at the moment native's session becomes ready - it isn't replayed.
// Since registration is itself an async RPC round-trip, a fast session (e.g. warm cache)
// can become ready before that round-trip lands, and the stream event is then lost with no
// listener to catch it. isSessionReady() is a synchronous query API precisely for closing
// that race: once registration completes, poll current state once and fall through to the
// same session-ready path if it's already true.
async void AwaitSessionReadyRegistration()
{
await AppsFlyer.registerSessionReadyListener();
bool alreadyReady = await AppsFlyer.isSessionReady();
if (alreadyReady)
HandleSessionReady("query");
}
void HandleSessionReady(string source)
{
if (_sessionReadySignaled) return;
_sessionReadySignaled = true;
AppsFlyer.OnSessionReady -= OnSessionReadyHandler;
AFQALogger.Log("[AF_QA][SESSION_READY] received via " + source);
// [REPRO] pin down the exact clock/frame this fired on the main thread, so a delayed
// "[AF_QA][start]" can be attributed to time elapsed vs. frames elapsed (a stalled
// player loop advances neither; a merely slow coroutine still advances frames).
AFQALogger.Log($"[AF_QA][REPRO] HandleSessionReady t={Time.realtimeSinceStartup:F3} frame={Time.frameCount}");
RequestATTThenStart();
}
// [REPRO] Correlates Activity background/foreground blips (e.g. from triggerLifecycleNudge)
// with any stall in the RequestATTThenStart coroutine below.
void OnApplicationPause(bool pause)
{
AFQALogger.Log($"[AF_QA][REPRO] OnApplicationPause({pause}) t={Time.realtimeSinceStartup:F3} frame={Time.frameCount}");
}
void OnApplicationFocus(bool focus)
{
AFQALogger.Log($"[AF_QA][REPRO] OnApplicationFocus({focus}) t={Time.realtimeSinceStartup:F3} frame={Time.frameCount}");
}
// Triggers ATT authorization and calls start() right away, without waiting on the
// user's decision: AppsFlyer.start() doesn't gate on ATT at the SDK level (see
// Tests_Suite.cs's WaitForATT_NoLongerFiresAnyRPCCall, which asserts the old
// waitForATTUserAuthorizationWithTimeoutInterval API is gone), and a real device/
// simulator showing the system prompt suspends the app's player loop until the prompt
// is answered — any in-app coroutine timeout meant to rescue an unanswered prompt
// (WaitForSeconds- or Time.realtimeSinceStartup-based alike) never gets to run while
// suspended, so a wait-then-start ordering here can hang indefinitely with no fallback.
// ATT resolution (OnATTAuthorizationDetermined) still logs asynchronously whenever it
// eventually fires; it just no longer blocks start().
async Awaitable RequestATTThenStart()
{
// [REPRO] entry marker: proves the coroutine was scheduled at all, before whatever
// follows (yield/ATT) has a chance to stall it.
AFQALogger.Log($"[AF_QA][REPRO] RequestATTThenStart entered t={Time.realtimeSinceStartup:F3} frame={Time.frameCount}");
#if UNITY_IOS && !UNITY_EDITOR
if (_requestATT)
{
// Safe to trigger now: AppsFlyer's own init flow has already fully run, so the
// resign/become-active cycle the ATT system prompt causes can't race it (see
// ATTPermissionRequest.mm for why any earlier hook point is unsafe).
_afqaRequestTrackingAuthorization();
AFQALogger.Log("[AF_QA][ATT] requestTrackingAuthorization triggered");
}
else
{
AFQALogger.Log("[AF_QA][ATT] requestTrackingAuthorization skipped (REQUEST_ATT not set)");
}
#endif
await Awaitable.NextFrameAsync();
// [REPRO] if this is late relative to the entry marker above, the stall is between
// yielding and resuming - i.e. the player loop itself paused (matches an Activity
// transition), not something inside AppsFlyer.start().
AFQALogger.Log($"[AF_QA][REPRO] RequestATTThenStart resumed t={Time.realtimeSinceStartup:F3} frame={Time.frameCount}");
// Awaited (see InitAsync) so "[AF_QA][start] result: SUCCESS" only logs once native has
// actually acknowledged the start() RPC, not merely dispatched it.
await AppsFlyer.start();
AFQALogger.Log("[AF_QA][start] result: SUCCESS");
StartCoroutine(RunPostStartApis());
}
// ── Pre-start APIs ────────────────────────────────────────────────────────
void RunPreStartApis()
{
AppsFlyer.setCustomerUserId("e2e_user_42");
AFQALogger.Log("[AF_QA][setCustomerUserId] result: e2e_user_42");
AppsFlyer.setCurrencyCode("EUR");
AFQALogger.Log("[AF_QA][setCurrencyCode] result: EUR");
var additionalData = new Dictionary<string, string>
{
{ "tenant", "qa_eu" },
{ "experiment", "rc_pipeline_v1" }
};
AppsFlyer.setAdditionalData(additionalData);
AFQALogger.Log("[AF_QA][setAdditionalData] tenant=qa_eu experiment=rc_pipeline_v1");
AFQALogger.Log("[AF_QA][AUTO_APIS] --- Pre-start auto APIs complete ---");
}
// ── Post-start APIs ───────────────────────────────────────────────────────
async void LogSdkVersion()
{
string sdkVersion = await AppsFlyer.getSdkVersion();
AFQALogger.Log("[AF_QA][getSDKVersion] result: " + sdkVersion);
}
async void LogAppsFlyerUid()
{
string uid = await AppsFlyer.getAppsFlyerUID();
AFQALogger.Log("[AF_QA][getAppsFlyerUID] result: " + uid);
}
IEnumerator RunPostStartApis()
{
// [REPRO] proves the coroutine was scheduled at all, before the WaitForSeconds below
// has a chance to stall it — see RequestATTThenStart's matching entry/resumed markers.
AFQALogger.Log($"[AF_QA][REPRO] RunPostStartApis entered t={Time.realtimeSinceStartup:F3} frame={Time.frameCount}");
yield return new WaitForSeconds(1f);
AFQALogger.Log($"[AF_QA][REPRO] RunPostStartApis resumed t={Time.realtimeSinceStartup:F3} frame={Time.frameCount}");
LogSdkVersion();
LogAppsFlyerUid();
// E2E-001: three standard events
AppsFlyer.logEvent("af_demo_launch", null);
AFQALogger.Log("[AF_QA][logEvent(af_demo_launch)] result: SUCCESS");
AppsFlyer.logEvent("af_purchase", new Dictionary<string, string>
{
{ "af_revenue", "9.99" },
{ "af_currency", "USD" },
{ "af_content_type", "subscription" }
});
AFQALogger.Log("[AF_QA][logEvent: af_purchase sent] result: SUCCESS");
AppsFlyer.logEvent("af_content_view", new Dictionary<string, string>
{
{ "af_content_id", "qa_content_1" }
});
AFQALogger.Log("[AF_QA][logEvent: af_content_view sent] result: SUCCESS");
// E2E-004: custom event with revenue, currency, and nested metadata
var customParams = new Dictionary<string, string>
{
{ "af_revenue", "19.99" },
{ "af_currency", "EUR" },
{ "metadata", "{\"source\":\"qa\",\"variant\":\"A\"}" }
};
AFQALogger.Log("[AF_QA][logEvent] name=af_qa_custom_purchase params=" + DictToJson(customParams));
AppsFlyer.logEvent("af_qa_custom_purchase", customParams);
yield return new WaitForSeconds(1f);
// E2E-005: identity check event — customer_user_id propagation
var identityParams = new Dictionary<string, string>
{
{ "customer_user_id", "e2e_user_42" },
{ "tenant", "qa_eu" },
{ "experiment", "rc_pipeline_v1" }
};
AFQALogger.Log("[AF_QA][logEvent] name=af_qa_identity_check params={customer_user_id: e2e_user_42, tenant: qa_eu, experiment: rc_pipeline_v1}");
AppsFlyer.logEvent("af_qa_identity_check", identityParams);
// Wait for conversion data before stopping — prevents ClearCache from evicting the
// in-flight conversion request. Falls back after 120s so the test can still complete.
float _conversionWaitTimeout = 120f;
while (!_conversionDataReceived && _conversionWaitTimeout > 0f)
{
yield return new WaitForSeconds(1f);
_conversionWaitTimeout -= 1f;
}
// E2E-006: stop / resume toggle
AppsFlyer.stop(true);
AFQALogger.Log("[AF_QA][stop] result: true");
AppsFlyer.logEvent("af_qa_suppressed", null);
AppsFlyer.stop(false);
AFQALogger.Log("[AF_QA][stop] result: false");
AppsFlyer.logEvent("af_qa_resumed", null);
AFQALogger.Log("[AF_QA][AUTO_APIS] --- Post-start auto APIs complete ---");
yield return StartCoroutine(RunRPCCoverageApis());
AFQALogger.Log("[AF_QA][AUTO_APIS] --- Auto run complete ---");
}
// ── RPC payload coverage ──────────────────────────────────────────────────
IEnumerator RunRPCCoverageApis()
{
AFQALogger.Log("[AF_QA][RPC_COVERAGE] --- start ---");
// Configuration
AppsFlyer.setAppInviteOneLink("rpc_onelink_id");
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setAppInviteOneLink oneLinkID=rpc_onelink_id");
AppsFlyer.setDeepLinkTimeout(1500);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setDeepLinkTimeout timeout=1500");
AppsFlyer.setResolveDeepLinkURLs("rpc_url_1", "rpc_url_2", "testunity6.onelink.me");
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setResolveDeepLinkURLs urls=rpc_url_1,rpc_url_2,testunity6.onelink.me");
AppsFlyer.setOneLinkCustomDomain("rpc_domain_1", "rpc_domain_2");
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setOneLinkCustomDomain domains=rpc_domain_1,rpc_domain_2");
AppsFlyer.setMinTimeBetweenSessions(7);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setMinTimeBetweenSessions seconds=7");
// setHost intentionally not exercised here — it already has unit-test coverage
// (Tests_Suite.cs, against a mocked RPC client), and calling it here with a real,
// running SDK would redirect every subsequent network call in this session to a
// fake domain (see AF_QA logs from earlier "rpc_hostname.com" runs).
AppsFlyer.setCurrentDeviceLanguage("rpc_lang");
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setCurrentDeviceLanguage lang=rpc_lang");
AppsFlyer.setUserPhone("1", "rpc_phone_123");
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setUserPhone countryCode=1 phone=rpc_phone_123");
AppsFlyer.setUserEmail("rpc_email@test.com");
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setUserEmail email=rpc_email@test.com");
AppsFlyer.setPartnerData("rpc_partner_id", new Dictionary<string, string> { { "rpc_key", "rpc_val" } });
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setPartnerData partnerId=rpc_partner_id key=rpc_key val=rpc_val");
AppsFlyer.setAdditionalData(new Dictionary<string, string> { { "rpc_data_key", "rpc_data_val" } });
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setAdditionalData key=rpc_data_key val=rpc_data_val");
// Privacy / consent
AppsFlyer.anonymizeUser(false);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] anonymizeUser anonymize=false");
AppsFlyer.enableTCFDataCollection(true);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] enableTCFDataCollection enabled=true");
var consent = new AppsFlyerConsent(isUserSubjectToGDPR: true, hasConsentForDataUsage: true, hasConsentForAdsPersonalization: true);
AppsFlyer.setConsentData(consent);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setConsentData gdpr=true hasConsent=true hasDataUsageConsent=true");
// Sharing filters
AppsFlyer.setSharingFilterForPartners("rpc_partner_a", "rpc_partner_b");
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setSharingFilterForPartners partners=rpc_partner_a,rpc_partner_b");
// iOS-specific flags
AppsFlyer.setDisableCollectASA(false);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setDisableCollectASA disabled=false");
AppsFlyer.setShouldCollectDeviceName(false);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setShouldCollectDeviceName shouldCollect=false");
AppsFlyer.setDisableAppleAdsAttribution(false);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setDisableAppleAdsAttribution disabled=false");
AppsFlyer.setUseReceiptValidationSandbox(true);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setUseReceiptValidationSandbox useSandbox=true");
AppsFlyer.setUseUninstallSandbox(true);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setUseUninstallSandbox useSandbox=true");
AppsFlyer.setDisableSKAdNetwork(false);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setDisableSKAdNetwork disabled=false");
AppsFlyer.setDisableIDFVCollection(false);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setDisableIDFVCollection disabled=false");
// Location / cross-promo
AppsFlyer.logLocation(37.7749, -122.4194);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] logLocation lat=37.7749 lon=-122.4194");
string crossPromoteAppId = Application.platform == RuntimePlatform.IPhonePlayer ? _iosAppId : _androidAppId;
AppsFlyer.logCrossPromoteImpression(crossPromoteAppId, "rpc_campaign", new Dictionary<string, string> { { "rpc_imp_key", "rpc_imp_val" } });
AFQALogger.Log($"[AF_QA][RPC_COVERAGE] logCrossPromoteImpression appId={crossPromoteAppId} campaign=rpc_campaign key=rpc_imp_key val=rpc_imp_val");
AppsFlyer.logAndOpenStore(crossPromoteAppId, "rpc_store_campaign", new Dictionary<string, string> { { "rpc_store_key", "rpc_store_val" } });
AFQALogger.Log($"[AF_QA][RPC_COVERAGE] logAndOpenStore appId={crossPromoteAppId} campaign=rpc_store_campaign key=rpc_store_key val=rpc_store_val");
// Push / deeplink paths
AppsFlyer.addPushNotificationDeepLinkPath("rpc_path_root", "rpc_path_child");
AFQALogger.Log("[AF_QA][RPC_COVERAGE] addPushNotificationDeepLinkPath path=rpc_path_root,rpc_path_child");
// Ad revenue
var adRevenue = new AFAdRevenueData("rpc_network", MediationNetwork.GoogleAdMob, "USD", 0.42);
AppsFlyer.logAdRevenue(adRevenue, new Dictionary<string, string> { { "rpc_rev_key", "rpc_rev_val" } });
AFQALogger.Log("[AF_QA][RPC_COVERAGE] logAdRevenue network=rpc_network currency=USD amount=0.42 key=rpc_rev_key val=rpc_rev_val");
// Uninstall token (dummy bytes)
AppsFlyer.updateServerUninstallToken(Encoding.UTF8.GetBytes("rpc_dummy_token"));
AFQALogger.Log("[AF_QA][RPC_COVERAGE] updateServerUninstallToken token=rpc_dummy_token");
// Identifiers
AppsFlyer.setDisableAdvertisingIdentifiers(false);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] setDisableAdvertisingIdentifiers disabled=false");
yield return new WaitForSeconds(1f);
AFQALogger.Log("[AF_QA][RPC_COVERAGE] --- end ---");
}
// ── IAppsFlyerConversionData ──────────────────────────────────────────────
public void onConversionDataSuccess(string conversionData)
{
_conversionDataReceived = true;
AFQALogger.Log("[AF_QA][CALLBACK][onInstallConversionData] " + conversionData);
}
public void onConversionDataFail(string error)
{
_conversionDataReceived = true;
AFQALogger.Log("[AF_QA][CALLBACK][onInstallConversionData] error: " + error);
}
// ── Deep link callback ────────────────────────────────────────────────────
void OnDeepLinkReceived(DeepLinkEventsArgs dlArgs)
{
if (dlArgs == null)
{
AFQALogger.Log("[AF_QA][CALLBACK][onDeepLinking] received: null args");
return;
}
string status = dlArgs.status.ToString();
string deepLinkValue = dlArgs.getDeepLinkValue() ?? "";
AFQALogger.Log("[AF_QA][CALLBACK][onDeepLinking] received: status=" + status + ", deepLinkValue=" + deepLinkValue + ", rawStatus=" + dlArgs.rawStatus);
}
// ── Utilities ─────────────────────────────────────────────────────────────
static string DictToJson(Dictionary<string, string> d)
{
var parts = new List<string>();
foreach (var kv in d)
parts.Add("\"" + kv.Key + "\":\"" + kv.Value + "\"");
return "{" + string.Join(",", parts) + "}";
}
}