-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from immutable/chore/analytics-auth
[DX-2647] chore: track auth functions
- Loading branch information
Showing
9 changed files
with
155 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 54 additions & 2 deletions
56
src/Packages/Passport/Runtime/Scripts/Private/Event/AnalyticsEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,71 @@ | ||
using System.Collections.Generic; | ||
using System; | ||
using UnityEngine; | ||
using Immutable.Passport.Model; | ||
using Immutable.Passport.Core; | ||
using Immutable.Passport.Helpers; | ||
using Cysharp.Threading.Tasks; | ||
|
||
namespace Immutable.Passport.Event | ||
{ | ||
public static class PassportAnalytics | ||
public class PassportAnalytics | ||
{ | ||
public const string TRACK = "track"; | ||
public const string MODULE_NAME = "unitySdk"; | ||
|
||
public static class EventName | ||
{ | ||
public const string START_INIT_PASSPORT = "startedInitialisePassport"; | ||
public const string INIT_PASSPORT = "initialisedPassport"; | ||
|
||
// Login | ||
public const string START_LOGIN = "startedLogin"; | ||
public const string COMPLETE_LOGIN = "performedLogin"; | ||
public const string START_LOGIN_PKCE = "startedLoginPKCE"; | ||
public const string COMPLETE_LOGIN_PKCE = "performedLoginPKCE"; | ||
public const string COMPLETE_RELOGIN = "performedRelogin"; | ||
|
||
// Connect | ||
public const string START_CONNECT_IMX = "startedConnectImx"; | ||
public const string COMPLETE_CONNECT_IMX = "performedConnectImx"; | ||
public const string START_CONNECT_IMX_PKCE = "startedConnectImxPKCE"; | ||
public const string COMPLETE_CONNECT_IMX_PKCE = "performedConnectImxPKCE"; | ||
public const string COMPLETE_RECONNECT = "performedReconnect"; | ||
|
||
// Logout | ||
public const string COMPLETE_LOGOUT = "performedLogout"; | ||
public const string COMPLETE_LOGOUT_PKCE = "performedLogoutPKCE"; | ||
} | ||
|
||
public static class Properties | ||
{ | ||
public const string SUCCESS = "succeeded"; | ||
} | ||
|
||
public async UniTask Track(IBrowserCommunicationsManager communicationsManager, string eventName, | ||
bool? success = null, Dictionary<string, object>? properties = null) | ||
{ | ||
try | ||
{ | ||
if (properties == null) | ||
{ | ||
properties = new Dictionary<string, object>(); | ||
} | ||
if (success != null) | ||
{ | ||
properties.Add(Properties.SUCCESS, success); | ||
} | ||
string json = JsonUtility.ToJson(new TrackData() | ||
{ | ||
moduleName = MODULE_NAME, | ||
eventName = eventName, | ||
properties = properties.ToJson() | ||
}); | ||
await communicationsManager.Call(TRACK, json); | ||
} | ||
catch (Exception) | ||
{ | ||
// Ignore tracking errors | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.