From 067886f5e8dcb96c6444f703a97e9f17b0d920e6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 30 Oct 2020 16:09:06 +0000 Subject: [PATCH] Only pass metrics if they exist otherwise Countly will be unhappy! --- src/CountlyAnalytics.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/CountlyAnalytics.ts b/src/CountlyAnalytics.ts index 41b995021f..600a9be1bf 100644 --- a/src/CountlyAnalytics.ts +++ b/src/CountlyAnalytics.ts @@ -525,9 +525,9 @@ export default class CountlyAnalytics { const metrics = this.getMetrics(); const ob: ICrash = { - _resolution: metrics._resolution, + _resolution: metrics?._resolution, _error: error, - _app_version: metrics._app_version, + _app_version: this.appVersion, _run: CountlyAnalytics.getTimestamp() - this.initTime, _nonfatal: !fatal, _view: this.lastView, @@ -729,11 +729,17 @@ export default class CountlyAnalytics { }, }; - await this.request({ + const request: Parameters[0] = { begin_session: 1, - metrics: JSON.stringify(this.getMetrics()), user_details: JSON.stringify(userDetails), - }); + } + + const metrics = this.getMetrics(); + if (metrics) { + request.metrics = JSON.stringify(metrics); + } + + await this.request(request); } }