Adgeneration: Rewrite adapter to match Prebid.js v1.6.6 spec - #11
Closed
ss-toshihide-tajima wants to merge 15 commits into
Closed
Adgeneration: Rewrite adapter to match Prebid.js v1.6.6 spec#11ss-toshihide-tajima wants to merge 15 commits into
ss-toshihide-tajima wants to merge 15 commits into
Conversation
Send ortb body as JSON POST to /adgen/prebid (was GET /adsv/v1 with URL params),
matching the current Prebid.js adgenerationBidAdapter implementation.
- Endpoint: GET /adsv/v1 -> POST /adgen/prebid (JSON body)
- Add Native mediaType support for app/site
- Read bid from results[0] (was response body root)
- Drop OS-based sdktype branching (fixed to sdktype=0)
- Drop idfa/advertising_id query params (consolidated into device.ifa)
- wrapNativeAdm: handle both {"native":{...}} and {assets:...} responses
- Add ADGBrowserMTag, location_params/upper_billboard handling
- Rewrite unit tests (10 tests pass)
- TestJsonSamples is t.Skip pending golden file rewrite
- Rewrite adgenerationtest/exemplary/ and supplemental/ to the new POST /adgen/prebid request shape (uri/body/headers/impIDs) - Update supplemental error cases to use expectedMakeBidsErrors - Enable TestJsonSamples (was t.Skip), now exercises full MakeRequests + MakeBids round-trip against the regenerated samples
- Bump adapterver 1.0.3 -> 1.6.6 so Prebid.js / Prebid Server send the
same ADG protocol version (sdkname still distinguishes the two)
- Native: append adResult.beaconurl to native.imptrackers in the AdM
JSON to match createNativeAd() in adgenerationBidAdapter.js, and
handle both {"native":{...}} and {assets:...} payload shapes
- ADGBrowserM: read marginTop from imp.ext.bidder.marginTop
(ExtImpAdgeneration.MarginTop) instead of hardcoding '0'; fall back
to '0' when unset, mirroring Prebid.js behavior
- Add bidder-params schema entry for marginTop
- Add unit tests covering the new ADGBrowserM marginTop wiring,
beaconurl appending, deduplication, and wrapped native input
- Regenerate golden file adapterver fields to 1.6.6
- Replace JS-style regex literal `/\r?\n/g` with Go-native `\r?\n` so vastxml line breaks are actually stripped before being interpolated into <script> string literals (APV and ADGBrowserM paths) - getCurrency() now mirrors Prebid.js getCurrencyType(): return "USD" iff request.Cur contains USD (case-insensitive), else "JPY". Drop the previous JPY-preferred / first-fallback behavior that could leak EUR/GBP downstream - MakeBids: resolve target imp from the body we sent (externalRequest.Body -> ortb.imp[0].id) instead of bidResp.locationid, matching Prebid.js' bidRequests.data.ortb.imp[0]; this also recovers bids when the backend omits locationid - buildAdMarkup: fall back to banner when adResult.native is present but assets[] is empty/missing, mirroring Prebid.js isNative() - Add regression tests: vastxml newline stripping (APV/ADGBrowserM), USD/JPY parity cases, and native-without-assets fallback
…ing to 0
Backend `/adgen/prebid` distinguishes web (0), Android app (1) and iOS
app (2) via the sdktype query. The previous PR hard-coded sdktype=0 to
match Prebid.js (CSHB), but Prebid Server is also called from Prebid
Mobile SDK / AMP / CTV where 0 is incorrect.
Detect the channel and pick the appropriate sdktype:
1. ext.prebid.channel.name == "app" -> mobile SDK request
2. Fallback: BidRequest.App != nil -> mobile SDK request
3. Otherwise -> web
When (1) or (2) applies, device.os ("android" / "ios", case-insensitive)
selects sdktype=1 or 2. Unknown OS falls back to 0.
- detectSdkType() encapsulates the rule, with tests covering web/amp
channels, app channel with android/ios casing, App-only fallback,
unknown OS, empty request, and broken ext.
- Golden files updated: single-banner-android.json -> sdktype=1,
single-banner-ios.json -> sdktype=2.
…e iOS compatibility Prebid Mobile iOS (PBMTransactionFactory) は adm に "<VAST" 文字列が含まれると HTML バナーを VAST クリエイティブと誤判定し VAST Parsing failed になる。 ADGBrowserM / APV ラッパーに埋め込む vastxml を percent-encoding し、 JS 側で decodeURIComponent して復元する形に変更 (機能は不変)。
ADGBrowserM / APV はブラウザ用 JS プレイヤーのため、Web (banner imp) 経路でのみ使用する。 Prebid Mobile の video ad unit (imp.video) に対しては VAST XML を生のまま video bid (ext.prebid.type=video) として返し、レンダリングは SDK 内蔵プレイヤーに任せる。 bidder-info の app capabilities に video を追加 (無いと PBS が imp.video を除去する)。
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…video" Prebid.js (adgenerationBidAdapter) は video 非対応 (supportedMediaTypes: BANNER, NATIVE) で、VAST 素材は banner として ADGBrowserM/APV でラップして 配信している。Prebid Server もこの方式に揃え、video mediaType は対応しない (全経路 banner 配信に統一)。 VAST percent-encode・APV/ADGBrowserM ラップ等の banner-in-video 処理は維持。 This reverts commit 5ffa175.
The backend /getuid endpoint work is scheduled for September or later, so the cookie-sync (userSync) definition is split out of this parity PR and tracked in its own PR instead.
… 97.6%
- Add exemplary/single-native.json covering the wrapped {"native":{...}}
backend response form (beaconurl appended to imptrackers, imark omitted
for native requests)
- Add supplemental/native-unwrapped-response.json covering the unwrapped
{assets:...} form
- Add unit tests for error branches (imp.ext validation, wrapNativeAdm,
MakeBids guards, 500/invalid-body responses)
- Remaining uncovered lines are json.Marshal / url.Parse defensive
branches, which upstream convention leaves untested
Comments and test case names only; no logic changes. Internal document references are replaced with self-contained explanations.
Follows the upstream builder-struct-name semgrep rule: the bidder identification is already supplied by the package name.
Collaborator
Author
|
この PR の最終形を単一コミットに整理した #13(upstream 提出候補・
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
adgenerationBidAdapterに仕様を合わせ、adgenerationアダプターを書き換えGET /adsv/v1(URL クエリ) からPOST /adgen/prebid(ortb JSON body) に変更主な変更
https://d.socdm.com/adsv/v1→https://d.socdm.com/adgen/prebidstatic/bidder-info/adgeneration.yamlの capability にnativeを追加 (app / site 両方)results[0]優先 (prebid.js 実装と一致)0固定 (prebid.js パリティ優先)device.ifaに集約wrapNativeAdmで{"native":{...}}と{assets:...}の両形式を吸収 (バックエンド応答形式未確定のため両対応)ADomain(旧adomain)、location_params/upper_billboard判定、ADGBrowserMTagを追加残作業
adapters/adgeneration/adgenerationtest/配下の JSON golden file (exemplary / supplemental) は旧 GET 形式のまま。TestJsonSamplesはt.Skipで退避中。POST + JSON body 形式への書き換えが別途必要d.socdm.com/adgen/prebid) がsdkname=prebidserverのリクエストを受けてresults[]形式で応答できるか要確認sdktype=0固定で app 配信のバックエンド処理に影響がないか要確認背景
adgenerationアダプターを Prebid.js 版と揃える施策projects/prebid-server/research/parity-concerns.md(社内資料)Test plan
go build ./...通過go test ./adapters/adgeneration/...通過 (10 件、TestJsonSamplesは Skip)TestJsonSamplesを有効化して通過確認/adgen/prebid仕様確認後、ステージングで疎通確認