示例#1
0
        public Task ReportViewAsync(PiwikViewInfo viewInfo)
        {
            if (null == viewInfo)
            {
                throw new ArgumentNullException(nameof(viewInfo));
            }

            return(SendRequestAsync(viewInfo, PiwikDataConverter.GetViewInfoArgs(viewInfo)));
        }
        /// <summary>
        /// Gets arguments that carry view information.
        /// </summary>
        /// <param name="viewInfo">View information.</param>
        public static IEnumerable <string> GetViewInfoArgs(PiwikViewInfo viewInfo)
        {
            if (null == viewInfo)
            {
                return(Enumerable.Empty <string>());
            }

            var args = new List <string>();

            args.SafeAddStringArgument("action_name", viewInfo.ViewName);
            if (viewInfo.ViewTime.HasValue)
            {
                args.Add(string.Format(CultureInfo.InvariantCulture, "gt_ms={0:f0}", viewInfo.ViewTime.Value.TotalMilliseconds));
            }

            return(args);
        }