/// <summary>
        /// Records the custom event to the local persistent storage. Background thread will deliver the event later.
        /// </summary>
        /// <param name="customEvent">The event.</param>
        public void RecordEvent(CustomEvent customEvent)
        {
            customEvent.Timestamp = DateTime.UtcNow.ToString(AWSSDKUtils.ISO8601DateFormat);

            Amazon.MobileAnalytics.Model.Event modelEvent = customEvent.ConvertToMobileAnalyticsModelEvent(this.Session);
            BackgroundDeliveryClient.EnqueueEventsForDelivery(modelEvent);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts to mobile analytics model event. <see cref="Amazon.MobileAnalytics.Model.Event"/>
        /// </summary>
        /// <returns>The to mobile analytics model event.</returns>
        /// <param name="session">Session.</param>
        public virtual Amazon.MobileAnalytics.Model.Event ConvertToMobileAnalyticsModelEvent(Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.Session session)
        {
            Amazon.MobileAnalytics.Model.Event modelEvent = new Amazon.MobileAnalytics.Model.Event();

            // get session info
            string startTimestamp = null, stopTimestamp = null, sessionId = null; long duration = 0;

            session.GetSessionInfo(out startTimestamp, out stopTimestamp, out sessionId, out duration);

            if (string.IsNullOrEmpty(this.StartTimestamp))
            {
                this.StartTimestamp = startTimestamp;
            }
            if (string.IsNullOrEmpty(this.SessionId))
            {
                this.SessionId = sessionId;
            }



            // assign session info from manager event to model event
            modelEvent.EventType              = this._eventType;
            modelEvent.Session                = new Amazon.MobileAnalytics.Model.Session();
            modelEvent.Session.Id             = this.SessionId;
            modelEvent.Session.StartTimestamp = DateTime.ParseExact(this.StartTimestamp, AWSSDKUtils.ISO8601DateFormat, CultureInfo.InvariantCulture);

            if (_eventType == "_session.stop")
            {
                modelEvent.Session.StopTimestamp = DateTime.ParseExact(stopTimestamp, AWSSDKUtils.ISO8601DateFormat, CultureInfo.InvariantCulture);
                modelEvent.Session.Duration      = this.Duration;
            }

            lock (_globalLock)
            {
                AddDict(_globalAttributes, modelEvent.Attributes);
                if (_eventTypeGlobalAttributes.ContainsKey(_eventType))
                {
                    AddDict(_eventTypeGlobalAttributes[_eventType], modelEvent.Attributes);
                }

                AddDict(_globalMetrics, modelEvent.Metrics);
                if (_eventTypeGlobalMetrics.ContainsKey(_eventType))
                {
                    AddDict(_eventTypeGlobalMetrics[_eventType], modelEvent.Metrics);
                }
            }

            lock (_lock)
            {
                AddDict(_attributes, modelEvent.Attributes);
                AddDict(_metrics, modelEvent.Metrics);
            }

            modelEvent.Timestamp = DateTime.ParseExact(this.Timestamp, AWSSDKUtils.ISO8601DateFormat, CultureInfo.InvariantCulture);
            modelEvent.Version   = "v2.0";

            return(modelEvent);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Records the custom event to the local persistent storage. Background thread will deliver the event later.
        /// </summary>
        /// <param name="customEvent">The Mobile Analytics event.</param>
        public void RecordEvent(CustomEvent customEvent)
        {
            if (null == customEvent)
            {
                throw new ArgumentNullException("customEvent");
            }

            customEvent.Timestamp = AWSSDKUtils.CorrectedUtcNow;
            Amazon.MobileAnalytics.Model.Event modelEvent = customEvent.ConvertToMobileAnalyticsModelEvent(this.Session);

            BackgroundDeliveryClient.EnqueueEventsForDelivery(modelEvent);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Converts to mobile analytics model event. <see cref="Amazon.MobileAnalytics.Model.Event"/>
        /// </summary>
        /// <returns>The to mobile analytics model event.</returns>
        /// <param name="session">Session. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.Session"/></param>
        internal virtual Amazon.MobileAnalytics.Model.Event ConvertToMobileAnalyticsModelEvent(Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.Session session)
        {
            Amazon.MobileAnalytics.Model.Event modelEvent = new Amazon.MobileAnalytics.Model.Event();

            this.StartTimestamp = session.StartTime;
            this.SessionId      = session.SessionId;


            // assign session info from custom event to model event
            modelEvent.EventType  = this.EventType;
            modelEvent.Session    = new Amazon.MobileAnalytics.Model.Session();
            modelEvent.Session.Id = session.SessionId;
            modelEvent.Session.StartTimestampUtc = session.StartTime;
            if (session.StopTime != null)
            {
                modelEvent.Session.StopTimestampUtc = session.StopTime.Value;
            }


            if (this.EventType == Constants.SESSION_STOP_EVENT_TYPE)
            {
                modelEvent.Session.StopTimestampUtc = this.StopTimestamp.Value;
                modelEvent.Session.Duration         = this.Duration;
            }

            lock (_globalLock)
            {
                AddDict(_globalAttributes, modelEvent.Attributes);
                if (_eventTypeGlobalAttributes.ContainsKey(EventType))
                {
                    AddDict(_eventTypeGlobalAttributes[EventType], modelEvent.Attributes);
                }

                AddDict(_globalMetrics, modelEvent.Metrics);
                if (_eventTypeGlobalMetrics.ContainsKey(EventType))
                {
                    AddDict(_eventTypeGlobalMetrics[EventType], modelEvent.Metrics);
                }
            }

            lock (_lock)
            {
                AddDict(_attributes, modelEvent.Attributes);
                AddDict(_metrics, modelEvent.Metrics);
            }

            modelEvent.TimestampUtc = Timestamp;
            modelEvent.Version      = "v2.0";

            return(modelEvent);
        }