File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def ask():
40
40
41
41
if not query :
42
42
return jsonify ({"error" : "No query provided" }), 400
43
-
43
+
44
44
# For analytics tracking, generates an anonymous id and uses it for the session
45
45
if 'anonymous_id' not in session :
46
46
session ['anonymous_id' ] = str (uuid .uuid4 ())
@@ -59,12 +59,13 @@ def generate():
59
59
if not full_response :
60
60
full_response = "No response generated"
61
61
62
- # Track the query and response
63
- analytics .track (
64
- anonymous_id = anonymous_id ,
65
- event = 'Chatbot Question submitted' ,
66
- properties = {'query' : query , 'response' : full_response , 'source' : 'Ask Defang' }
67
- )
62
+ if analytics .write_key :
63
+ # Track the query and response
64
+ analytics .track (
65
+ anonymous_id = anonymous_id ,
66
+ event = 'Chatbot Question submitted' ,
67
+ properties = {'query' : query , 'response' : full_response , 'source' : 'Ask Defang' }
68
+ )
68
69
69
70
return Response (stream_with_context (generate ()), content_type = 'text/markdown' )
70
71
You can’t perform that action at this time.
0 commit comments