Skip to content

Commit

Permalink
Remove comscore pageview tracking (#863)
Browse files Browse the repository at this point in the history
Co-authored-by: Gaëtan Muller <[email protected]>
  • Loading branch information
StaehliJ and MGaetan89 authored Jan 21, 2025
1 parent f043139 commit eee45c9
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 143 deletions.
9 changes: 3 additions & 6 deletions pillarbox-analytics/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ The updated values will be sent with the next analytics event.

### Send page view

To send a page view, use [SRGAnalytics.sendPageView()][ch.srgssr.pillarbox.analytics.SRGAnalytics.sendPageView]. It will send the event to both
Commanders Act and ComScore.
To send a page view, use [SRGAnalytics.sendPageView()][ch.srgssr.pillarbox.analytics.SRGAnalytics.sendPageView]. It will send the event only to
Commanders Act.

```kotlin
val commandersActPageView = CommandersActPageView(
Expand All @@ -89,11 +89,8 @@ val commandersActPageView = CommandersActPageView(
levels = listOf("level1", "level2"),
)

val comScorePageView = ComScorePageView(name = "page_name")

SRGAnalytics.sendPageView(
commandersAct = commandersActPageView,
comScore = comScorePageView,
commandersAct = commandersActPageView
)
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import ch.srgssr.pillarbox.analytics.commandersact.CommandersActPageView
import ch.srgssr.pillarbox.analytics.commandersact.CommandersActSrg
import ch.srgssr.pillarbox.analytics.commandersact.NoOpCommandersAct
import ch.srgssr.pillarbox.analytics.comscore.ComScore
import ch.srgssr.pillarbox.analytics.comscore.ComScorePageView
import ch.srgssr.pillarbox.analytics.comscore.ComScoreSrg
import ch.srgssr.pillarbox.analytics.comscore.NoOpComScore

Expand Down Expand Up @@ -104,10 +103,9 @@ object SRGAnalytics {
* Sends a page view event to both Commanders Act and ComScore.
*
* @param commandersAct The page view data for Commanders Act.
* @param comScore The page view data for ComScore.
*/
fun sendPageView(commandersAct: CommandersActPageView, comScore: ComScorePageView) {
instance?.sendPageView(commandersAct, comScore)
fun sendPageView(commandersAct: CommandersActPageView) {
instance?.sendPageView(commandersAct)
}

/**
Expand Down Expand Up @@ -203,9 +201,9 @@ object SRGAnalytics {
var commandersAct: CommandersAct
) {

fun sendPageView(commandersAct: CommandersActPageView, comScore: ComScorePageView) {
fun sendPageView(commandersAct: CommandersActPageView) {
this.commandersAct.sendPageView(commandersAct)
this.comScore.sendPageView(comScore)
// Business decision to not send those events to comScore.
}

fun sendEvent(commandersAct: CommandersActEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ package ch.srgssr.pillarbox.analytics.comscore
/**
* Interface for interacting with the ComScore SDK.
*
* This interface provides methods for sending page view to ComScore. It also allows for managing permanent data and user consent.
* This interface provides methods for managing permanent data and user consent.
*/
interface ComScore {
/**
* Sends a page view event to ComScore.
*
* @param pageView The [ComScorePageView] to be sent.
*/
fun sendPageView(pageView: ComScorePageView)

/**
* Puts the provided labels as persistent data.
Expand Down Expand Up @@ -49,8 +43,6 @@ interface ComScore {

internal object NoOpComScore : ComScore {

override fun sendPageView(pageView: ComScorePageView) = Unit

override fun putPersistentLabels(labels: Map<String, String>) = Unit

override fun removePersistentLabel(label: String) = Unit
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,6 @@ internal object ComScoreSrg : ComScore, Application.ActivityLifecycleCallbacks {
}
}

override fun sendPageView(pageView: ComScorePageView) {
checkInitialized()
if (!started.get()) return
with(pageView.toLabels()) {
Analytics.notifyViewEvent(this)
}
}

override fun putPersistentLabels(labels: Map<String, String>) {
val configuration = Analytics.getConfiguration().getPublisherConfiguration(publisherId)
configuration.addPersistentLabels(labels)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ch.srgssr.pillarbox.analytics.commandersact.CommandersAct
import ch.srgssr.pillarbox.analytics.commandersact.CommandersActEvent
import ch.srgssr.pillarbox.analytics.commandersact.CommandersActPageView
import ch.srgssr.pillarbox.analytics.comscore.ComScore
import ch.srgssr.pillarbox.analytics.comscore.ComScorePageView
import io.mockk.Called
import io.mockk.clearAllMocks
import io.mockk.confirmVerified
Expand Down Expand Up @@ -45,16 +44,14 @@ class SRGAnalyticsTest {
type = "Type",
levels = listOf("level1", "level2"),
)
val comScorePageView = ComScorePageView("Title")

analytics.sendPageView(
commandersAct = commandersActPageView,
comScore = comScorePageView,
)

verify(exactly = 1) {
commandersAct.sendPageView(commandersActPageView)
comScore.sendPageView(comScorePageView)
comScore wasNot Called
}
confirmVerified(comScore, commandersAct)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,4 @@ class ComScoreSrgTest {
}
confirmVerified(config)
}

@Test
fun `send page view with no labels`() {
ComScoreSrg.sendPageView(ComScorePageView("page"))
val expectedLabels = mapOf(ComScoreLabel.C8.label to "page")
verify(exactly = 1) {
Analytics.notifyViewEvent(expectedLabels)
}
}

@Test
fun `send page view with labels`() {
val labels = mapOf("key01" to "value01", "key02" to "value02")
ComScoreSrg.sendPageView(ComScorePageView("page", labels = labels))
val expectedLabels = mapOf(ComScoreLabel.C8.label to "page", "key01" to "value01", "key02" to "value02")
verify(exactly = 1) {
Analytics.notifyViewEvent(expectedLabels)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package ch.srgssr.pillarbox.demo

import ch.srgssr.pillarbox.analytics.SRGAnalytics
import ch.srgssr.pillarbox.analytics.commandersact.CommandersActPageView
import ch.srgssr.pillarbox.analytics.comscore.ComScorePageView

/**
* Demo page view that create the ComScore and CommandersAct page view object.
Expand All @@ -22,7 +21,6 @@ data class DemoPageView(val title: String, val levels: List<String> = emptyList(
* @param demoPageView
*/
fun SRGAnalytics.trackPagView(demoPageView: DemoPageView) {
val comScorePageView = ComScorePageView(name = demoPageView.title)
val commandersActPageView = CommandersActPageView(name = demoPageView.title, type = "DemoScreen", levels = demoPageView.levels)
sendPageView(commandersAct = commandersActPageView, comScore = comScorePageView)
sendPageView(commandersAct = commandersActPageView)
}

0 comments on commit eee45c9

Please sign in to comment.