@@ -24,9 +24,9 @@ internal class Controller : MonoBehaviour
24
24
25
25
private static int _retryCount = 0 ;
26
26
private static DateTime _retryTime ;
27
-
27
+
28
28
#region Singleton
29
-
29
+
30
30
private static Controller _instance ;
31
31
32
32
[ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . BeforeSceneLoad ) ]
@@ -118,11 +118,11 @@ private void CheckForMixpanelImplemented()
118
118
implementedScore += MixpanelStorage . HasIdendified ? 1 : 0 ;
119
119
implementedScore += MixpanelStorage . HasAliased ? 1 : 0 ;
120
120
implementedScore += MixpanelStorage . HasUsedPeople ? 1 : 0 ;
121
-
121
+
122
122
if ( implementedScore >= 3 ) {
123
123
MixpanelStorage . HasImplemented = true ;
124
124
125
- StartCoroutine ( SendHttpEvent ( "SDK Implemented" , "metrics-1" , MixpanelSettings . Instance . Token ,
125
+ StartCoroutine ( SendHttpEvent ( "SDK Implemented" , "metrics-1" , MixpanelSettings . Instance . Token ,
126
126
$ ",\" Tracked\" :{ MixpanelStorage . HasTracked . ToString ( ) . ToLower ( ) } " +
127
127
$ ",\" Identified\" :{ MixpanelStorage . HasIdendified . ToString ( ) . ToLower ( ) } " +
128
128
$ ",\" Aliased\" :{ MixpanelStorage . HasAliased . ToString ( ) . ToLower ( ) } " +
@@ -145,13 +145,13 @@ internal void DoFlush(Action<bool> onFlushComplete = null)
145
145
{
146
146
int coroutinesCount = 2 ; // Number of coroutines to wait for
147
147
bool overallSuccess = true ;
148
-
149
- Action < bool > onComplete = onFlushComplete != null ? success =>
150
- {
148
+
149
+ Action < bool > onComplete = onFlushComplete != null ?
150
+ new Action < bool > ( success => {
151
151
overallSuccess &= success ;
152
152
CheckCompletion ( onFlushComplete , ref coroutinesCount , overallSuccess ) ;
153
- }
154
- : null ;
153
+ } )
154
+ : ( Action < bool > ) null ;
155
155
StartCoroutine ( SendData ( MixpanelStorage . FlushType . EVENTS , onComplete ) ) ;
156
156
StartCoroutine ( SendData ( MixpanelStorage . FlushType . PEOPLE , onComplete ) ) ;
157
157
}
@@ -199,10 +199,10 @@ private IEnumerator SendData(MixpanelStorage.FlushType flushType, Action<bool> o
199
199
}
200
200
}
201
201
}
202
-
202
+
203
203
onComplete ? . Invoke ( true ) ;
204
204
}
205
-
205
+
206
206
private void CheckCompletion ( Action < bool > onFlushComplete , ref int coroutinesCount , bool overallSuccess )
207
207
{
208
208
// Decrease the counter
@@ -217,27 +217,27 @@ private void CheckCompletion(Action<bool> onFlushComplete, ref int coroutinesCou
217
217
218
218
private IEnumerator SendHttpEvent ( string eventName , string apiToken , string distinctId , string properties , bool updatePeople )
219
219
{
220
- string body = "{\" event\" :\" " + eventName + "\" ,\" properties\" :{\" token\" :\" " +
221
- apiToken + "\" ,\" DevX\" :true,\" mp_lib\" :\" unity\" ," +
220
+ string body = "{\" event\" :\" " + eventName + "\" ,\" properties\" :{\" token\" :\" " +
221
+ apiToken + "\" ,\" DevX\" :true,\" mp_lib\" :\" unity\" ," +
222
222
"\" $lib_version\" :\" " + Mixpanel . MixpanelUnityVersion + "\" ," +
223
223
"\" Project Token\" :\" " + distinctId + "\" ,\" distinct_id\" :\" " + distinctId + "\" " + properties + "}}" ;
224
224
string payload = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( body ) ) ;
225
225
WWWForm form = new WWWForm ( ) ;
226
226
form . AddField ( "data" , payload ) ;
227
-
227
+
228
228
using ( UnityWebRequest request = UnityWebRequest . Post ( Config . TrackUrl , form ) ) {
229
229
yield return request . SendWebRequest ( ) ;
230
230
}
231
231
232
232
if ( updatePeople ) {
233
- body = "{\" $add\" :" + "{\" " + eventName +
234
- "\" :1}," +
233
+ body = "{\" $add\" :" + "{\" " + eventName +
234
+ "\" :1}," +
235
235
"\" $token\" :\" " + apiToken + "\" ," +
236
236
"\" $distinct_id\" :\" " + distinctId + "\" }" ;
237
237
payload = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( body ) ) ;
238
238
form = new WWWForm ( ) ;
239
239
form . AddField ( "data" , payload ) ;
240
-
240
+
241
241
using ( UnityWebRequest request = UnityWebRequest . Post ( Config . EngageUrl , form ) ) {
242
242
yield return request . SendWebRequest ( ) ;
243
243
}
@@ -386,7 +386,7 @@ internal static void DoTrack(string eventName, Value properties)
386
386
properties [ "time" ] = Util . CurrentTimeInMilliseconds ( ) ;
387
387
388
388
Value data = new Value ( ) ;
389
-
389
+
390
390
data [ "event" ] = eventName ;
391
391
data [ "properties" ] = properties ;
392
392
data [ "$mp_metadata" ] = Metadata . GetEventMetadata ( ) ;
0 commit comments