BB.Caching.Redis.Analytics.BitwiseAnalytics.TrackEventAsync C# (CSharp) Method

TrackEventAsync() public static method

Tracks an event.
public static TrackEventAsync ( string category, string action, long eventId, TimePrecision precision = TimePrecision.OneDay, System.DateTime now = default(DateTime) ) : System.Threading.Tasks.Task
category string /// Typically the object that was interacted with (e.g. button) ///
action string /// The type of interaction (e.g. click) ///
eventId long /// The id of the thing being interacted with. ///
precision TimePrecision /// The precision that this event should be tracked at. ///
now System.DateTime /// The now. ///
return System.Threading.Tasks.Task
        public static Task TrackEventAsync(
            string category,
            string action,
            long eventId,
            TimePrecision precision = TimePrecision.OneDay,
            DateTime now = default(DateTime))
        {
            if (now == default(DateTime))
            {
                now = DateTime.UtcNow;
            }

            string time;
            switch (precision)
            {
                case TimePrecision.FifteenMinutes:
                {
                    time = DateTimeUtil.FifteenMinutes(now);
                    break;
                }

                case TimePrecision.OneHour:
                {
                    time = DateTimeUtil.OneHour(now);
                    break;
                }

                case TimePrecision.OneDay:
                {
                    time = DateTimeUtil.OneDay(now);
                    break;
                }

                case TimePrecision.OneMonth:
                {
                    time = DateTimeUtil.OneMonth(now);
                    break;
                }

                default:
                {
                    throw new Exception(string.Format("unsupported precision encountered\n\t{0}", precision));
                }
            }

            RedisKey key = EventKey(category, action, time);

            return SharedCache.Instance.GetAnalyticsWriteConnection()
                .GetDatabase(SharedCache.Instance.Db)
                .StringSetBitAsync(key, eventId, true);
        }