From 70ce1861c7979ec64c27d78a872f406fd6b5c958 Mon Sep 17 00:00:00 2001 From: AntonAFA Date: Tue, 28 Mar 2017 14:48:59 +0300 Subject: [PATCH] =?UTF-8?q?Analytics=20report=20event=20added.=20Will=20be?= =?UTF-8?q?=20dispatched=20every=20time=20the=20corre=E2=80=A6=20(#193)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Analytics report event added. Will be dispatched every time the corresponding analytics report sent to backend. * Report events renamed to REPORT_SENT. Removed unnecessary LogEvent from analytics --- .../plugins/KalturaLiveStatsEvent.java | 33 +++++++++++++++++++ .../plugins/KalturaLiveStatsPlugin.java | 5 ++- .../playkit/plugins/KalturaStatsEvent.java | 33 +++++++++++++++++++ .../playkit/plugins/KalturaStatsPlugin.java | 2 +- .../plugins/PhoenixAnalyticsEvent.java | 33 +++++++++++++++++++ .../plugins/PhoenixAnalyticsPlugin.java | 3 +- .../plugins/TVPAPIAnalyticsPlugin.java | 3 +- .../playkit/plugins/TVPapiAnalyticsEvent.java | 33 +++++++++++++++++++ .../plugins/Youbora/YouboraAdManager.java | 14 ++++---- .../playkit/plugins/Youbora/YouboraEvent.java | 33 +++++++++++++++++++ .../Youbora/YouboraLibraryManager.java | 29 ++++++++-------- 11 files changed, 193 insertions(+), 28 deletions(-) create mode 100644 playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsEvent.java create mode 100644 playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsEvent.java create mode 100644 playkit/src/main/java/com/kaltura/playkit/plugins/PhoenixAnalyticsEvent.java create mode 100644 playkit/src/main/java/com/kaltura/playkit/plugins/TVPapiAnalyticsEvent.java create mode 100644 playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraEvent.java diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsEvent.java b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsEvent.java new file mode 100644 index 000000000..b01b0c085 --- /dev/null +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsEvent.java @@ -0,0 +1,33 @@ +package com.kaltura.playkit.plugins; + +import com.kaltura.playkit.PKEvent; + +/** + * Created by anton.afanasiev on 27/03/2017. + */ + +public class KalturaLiveStatsEvent implements PKEvent { + + public enum Type { + REPORT_SENT + } + + public static class KalturaLiveStatsReport extends KalturaLiveStatsEvent { + + private long bufferTime; + + public KalturaLiveStatsReport(long bufferTime) { + this.bufferTime = bufferTime; + } + + public long getBufferTime() { + return bufferTime; + } + } + + + @Override + public Enum eventType() { + return Type.REPORT_SENT; + } +} diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsPlugin.java b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsPlugin.java index 905738c63..1d4c9b2b5 100644 --- a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsPlugin.java +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaLiveStatsPlugin.java @@ -4,7 +4,6 @@ import android.util.Log; import com.google.gson.JsonObject; -import com.kaltura.playkit.LogEvent; import com.kaltura.playkit.MessageBus; import com.kaltura.playkit.PKEvent; import com.kaltura.playkit.PKLog; @@ -207,7 +206,7 @@ private void stopLiveEvents() { isLive = false; } - private void sendLiveEvent(long bufferTime) { + private void sendLiveEvent(final long bufferTime) { String sessionId = pluginConfig.has("sessionId") ? pluginConfig.getAsJsonPrimitive("sessionId").getAsString() : ""; String baseUrl = pluginConfig.has("baseUrl") ? pluginConfig.getAsJsonPrimitive("baseUrl").getAsString() : BASE_URL; int partnerId = pluginConfig.has("partnerId") ? pluginConfig.getAsJsonPrimitive("partnerId").getAsInt() : 0; @@ -222,7 +221,7 @@ private void sendLiveEvent(long bufferTime) { @Override public void onComplete(ResponseElement response) { Log.d(TAG, "onComplete: " + isLive); - messageBus.post(new LogEvent(TAG + " " + isLive)); + messageBus.post(new KalturaLiveStatsEvent.KalturaLiveStatsReport(bufferTime)); } }); requestsExecutor.queue(requestBuilder.build()); diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsEvent.java b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsEvent.java new file mode 100644 index 000000000..2440ca6a8 --- /dev/null +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsEvent.java @@ -0,0 +1,33 @@ +package com.kaltura.playkit.plugins; + +import com.kaltura.playkit.PKEvent; + +/** + * Created by anton.afanasiev on 27/03/2017. + */ + +public class KalturaStatsEvent implements PKEvent{ + + public enum Type { + REPORT_SENT + } + + public static class KalturaStatsReport extends KalturaStatsEvent { + + private String reportedEventName; + + public KalturaStatsReport(String reportedEventName) { + this.reportedEventName = reportedEventName; + } + + public String getReportedEventName() { + return reportedEventName; + } + } + + + @Override + public Enum eventType() { + return Type.REPORT_SENT; + } +} diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsPlugin.java b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsPlugin.java index cbe126bae..2810f0fca 100644 --- a/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsPlugin.java +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/KalturaStatsPlugin.java @@ -416,9 +416,9 @@ private void sendAnalyticsEvent(final KStatsEvent eventType) { @Override public void onComplete(ResponseElement response) { log.d("onComplete send event: " + eventType.toString()); + messageBus.post(new KalturaStatsEvent.KalturaStatsReport(eventType.toString())); } }); requestsExecutor.queue(requestBuilder.build()); - messageBus.post(new LogEvent(TAG + " " + eventType.toString(), requestBuilder.build().getUrl())); } } diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/PhoenixAnalyticsEvent.java b/playkit/src/main/java/com/kaltura/playkit/plugins/PhoenixAnalyticsEvent.java new file mode 100644 index 000000000..c62b649a5 --- /dev/null +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/PhoenixAnalyticsEvent.java @@ -0,0 +1,33 @@ +package com.kaltura.playkit.plugins; + +import com.kaltura.playkit.PKEvent; + +/** + * Created by anton.afanasiev on 27/03/2017. + */ + +public class PhoenixAnalyticsEvent implements PKEvent { + + public enum Type { + REPORT_SENT + } + + public static class PhoenixAnalyticsReport extends PhoenixAnalyticsEvent { + + private String reportedEventName; + + public PhoenixAnalyticsReport(String reportedEventName) { + this.reportedEventName = reportedEventName; + } + + public String getReportedEventName() { + return reportedEventName; + } + } + + + @Override + public Enum eventType() { + return Type.REPORT_SENT; + } +} diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/PhoenixAnalyticsPlugin.java b/playkit/src/main/java/com/kaltura/playkit/plugins/PhoenixAnalyticsPlugin.java index 146bba729..b02f7ea78 100644 --- a/playkit/src/main/java/com/kaltura/playkit/plugins/PhoenixAnalyticsPlugin.java +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/PhoenixAnalyticsPlugin.java @@ -3,7 +3,6 @@ import android.content.Context; import com.google.gson.JsonObject; -import com.kaltura.playkit.LogEvent; import com.kaltura.playkit.MessageBus; import com.kaltura.playkit.OttEvent; import com.kaltura.playkit.PKEvent; @@ -195,12 +194,12 @@ protected void sendAnalyticsEvent(final PhoenixActionType eventType){ public void onComplete(ResponseElement response) { if (response.isSuccess() && response.getError() != null && response.getError().getCode().equals("4001")){ messageBus.post(new OttEvent(OttEvent.OttEventType.Concurrency)); + messageBus.post(new PhoenixAnalyticsEvent.PhoenixAnalyticsReport(eventType.toString())); } log.d("onComplete send event: "); } }); requestsExecutor.queue(requestBuilder.build()); - messageBus.post(new LogEvent(TAG + " " + eventType.toString(), requestBuilder.build().getBody())); } } diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/TVPAPIAnalyticsPlugin.java b/playkit/src/main/java/com/kaltura/playkit/plugins/TVPAPIAnalyticsPlugin.java index a0c132499..b6be1885e 100644 --- a/playkit/src/main/java/com/kaltura/playkit/plugins/TVPAPIAnalyticsPlugin.java +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/TVPAPIAnalyticsPlugin.java @@ -3,7 +3,6 @@ import android.content.Context; import com.google.gson.JsonObject; -import com.kaltura.playkit.LogEvent; import com.kaltura.playkit.OttEvent; import com.kaltura.playkit.PKLog; import com.kaltura.playkit.PKPlugin; @@ -62,11 +61,11 @@ protected void sendAnalyticsEvent(final PhoenixActionType eventType){ public void onComplete(ResponseElement response) { if (response.isSuccess() && response.getResponse().toLowerCase().contains("concurrent")){ messageBus.post(new OttEvent(OttEvent.OttEventType.Concurrency)); + messageBus.post(new TVPapiAnalyticsEvent.TVPapiAnalyticsReport(eventType.toString())); } log.d("onComplete send event: "); } }); requestsExecutor.queue(requestBuilder.build()); - messageBus.post(new LogEvent(TAG + " " + eventType.toString(), requestBuilder.build().getBody())); } } diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/TVPapiAnalyticsEvent.java b/playkit/src/main/java/com/kaltura/playkit/plugins/TVPapiAnalyticsEvent.java new file mode 100644 index 000000000..6248a1389 --- /dev/null +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/TVPapiAnalyticsEvent.java @@ -0,0 +1,33 @@ +package com.kaltura.playkit.plugins; + +import com.kaltura.playkit.PKEvent; + +/** + * Created by anton.afanasiev on 27/03/2017. + */ + +public class TVPapiAnalyticsEvent implements PKEvent { + + public enum Type { + REPORT_SENT + } + + public static class TVPapiAnalyticsReport extends TVPapiAnalyticsEvent { + + private String reportedEventName; + + public TVPapiAnalyticsReport(String reportedEventName) { + this.reportedEventName = reportedEventName; + } + + public String getReportedEventName() { + return reportedEventName; + } + } + + + @Override + public Enum eventType() { + return Type.REPORT_SENT; + } +} diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraAdManager.java b/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraAdManager.java index 4b445f378..8ccdb8b33 100644 --- a/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraAdManager.java +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraAdManager.java @@ -1,6 +1,5 @@ package com.kaltura.playkit.plugins.Youbora; -import com.kaltura.playkit.LogEvent; import com.kaltura.playkit.MessageBus; import com.kaltura.playkit.PKEvent; import com.kaltura.playkit.PKLog; @@ -48,8 +47,7 @@ private void onEvent(PlayerEvent.StateChanged event) { default: break; } - log.d(event.newState.toString()); - messageBus.post(new LogEvent(TAG + " " + event.newState.toString())); + sendReportEvent(event); } private PKEvent.Listener mEventListener = new PKEvent.Listener() { @@ -108,8 +106,7 @@ public void onEvent(PKEvent event) { case ALL_ADS_COMPLETED: break; } - log.d(event.eventType().name()); - messageBus.post(new LogEvent(TAG + " " + ((AdEvent) event).type.toString())); + sendReportEvent(event); } else if (event instanceof PlayerEvent) { switch (((PlayerEvent) event).type) { case STATE_CHANGED: @@ -119,7 +116,6 @@ public void onEvent(PKEvent event) { } }; - public void startMonitoring(Object player) { log.d("startMonitoring"); super.startMonitoring(player); @@ -157,4 +153,10 @@ public Double getAdDuration() { public String getAdPlayerVersion() { return PlayKitManager.CLIENT_TAG; } + + private void sendReportEvent(PKEvent event) { + String reportedEventName = event.eventType().name(); + log.d(reportedEventName); + messageBus.post(new YouboraEvent.YouboraReport(reportedEventName)); + } } diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraEvent.java b/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraEvent.java new file mode 100644 index 000000000..ab2030fa2 --- /dev/null +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraEvent.java @@ -0,0 +1,33 @@ +package com.kaltura.playkit.plugins.Youbora; + +import com.kaltura.playkit.PKEvent; + +/** + * Created by anton.afanasiev on 27/03/2017. + */ + +public class YouboraEvent implements PKEvent { + + public enum Type { + REPORT_SENT + } + + public static class YouboraReport extends YouboraEvent{ + + private String reportedEventName; + + public YouboraReport(String reportedEventName) { + this.reportedEventName = reportedEventName; + } + + public String getReportedEventName() { + return reportedEventName; + } + } + + + @Override + public Enum eventType() { + return Type.REPORT_SENT; + } +} diff --git a/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraLibraryManager.java b/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraLibraryManager.java index 52f9e1542..ca6ae6fd7 100644 --- a/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraLibraryManager.java +++ b/playkit/src/main/java/com/kaltura/playkit/plugins/Youbora/YouboraLibraryManager.java @@ -1,6 +1,5 @@ package com.kaltura.playkit.plugins.Youbora; -import com.kaltura.playkit.LogEvent; import com.kaltura.playkit.MessageBus; import com.kaltura.playkit.PKEvent; import com.kaltura.playkit.PKLog; @@ -54,12 +53,11 @@ public YouboraLibraryManager(Map options, MessageBus messageBus, protected void init() { super.init(); this.pluginName = PlayKitManager.CLIENT_TAG; - this.pluginVersion = "5.3.0-"+ PlayKitManager.CLIENT_TAG; + this.pluginVersion = "5.3.0-" + PlayKitManager.CLIENT_TAG; ViewManager.setMonitoringInterval(MONITORING_INTERVAL); } private void onEvent(PlayerEvent.StateChanged event) { - log.d(event.newState.toString()); switch (event.newState) { case READY: if (isBuffering && !isFirstPlay) { @@ -76,8 +74,7 @@ private void onEvent(PlayerEvent.StateChanged event) { default: break; } - log.d(event.newState.toString()); - messageBus.post(new LogEvent(TAG + " " + event.newState.toString())); + sendReportEvent(event); } private PKEvent.Listener mEventListener = new PKEvent.Listener() { @@ -122,7 +119,7 @@ public void onEvent(PKEvent event) { } break; case PLAYING: - if (isFirstPlay){ + if (isFirstPlay) { isFirstPlay = false; playHandler(); } @@ -140,18 +137,16 @@ public void onEvent(PKEvent event) { default: break; } - log.d(event.eventType().name()); - if (((PlayerEvent) event).type != STATE_CHANGED){ - messageBus.post(new LogEvent(TAG + " " + ((PlayerEvent) event).type.toString())); + if (((PlayerEvent) event).type != STATE_CHANGED) { + sendReportEvent(event); } - } else if (event instanceof AdEvent){ + } else if (event instanceof AdEvent) { onAdEvent((AdEvent) event); } } }; private void onAdEvent(AdEvent event) { - log.d(event.type.toString()); switch (event.type) { case STARTED: ignoringAdHandler(); @@ -163,10 +158,10 @@ private void onAdEvent(AdEvent event) { default: break; } - log.d(event.type.toString()); - messageBus.post(new LogEvent(TAG + " " + event.type.toString())); + sendReportEvent(event); } + public void startMonitoring(Object player) { log.d("startMonitoring"); super.startMonitoring(player); @@ -199,7 +194,7 @@ public String getPlayerVersion() { } public String getResource() { - return this.mediaUrl; + return this.mediaUrl; } public Double getPlayhead() { @@ -210,4 +205,10 @@ public Boolean getIsLive() { return mediaConfig != null && (mediaConfig.getMediaEntry().getMediaType() == PKMediaEntry.MediaEntryType.Live); } + private void sendReportEvent(PKEvent event) { + String reportedEventName = event.eventType().name(); + log.d(reportedEventName); + messageBus.post(new YouboraEvent.YouboraReport(reportedEventName)); + } + }