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

Add Ext.Prebid.Analytics Support #3563

Merged
merged 15 commits into from
Mar 26, 2024

Conversation

AlexBVolcy
Copy link
Contributor

@AlexBVolcy AlexBVolcy commented Mar 5, 2024

Addresses this issue: #1800

The goal of this PR is to add a new object on the request: bidrequest.ext.prebid.analytics and pass this object to analytics adapters.

The object that will live at this path will be ExtPrebidAnalytics: {name_of_analytics_adapter: {client-analytics: bool}}

Before the object is made available to the analytics adapters through the various LogObject functions in build.go, PBS-Go will loop over the new analytics object on the request, and before logging for a specific analytics adapter, we'll update the request that's being logged to only include the analytics information for that specific adapter.

analytics/build/build.go Outdated Show resolved Hide resolved
// Given analytics adapter module is not present in ext.prebid.analytics, remove the entire analytics object from request for logging
if _, ok := extPrebidAnalytics[adapterName]; !ok {
reqExtPrebid.Analytics = nil
reqExt.SetPrebid(reqExtPrebid)
Copy link
Collaborator

Choose a reason for hiding this comment

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

At this point, we will be modifying the original request wrapper sent in to LogAuctionObject() at the top of this file unless evaluateActivities() found something it needed to change and thus has already cloned the request wrapper. You probably need to record a isCloned flag and pass it down here, so you can know if you need to clone the request wrapper before modifying the Analytics object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My latest commits should address this, and I added tests that should've caught this issue initially!

openrtb_ext/request.go Outdated Show resolved Hide resolved
}

func TestLogAnalyticsObjectExtRequestPrebidAnalytics(t *testing.T) {
func (m *secondMockAnalytics) LogVideoObject(vo *analytics.VideoObject) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you have two independent struct types rather than one type with two independent instances?

Copy link
Collaborator

@hhhjort hhhjort left a comment

Choose a reason for hiding this comment

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

LGTM

@hhhjort hhhjort merged commit 25a4466 into prebid:master Mar 26, 2024
3 checks passed
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.

None yet

3 participants