Skip to content

Commit

Permalink
adds manual gpid to prebid ad unit
Browse files Browse the repository at this point in the history
  • Loading branch information
dskamiotis committed Nov 8, 2024
1 parent 75f985d commit 60d74a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/header-bidding/prebid-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type HeaderBiddingSizeKey =
export type HeaderBiddingSlot = {
key: HeaderBiddingSizeKey;
sizes: HeaderBiddingSize[];
name: string;
};

export type HeaderBiddingSizeMapping = Record<
Expand Down
18 changes: 18 additions & 0 deletions src/lib/header-bidding/prebid/prebid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class PrebidAdUnit {
code: string | null | undefined;
bids: PrebidBid[] | null | undefined;
mediaTypes: PrebidMediaTypes | null | undefined;
gpid: string;

constructor(
advert: Advert,
Expand All @@ -172,13 +173,30 @@ class PrebidAdUnit {
this.code = advert.id;
this.bids = bids(advert.id, slot.sizes, pageTargeting);
this.mediaTypes = { banner: { sizes: slot.sizes } };
this.gpid = this.generateGpid(advert, slot, pageTargeting);
advert.headerBiddingSizes = slot.sizes;
log('commercial', `PrebidAdUnit ${this.code}`, this.bids);
}

isEmpty() {
return this.code == null;
}
private generateGpid(
advert: Advert,
slot: HeaderBiddingSlot,
pageTargeting: PageTargeting,
): string {
const sectionName = Array.isArray(pageTargeting.sectionName)
? pageTargeting.sectionName.join(',')
: pageTargeting.sectionName;
const contentType = Array.isArray(pageTargeting.contentType)
? pageTargeting.contentType.join(',')
: pageTargeting.contentType;
const slotName = Array.isArray(slot.name)
? slot.name.join(',')
: slot.name;
return `/59666047/gu/${sectionName}/${contentType}/${slotName}`;
}
}

declare global {
Expand Down

0 comments on commit 60d74a3

Please sign in to comment.