The current implementation of GoogleAnalyticsV4 does not implement LogItem, LogException, LogSocial or LogTiming. An implementation is below, although it has not been fully vetted against the protocol specification.
internal void LogTransaction(TransactionHitBuilder builder) {
AndroidJavaObject eventBuilder = new AndroidJavaObject("com.google.android.gms.analytics.HitBuilders$TransactionBuilder");
eventBuilder.Call<AndroidJavaObject>("setAffiliation", new object[] { builder.GetAffiliation() });
eventBuilder.Call<AndroidJavaObject>("setCurrencyCode", new object[] { builder.GetCurrencyCode() });
eventBuilder.Call<AndroidJavaObject>("setRevenue", new object[] { builder.GetRevenue() });
eventBuilder.Call<AndroidJavaObject>("setShipping", new object[] { builder.GetShipping() });
eventBuilder.Call<AndroidJavaObject>("setTax", new object[] { builder.GetTax() });
eventBuilder.Call<AndroidJavaObject>("setTransactionId", new object[] { builder.GetTransactionID() });
foreach(KeyValuePair<int, string> i in builder.GetCustomDimensions())
{
eventBuilder.Call<AndroidJavaObject>("setCustomDimension", new object[] { i.Key, i.Value });
}
foreach(KeyValuePair<int, string> i in builder.GetCustomMetrics())
{
eventBuilder.Call<AndroidJavaObject>("setCustomMetric", new object[] { i.Key, i.Value });
}
object[] builtEvent = new object[] { eventBuilder.Call<AndroidJavaObject>("build") };
tracker.Call("send", builtEvent);
}
internal void LogItem(ItemHitBuilder builder) {
AndroidJavaObject eventBuilder = new AndroidJavaObject("com.google.android.gms.analytics.HitBuilders$ItemBuilder");
eventBuilder.Call<AndroidJavaObject>("setCategory", new object[] { builder.GetCategory() });
eventBuilder.Call<AndroidJavaObject>("setCurrencyCode", new object[] { builder.GetCurrencyCode() });
eventBuilder.Call<AndroidJavaObject>("setName", new object[] { builder.GetName() });
eventBuilder.Call<AndroidJavaObject>("setPrice", new object[] { builder.GetPrice() });
eventBuilder.Call<AndroidJavaObject>("setQuantity", new object[] { builder.GetQuantity() });
eventBuilder.Call<AndroidJavaObject>("setSku", new object[] { builder.GetSKU() });
eventBuilder.Call<AndroidJavaObject>("setTransactionId", new object[] { builder.GetTransactionID() });
foreach(KeyValuePair<int, string> i in builder.GetCustomDimensions())
{
eventBuilder.Call<AndroidJavaObject>("setCustomDimension", new object[] { i.Key, i.Value });
}
foreach(KeyValuePair<int, string> i in builder.GetCustomMetrics())
{
eventBuilder.Call<AndroidJavaObject>("setCustomMetric", new object[] { i.Key, i.Value });
}
object[] builtEvent = new object[] { eventBuilder.Call<AndroidJavaObject>("build") };
tracker.Call("send", builtEvent);
}
public void LogException(ExceptionHitBuilder builder) {
AndroidJavaObject eventBuilder = new AndroidJavaObject("com.google.android.gms.analytics.HitBuilders$ExceptionBuilder");
eventBuilder.Call<AndroidJavaObject>("setDescription", new object[] { builder.GetExceptionDescription() });
eventBuilder.Call<AndroidJavaObject>("setFatal", new object[] { builder.IsFatal() });
foreach(KeyValuePair<int, string> i in builder.GetCustomDimensions())
{
eventBuilder.Call<AndroidJavaObject>("setCustomDimension", new object[] { i.Key, i.Value });
}
foreach(KeyValuePair<int, string> i in builder.GetCustomMetrics())
{
eventBuilder.Call<AndroidJavaObject>("setCustomMetric", new object[] { i.Key, i.Value });
}
object[] builtEvent = new object[] { eventBuilder.Call<AndroidJavaObject>("build") };
tracker.Call("send", builtEvent);
}
public void LogSocial(SocialHitBuilder builder) {
AndroidJavaObject eventBuilder = new AndroidJavaObject("com.google.android.gms.analytics.HitBuilders$SocialBuilder");
eventBuilder.Call<AndroidJavaObject>("setAction", new object[] { builder.GetSocialAction() });
eventBuilder.Call<AndroidJavaObject>("setNetwork", new object[] { builder.GetSocialNetwork() });
eventBuilder.Call<AndroidJavaObject>("setTarget", new object[] { builder.GetSocialTarget() });
foreach(KeyValuePair<int, string> i in builder.GetCustomDimensions())
{
eventBuilder.Call<AndroidJavaObject>("setCustomDimension", new object[] { i.Key, i.Value });
}
foreach(KeyValuePair<int, string> i in builder.GetCustomMetrics())
{
eventBuilder.Call<AndroidJavaObject>("setCustomMetric", new object[] { i.Key, i.Value });
}
object[] builtEvent = new object[] { eventBuilder.Call<AndroidJavaObject>("build") };
tracker.Call("send", builtEvent);
}
public void LogTiming(TimingHitBuilder builder) {
AndroidJavaObject eventBuilder = new AndroidJavaObject("com.google.android.gms.analytics.HitBuilders$TimingBuilder");
eventBuilder.Call<AndroidJavaObject>("setCategory", new object[] { builder.GetTimingCategory() });
eventBuilder.Call<AndroidJavaObject>("setLabel", new object[] { builder.GetTimingLabel() });
eventBuilder.Call<AndroidJavaObject>("setValue", new object[] { builder.GetTimingInterval() }); // SCD Some speculation going on here that this is the correct mapping.
// SCD TODO setVariable
foreach(KeyValuePair<int, string> i in builder.GetCustomDimensions())
{
eventBuilder.Call<AndroidJavaObject>("setCustomDimension", new object[] { i.Key, i.Value });
}
foreach(KeyValuePair<int, string> i in builder.GetCustomMetrics())
{
eventBuilder.Call<AndroidJavaObject>("setCustomMetric", new object[] { i.Key, i.Value });
}
object[] builtEvent = new object[] { eventBuilder.Call<AndroidJavaObject>("build") };
tracker.Call("send", builtEvent);
}
The current implementation of GoogleAnalyticsV4 does not implement LogItem, LogException, LogSocial or LogTiming. An implementation is below, although it has not been fully vetted against the protocol specification.