Skip to content

Commit 08a7b92

Browse files
chore(logout): add targeted logging for deep-link diagnostics
Add strategic logging to diagnose logout deep-link issues without impacting performance. Logs focus on key events only: - Logout initiation and browser launch - Deep-link reception and URI matching - Callback invocation and completion Removed excessive polling logs that were causing timeouts during login flow due to performance degradation.
1 parent 702b6fb commit 08a7b92

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/Packages/Passport/Runtime/Scripts/Private/Helpers/WindowsDeepLink.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ private void HandleDeeplink()
393393
return;
394394
}
395395

396+
PassportLogger.Info($"Deeplink found in registry - processing...");
397+
396398
// Read deeplink data
397399
var data = new byte[dataSize];
398400
result = RegQueryValueEx(hKey, REGISTRY_DEEP_LINK_NAME, IntPtr.Zero, ref type, data, ref dataSize);
@@ -402,6 +404,8 @@ private void HandleDeeplink()
402404
{
403405
// Convert and validate URI
404406
var uri = System.Text.Encoding.Unicode.GetString(data, 0, (int)dataSize - 2); // Remove null terminator
407+
PassportLogger.Info($"Deeplink URI: {uri}");
408+
405409
if (_protocolName != null && !uri.StartsWith(_protocolName))
406410
{
407411
PassportLogger.Error($"Incorrect prefix uri {uri}");
@@ -411,6 +415,7 @@ private void HandleDeeplink()
411415
// Invoke callback with valid URI
412416
_callback?.Invoke(uri);
413417
callbackInvoked = true;
418+
PassportLogger.Info($"Deeplink callback invoked successfully");
414419
}
415420
}
416421
else

src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,22 @@ public async void OnDeepLinkActivated(string url)
265265

266266
if (domain.Equals(_logoutRedirectUri))
267267
{
268+
PassportLogger.Info($"{TAG} Logout deeplink matched - processing logout...");
268269
HandleLogoutPkceSuccess();
269270
}
270271
else if (domain.Equals(_redirectUri))
271272
{
273+
PassportLogger.Info($"{TAG} Login deeplink matched - completing login flow...");
272274
await CompleteLoginPKCEFlow(url);
273275
}
276+
else
277+
{
278+
PassportLogger.Warn($"{TAG} Deeplink mismatch - received: '{domain}', expected logout: '{_logoutRedirectUri}' or login: '{_redirectUri}'");
279+
}
274280
}
275281
catch (Exception ex)
276282
{
277-
PassportLogger.Error($"{TAG} Deeplink error {url}: {ex.Message}");
283+
PassportLogger.Error($"{TAG} Deeplink error for URL {url}: {ex.Message}");
278284
}
279285
}
280286

@@ -454,6 +460,7 @@ public async UniTask<bool> Logout(bool hardLogout = true)
454460
{
455461
try
456462
{
463+
PassportLogger.Info($"{TAG} Starting logout (hardLogout={hardLogout})");
457464
SendAuthEvent(PassportAuthEvent.LoggingOutPKCE);
458465

459466
var task = new UniTaskCompletionSource<bool>();
@@ -477,6 +484,7 @@ public async UniTask<bool> Logout(bool hardLogout = true)
477484

478485
private async void HandleLogoutPkceSuccess()
479486
{
487+
PassportLogger.Info($"{TAG} Logout callback received - processing...");
480488
await UniTask.SwitchToMainThread();
481489
if (_isLoggedIn)
482490
{
@@ -486,11 +494,13 @@ private async void HandleLogoutPkceSuccess()
486494
SendAuthEvent(PassportAuthEvent.LogoutPKCESuccess);
487495
_isLoggedIn = false;
488496
_pkceCompletionSource = null;
497+
PassportLogger.Info($"{TAG} Logout completed successfully");
489498
}
490499

491500
private async void LaunchLogoutPkceUrl(bool hardLogout)
492501
{
493502
var logoutUrl = await GetLogoutUrl();
503+
PassportLogger.Info($"{TAG} Logout URL obtained, launching browser...");
494504
if (hardLogout)
495505
{
496506
#if UNITY_ANDROID && !UNITY_EDITOR

src/Packages/Passport/Samples~/SamplesScenesScripts/Scripts/Passport/Logout/LogoutScript.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ private async UniTaskVoid LogoutAsync()
2222
}
2323
try
2424
{
25+
Debug.Log("Logout button clicked - starting logout...");
2526
await Passport.Instance.Logout();
2627
SampleAppManager.IsConnectedToImx = false;
2728
SampleAppManager.IsConnectedToZkEvm = false;
2829
AuthenticatedSceneManager.NavigateToUnauthenticatedScene();
30+
Debug.Log("Logout completed successfully");
2931
}
3032
catch (System.Exception ex)
3133
{

0 commit comments

Comments
 (0)