Beispiel #1
0
        public Task ReportEventAsync(PiwikEventInfo eventInfo)
        {
            if (null == eventInfo)
            {
                throw new ArgumentNullException(nameof(eventInfo));
            }

            return(SendRequestAsync(eventInfo, PiwikDataConverter.GetEventInfoArgs(eventInfo)));
        }
        /// <summary>
        /// Gets arguments that carry event information.
        /// </summary>
        /// <param name="eventInfo">Event information.</param>
        public static IEnumerable <string> GetEventInfoArgs(PiwikEventInfo eventInfo)
        {
            if (null == eventInfo)
            {
                return(Enumerable.Empty <string>());
            }

            var args = new List <string>()
            {
                $"e_c={Uri.EscapeDataString(eventInfo.Category)}",
                $"e_a={Uri.EscapeDataString(eventInfo.Action)}"
            };

            args.SafeAddStringArgument("e_n", eventInfo.Name);
            if (eventInfo.Value.HasValue)
            {
                args.Add(string.Format(CultureInfo.InvariantCulture, "e_v={0:.##}", eventInfo.Value.Value));
            }

            return(args);
        }