Skip to content

Commit

Permalink
Merge pull request #268 from privacysandbox/dev
Browse files Browse the repository at this point in the history
Update instream video ad demo documentation
  • Loading branch information
kevinkiklee authored Feb 22, 2024
2 parents a1024e6 + 6f17e72 commit d13d66c
Show file tree
Hide file tree
Showing 25 changed files with 138 additions and 46 deletions.
4 changes: 2 additions & 2 deletions services/ad-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
"skipLibCheck": true
}
}
4 changes: 2 additions & 2 deletions services/dsp-a/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
"skipLibCheck": true
}
}
4 changes: 2 additions & 2 deletions services/dsp-b/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
"skipLibCheck": true
}
}
8 changes: 4 additions & 4 deletions services/dsp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/dsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ncu": "npx npm-check-updates -u"
},
"dependencies": {
"cbor": "^9.0.0",
"cbor": "^9.0.2",
"ejs": "^3.1.9",
"express": "^4.18.2",
"structured-field-values": "^2.0.1"
Expand Down
8 changes: 6 additions & 2 deletions services/dsp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,12 @@ app.post(
},
);

app.get('/private-aggregation', (req, res) => {
res.render('private-aggregation');
app.get('/private-aggregation-aws', (req, res) => {
res.render('private-aggregation-aws');
});

app.get('/private-aggregation-gcp', (req, res) => {
res.render('private-aggregation-gcp');
});

app.post(
Expand Down
9 changes: 6 additions & 3 deletions services/dsp/src/public/js/dsp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
let dsp = document.currentScript.getAttribute('dsp');
window.addEventListener('load', (event) => {
let iframe = document.createElement('iframe');
let iframeAws = document.createElement('iframe');
let iframeGcp = document.createElement('iframe');
// let dsp = document.currentScript.getAttribute('dsp');
iframe.src = `https://${dsp}/private-aggregation`;
document.body.appendChild(iframe);
iframeAws.src = `https://${dsp}/private-aggregation-aws`;
iframeGcp.src = `https://${dsp}/private-aggregation-gcp`;
document.body.appendChild(iframeAws);
document.body.appendChild(iframeGcp);
});
14 changes: 14 additions & 0 deletions services/dsp/src/public/js/private-aggregation-aws.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
async function runPrivateAggregationAws() {
const privateAggCloud = {
'privateAggregationConfig': {
'aggregationCoordinatorOrigin':
'https://publickeyservice.msmt.aws.privacysandboxservices.com',
},
};
await window.sharedStorage.worklet.addModule(
'js/private-aggregation-worklet-aws.js',
);
await window.sharedStorage.run('test-private-aggregation', privateAggCloud);
}

runPrivateAggregationAws();
14 changes: 14 additions & 0 deletions services/dsp/src/public/js/private-aggregation-gcp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
async function runPrivateAggregationGcp() {
const privateAggCloud = {
'privateAggregationConfig': {
'aggregationCoordinatorOrigin':
'https://publickeyservice.msmt.gcp.privacysandboxservices.com',
},
};
await window.sharedStorage.worklet.addModule(
'js/private-aggregation-worklet-gcp.js',
);
await window.sharedStorage.run('test-private-aggregation', privateAggCloud);
}

runPrivateAggregationGcp();
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class TestPrivateAggregation {
async run(data) {
console.log('Enabling Private Aggregation Debug Mode');
console.log('Enabling AWS Private Aggregation Debug Mode');
privateAggregation.enableDebugMode({debugKey: 1234n});
let campaignId = await sharedStorage.get('campaignId');
if (!campaignId) {
Expand Down
24 changes: 24 additions & 0 deletions services/dsp/src/public/js/private-aggregation-worklet-gcp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class TestPrivateAggregation {
async run(data) {
console.log('Enabling GCP Private Aggregation Debug Mode');
privateAggregation.enableDebugMode({debugKey: 1234n});
let campaignId = await sharedStorage.get('campaignId');
if (!campaignId) {
console.log(
'No campaign id found for client. Adding campaignId 1234567890.',
);
campaignId = '1234567890';
sharedStorage.set('campaignId', campaignId);
} else {
console.log(`Campaign ID found: ${campaignId}`);
}
function convertToBucket(bucketId) {
return BigInt(bucketId);
}
const bucket = convertToBucket(campaignId);
const value = 128;
privateAggregation.contributeToHistogram({bucket, value});
}
}

register('test-private-aggregation', TestPrivateAggregation);
8 changes: 0 additions & 8 deletions services/dsp/src/public/js/private-aggregation.js

This file was deleted.

5 changes: 5 additions & 0 deletions services/dsp/src/views/private-aggregation-aws.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<header>
<script src="/js/private-aggregation-aws.js"></script>
</header>
</html>
5 changes: 5 additions & 0 deletions services/dsp/src/views/private-aggregation-gcp.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<header>
<script src="/js/private-aggregation-gcp.js"></script>
</header>
</html>
4 changes: 2 additions & 2 deletions services/dsp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
"skipLibCheck": true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 25 additions & 9 deletions services/home/docs/demos/instream-video-ad-multi-seller.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
<Tabs>
<TabItem value="overview" label="Overview" default>

☝️ Use the tabs to navigate to other sections in this document

If you have any questions and comments for this instream video ad demo, use
[the instream video ad demo post](https://github.com/privacysandbox/privacy-sandbox-demos/discussions/254) in the Discussions tab.

Expand Down Expand Up @@ -185,6 +187,8 @@ DSPA ->> Browser: Add user to Interest Group<br>Set a render URL with SSP VAST m
DSPB ->> Browser: Add user to Interest Group<br>Set a render URL with SSP VAST macro (%%SSP_VAST_URL%%)
```

[Full-sized diagram](./img/instream-video-ad-ig-time.png)

#### Header bidding time

This is the time period when the seller defines the macro substitution in the component auction config
Expand Down Expand Up @@ -217,6 +221,8 @@ SSPB ->> HB: Respond with the header bid and component auction config
HB ->> AS: Pass the header bidding auction result to the ad server client-side library
```

[Full-sized diagram](./img/instream-video-ad-hb-time.png)

### Ad rendering time

This is the time period when the VAST is transformed and passed to the creative.
Expand Down Expand Up @@ -255,33 +261,43 @@ AS ->> VP: The VAST is passed to the video player
VP ->> Publisher: The instream video ad is rendered
```

## Alternate mechanism
[Full-sized diagram](.//img/instream-video-ad-render-time.png)

## Alternative approach

In another approach, the SSP can provide the render URL. The DSP sets the following render URL in the IG:

```js
const interestGroup = {
// ...
ads: [{
renderUrl: 'https://privacy-sandbox-demos-ssp-a.dev/video-ad.html?dspVastUri=https://privacy-sandbox-demos-dsp-a.dev/preroll.xml',
}]
ads: [
{
renderUrl: 'https://privacy-sandbox-demos-ssp-a.dev/video-ad.html?dspVastUri=https://privacy-sandbox-demos-dsp-a.dev/preroll.xml',
metadata: {
seller: 'ssp-a'
}
},
{
renderUrl: 'https://privacy-sandbox-demos-ssp-b.dev/video-ad.html?dspVastUri=https://privacy-sandbox-demos-dsp-a.dev/preroll.xml',
metadata: {
seller: 'ssp-b'
}
},
]
}
```

- The render URL points to the SSP’s video ad serving endpoint, and the DSP’s VAST URI is added as query params.
- The SSP is now responsible for serving the actual ad that is rendered inside the iframe, and it contains the SSP VAST XML that wraps the DSP VAST
URI.
- To support multiple SSPs, the buyer adds a render URL for each SSP. During the bid generation time, the buyer can filter the ads object and return
a render URL for the matching seller.
- When that ad wins the auction, the browser makes a request to the render URL which is the SSP's ad serving endpoint `/video-ad.html` with the DSP's
VAST URI set in the query params
- SSP’s HTML document is rendered in the ad iframe and parses the DSP's VAST URI from the query params
- The code inside SSP's video-ad.html wraps the DSP's VAST URI with its own VAST
- The finalized VAST XML is post-messaged out of the creative frame to the video player

To support multiple SSPs, the SSP's video ad serving endpoint can be substituted with a macro:
`https://%%SSP_VIDEO_AD%%?dspVastUri=https://privacy-sandbox-demos-dsp-a.dev/preroll.xml` .

We will add a demo for this alternate approach in the future.

</TabItem>
<TabItem value="implementation" label="Implementation">

Expand Down
4 changes: 2 additions & 2 deletions services/news/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"skipLibCheck": true
},
"exclude": ["src/public"],
"exclude": ["src/public"]
}
4 changes: 2 additions & 2 deletions services/shop/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
"skipLibCheck": true
}
}
4 changes: 2 additions & 2 deletions services/topics-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
"skipLibCheck": true
}
}
4 changes: 2 additions & 2 deletions services/topics/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
"skipLibCheck": true
}
}
4 changes: 2 additions & 2 deletions services/travel/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
"skipLibCheck": true
}
}
15 changes: 15 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

npm install

npm run cert

cd services/home

npm install

npm run build

cd ../..

sudo npm run start

0 comments on commit d13d66c

Please sign in to comment.