这段代码给了我不期望的日志,我的问题是如何删除这些日志然后我很容易指出我自己的开发者日志
这是我的代码:
process.env.DEBUG = 'actions-on-google:*';
import * as admin from 'firebase-admin';
const Assistant = require('actions-on-google').ApiAiAssistant;
import * as functions from 'firebase-functions';
import data from './../../db/index';
import { Request, Response } from "express";
import * as functionRequest from 'request';
// API.AI Action names
const SUBMIT_REPORT = 'submitReport';
const NEXT_QUESTION = 'next_question';
export const webhook = functions.https.onRequest(async (request: Request, response: Response) => {
const assistant = new Assistant({ request: request, response: response });
let actionMap = new Map();
actionMap.set(SUBMIT_REPORT, submitReport);
actionMap.set(NEXT_QUESTION, next_question);
assistant.handleRequest(actionMap);
function submitReport(assistant: any) {
console.info("user ask for submit report, request body: ", request.body);
let dataRef = request.body.originalRequest.data.user;
let userData = {
groupId: dataRef.groupId,
subgroupId: dataRef.subgroupId,
userId: dataRef.userId
}
//console.log("userdata: ", userData)
let botRef = data.db.ref('subgroup-bot-chat-mode/' + userData.groupId + '/' + userData.subgroupId + '/' + userData.userId)
botRef
.once('value', function (snapshot) {
let data = snapshot.val()
//console.log("here is recieved data: ", data)
if (data == null) {
let entry = {
'userAgreed': true,
'askedForReport': true,
'timestamp': admin.database.ServerValue.TIMESTAMP,
'reportIndex': 0,
}
botRef
.set(entry, function (error) {
if (!error) {
//console.log("Data save successfully at subgroup-bot-chat-mode/")
// start asking questions
const fullfillment = {
"speech": "qedfqwedf",
"followupEvent": {
"name": "ESOX_WRITE_STANDUP_REPORT_NOW"
},
"contextOut": [
{
"name": "quiz",
"lifespan": 5,
"parameters": {
"index": "0"
}
},
{
"name": "sendReportNow-followup",
"lifespan": 5,
},
]
}
response.send(fullfillment);
return;
}
}).catch((e) => {
console.error("1. an error occured when getting data from db");
response.send({
speech: "error on db"
})
return;
})
} else {
response.send({
speech: "already"
})
return;
}
}).catch((e) => {
console.error("2. an error occured when getting data from db");
response.send({
speech: "error on db"
})
return;
})
}
function next_question(assistant: any) {
let dataRef = request.body.originalRequest.data.user;
let userData = {
groupId: dataRef.groupId,
subgroupId: dataRef.subgroupId,
userId: dataRef.userId
}
let questionIndex = request.body.result.contexts[0].parameters.index;
console.log("index: ", questionIndex);
// if question index == 0 it means it is first time, we will send first question to user
// if question index > 0 it means it means user is answered th index
if (questionIndex == 0) {
console.log("going to send first question");
} else if (questionIndex > 0) {
//todo: process answer here
console.log("answer: ", request.body.result.parameters.answer);
let answer = request.body.result.parameters.answer;
// data.db.ref('subgroup-progress-reports/' + userData.groupId + '/' + userData.subgroupId + '/' + userData.userId + '/' + reportId + '/answers/' + reportIndex)
// .set(answer)
}
// start asking questions
functionRequest({
url: 'https://us-central1-luminous-torch-4640.cloudfunctions.net/getReportQuestions',
method: 'POST',
json: {
'groupId': userData.groupId,
'subgroupId': userData.subgroupId,
'userId': userData.userId
}
}, function (error, res, body) {
if (!error && response.statusCode == 200) {
//console.log("hello: ", res.body)
switch (res.body.status) {
case 'EOF':
response.send({
"speech": "EOF",
"contextOut": [
{
"name": "quiz",
"lifespan": 0
},
{
"name": "sendReportNow-followup",
"lifespan": 0,
}
]
})
break;
case 'OK':
//sending question back
let botRef = data.db.ref('subgroup-bot-chat-mode/' + userData.groupId + '/' + userData.subgroupId + '/' + userData.userId)
.update({
reportIndex: res.body.reportIndex,
reportId: res.body.reportId
})
response.send({
"speech": res.body.question,
"contextOut": [
{
"name": "quiz",
"lifespan": 5,
"parameters": {
"index": res.body.reportIndex,
"reportId": res.body.reportId
}
},
{
"name": "sendReportNow-followup",
"lifespan": 5,
}
]
})
break;
case 'ALREADY_ASKED_FOR_TODAY':
response.send({
"speech": "you are already submited the report for today",
"contextOut": [
{
"name": "quiz",
"lifespan": 0
},
{
"name": "sendReportNow-followup",
"lifespan": 0,
}
]
})
break;
default:
console.error("Unknown case");
//http request failed
response.send({
"speech": "Something went wront on question server",
"contextOut": [
{
"name": "quiz",
"lifespan": 0
},
{
"name": "sendReportNow-followup",
"lifespan": 0,
}
]
})
return;
}
} else {
//http request failed
response.send({
"speech": "Something went wront on question server",
"contextOut": [
{
"name": "quiz",
"lifespan": 0
},
{
"name": "sendReportNow-followup",
"lifespan": 0,
}
]
})
}
})
}
})//end of webhook http trigger
firebase功能的日志在这里:
2:10:34.707 PM info webhook星期六,05八月2017 09:10:34 GMT actions-on-google:调试意图的地图 2:10:34.707 PM info webhook星期六,05八月2017 09:10:34 GMT actions-on-google:debug name = next_question 2:10:34.707 PM info
webhook星期六,05八月2017 09:10:34 GMT动作 - 谷歌:调试密钥是 身高2:10:34.706 PM信息webhook星期六,05八月2017 09:10:34 GMT actions-on-google:debug name = submitReport 2:10:34.706 PM info webhook 星期六,2017年8月5日09:10:34 GMT action-on-google:调试密钥是id 2:10:34.706 PM info webhook星期六,05八月2017 09:10:34 GMT actions-on-google:debug invokeIntentHandler_:handler = [object Map], 意图= next_question
答案 0 :(得分:2)
第一行
<a data-bind="click:functionClick"> Click here</a>
是导致google上的动作库打印大量调试的原因。
您可以删除该行。