Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSAI tracking API #78

Merged
merged 18 commits into from
Jul 4, 2024
Merged

SSAI tracking API #78

merged 18 commits into from
Jul 4, 2024

Conversation

rolandkakonyi
Copy link
Contributor

@rolandkakonyi rolandkakonyi commented Jul 2, 2024

Problem

We don't support tracking SSAI ads via the Conviva integration.

Solution

Introduced ConvivaAnalytics.ssai property with SsaiApi type which has:

  • SsaiApi.isAdBreakActive for checking if an SSAI ad break is active
  • SsaiApi.reportAdBreakStarted() for reporting SSAI ad break started events
  • SsaiApi.reportAdBreakFinished() for reporting SSAI ad break finished events
  • SsaiApi.reportAdStarted() for reporting SSAI ad started events
  • SsaiApi.reportAdFinished() for reporting SSAI ad finished events
  • SsaiApi.reportAdSkipped() for reporting SSAI ad skipped events
  • SsaiApi.update(adInfo:) for updating the ad info

Notes

The example application has no way of testing this built-in.

Checklist

  • I added an update to CHANGELOG.md file
  • I ran all the tests in the project and they succeed

@rolandkakonyi rolandkakonyi self-assigned this Jul 2, 2024
Comment on lines 788 to 790
let mergedAdInfo = contentMetadataBuilder
.build()
.merging(adInfo) { $1 }
Copy link
Contributor Author

@rolandkakonyi rolandkakonyi Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBD if we want to carry over the already collected metadata.
On iOS this was needed to fix missing player name and viewer ID errors, despite the documentation stating those would be auto-collected from the videoAnalytics instance (they are not in practice).

This will take adInfo with priority over content metadata when values exist for both.

@@ -76,9 +76,15 @@ class CISAdAnalyticsTestDouble: NSObject, CISAdAnalyticsProtocol, TestDoubleData
}

func reportAdMetric(_ key: String, value: Any) {
let valueToTrack: String
if let size = value as? CGSize {
valueToTrack = "\(size.width)x\(size.height)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a workaround for testing as printing a CGSize value can have 2 different formats somehow.

spyResult = spyTracker.hasCalledFunction(functionName, withArgs: expectedArgs)
argsAreMatching = spyResult.success

let messageString = """
have called <\(functionName)> with args<\(expectedArgs)> \
have called <\(functionName)> \
with args<\(expectedArgs.toStringWithStableOrder())> \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small little fix to print expected values ordered

Comment on lines +396 to +397
CIS_SSDK_METADATA_VIEWER_ID,
CIS_SSDK_METADATA_PLAYER_NAME,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two are listed in the Conviva documentation as "autocollected" from the main video session but during testing they were showing up as error due to missing values in the ad session, therefore we decided to explicitly set these for the ad info.

@rolandkakonyi rolandkakonyi marked this pull request as ready for review July 3, 2024 14:04
Copy link
Contributor

@strangesource strangesource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my limited knowledge of the language, this looks very good. 👍

Just some minor comments/questions from my side.

@@ -343,6 +384,23 @@ public final class ConvivaAnalytics: NSObject {
buildDynamicContentMetadata()
}

private func buildAdMetadata() -> [String: Any] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Should have some indication in the name that this is for server-side ads.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, renamed in 54d8d54

Comment on lines 42 to 44
/// Reports the start of a server-side ad.
///
/// - Parameter adInfo: Object containing metadata about the server-side ad.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Could use some documentation that there needs to be an active ad break first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, fixed in 2e0c820

@@ -343,6 +384,23 @@ public final class ConvivaAnalytics: NSObject {
buildDynamicContentMetadata()
}

private func buildAdMetadata() -> [String: Any] {
let includedTags: Set<String> = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't carry over the asset name yet. Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is a mistake, I missed that one. Fixed in 6fbe0f6

@rolandkakonyi
Copy link
Contributor Author

@strangesource FYI I just added an SSAI README section and aligned the CHANGELOG entry in 4b92076

Copy link
Contributor

@strangesource strangesource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. 🎉

Copy link
Contributor

@matamegger matamegger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@rolandkakonyi rolandkakonyi merged commit ae15fe5 into develop Jul 4, 2024
3 checks passed
@rolandkakonyi rolandkakonyi deleted the feature/SSAI-tracking-API branch July 4, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants