Skip to content

GumGum: Collect the ad unit name for reporting #3912

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

ShayanK16GumGum
Copy link

@ShayanK16GumGum ShayanK16GumGum commented Apr 16, 2025

🔧 Type of changes

  • new bid adapter
  • bid adapter update
  • new feature
  • new analytics adapter
  • new module
  • module update
  • bugfix
  • documentation
  • configuration
  • dependency update
  • tech debt (test coverage, refactorings, etc.)

✨ What's the context?

What's the context for the changes?

🧠 Rationale behind the change

Why did you choose to make these changes? Were there any trade-offs you had to consider?

🔎 New Bid Adapter Checklist

  • verify email contact works
  • NO fully dynamic hostnames
  • geographic host parameters are NOT required
  • direct use of HTTP is prohibited - implement an existing Bidder interface that will do all the job
  • if the ORTB is just forwarded to the endpoint, use the generic adapter - define the new adapter as the alias of the generic adapter
  • cover an adapter configuration with an integration test

🧪 Test plan

How do you know the changes are safe to ship to production?

🏎 Quality check

  • Are your changes following our code style guidelines?
  • Are there any breaking changes in your code?
  • Does your test coverage exceed 90%?
  • Are there any erroneous console logs, debuggers or leftover code in your changes?

@osulzhenko osulzhenko requested a review from CTMBNara April 22, 2025 09:45
@CTMBNara CTMBNara changed the title GumGum: Update Prebid Server Adapter (Java) to collect the ad unit name for reporting. GumGum: Collect the ad unit name for reporting Apr 23, 2025
@ShayanK16GumGum
Copy link
Author

Thank you for the review, I am looking into the comments.

@osulzhenko
Copy link
Collaborator

@ShayanK16GumGum any updates on this one?

@ShayanK16GumGum
Copy link
Author

The code changes are done, will push. @osulzhenko

@osulzhenko osulzhenko requested a review from CTMBNara May 12, 2025 08:27
@osulzhenko
Copy link
Collaborator

@ShayanK16GumGum

[INFO] Starting audit...
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:85:16: Variable 'requestBody' should be declared final. [FinalLocalVariable]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:86:20: Variable 'modifiedRequest' should be declared final. [FinalLocalVariable]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:94:17: There is more than 1 empty line after this line. [EmptyLineSeparator]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:100:20: Variable 'extImp' should be declared final. [FinalLocalVariable]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:103:13: Variable 'imp' should be declared final. [FinalLocalVariable]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:109:20: Variable 'bidRequest' should be declared final. [FinalLocalVariable]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:116:47: Variable 'result' should be declared final. [FinalLocalVariable]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:123:16: Variable 'requestBody' should be declared final. [FinalLocalVariable]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:124:20: Variable 'modifiedRequest' should be declared final. [FinalLocalVariable]
Error:  /home/runner/work/prebid-server-java/prebid-server-java/src/test/java/org/prebid/server/bidder/gumgum/GumgumBidderTest.java:128:13: Variable 'modifiedImp' should be declared final. [FinalLocalVariable]
Audit done.

@ShayanK16GumGum
Copy link
Author

@osulzhenko looking into it and fixing.

@osulzhenko
Copy link
Collaborator

@ShayanK16GumGum any updates on this one?

@ShayanK16GumGum
Copy link
Author

@osulzhenko I have pushed the changes. Please have a look.
Screenshot 2025-06-02 at 11 32 47 AM

Comment on lines +118 to +126
private String extractAdUnitCode(Imp imp) {
final ExtPrebid<?, ExtImpGumgum> extPrebid = mapper.mapper()
.convertValue(imp.getExt(), GUMGUM_EXT_TYPE_REFERENCE);

return Optional.ofNullable(extPrebid.getPrebid())
.map(prebid -> mapper.mapper().convertValue(prebid, ExtImpPrebid.class))
.map(ExtImpPrebid::getAdUnitCode)
.orElse(null);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of this method, use the following approach:

    private static final TypeReference<ExtPrebid<ExtImpPrebid, ExtImpGumgum>> GUMGUM_EXT_TYPE_REFERENCE =
            new TypeReference<>() {
            };
    private ExtPrebid<ExtImpPrebid, ExtImpGumgum> parseImpExt(Imp imp) {
        try {
            return mapper.mapper().convertValue(imp.getExt(), GUMGUM_EXT_TYPE_REFERENCE);
        } catch (IllegalArgumentException e) {
            throw new PreBidException(e.getMessage());
        }
    }
                final ExtPrebid<ExtImpPrebid, ExtImpGumgum> extImp = parseImpExt(imp);
                final ExtImpGumgum extImpGumgum = extImp.getBidder();
                final String adUnitCode = Optional.ofNullable(extImp.getPrebid())
                        .map(ExtImpPrebid::getAdUnitCode)
                        .orElse(null);

                modifiedImps.add(modifyImp(imp, extImpGumgum, adUnitCode));

                final String extZone = extImpGumgum.getZone();
                if (StringUtils.isNotEmpty(extZone)) {
                    zone = extZone;
                }

                final BigInteger extPubId = extImpGumgum.getPubId();
                if (extPubId != null && !extPubId.equals(BigInteger.ZERO)) {
                    pubId = extPubId;
                }


@Test
public void testMakeHttpRequestsShouldNotSetTagIdFromZoneWhenAdUnitIdIsMissing() throws IOException {
//given:Imp without adUnitId but with zone
Copy link
Collaborator

Choose a reason for hiding this comment

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

No explanation needed. The method name already does that. Just leave // given

Comment on lines +56 to +63
//given
final BidRequest bidRequest = givenBidRequest(impBuilder ->
impBuilder.ext(mapper.valueToTree(ExtPrebid.of(null, mapper.createArrayNode()))));

//when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

//then
Copy link
Collaborator

Choose a reason for hiding this comment

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

// given // when // then and fix it in other places

//when
final Result<List<HttpRequest<BidRequest>>> result = target.makeHttpRequests(bidRequest);

//deserialize byte[] body into BidRequest
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for this comment

Comment on lines +85 to +92
final byte[] requestBody = result.getValue().get(0).getBody();
final BidRequest modifiedRequest = mapper.readValue(requestBody, BidRequest.class);

//then
assertThat(modifiedRequest.getImp()).hasSize(1);
assertThat(modifiedRequest.getImp())
.extracting(Imp::getTagid)
.containsExactly("adUnit123");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Refactor other tests in the same style:

        assertThat(result.getValue())
                .extracting(HttpRequest::getPayload)
                .flatExtracting(BidRequest::getImp)
                .extracting(Imp::getTagid)
                .containsExactly("adUnit123");

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