Skip to content

Commit a460f09

Browse files
authored
Merge pull request #166 from immutable/chore/analytics-auth
[DX-2647] chore: track auth functions
2 parents f7eede5 + 0d414cf commit a460f09

File tree

9 files changed

+155
-72
lines changed

9 files changed

+155
-72
lines changed

sample/ProjectSettings/ProjectSettings.asset

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PlayerSettings:
1313
useOnDemandResources: 0
1414
accelerometerFrequency: 60
1515
companyName: immutable
16-
productName: unitysample
16+
productName: Immutable Sample
1717
defaultCursor: {fileID: 0}
1818
cursorHotspot: {x: 0, y: 0}
1919
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
@@ -155,7 +155,7 @@ PlayerSettings:
155155
androidSupportedAspectRatio: 1
156156
androidMaxAspectRatio: 2.1
157157
applicationIdentifier:
158-
Standalone: com.DefaultCompany.2DProject
158+
Standalone: com.immutable.unitysample
159159
buildNumber:
160160
Standalone: 0
161161
iPhone: 0
@@ -792,7 +792,7 @@ PlayerSettings:
792792
allowUnsafeCode: 0
793793
useDeterministicCompilation: 1
794794
enableRoslynAnalyzers: 1
795-
selectedPlatform: 0
795+
selectedPlatform: 2
796796
additionalIl2CppArgs:
797797
scriptingRuntimeVersion: 1
798798
gcIncremental: 1

src/Packages/Passport/Runtime/Scripts/Private/Core/BrowserCommunicationsManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Immutable.Browser.Core;
1111
using Immutable.Passport.Model;
1212
using UnityEngine;
13-
using Immutable.Passport;
1413
using UnityEngine.Scripting;
1514
using Immutable.Passport.Helpers;
1615

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,71 @@
1+
using System.Collections.Generic;
2+
using System;
3+
using UnityEngine;
4+
using Immutable.Passport.Model;
5+
using Immutable.Passport.Core;
6+
using Immutable.Passport.Helpers;
7+
using Cysharp.Threading.Tasks;
8+
19
namespace Immutable.Passport.Event
210
{
3-
public static class PassportAnalytics
11+
public class PassportAnalytics
412
{
513
public const string TRACK = "track";
614
public const string MODULE_NAME = "unitySdk";
715

816
public static class EventName
917
{
10-
public const string START_INIT_PASSPORT = "startedInitialisePassport";
1118
public const string INIT_PASSPORT = "initialisedPassport";
19+
20+
// Login
21+
public const string START_LOGIN = "startedLogin";
22+
public const string COMPLETE_LOGIN = "performedLogin";
23+
public const string START_LOGIN_PKCE = "startedLoginPKCE";
24+
public const string COMPLETE_LOGIN_PKCE = "performedLoginPKCE";
25+
public const string COMPLETE_RELOGIN = "performedRelogin";
26+
27+
// Connect
28+
public const string START_CONNECT_IMX = "startedConnectImx";
29+
public const string COMPLETE_CONNECT_IMX = "performedConnectImx";
30+
public const string START_CONNECT_IMX_PKCE = "startedConnectImxPKCE";
31+
public const string COMPLETE_CONNECT_IMX_PKCE = "performedConnectImxPKCE";
32+
public const string COMPLETE_RECONNECT = "performedReconnect";
33+
34+
// Logout
35+
public const string COMPLETE_LOGOUT = "performedLogout";
36+
public const string COMPLETE_LOGOUT_PKCE = "performedLogoutPKCE";
1237
}
1338

1439
public static class Properties
1540
{
1641
public const string SUCCESS = "succeeded";
1742
}
43+
44+
public async UniTask Track(IBrowserCommunicationsManager communicationsManager, string eventName,
45+
bool? success = null, Dictionary<string, object>? properties = null)
46+
{
47+
try
48+
{
49+
if (properties == null)
50+
{
51+
properties = new Dictionary<string, object>();
52+
}
53+
if (success != null)
54+
{
55+
properties.Add(Properties.SUCCESS, success);
56+
}
57+
string json = JsonUtility.ToJson(new TrackData()
58+
{
59+
moduleName = MODULE_NAME,
60+
eventName = eventName,
61+
properties = properties.ToJson()
62+
});
63+
await communicationsManager.Call(TRACK, json);
64+
}
65+
catch (Exception)
66+
{
67+
// Ignore tracking errors
68+
}
69+
}
1870
}
1971
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Generic;
21
using System;
32

43
namespace Immutable.Passport.Model
@@ -8,7 +7,6 @@ internal class TrackData
87
{
98
public string moduleName;
109
public string eventName;
11-
public string? properties;
10+
public string properties;
1211
}
1312
}
14-

src/Packages/Passport/Runtime/Scripts/Private/Model/Request/VersionInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ public class VersionInfo
99
public string engineVersion;
1010
public string platform;
1111
public string platformVersion;
12+
public string deviceModel;
1213
}
1314
}

0 commit comments

Comments
 (0)