privacysandbox / privacy-sandbox-demos

https://developer.chrome.com/blog/privacy-sandbox-demos/
Apache License 2.0
42 stars 39 forks source link

[BA] Setup B&A demo loading mechanism #412

Open kevinkiklee opened 1 month ago

kevinkiklee commented 1 month ago

Description

This PR sets up the loading mechanism for the B&A demo.

The code specific to a demo is now stored in the /uc-[USE_CASE_NAME]/. This approach has not been migrated to the existing demos using other DSPs and SSPs yet.


DSP

The route is matched like the following:

app.get('/uc-:useCaseName/join-ad-interest-group.html',
  async (req: Request, res: Response) => {
    const {useCaseName} = req.params;
  },
);

SSP


Advertiser (Shop)

On the advertiser page, the tag loading is controlled with a switch statement:

switch ('<%= auctionType %>') {
  case 'multi':
    document.body.appendChild(dspAScript);
    document.body.appendChild(dspBScript);
    break;

  case 'ba':
    document.body.appendChild(dspAScript);
    document.body.appendChild(dspBScript);
    document.body.appendChild(dspXScript);
    document.body.appendChild(dspYScript);
    break;

  default: 
    document.body.appendChild(dspScript);
}

Publisher (News)

The publisher page isn't constructed like the advertiser (shop) site where the pages are linked/related to one another. Therefore, I just added a whole new page to build the B&A demo to keep the code cleaner.


Affected services