public static void SetNewSession(HitBuilders.HitBuilder builder) { if (HitBuilderSetNewSessionId == IntPtr.Zero) { HitBuilderSetNewSessionId = Android.Runtime.JNIEnv.GetMethodID(HitBuilderClassRef, "setNewSession", "()Lcom/google/android/gms/analytics/HitBuilders$HitBuilder;"); } Android.Runtime.JNIEnv.CallObjectMethod(builder.Handle, HitBuilderSetNewSessionId); }
private void SendHit(HitBuilders.HitBuilder builder) { // Inject custom dimensions, if any have been set: foreach (var kvp in customDimensions) { // XXX: Workaround wrong signature for setCustomDimension in the component bindings: HitBuilderWorkaround.SetCustomDimension(builder, kvp.Key, kvp.Value); } customDimensions.Clear(); tracker.Send(builder.Build()); }
public static void SetCustomDimension(HitBuilders.HitBuilder builder, int index, string dimension) { if (HitBuilderSetCustomDimensionId == IntPtr.Zero) { HitBuilderSetCustomDimensionId = Android.Runtime.JNIEnv.GetMethodID(HitBuilderClassRef, "setCustomDimension", "(ILjava/lang/String;)Lcom/google/android/gms/analytics/HitBuilders$HitBuilder;"); } IntPtr dimensionPtr = Android.Runtime.JNIEnv.NewString(dimension); Android.Runtime.JNIEnv.CallObjectMethod(builder.Handle, HitBuilderSetCustomDimensionId, new Android.Runtime.JValue[] { new Android.Runtime.JValue(index), new Android.Runtime.JValue(dimensionPtr) }); Android.Runtime.JNIEnv.DeleteLocalRef(dimensionPtr); }
static void SetUserIDDimension(HitBuilders.HitBuilder builder) { if (UserIdDimensionIndex > 0) { var userId = string.Empty; try { userId = GATracker.Get("&uid"); } catch (Exception obj) { Console.WriteLine(obj.Message); } if (!string.IsNullOrEmpty(userId)) { builder.SetCustomDimension(UserIdDimensionIndex, userId); } } }