From f3e8242f7bca4bc1f48e3cdb53059c2f981b7a62 Mon Sep 17 00:00:00 2001 From: ss-toshihide-tajima Date: Thu, 28 Aug 2025 17:48:49 +0900 Subject: [PATCH 1/3] fix currency --- modules/adgenerationBidAdapter.js | 7 +- .../modules/adgenerationBidAdapter_spec.js | 126 +++++++++++++++++- 2 files changed, 127 insertions(+), 6 deletions(-) diff --git a/modules/adgenerationBidAdapter.js b/modules/adgenerationBidAdapter.js index 69a70f2d329..d3b42cf14eb 100644 --- a/modules/adgenerationBidAdapter.js +++ b/modules/adgenerationBidAdapter.js @@ -16,7 +16,7 @@ const adgLogger = prefixLog('Adgeneration: '); */ const ADG_BIDDER_CODE = 'adgeneration'; -const ADGENE_PREBID_VERSION = '1.6.4'; +const ADGENE_PREBID_VERSION = '1.6.5'; const DEBUG_URL = 'https://api-test.scaleout.jp/adgen/prebid'; const URL = 'https://d.socdm.com/adgen/prebid'; @@ -139,7 +139,8 @@ export const spec = { const adResult = body?.results[0]; const targetImp = bidRequests?.data?.ortb?.imp[0]; const requestId = targetImp?.id; - + + const bidResponse = { requestId: requestId, cpm: adResult.cpm || 0, @@ -147,7 +148,7 @@ export const spec = { height: adResult.h ? adResult.h : 1, creativeId: adResult.creativeid || '', dealId: adResult.dealid || '', - currency: getCurrencyType(bidRequests.bidderRequest), + currency: bidRequests?.data?.currency || 'JPY', netRevenue: true, ttl: adResult.ttl || 10, }; diff --git a/test/spec/modules/adgenerationBidAdapter_spec.js b/test/spec/modules/adgenerationBidAdapter_spec.js index 3a891ad5efd..830053273e4 100644 --- a/test/spec/modules/adgenerationBidAdapter_spec.js +++ b/test/spec/modules/adgenerationBidAdapter_spec.js @@ -8,7 +8,7 @@ import { addFPDToBidderRequest } from '../../helpers/fpd.js'; describe('AdgenerationAdapter', function () { const adapter = newBidder(spec); - const ADGENE_PREBID_VERSION = '1.6.4'; + const ADGENE_PREBID_VERSION = '1.6.5'; const ENDPOINT_STG = 'https://api-test.scaleout.jp/adgen/prebid'; const ENDPOINT_RELEASE = 'https://d.socdm.com/adgen/prebid'; @@ -791,7 +791,7 @@ describe('AdgenerationAdapter', function () { method: 'POST', url: 'https://api-test.scaleout.jp/adgen/prebid?id=15410&posall=SSPLOC&sdktype=0', data: { - 'currency': 'JPY', + 'currency': 'USD', 'pbver': prebid.version, 'sdkname': 'prebidjs', 'adapterver': ADGENE_PREBID_VERSION, @@ -1235,7 +1235,10 @@ describe('AdgenerationAdapter', function () { } }; return addFPDToBidderRequest(bidderRequest).then(res => { - const result = spec.interpretResponse({body: serverResponse.normal.upperBillboard}, { ...bidRequests.upperBillboard, bidderRequest: res })[0]; + const sr = {body: serverResponse.normal.upperBillboard}; + const br = { bidderRequest: res, ...bidRequests.upperBillboard }; + + const result = spec.interpretResponse(sr, br)[0]; expect(result.requestId).to.equal(bidResponses.normal.upperBillboard.requestId); expect(result.width).to.equal(bidResponses.normal.upperBillboard.width); expect(result.height).to.equal(bidResponses.normal.upperBillboard.height); @@ -1340,5 +1343,122 @@ describe('AdgenerationAdapter', function () { expect(result).to.not.have.any.keys('meta'); expect(result).to.not.have.any.keys('advertiserDomains'); }); + + describe('currency handling', function () { + const bidRequest = { + method: 'POST', + url: 'https://d.socdm.com/adgen/prebid', + data: { + currency: 'USD', + pbver: prebid.version, + sdkname: 'prebidjs', + adapterver: ADGENE_PREBID_VERSION, + ortb: { + imp: [{ + id: 'test-imp-id', + ext: { + params: { id: '58278' }, + mediaTypes: { banner: { sizes: [[300, 250]] } } + } + }] + } + } + }; + + it('uses currency from data when available', function () { + const serverResponse = { + body: { + results: [{ + cpm: 100, + w: 300, + h: 250, + creativeid: 'test-creative-id', + dealid: 'test-deal-id', + ad: '
Test Ad
' + }] + } + }; + + const result = spec.interpretResponse(serverResponse, bidRequest)[0]; + expect(result.currency).to.equal('USD'); + expect(result.cpm).to.equal(100); + }); + + it('defaults to JPY when no currency information available', function () { + const requestWithoutCurrency = { + method: 'POST', + url: 'https://d.socdm.com/adgen/prebid', + data: { + pbver: prebid.version, + sdkname: 'prebidjs', + adapterver: ADGENE_PREBID_VERSION, + ortb: { + imp: [{ + id: 'test-imp-id', + ext: { + params: { id: '58278' }, + mediaTypes: { banner: { sizes: [[300, 250]] } } + } + }] + } + } + }; + + const serverResponse = { + body: { + results: [{ + cpm: 300, + w: 300, + h: 250, + creativeid: 'test-creative-id', + dealid: 'test-deal-id', + ad: '
Test Ad
' + }] + } + }; + + const result = spec.interpretResponse(serverResponse, requestWithoutCurrency)[0]; + expect(result.currency).to.equal('JPY'); + }); + + it('handles currency correctly with getCurrencyType function logic', function () { + // Test the current implementation which uses bidRequests?.data?.currency || 'JPY' + const bidRequestWithJPY = { + method: 'POST', + url: 'https://d.socdm.com/adgen/prebid', + data: { + currency: 'JPY', + pbver: prebid.version, + sdkname: 'prebidjs', + adapterver: ADGENE_PREBID_VERSION, + ortb: { + imp: [{ + id: 'test-imp-id', + ext: { + params: { id: '58278' }, + mediaTypes: { banner: { sizes: [[300, 250]] } } + } + }] + } + } + }; + + const serverResponse = { + body: { + results: [{ + cpm: 150, + w: 300, + h: 250, + creativeid: 'test-creative-id', + dealid: 'test-deal-id', + ad: '
Test Ad
' + }] + } + }; + + const result = spec.interpretResponse(serverResponse, bidRequestWithJPY)[0]; + expect(result.currency).to.equal('JPY'); + }); + }); }); }); From 0d2dd3befea9495feb4a24e9179a659b2fee14c7 Mon Sep 17 00:00:00 2001 From: ss-toshihide-tajima Date: Fri, 29 Aug 2025 11:17:55 +0900 Subject: [PATCH 2/3] Exclusion of unused processing --- modules/adgenerationBidAdapter.js | 8 --- .../modules/adgenerationBidAdapter_spec.js | 49 ++----------------- 2 files changed, 3 insertions(+), 54 deletions(-) diff --git a/modules/adgenerationBidAdapter.js b/modules/adgenerationBidAdapter.js index d3b42cf14eb..a21f2af47b2 100644 --- a/modules/adgenerationBidAdapter.js +++ b/modules/adgenerationBidAdapter.js @@ -30,7 +30,6 @@ const converter = ortbConverter({ const imp = buildImp(bidRequest, context); deepSetValue(imp, 'ext.params', bidRequest.params); deepSetValue(imp, 'ext.mediaTypes', bidRequest.mediaTypes); - deepSetValue(imp, 'ext.novatiqSyncResponse', bidRequest?.userId?.novatiq?.snowflake?.syncResponse); return imp; }, request(buildRequest, imps, bidderRequest, context) { @@ -70,13 +69,6 @@ export const spec = { const id = getBidIdParameter('id', customParams); const additionalParams = JSON.parse(JSON.stringify(rest)); - // hyperIDが有効ではない場合、パラメータから削除する - if (!impObj?.ext?.novatiqSyncResponse || impObj?.ext?.novatiqSyncResponse !== 1) { - if (additionalParams?.user?.ext?.eids && Array.isArray(additionalParams?.user?.ext?.eids)) { - additionalParams.user.ext.eids = additionalParams?.user?.ext?.eids.filter((eid) => eid?.source !== 'novatiq.com'); - } - } - let urlParams = ``; urlParams = tryAppendQueryString(urlParams, 'id', id); urlParams = tryAppendQueryString(urlParams, 'posall', 'SSPLOC');// not reaquired diff --git a/test/spec/modules/adgenerationBidAdapter_spec.js b/test/spec/modules/adgenerationBidAdapter_spec.js index 830053273e4..594318c3d69 100644 --- a/test/spec/modules/adgenerationBidAdapter_spec.js +++ b/test/spec/modules/adgenerationBidAdapter_spec.js @@ -117,23 +117,6 @@ describe('AdgenerationAdapter', function () { auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a' }, - { // bannerWithHyperId - bidder: 'adg', - params: { - id: '58278', // banner - }, - adUnitCode: 'adunit-code', - sizes: [[320, 100]], - bidId: '2f6ac468a9c15e', - bidderRequestId: '14a9f773e30243', - auctionId: '4aae9f05-18c6-4fcd-80cf-282708cd584a', - transactionTd: 'f76f6dfd-d64f-4645-a29f-682bac7f431a', - userId: { - novatiq: { - snowflake: {'id': 'novatiqId', syncResponse: 1} - } - } - }, { // bannerWithAdgextCriteoId bidder: 'adg', params: { @@ -296,34 +279,10 @@ describe('AdgenerationAdapter', function () { expect(request.data.sdkname).to.equal('prebidjs'); expect(request.data.adapterver).to.equal(ADGENE_PREBID_VERSION); expect(request.data.ortb.imp[0].id).to.equal('2f6ac468a9c15e'); - expect(request.data.ortb.imp[0].ext.novatiqSyncResponse).to.equal(undefined); expect(request.data.ortb.imp[0].ext.params.id).to.equal('58278'); expect(request.data.ortb.imp[0].ext.mediaTypes).to.deep.equal(expectedMediaTypes); }); - it('should attache params to the bannerWithHyperId request', function () { - const hyperIdParams = { - user: { - ext: { - eids: [ - { - source: 'novatiq.com', - uids: [ - { - 'id': 'xxxxxx' - } - ] - }, - ] - } - } - } - const request = spec.buildRequests(bidRequests, {...bidderRequest, ortb2: hyperIdParams})[2]; - - expect(request.data.ortb.imp[0].ext.novatiqSyncResponse).to.equal(1); - expect(request.data.ortb.user).to.deep.equal(hyperIdParams.user); - }); - it('should attache params to the bannerWithAdgextCriteoId request', function () { const criteoParams = { user: { @@ -395,7 +354,7 @@ describe('AdgenerationAdapter', function () { } }, } - const request = spec.buildRequests(bidRequests, {...bidderRequest, ortb2: idparams})[4]; + const request = spec.buildRequests(bidRequests, {...bidderRequest, ortb2: idparams})[3]; expect(request.data.ortb.user).to.deep.equal(idparams.user); // gpid @@ -668,8 +627,7 @@ describe('AdgenerationAdapter', function () { 'sendId': false } } - }, - 'novatiqSyncResponse': 2 + } }, 'id': '2f6ac468a9c15e', 'native': { @@ -833,8 +791,7 @@ describe('AdgenerationAdapter', function () { ] ] } - }, - 'novatiqSyncResponse': 2 + } }, 'id': '2f6ac468a9c15e', 'banner': { From eab6d3fdc1151c605a612ce26a009b3d5d5e80f8 Mon Sep 17 00:00:00 2001 From: ss-toshihide-tajima Date: Thu, 4 Sep 2025 11:34:52 +0900 Subject: [PATCH 3/3] style: fix linting errors in adgenerationBidAdapter.js, adgenerationBidAdapter_spec.js Remove trailing spaces and unnecessary blank lines --- modules/adgenerationBidAdapter.js | 3 +-- test/spec/modules/adgenerationBidAdapter_spec.js | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/adgenerationBidAdapter.js b/modules/adgenerationBidAdapter.js index a21f2af47b2..4c36c60dbda 100644 --- a/modules/adgenerationBidAdapter.js +++ b/modules/adgenerationBidAdapter.js @@ -131,8 +131,7 @@ export const spec = { const adResult = body?.results[0]; const targetImp = bidRequests?.data?.ortb?.imp[0]; const requestId = targetImp?.id; - - + const bidResponse = { requestId: requestId, cpm: adResult.cpm || 0, diff --git a/test/spec/modules/adgenerationBidAdapter_spec.js b/test/spec/modules/adgenerationBidAdapter_spec.js index 594318c3d69..8a542ba2966 100644 --- a/test/spec/modules/adgenerationBidAdapter_spec.js +++ b/test/spec/modules/adgenerationBidAdapter_spec.js @@ -1193,7 +1193,7 @@ describe('AdgenerationAdapter', function () { }; return addFPDToBidderRequest(bidderRequest).then(res => { const sr = {body: serverResponse.normal.upperBillboard}; - const br = { bidderRequest: res, ...bidRequests.upperBillboard }; + const br = { bidderRequest: res, ...bidRequests.upperBillboard }; const result = spec.interpretResponse(sr, br)[0]; expect(result.requestId).to.equal(bidResponses.normal.upperBillboard.requestId); @@ -1335,7 +1335,7 @@ describe('AdgenerationAdapter', function () { }] } }; - + const result = spec.interpretResponse(serverResponse, bidRequest)[0]; expect(result.currency).to.equal('USD'); expect(result.cpm).to.equal(100); @@ -1373,7 +1373,7 @@ describe('AdgenerationAdapter', function () { }] } }; - + const result = spec.interpretResponse(serverResponse, requestWithoutCurrency)[0]; expect(result.currency).to.equal('JPY'); }); @@ -1412,7 +1412,7 @@ describe('AdgenerationAdapter', function () { }] } }; - + const result = spec.interpretResponse(serverResponse, bidRequestWithJPY)[0]; expect(result.currency).to.equal('JPY'); });