Ejemplo n.º 1
0
        public void SendEvent(string eventName, IDictionary <string, object> properties)
        {
            try
            {
                var eventProperties = new Dictionary <string, object>(_defaultPropertiesProvider.Properties);

                foreach (var property in properties)
                {
                    eventProperties[property.Key] = property.Value;
                }

                if (!string.IsNullOrWhiteSpace(_options.UserAgent) && !eventProperties.Keys.Contains(EventProperties.UserAgent))
                {
                    eventProperties[EventProperties.UserAgent] = _options.UserAgent;
                }

                if (_timeProvider != null && !eventProperties.Keys.Contains(EventProperties.DateTime))
                {
                    eventProperties[EventProperties.DateTime] = _timeProvider.UtcTime.ToString("yyyy-MM-ddTHH:mm:ss");
                }

                _tracker.Track(eventName, eventProperties);
            }
            catch (Exception ex)
            {
#if DEBUG
                System.Diagnostics.Trace.WriteLine("Caught mixpanel exception");
                System.Diagnostics.Trace.WriteLine(ex.ToString());
#endif
            }
        }