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

New Analytics Adapter: agma #3400

Merged
merged 10 commits into from
Mar 12, 2024
Merged

Conversation

steffenmllr
Copy link
Contributor

Following up on #3299 (comment), this is a refactored version of the HTTP analytics PR, scoped to the data used by agma.

As requested by @bretg, I've limited the data collection to our GVLID and Propose 7.

Since I'm not entirely familiar with the entire codebase, I have some questions regarding whether there is a better way to do things:

  • I'm parsing the consent in the userExt, as this was the only place I found the user consent in my environment. Is this the correct approach, or is the consent also available in the OpenRTB user object?
  • Does this require more publicly available documentation than the provided README ?

Thank you for your review.

@bretg
Copy link
Contributor

bretg commented Jan 16, 2024

limited the data collection to our GVLID and Propose 7.

For the record, it's ok to have a host configuration that allows the host company to decide to skip the Purpose 7 check.

@steffenmllr
Copy link
Contributor Author

Thanks for reviewing this, @bsardo. Could you give me a rough estimate of when you will have time for this?

analytics/agma/model.go Outdated Show resolved Hide resolved
@steffenmllr
Copy link
Contributor Author

@SyntaxNode - Is there anything else you want me to change?

@steffenmllr
Copy link
Contributor Author

@bsardo // @AlexBVolcy // @bretg - Could you please provide me with an estimate of when this can be merged?

@bsardo
Copy link
Contributor

bsardo commented Feb 21, 2024

@steffenmllr I apologize for not responding as I didn't realize you kept pinging me. I was holding off on this because I wanted to get the TCF purpose 7 logic into PBS core first. I created a PR for it last year but hadn't had a chance to revisit it. I'll try to get to this and put up my purpose 7 PR this week.

@steffenmllr
Copy link
Contributor Author

@bsardo - thanks for the info!

You are taking about this? #2823. This would remove the need for me to manually check the consent like this: https://github.com/prebid/prebid-server/pull/3400/files#diff-f65aea57707f44f34323f70c397368ab5e22e7f2cb6273e1d6f1fc750c382d1eR165-R183

If there is anything I can do or help/review, please let me know!

@steffenmllr
Copy link
Contributor Author

@bsardo - I apologize if I seem overly persistent; I was wondering if there might be any updates you could share regarding the current status?

If you give me a list of do's for #2823, I can take a look at it and try to push this forward. From my understanding, this ports the Java functionality, right?

Thank you very much for your time and consideration.

@steffenmllr
Copy link
Contributor Author

@bsardo, I also wanted to ask if it would be an option to review & merge this PR first and replace the purpose 7 handling when you have the time, since our adapter handles p7 by itself.

@steffenmllr
Copy link
Contributor Author

After a discussion with our privacy lawyer, we decided that in our case (aggregated market research) it's Purpose 9 that applies here rather than Purpose 7. I've updated the code to reflect this.

Would be great if you could review this, @bsardo - a lot of technology partners in Germany are waiting for this PR so they can start rolling it out.

@SyntaxNode SyntaxNode assigned hhhjort and unassigned bsardo Mar 4, 2024
Comment on lines 136 to 139
if err != nil {
l.reset()
l.mux.Unlock()
glog.Warning("[AgmaAnalytics] fail to close the json array")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to cover these error lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think l.buffer.Write can only fail if l.buffer is nil (which can not be the case) or the expanding of the buffer with the tryGrowByReslice on the buffer itself. Since we also don't check the l.buffer.Write I think would would like to remove this error check since it does reset on the buffer a couple lines down on error - what do you think

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's fine!

Comment on lines +145 to +149
if err != nil {
l.reset()
l.mux.Unlock()
glog.Warning("[AgmaAnalytics] fail to copy the buffer")
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to cover these error lines?

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 question. I believe this situation can only occur if the buffer is empty and does not reset. However, this would effectively test the buffer's Read functionality. Do you have a specific test case in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's okay to leave it uncovered.

}

if publisherId == "" && appSiteId == "" {
return false, ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you cover this line?

l.mux.Lock()

if l.eventCount == 0 || l.buffer.Len() == 0 {
l.mux.Unlock()
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if you can remove all of the Unlock calls, and instead utilize a defer l.mux.Unlock() instead to ensure it's calling when the function returns. What do you think?

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 was the initial design i had in the first Adapter, as per #3299 (comment) - which this PR is based of - I'm handling this explicitly

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there may be another solution to the issue:

defer {
    l.reset()
    l.mux.Unlock() }

This would prevent the reset and unlock becoming detached from each other. But in this case you don't want this pattern, as you have a path that doesn't call l.reset().

Comment on lines 186 to 197
if requestWrapper.Site != nil {
if requestWrapper.Site.Publisher != nil {
publisherId = requestWrapper.Site.Publisher.ID
}
appSiteId = requestWrapper.Site.ID
}
if requestWrapper.App != nil {
if requestWrapper.App.Publisher != nil {
publisherId = requestWrapper.App.Publisher.ID
}
appSiteId = requestWrapper.App.ID
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you extract this code that seems repetitive to its own function?

Comment on lines +78 to +82
if resp.StatusCode != http.StatusOK {
glog.Errorf("[agmaAnalytics] Wrong code received %d instead of %d", resp.StatusCode, http.StatusOK)
return fmt.Errorf("wrong code received %d instead of %d", resp.StatusCode, http.StatusOK)
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to cover/trigger these lines with tests.

@steffenmllr
Copy link
Contributor Author

steffenmllr commented Mar 4, 2024

@hhhjort // @AlexBVolcy - Thanks for review! If you need me to change anything else please let me know.

Test coverage is up to 84.5%

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

@steffenmllr
Copy link
Contributor Author

Thanks for the approval. Any chance this can make it in the next release?

@hhhjort hhhjort merged commit e78ffb4 into prebid:master Mar 12, 2024
3 checks passed
@bretg
Copy link
Contributor

bretg commented Mar 22, 2024

@steffenmllr - do you need this ported to PBS-Java?

@steffenmllr
Copy link
Contributor Author

@bretg yes it would be great to also have this in prebid java, we just wanted to focus on golang first. Would this be handled as the prebid bidders or should we add a PR ?

@bretg
Copy link
Contributor

bretg commented Mar 25, 2024

@steffenmllr - it will eventually get ported by the team, but we don't commit to a specific timeline. Depends on how busy we are with features and the size of the backlog.

If there's a specific date you need the port, you should consider doing it yourself. If you're flexible, then we'll get to it.

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

8 participants