Skip to content

Commit

Permalink
Allow app.bundle to be used as a account app_id
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenmllr committed Jun 28, 2024
1 parent 07f3ee2 commit 70c0707
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 2 additions & 2 deletions analytics/agma/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ analytics:
# Required: set the accounts you want to track
accounts:
- code: "my-code" # Required: provied by agma
publisher_id: "123" # Required: Exchange specific publisher_id
site_app_id: "openrtb2-site.id-or-app.id" # optional: scope to the publisher with an openrtb2 Site object id or App object id
publisher_id: "123" # Required: Exchange specific publisher_id, can be an empty string accounts are not used
site_app_id: "openrtb2-site.id-or-app.id-or-app.bundle" # optional: scope to the publisher with an openrtb2 Site object id or App object id/bundle
# Optional properties (advanced configuration)
endpoint:
url: "https://go.pbs.agma-analytics.de/v1/prebid-server" # Check with agma if your site needs an extra url
Expand Down
4 changes: 4 additions & 0 deletions analytics/agma/agma_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ func (l *AgmaLogger) extractPublisherAndSite(requestWrapper *openrtb_ext.Request
publisherId = requestWrapper.App.Publisher.ID
}
appSiteId = requestWrapper.App.ID
if appSiteId == "" {
appSiteId = requestWrapper.App.Bundle
}

}
return publisherId, appSiteId
}
Expand Down
35 changes: 35 additions & 0 deletions analytics/agma/agma_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ func TestShouldTrackEvent(t *testing.T) {
PublisherId: "track-me",
Code: "abc",
},
{
PublisherId: "",
SiteAppId: "track-me",
Code: "abc",
},
},
}
mockedSender := new(MockedSender)
Expand Down Expand Up @@ -283,6 +288,36 @@ func TestShouldTrackEvent(t *testing.T) {

assert.False(t, shouldTrack)
assert.Equal(t, "", code)

// should allow empty accounts
shouldTrack, code = logger.shouldTrackEvent(&openrtb_ext.RequestWrapper{
BidRequest: &openrtb2.BidRequest{
App: &openrtb2.App{
ID: "track-me",
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
},
},
})

assert.True(t, shouldTrack)
assert.Equal(t, "abc", code)

// Bundle ID instead of app.id
shouldTrack, code = logger.shouldTrackEvent(&openrtb_ext.RequestWrapper{
BidRequest: &openrtb2.BidRequest{
App: &openrtb2.App{
Bundle: "track-me",
},
User: &openrtb2.User{
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
},
},
})

assert.True(t, shouldTrack)
assert.Equal(t, "abc", code)
}

func TestShouldTrackMultipleAccounts(t *testing.T) {
Expand Down

0 comments on commit 70c0707

Please sign in to comment.