@@ -461,6 +461,60 @@ public void GetTags()
461461 _log ( $ "Get all user tags " + dictionaryString . TrimEnd ( ',' , ' ' ) + "}" ) ;
462462 }
463463
464+ public void TrackEvent ( )
465+ {
466+ // Detect platform
467+ string platform =
468+ Application . platform == RuntimePlatform . Android ? "android"
469+ : Application . platform == RuntimePlatform . IPhonePlayer ? "ios"
470+ : "unknown" ;
471+
472+ // Track event without properties
473+ _log ( $ "Tracking an event <b>Unity-{ platform } -noprops</b> without properties") ;
474+ OneSignal . User . TrackEvent ( $ "Unity-{ platform } -noprops") ;
475+
476+ // Track event with comprehensive properties
477+ var properties = new Dictionary < string , object >
478+ {
479+ { "someNum" , 123 } ,
480+ { "someFloat" , 3.14159f } ,
481+ { "someString" , "abc" } ,
482+ { "someBool" , true } ,
483+ {
484+ "someObject" ,
485+ new Dictionary < string , object >
486+ {
487+ { "abc" , "123" } ,
488+ {
489+ "nested" ,
490+ new Dictionary < string , object > { { "def" , "456" } }
491+ } ,
492+ { "ghi" , null } ,
493+ }
494+ } ,
495+ {
496+ "someArray" ,
497+ new List < object > { 1 , 2 }
498+ } ,
499+ {
500+ "someMixedArray" ,
501+ new List < object >
502+ {
503+ 1 ,
504+ "2" ,
505+ new Dictionary < string , object > { { "abc" , "123" } } ,
506+ null ,
507+ }
508+ } ,
509+ { "someNull" , null } ,
510+ } ;
511+
512+ _log (
513+ $ "Tracking an event <b>Unity-{ platform } </b> with properties: { Json . Serialize ( properties ) } "
514+ ) ;
515+ OneSignal . User . TrackEvent ( $ "Unity-{ platform } ", properties ) ;
516+ }
517+
464518 /*
465519 * Outcomes
466520 */
0 commit comments