1+ #nullable enable
2+
13using System ;
24using System . Collections . Generic ;
35using System . Net . Http ;
@@ -11,22 +13,22 @@ public static class ImmutableAudience
1113 {
1214 // Reference fields are written inside _initLock; readers fence off the volatile _initialized load.
1315 // _consent and _userId are mutated outside the lock and need volatile themselves.
14- private static AudienceConfig _config ;
15- private static DiskStore _store ;
16- private static EventQueue _queue ;
17- private static HttpTransport _transport ;
18- private static HttpClient _controlClient ;
19- private static Timer _sendTimer ;
16+ private static AudienceConfig ? _config ;
17+ private static DiskStore ? _store ;
18+ private static EventQueue ? _queue ;
19+ private static HttpTransport ? _transport ;
20+ private static HttpClient ? _controlClient ;
21+ private static Timer ? _sendTimer ;
2022 private static volatile ConsentLevel _consent ;
21- private static volatile string _userId ;
23+ private static volatile string ? _userId ;
2224 private static volatile bool _initialized ;
2325 private static readonly object _initLock = new object ( ) ;
2426
2527 // AudienceUnityHooks sets this at SubsystemRegistration so Unity studios
2628 // can omit PersistentDataPath from AudienceConfig and Init will fill it
2729 // from Application.persistentDataPath. Non-Unity callers must still set
2830 // PersistentDataPath on the config.
29- internal static Func < string > DefaultPersistentDataPathProvider ;
31+ internal static Func < string > ? DefaultPersistentDataPathProvider ;
3032
3133 // Starts the SDK. Call once at launch.
3234 public static void Init ( AudienceConfig config )
@@ -119,7 +121,7 @@ public static void Track(IEvent evt)
119121 }
120122
121123 // Send a custom event.
122- public static void Track ( string eventName , Dictionary < string , object > properties = null )
124+ public static void Track ( string eventName , Dictionary < string , object > ? properties = null )
123125 {
124126 if ( ! CanTrack ( ) ) return ;
125127 if ( string . IsNullOrEmpty ( eventName ) )
@@ -142,12 +144,12 @@ public static void Track(string eventName, Dictionary<string, object> properties
142144 // -----------------------------------------------------------------
143145
144146 // Attach a known user id to subsequent events.
145- public static void Identify ( string userId , IdentityType identityType , Dictionary < string , object > traits = null ) =>
147+ public static void Identify ( string userId , IdentityType identityType , Dictionary < string , object > ? traits = null ) =>
146148 Identify ( userId , identityType . ToLowercaseString ( ) , traits ) ;
147149
148150 // Attach a known user id to subsequent events. String overload for
149151 // providers not in IdentityType.
150- public static void Identify ( string userId , string identityType , Dictionary < string , object > traits = null )
152+ public static void Identify ( string userId , string ? identityType , Dictionary < string , object > ? traits = null )
151153 {
152154 if ( ! _initialized ) return ;
153155
@@ -185,7 +187,7 @@ public static void Alias(string fromId, IdentityType fromType, string toId, Iden
185187
186188 // Link two user ids for the same player. String overload for
187189 // providers not in IdentityType.
188- public static void Alias ( string fromId , string fromType , string toId , string toType )
190+ public static void Alias ( string fromId , string ? fromType , string toId , string ? toType )
189191 {
190192 if ( ! _initialized ) return ;
191193
@@ -225,7 +227,7 @@ public static void Reset()
225227 }
226228
227229 // Ask the backend to erase this player's data.
228- public static void DeleteData ( string userId = null )
230+ public static void DeleteData ( string ? userId = null )
229231 {
230232 if ( ! _initialized ) return ;
231233
@@ -273,7 +275,7 @@ public static void DeleteData(string userId = null)
273275 } ) ;
274276 }
275277
276- private static void NotifyErrorCallback ( Action < AudienceError > onError , AudienceErrorCode code , string message )
278+ private static void NotifyErrorCallback ( Action < AudienceError > ? onError , AudienceErrorCode code , string message )
277279 {
278280 if ( onError == null ) return ;
279281 try
@@ -312,7 +314,8 @@ public static void SetConsent(ConsentLevel level)
312314
313315 try
314316 {
315- ConsentStore . Save ( config . PersistentDataPath , level ) ;
317+ // PersistentDataPath is validated non-null in Init; compiler can't propagate that.
318+ ConsentStore . Save ( config . PersistentDataPath ! , level ) ;
316319 }
317320 catch ( Exception ex )
318321 {
@@ -486,10 +489,10 @@ private static bool CanTrack()
486489 }
487490
488491 // Shallow-copy the caller's dict so a post-call mutation cannot race the drain-thread serialiser.
489- private static Dictionary < string , object > SnapshotCallerDict ( Dictionary < string , object > src ) =>
492+ private static Dictionary < string , object > ? SnapshotCallerDict ( Dictionary < string , object > ? src ) =>
490493 src != null ? new Dictionary < string , object > ( src ) : null ;
491494
492- private static void Enqueue ( Dictionary < string , object > msg )
495+ private static void Enqueue ( Dictionary < string , object > ? msg )
493496 {
494497 var queue = _queue ;
495498 if ( queue == null ) return ;
0 commit comments