Skip to content
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

Core: Local cache for video bids #12598

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

Conversation

mkomorski
Copy link
Collaborator

Type of change

  • Feature

Description of change

Other information

vastsLocalCache.set(getLocalCacheBidId(bid), dataUri);
};

export async function getLocalCachedBidWithGam(adTagUrl) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be in the dfp module.

IMO the GAM flow in general needs to change, instead of calling dfp's buildVideoUrl and passing the URL to the player it should be something like getVast and pass the XML to the player, which should work regardless of whether one is using local cache, and should also be the same thing that's called by the video module (regardless of the type of cache in use).

It might help to update / add a non-video module example to flesh out how the new API should look.


const gamVastWrapper = await response.text();
const bidVastDataUri = vastsLocalCache.get(`${hb_bidder}_${hb_adid}`);
const mockUrl = LOCAL_CACHE_MOCK_URL + hb_bidder;
Copy link
Collaborator

Choose a reason for hiding this comment

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

the "normal" cache generates a UUID which is then passed on to the creative and echoed back in the VAST.

I think the local cache could also generate a UUID, pass it along in the same way, and this could look for it in the response contents instead of imposing a different URL structure in the creative. It'd have the advantage of working with existing integrations, and being easier to switch into / out of.

@mkomorski mkomorski marked this pull request as ready for review January 9, 2025 23:36
Copy link

Tread carefully! This PR adds 1 linter error (possibly disabled through directives):

  • modules/dfpAdServerVideo.js (+1 error)

@pm-azhar-mulla
Copy link
Contributor

We also need to update the functionality that triggers the BID_WON event, particularly for instream video scenarios handled within the instreamTracking module.

export async function getBidVastWithGam(adTagUrl, cacheMap = vastsLocalCache) {
const gamAdTagUrl = new URL(adTagUrl);
const custParams = new URLSearchParams(gamAdTagUrl.searchParams.get('cust_params'));
const videoCacheKey = custParams.get('hb_uuid');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Id prefer not doing the URL parsing, since it couples this to the URL structure which is also tied to the ad server. Since the local cache generates the UUIDs, it seems like the response parser could look for them without first checking the URL.

@@ -201,13 +201,17 @@ export function VideojsProvider(providerConfig, vjs_, adState_, timeState_, call

// Plugins to integrate: https://github.com/googleads/videojs-ima
function setAdTagUrl(adTagUrl, options) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It'd be cleaner if we had a separate setAdXml rather than a setAdTagUrl that doesn't actually set the ad tag url. (same with jwplayer)

@@ -162,6 +175,20 @@ export function getCacheUrl(id) {
return `${config.getConfig('cache.url')}?uuid=${id}`;
}

export const storeLocally = (bid) => {
const vastValue = getVastXml(bid);
const strategy = config.getConfig('cache.strategy') || BLOB;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why expose these / make them mutually exclusive? I'd always generate a blob and translate it to a string only if/when we need to. It's less for the pub to understand and it also allows using different players with the same bid.

Comment on lines +186 to +187
bid.vastUrl = bidVastUrl;
bid.videoCacheKey = generateUUID();
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be shared with the "normal" cache flow - so that they don't get out of sync if the logic changes

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