Exemplo n.º 1
0
        private static KinesisLogEvent CreateTagEvent(SessionData sessionData, string tag, IDictionary <string, object> properties)
        {
            if (properties == null)
            {
                properties = new Dictionary <string, object>();
            }

            AddStandardProperties(sessionData, properties);

            var indexName = (properties != null && properties.ContainsKey("partner")) ? "tag_events_" + ((string)properties["partner"]).ToLower() : "tag_events";
            var indexType = (properties != null && properties.ContainsKey("partner")) ? "tag_events_" + ((string)properties["partner"]).ToLower() : "claims_tag_events";

            KinesisLogEvent logEvent = new KinesisLogEvent
            {
                Session_id       = sessionData.SessionId,
                Logger_info      = "flow_engine:tag_events",
                Application_info = sessionData.PartnerContext,
                Data             = "",
                Log           = "",
                To_index      = true,
                Index_type    = indexType,
                Index_name    = indexName,
                Index_content = new
                {
                    chat_id    = sessionData.ChatId,
                    session_id = sessionData.SessionId,
                    // Can't use standard "o" format, since it provides 6 digit milliseconds, which causes errors when its saved to Dynamo
                    timestamp = AWSDynamoService.ToDynamoDateString(DateTime.UtcNow),
                    tag,
                    properties
                }
            };

            return(logEvent);
        }
Exemplo n.º 2
0
        public async Task SendFailToUnderstandEvent(ChatModel chat, ChatFlowStep flowStep)
        {
            if (chat == null)
            {
                return;
            }

            var lastMessage = chat.CurrentState.GetLastMessage();

            var properties = new Dictionary <string, object>();

            AddStandardProperties(chat.CurrentState.SessionData, properties);

            KinesisLogEvent logEvent = new KinesisLogEvent
            {
                Session_id       = chat.SessionLogId,
                Logger_info      = String.Format("flow_engine:{0}:{1}", flowStep.Flow, flowStep.Id),
                Application_info = chat.CurrentState.SessionData.PartnerContext,
                Data             = "",
                Log           = "",
                To_index      = true,
                Index_type    = "engine_flowfailure",
                Index_name    = "flow_failures",
                Index_content = new
                {
                    chat_id    = chat.ChatId,
                    session_id = chat.SessionLogId,
                    // Can't use standard "o" format, since it provides 6 digit milliseconds, which causes errors when its saved to Dynamo
                    timestamp           = AWSDynamoService.ToDynamoDateString(DateTime.UtcNow),
                    step                = new ChatStepId(flowStep),
                    chat_text           = filterService.FilterUserData(chat.CurrentState, lastMessage.UserInput),
                    chat_corrected_text = filterService.FilterUserData(chat.CurrentState, lastMessage.CorrectedUserInput),
                    bot_text            = filterService.FilterUserData(chat.CurrentState, lastMessage.BotQuestionsText),
                    properties
                }
            };

            await PutRecordInternalAsync(logEvent);
        }