Exemplo n.º 1
0
        /// <summary>
        /// Add a single event to the specified collection.
        /// </summary>
        /// <param name="collection">Collection name</param>
        /// <param name="eventInfo">An object representing the event to be added.</param>
        /// <param name="addOns">Optional collection of Data Enhancement Add-ons</param>
        public void AddEvent(string collection, object eventInfo, IEnumerable <AddOn> addOns = null)
        {
            // Preconditions
            KeenUtil.ValidateEventCollectionName(collection);
            if (null == eventInfo)
            {
                throw new KeenException("Event data is required.");
            }
            if (_prjSettings.WriteKey.IsNullOrWhiteSpace())
            {
                throw new KeenException("Write API key is requried for AddEvent");
            }

            var jEvent = PrepareUserObject(eventInfo, addOns);

            // If an event cache has been provided, cache this event insead of sending it.
            if (null != EventCache)
            {
                EventCache.Add(new CachedEvent(collection, jEvent));
            }
            else
            {
                EventCollection.AddEvent(collection, jEvent);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieve the schema for the specified collection. This requires
        /// a value for the project settings Master API key.
        /// </summary>
        /// <param name="collection"></param>
        public JObject GetSchema(string collection)
        {
            // Preconditions
            KeenUtil.ValidateEventCollectionName(collection);
            if (_prjSettings.MasterKey.IsNullOrWhiteSpace())
            {
                throw new KeenException("Master API key is requried for GetSchema");
            }

            return(EventCollection.GetSchema(collection));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Delete the specified collection. Deletion may be denied for collections with many events.
        /// Master API key is required.
        /// </summary>
        /// <param name="collection">Name of collection to delete.</param>
        public void DeleteCollection(string collection)
        {
            // Preconditions
            KeenUtil.ValidateEventCollectionName(collection);
            if (_prjSettings.MasterKey.IsNullOrWhiteSpace())
            {
                throw new KeenException("Master API key is requried for DeleteCollection");
            }

            EventCollection.DeleteCollection(collection);
        }