Exemple #1
0
        protected IAmazonPersonalizeEvents CreateClient(AWSCredentials credentials, RegionEndpoint region)
        {
            var config = new AmazonPersonalizeEventsConfig {
                RegionEndpoint = region
            };

            Amazon.PowerShell.Utils.Common.PopulateConfig(this, config);
            this.CustomizeClientConfig(config);
            var client = new AmazonPersonalizeEventsClient(credentials, config);

            client.BeforeRequestEvent += RequestEventHandler;
            client.AfterResponseEvent += ResponseEventHandler;
            return(client);
        }
Exemple #2
0
        public void AddEventTracker(string movieItemId, string userId)
        {
            try
            {
                //record events
                var eventRequest = new PutEventsRequest
                {
                    TrackingId =
                        AwsParameterStoreClient.GetClickStreamTrackingId(),
                    UserId    = userId,                   //USER_ID
                    SessionId = Guid.NewGuid().ToString() //SESSION_ID
                };

                var ev1 = new TrackingEvent {
                    itemId = movieItemId
                };

                var ev = JsonConvert.SerializeObject(ev1);

                var e = new Event
                {
                    //e.EventId = "event1";
                    EventType  = "click",     //EVENT_TYPE
                    Properties = ev,
                    SentAt     = DateTime.Now //TIMESTAMP
                };

                var events = new List <Event> {
                    e
                };

                eventRequest.EventList = events;

                var amazonPersonalizeEventsClient = new AmazonPersonalizeEventsClient(RegionEndpoint.USEast1);

                amazonPersonalizeEventsClient.PutEventsAsync(eventRequest);

                Logger.LogInformation("Adding a clickstream event for userid:" + userId + ", movieitemid: " + movieItemId);
            }
            catch (Exception exception)
            {
                throw;
            }
        }