-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathAnalyticsEvent.cs
More file actions
66 lines (59 loc) · 2.19 KB
/
Copy pathAnalyticsEvent.cs
File metadata and controls
66 lines (59 loc) · 2.19 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
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 class PassportAnalytics
{
public const string TRACK = "track";
public const string MODULE_NAME = "unitySdk";
public static class EventName
{
public const string INIT_PASSPORT = "initialisedPassport";
// Login
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_PKCE = "startedConnectImxPkce";
public const string COMPLETE_CONNECT_IMX_PKCE = "performedConnectImxPkce";
public const string COMPLETE_RECONNECT = "performedReconnect";
// Logout
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
}
}
}
}