@@ -105,6 +105,24 @@ def log_node_added(self, widget_name, extended_widget=None):
105105 def set_node_type (self , addition_type ):
106106 self .__node_addition_type = addition_type
107107
108+ def send_statistics (self ):
109+ if release and config .settings ()["error-reporting/send-statistics" ]:
110+ if os .path .isfile (statistics_path ):
111+ with open (statistics_path ) as f :
112+ data = json .load (f )
113+ try :
114+ r = requests .post (server_url , files = {'file' : json .dumps (data )})
115+ if r .status_code != 200 :
116+ log .warning ("Error communicating with server while attempting to send "
117+ "usage statistics." )
118+ return
119+ # success - wipe statistics file
120+ log .info ("Usage statistics sent." )
121+ with open (statistics_path , 'w' ) as f :
122+ json .dump ([], f )
123+ except (ConnectionError , requests .exceptions .RequestException ):
124+ log .warning ("Connection error while attempting to send usage statistics." )
125+
108126 def write_statistics (self ):
109127 if not release :
110128 log .info ("Not sending usage statistics (non-release version of Orange detected)." )
@@ -134,24 +152,9 @@ def write_statistics(self):
134152
135153 data .append (statistics )
136154
137- def store_data (d ):
138- with open (statistics_path , 'w' ) as f :
139- json .dump (d , f )
140-
141- try :
142- r = requests .post (server_url , files = {'file' : json .dumps (data )})
143- if r .status_code != 200 :
144- log .warning ("Error communicating with server while attempting to send "
145- "usage statistics." )
146- store_data (data )
147- return
148- # success - wipe statistics file
149- log .info ("Usage statistics sent." )
150- with open (statistics_path , 'w' ) as f :
151- json .dump ([], f )
152- except (ConnectionError , requests .exceptions .RequestException ):
153- log .warning ("Connection error while attempting to send usage statistics." )
154- store_data (data )
155+ with open (statistics_path , 'w' ) as f :
156+ json .dump (data , f )
157+
155158
156159 @staticmethod
157160 def set_last_search_query (query ):
0 commit comments