From 7a7576369d13d96cb2bc56385a648007d67c525c Mon Sep 17 00:00:00 2001 From: Kun Wu Date: Tue, 15 Aug 2023 15:34:46 +0200 Subject: [PATCH] feat: log statck trace to Conviva in case of error events --- .../conviva/ConvivaAnalyticsIntegration.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/conviva/src/main/java/com/bitmovin/analytics/conviva/ConvivaAnalyticsIntegration.java b/conviva/src/main/java/com/bitmovin/analytics/conviva/ConvivaAnalyticsIntegration.java index f8e64b3..ea75e31 100644 --- a/conviva/src/main/java/com/bitmovin/analytics/conviva/ConvivaAnalyticsIntegration.java +++ b/conviva/src/main/java/com/bitmovin/analytics/conviva/ConvivaAnalyticsIntegration.java @@ -5,6 +5,7 @@ import android.util.Log; import com.bitmovin.player.api.Player; +import com.bitmovin.player.api.deficiency.ErrorEvent; import com.bitmovin.player.api.event.Event; import com.bitmovin.player.api.event.EventListener; import com.bitmovin.player.api.event.PlayerEvent; @@ -235,7 +236,6 @@ public void reportAppBackgrounded() { ConvivaAnalytics.reportAppBackgrounded(); isBackgrounded = true; } - } // endregion @@ -247,7 +247,15 @@ private void ensureConvivaSessionIsCreatedAndInitialized() { } private void customEvent(Event event) { - customEvent(event, new HashMap()); + Map eventAttributes = new HashMap<>(); + if (event instanceof PlayerEvent.Error || event instanceof SourceEvent.Error) { + ErrorEvent errorEvent = ((ErrorEvent) event); + if (errorEvent.getData() != null) { + // Report stack trace to Conviva + eventAttributes.put("stack trace", errorEvent.getData().toString()); + } + } + customEvent(event, eventAttributes); } private void customEvent(Event event, Map attributes) { @@ -454,6 +462,7 @@ public void run() { public void onEvent(PlayerEvent.Error event) { Log.d(TAG, "[Player Event] Error"); String message = String.format("%s - %s", event.getCode(), event.getMessage()); + customEvent(event); // In case of Error, report current stack trace if available convivaVideoAnalytics.reportPlaybackError(message, ConvivaSdkConstants.ErrorSeverity.FATAL); internalEndSession(); } @@ -464,6 +473,7 @@ public void onEvent(PlayerEvent.Error event) { public void onEvent(SourceEvent.Error event) { Log.d(TAG, "[Source Event] Error"); String message = String.format("%s - %s", event.getCode(), event.getMessage()); + customEvent(event); // In case of Error, report current stack trace if available convivaVideoAnalytics.reportPlaybackError(message, ConvivaSdkConstants.ErrorSeverity.FATAL); internalEndSession(); }