Skip to content

Commit

Permalink
feat: log statck trace to Conviva in case of error events
Browse files Browse the repository at this point in the history
  • Loading branch information
Wkkkkk committed Aug 15, 2023
1 parent a64aac1 commit 7a75763
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -235,7 +236,6 @@ public void reportAppBackgrounded() {
ConvivaAnalytics.reportAppBackgrounded();
isBackgrounded = true;
}

}

// endregion
Expand All @@ -247,7 +247,15 @@ private void ensureConvivaSessionIsCreatedAndInitialized() {
}

private void customEvent(Event event) {
customEvent(event, new HashMap<String, Object>());
Map<String, Object> 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<String, Object> attributes) {
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit 7a75763

Please sign in to comment.