def ping_backend(): if isDebug(): # Donot track the ping from debug return global ping_backend_ts if (datetime.datetime.now() - ping_backend_ts).total_seconds() < 60 * 60: return ping_backend_ts = datetime.datetime.now() ping(name="PROTREADING-FLASK", endpoint="https://dev.api.grodok.com:5000")
def pingCelery(): if isDebug(): # Donot track the ping from debug return global pingCelery_ts if (datetime.datetime.now() - pingCelery_ts).total_seconds() < 60 * 60: return pingCelery_ts = datetime.datetime.now() ping(name="PROTREADING-WORKER", endpoint="null")
def reportAction(tag: str, extra: dict = {}): dlog.d("logging remore action with tag:" + tag) if isDebug(): dlog.d("ignore remote log in debug mode") return try: simplestore_post( url="{}/api/analytics/action".format(SIMPLESTORE_ENDPOINT), data={ "app_id": APP_ID, "session": session, "tag": tag, "extra": extra }) except Exception as ex: dlog.ex(ex)
def reportException(ex: Exception, location=""): if isDebug(): dlog.d("ignore remote log in debug mode") return try: res = simplestore_post( url="{}/api/analytics/exception".format(SIMPLESTORE_ENDPOINT), data={ "app_id": APP_ID, "session": session, "location": traceback.format_exc().split("\n")[-4].strip(), "type": "exception", "stack": traceback.format_exc(), "args": str(ex.args) }) dlog.d(str(res)) except Exception as ex: dlog.ex(ex)
def init(): if isDebug(): dlog.d("ignore remote log in debug mode") return global session if session != '': dlog.d("Already session exist") return try: data: dict = simplestore_post( url="{}/api/analytics/launch".format(SIMPLESTORE_ENDPOINT), data={ "app_id": APP_ID, "app_version": "1.0", "device_os": "web", "device_id": "null", "device_api": "null" }) session = data.get('out')[0].get('session') dlog.d("Remote log is inited with session:{}".format(session)) except Exception as ex: dlog.ex(e=ex) pass