Skip to content

Commit ec6a45d

Browse files
authored
Agma: Allow app.bundle to be used as selector for apps (#3780)
1 parent 8237f7f commit ec6a45d

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

analytics/agma/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ analytics:
1212
# Required: set the accounts you want to track
1313
accounts:
1414
- code: "my-code" # Required: provied by agma
15-
publisher_id: "123" # Required: Exchange specific publisher_id
16-
site_app_id: "openrtb2-site.id-or-app.id" # optional: scope to the publisher with an openrtb2 Site object id or App object id
15+
publisher_id: "123" # Required: Exchange specific publisher_id, can be an empty string accounts are not used
16+
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
1717
# Optional properties (advanced configuration)
1818
endpoint:
1919
url: "https://go.pbs.agma-analytics.de/v1/prebid-server" # Check with agma if your site needs an extra url

analytics/agma/agma_module.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ func (l *AgmaLogger) extractPublisherAndSite(requestWrapper *openrtb_ext.Request
169169
publisherId = requestWrapper.App.Publisher.ID
170170
}
171171
appSiteId = requestWrapper.App.ID
172+
if appSiteId == "" {
173+
appSiteId = requestWrapper.App.Bundle
174+
}
175+
172176
}
173177
return publisherId, appSiteId
174178
}

analytics/agma/agma_module_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ func TestShouldTrackEvent(t *testing.T) {
188188
PublisherId: "track-me",
189189
Code: "abc",
190190
},
191+
{
192+
PublisherId: "",
193+
SiteAppId: "track-me",
194+
Code: "abc",
195+
},
191196
},
192197
}
193198
mockedSender := new(MockedSender)
@@ -283,6 +288,36 @@ func TestShouldTrackEvent(t *testing.T) {
283288

284289
assert.False(t, shouldTrack)
285290
assert.Equal(t, "", code)
291+
292+
// should allow empty accounts
293+
shouldTrack, code = logger.shouldTrackEvent(&openrtb_ext.RequestWrapper{
294+
BidRequest: &openrtb2.BidRequest{
295+
App: &openrtb2.App{
296+
ID: "track-me",
297+
},
298+
User: &openrtb2.User{
299+
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
300+
},
301+
},
302+
})
303+
304+
assert.True(t, shouldTrack)
305+
assert.Equal(t, "abc", code)
306+
307+
// Bundle ID instead of app.id
308+
shouldTrack, code = logger.shouldTrackEvent(&openrtb_ext.RequestWrapper{
309+
BidRequest: &openrtb2.BidRequest{
310+
App: &openrtb2.App{
311+
Bundle: "track-me",
312+
},
313+
User: &openrtb2.User{
314+
Ext: json.RawMessage(`{"consent": "` + agmaConsent + `"}`),
315+
},
316+
},
317+
})
318+
319+
assert.True(t, shouldTrack)
320+
assert.Equal(t, "abc", code)
286321
}
287322

288323
func TestShouldTrackMultipleAccounts(t *testing.T) {

0 commit comments

Comments
 (0)