Skip to content

Commit

Permalink
Merge pull request #166 from immutable/chore/analytics-auth
Browse files Browse the repository at this point in the history
[DX-2647] chore: track auth functions
  • Loading branch information
nattb8 authored Feb 9, 2024
2 parents f7eede5 + 0d414cf commit a460f09
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 72 deletions.
6 changes: 3 additions & 3 deletions sample/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PlayerSettings:
useOnDemandResources: 0
accelerometerFrequency: 60
companyName: immutable
productName: unitysample
productName: Immutable Sample
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
Expand Down Expand Up @@ -155,7 +155,7 @@ PlayerSettings:
androidSupportedAspectRatio: 1
androidMaxAspectRatio: 2.1
applicationIdentifier:
Standalone: com.DefaultCompany.2DProject
Standalone: com.immutable.unitysample
buildNumber:
Standalone: 0
iPhone: 0
Expand Down Expand Up @@ -792,7 +792,7 @@ PlayerSettings:
allowUnsafeCode: 0
useDeterministicCompilation: 1
enableRoslynAnalyzers: 1
selectedPlatform: 0
selectedPlatform: 2
additionalIl2CppArgs:
scriptingRuntimeVersion: 1
gcIncremental: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Immutable.Browser.Core;
using Immutable.Passport.Model;
using UnityEngine;
using Immutable.Passport;
using UnityEngine.Scripting;
using Immutable.Passport.Helpers;

Expand Down
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
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System;

namespace Immutable.Passport.Model
Expand All @@ -8,7 +7,6 @@ internal class TrackData
{
public string moduleName;
public string eventName;
public string? properties;
public string properties;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public class VersionInfo
public string engineVersion;
public string platform;
public string platformVersion;
public string deviceModel;
}
}
Loading

0 comments on commit a460f09

Please sign in to comment.