示例#1
0
 public void Debug(string message, EventLogEntryType entryType, string additionalDebugInformation)
 {
     try
     {
         keenClient.AddEventAsync(string.Format("{0}.Debug.Details", "Config.Proxy"), new
         {
             Message      = message,
             DebugMessage = additionalDebugInformation,
             entryType,
             TimeStamp = DateTime.UtcNow,
         });
     }
     catch (Exception ex)
     {
         // ex.Log();
     }
 }
示例#2
0
 public static void AddDeferredEvent(string eventName, object eventData)
 {
     //var addons = new[]
     //{
     //    AddOn.IpToGeo("IPAddress", "Location")
     //};
     DeferredClient.AddEventAsync(eventName, eventData);
 }
示例#3
0
 public static void SendEventImmediately(string eventName, object eventData)
 {
     //var addons = new[]
     //{
     //    AddOn.IpToGeo("IPAddress", "Location")
     //};
     Client.AddEventAsync(eventName, eventData);
 }
        public async Task <MapModel> GetFeaturedMap()
        {
            MapModel model = MapModel.FromEntity(await TableStorage.GetFeaturedMap(DateTimeOffset.UtcNow));

            // If no featured map is set return a random one and set a short update check.
            if (model == null)
            {
                model = MapModel.FromEntity(await TableStorage.GetRandomMap());

                var nextHour = DateTimeOffset.UtcNow.AddHours(1) - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

                model.NextUpdate = (long)nextHour.TotalSeconds;

                Analytics.AddEventAsync("api.public.get.featured", new
                {
                    client_id         = this.ClientId,
                    map_id            = model.Id,
                    map_title         = model.Title,
                    map_author        = model.Author,
                    map_year          = model.Year,
                    map_image_url     = model.ImageAddress,
                    map_reference_url = model.ReferenceAddress,
                    next_update       = model.NextUpdate
                });

                return(model);
            }

            model.NextUpdate = Utils.NextFeaturedUpdateTime();

            Analytics.AddEventAsync("api.public.get.featured", new
            {
                client_id         = this.ClientId,
                map_id            = model.Id,
                map_title         = model.Title,
                map_author        = model.Author,
                map_year          = model.Year,
                map_image_url     = model.ImageAddress,
                map_reference_url = model.ReferenceAddress,
                next_update       = model.NextUpdate
            });

            return(model);
        }
示例#5
0
 public void Debug(string message, EventLogEntryType entryType, string additionalDebugInformation)
 {
     if (!ConfigurationManagerHelper.GetValueOnKey("stardust.logToKeen", false))
     {
         return;
     }
     try
     {
         keenClient.AddEventAsync(string.Format("{0}.Debug.Details", "Config"), new
         {
             Message      = message,
             DebugMessage = additionalDebugInformation,
             entryType,
             TimeStamp = DateTime.UtcNow,
         });
     }
     catch (Exception ex)
     {
         // ex.Log();
     }
 }
示例#6
0
        public async Task Async_AddEvent_Success()
        {
            var client = new KeenClient(SettingsEnv);

            if (UseMocks)
            {
                client.EventCollection = new EventCollectionMock(SettingsEnv,
                                                                 addEvent: new Action <string, JObject, IProjectSettings>((c, e, p) =>
                {
                    if ((p == SettingsEnv) && (c == "AddEventTest") && (e["AProperty"].Value <string>() == "Value"))
                    {
                        throw new KeenResourceNotFoundException(c);
                    }
                }));
            }

            await client.AddEventAsync("AddEventTest", new { AProperty = "AValue" });
        }
示例#7
0
        public async Task Async_AddEvent_ValidProjectIdInvalidWriteKey_Throws()
        {
            var settings = new ProjectSettingsProvider(projectId: SettingsEnv.ProjectId, writeKey: "X");
            var client   = new KeenClient(settings);

            if (UseMocks)
            {
                client.EventCollection = new EventCollectionMock(settings,
                                                                 addEvent: new Action <string, JObject, IProjectSettings>((c, e, p) =>
                {
                    if ((p == settings) && (c == "AddEventTest") && (e["AProperty"].Value <string>() == "Value"))
                    {
                        throw new KeenInvalidApiKeyException(c);
                    }
                }));
            }

            await client.AddEventAsync("AddEventTest", new { AProperty = "Value" });
        }
        public void Async_AddEvent_InvalidProjectId_Throws()
        {
            var settings = new ProjectSettingsProvider(projectId: "X", writeKey: SettingsEnv.WriteKey);
            var client   = new KeenClient(settings);

            if (UseMocks)
            {
                client.EventCollection = new EventCollectionMock(settings,
                                                                 addEvent: new Action <string, JObject, IProjectSettings>((c, e, p) =>
                {
                    if ((p == settings) && (c == "AddEventTest") && (e["AProperty"].Value <string>() == "Value"))
                    {
                        throw new KeenResourceNotFoundException(c);
                    }
                }));
            }

            Assert.ThrowsAsync <Keen.Core.KeenResourceNotFoundException>(() => client.AddEventAsync("AddEventTest", new { AProperty = "Value" }));
        }