public virtual async Task TrackEventAsync(string eventName, Dictionary <string, string> properties)
        {
            try
            {
                string action = string.Empty;
                string label  = string.Empty;
                int    number = 0;

                if (properties != null && properties.ContainsKey("action"))
                {
                    action = properties["action"];
                }

                if (properties != null && properties.ContainsKey("label"))
                {
                    label = properties["label"];
                }

                if (properties != null && properties.ContainsKey("number"))
                {
                    int.TryParse(properties["number"], out number);
                }

                var builder = new HitBuilders.EventBuilder();
                builder.SetCategory(eventName.ToLower());
                builder.SetAction(action.ToLower());
                builder.SetLabel(label.ToLower());
                builder.SetValue(number);

                var eventToTrack = builder.Build();

                if (properties != null)
                {
                    foreach (var property in properties)
                    {
                        if (property.Key != "action" && property.Key != "label" && property.Key != "number")
                        {
                            eventToTrack.Add(property.Key, property.Value);
                        }
                    }
                }

                Tracker.Send(eventToTrack);
            }
            catch (Exception ex)
            {
                _ = TinyInsights.TrackErrorAsync(ex);
            }
        }
Exemplo n.º 2
0
        public void sendGaEvent(String action, String category, String label, long?value)
        {
            var gaEvent = new HitBuilders.EventBuilder();

            gaEvent.SetAction(action);
            gaEvent.SetCategory(category);
            gaEvent.SetLabel(label);

            if (value.HasValue)
            {
                gaEvent.SetValue(value.Value);
            }

            var build = gaEvent.Build();

            mGATracker.Send(build.ToDictionary());
        }
Exemplo n.º 3
0
        public void TrackTransaction(string transactionName, string transactionId, long transactionCount = 1)
        {
            if (Verbosity != VerbosityLevel.AnalyticsOff)
            {
                var builder = new HitBuilders.EventBuilder();

                SetUserIDDimension(builder);

                builder.SetCategory("Transactions");
                builder.SetAction(transactionName);
                builder.SetLabel(transactionId);

                builder.SetValue(transactionCount);

                GATracker.Send(builder.Build());
            }
        }
Exemplo n.º 4
0
        public void TrackEvent(string eventCategory, string eventAction, string eventLabel = "AppEvent", long eventValue = 0)
        {
            if (Verbosity == VerbosityLevel.ReportAll)
            {
                var builder = new HitBuilders.EventBuilder();

                SetUserIDDimension(builder);

                builder.SetCategory(eventCategory);
                builder.SetAction(eventAction);
                builder.SetLabel(eventLabel);

                builder.SetValue(eventValue);

                GATracker.Send(builder.Build());
            }
        }
        public void TrackEvent(
            EventData eventData,
            List <CustomDimension> customDimensions,
            List <CustomMetric> customMetrics
            )
        {
            var builder = new HitBuilders.EventBuilder()
                          .SetCategory(eventData.EventCategory)
                          .SetAction(eventData.EventAction);

            if (!string.IsNullOrWhiteSpace(eventData?.EventLabel))
            {
                builder.SetLabel(eventData.EventLabel);
            }

            if (!string.IsNullOrWhiteSpace(eventData?.EventLabel))
            {
                builder.SetValue(eventData.Id);
            }

            if (customDimensions?.Count > 0)
            {
                foreach (var customDimension in customDimensions)
                {
                    builder.SetCustomDimension(customDimension.DimensionIndex, customDimension.DimensionValue);
                }
            }

            if (customMetrics?.Count > 0)
            {
                foreach (var customMetric in customMetrics)
                {
                    builder.SetCustomMetric(customMetric.MetricIndex, customMetric.MetricValue);
                }
            }

            analyticsTracker.Send(builder.Build());
        }
Exemplo n.º 6
0
        public void TrackEvent(string category, string action, string label, int value)
        {
            try
            {
                Debug.WriteLine($"{nameof(TrackEvent)}({category}, {action}, {label}, {value})");

                HitBuilders.EventBuilder builder = new HitBuilders.EventBuilder();
                builder.SetCategory(category);
                builder.SetAction(action);
                builder.SetLabel(label);
                builder.SetValue(value);

                GATracker.Send(builder.Build());
            }
            catch (Exception ex)
            {
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }

                Debug.WriteLine(ex);
            }
        }