From 5d4f92840c6044c92031dd4f6fbe25bc6770dafd Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Wed, 20 Feb 2019 13:40:39 +0800 Subject: [PATCH] fix: wait for execution --- src/analytics.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/analytics.ts b/src/analytics.ts index 36e22e4..eb19aa1 100644 --- a/src/analytics.ts +++ b/src/analytics.ts @@ -1,6 +1,6 @@ -import { version } from '../package.json' import { Middleware } from 'driver/connect.js' import { IN_PRODUCTION_MODE } from 'env' +import { version } from '../package.json' // TODO: set this through ENV or something else const LOG_ENDPOINT = 'https://enix.one/gitako/log' @@ -10,9 +10,9 @@ export function raiseError(error: Error) { export const withErrorLog: Middleware = function withErrorLog(method, args) { return [ - function() { + async function() { try { - method.apply(this, arguments) + await method.apply(this, arguments) } catch (error) { raiseError(error) } @@ -34,6 +34,6 @@ function reportError(error: Error) { error: (error && error.message) || error, path: window.location.href, version, - })}` + })}`, ) }