Skip to content

Commit

Permalink
send header
Browse files Browse the repository at this point in the history
  • Loading branch information
peixunzhang committed Nov 1, 2024
1 parent f62f500 commit 0f03912
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 35 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Prebid.js is open source software that is offered for free as a convenience. Whi

*Note:* Requires Prebid.js v1.38.0+

Prebid.js depends on Babel and some Babel Plugins in order to run correctly in the browser. Here are some examples for
Prebid.js depends on Babel and some Babel Plugins in order to run correctly in the browser. Here are some examples for
configuring webpack to work with Prebid.js.

With Babel 7:
Expand All @@ -37,7 +37,7 @@ module.exports = {
mode: 'production',
module: {
rules: [

// this rule can be excluded if you don't require babel-loader for your other application files
{
test: /\.m?js$/,
Expand All @@ -46,7 +46,7 @@ module.exports = {
loader: 'babel-loader',
}
},

// this separate rule is required to make sure that the Prebid.js files are babel-ified. this rule will
// override the regular exclusion from above (for being inside node_modules).
{
Expand All @@ -71,15 +71,15 @@ Or for Babel 6:
// you must manually install and specify the presets and plugins yourself
options: {
plugins: [
"transform-object-assign", // required (for IE support) and "babel-plugin-transform-object-assign"
"transform-object-assign", // required (for IE support) and "babel-plugin-transform-object-assign"
// must be installed as part of your package.
require('prebid.js/plugins/pbjsGlobals.js') // required!
],
presets: [
["env", { // you can use other presets if you wish.
"targets": { // this example is using "babel-presets-env", which must be installed if you
"browsers": [ // follow this example.
... // your browser targets. they should probably match the targets you're using for the rest
... // your browser targets. they should probably match the targets you're using for the rest
// of your application
]
}
Expand Down Expand Up @@ -143,7 +143,7 @@ This will run testing but not linting. A web server will start at `http://localh

Development may be a bit slower but if you prefer linting and additional watch files you can also still run just:

$ gulp serve
$ gulp serve


### Build Optimization
Expand All @@ -162,11 +162,11 @@ Building with just these adapters will result in a smaller bundle which should a
- Then run the build:

$ gulp build --modules=openxBidAdapter,rubiconBidAdapter,sovrnBidAdapter

Alternatively, a `.json` file can be specified that contains a list of modules you would like to include.

$ gulp build --modules=modules.json

With `modules.json` containing the following
```json modules.json
[
Expand Down Expand Up @@ -202,7 +202,7 @@ gulp bundle --tag one --modules=one.json
gulp bundle --tag two --modules=two.json
```

This generates slightly larger files, but has the advantage of being much faster to run (after the initial `gulp build`). It's also the method used by [the Prebid.org download page](https://docs.prebid.org/download.html).
This generates slightly larger files, but has the advantage of being much faster to run (after the initial `gulp build`). It's also the method used by [the Prebid.org download page](https://docs.prebid.org/download.html).

<a name="Run"></a>

Expand Down Expand Up @@ -378,7 +378,7 @@ For instructions on writing tests for Prebid.js, see [Testing Prebid.js](https:/

### Supported Browsers

Prebid.js is supported on IE11 and modern browsers until 5.x. 6.x+ transpiles to target >0.25%; not Opera Mini; not IE11.
Prebid.js is supported on IE11 and modern browsers until 5.x. 6.x+ transpiles to target >0.25%; not Opera Mini; not IE11.

### Governance
Review our governance model [here](https://github.com/prebid/Prebid.js/tree/master/governance.md).
Expand Down
2 changes: 1 addition & 1 deletion integrationExamples/gpt/x-domain/creative.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// creative will be rendered, e.g. GAM delivering a SafeFrame

// this code is autogenerated, also available in 'build/creative/creative.js'
<script>!function(){"use strict";const e="Prebid Event",n=(()=>{const e={frameBorder:0,scrolling:"no",marginHeight:0,marginWidth:0,topMargin:0,leftMargin:0,allowTransparency:"true"};return(n,t)=>{const r=n.createElement("iframe");return Object.entries(Object.assign({},t,e)).forEach((([e,n])=>r.setAttribute(e,n))),r}})();function t(e){return!!e.frames.__pb_locator__}window.pbRender=function(r){let o=r.parent;try{for(;o!==r.top&&!t(o);)o=o.parent;t(o)||(o=r.parent)}catch(e){}return function({adId:t,pubUrl:s,clickUrl:i}){const c=new URL(s,window.location).origin;function a(e,n,r){const s=new MessageChannel;s.port1.onmessage=u(r),o.postMessage(JSON.stringify(Object.assign({message:e,adId:t},n)),c,[s.port2])}function d(n){a(e,{event:"adRenderFailed",info:{reason:n?.reason||"exception",message:n?.message}}),n?.stack&&console.error(n)}function u(e){return function(){try{return e.apply(this,arguments)}catch(e){d(e)}}}a("Prebid Request",{options:{clickUrl:i}},(function(o){let s;try{s=JSON.parse(o.data)}catch(e){return}if("Prebid Response"===s.message&&s.adId===t){const t=n(r.document,{width:0,height:0,style:"display: none",srcdoc:`<script>${s.renderer}<\/script>`});t.onload=u((function(){const o=t.contentWindow;o.Promise.resolve(o.render(s,{sendMessage:a,mkFrame:n},r)).then((()=>a(e,{event:"adRenderSucceeded"})),d)})),r.document.body.appendChild(t)}}))}}(window)}();</script>
<script>(()=>{"use strict";const e="Prebid Event",n=(()=>{const e={frameBorder:0,scrolling:"no",marginHeight:0,marginWidth:0,topMargin:0,leftMargin:0,allowTransparency:"true"};return(n,t)=>{const r=n.createElement("iframe");return Object.entries(Object.assign({},t,e)).forEach((([e,n])=>r.setAttribute(e,n))),r}})();function t(e){return!!e.frames.__pb_locator__}window.pbRender=function(r){let o=r.parent;try{for(;o!==r.top&&!t(o);)o=o.parent;t(o)||(o=r.parent)}catch(e){}return function({adId:t,pubUrl:s,clickUrl:i}){const a=new URL(s,window.location).origin;function c(e,n,r){const s=new MessageChannel;s.port1.onmessage=l(r),o.postMessage(JSON.stringify(Object.assign({message:e,adId:t},n)),a,[s.port2])}function d(n){c(e,{event:"adRenderFailed",info:{reason:n?.reason||"exception",message:n?.message}}),n?.stack&&console.error(n)}function l(e){return function(){try{return e.apply(this,arguments)}catch(e){d(e)}}}c("Prebid Request",{options:{clickUrl:i}},(function(o){let s;try{s=JSON.parse(o.data)}catch(e){return}if("Prebid Response"===s.message&&s.adId===t){const t=n(r.document,{width:0,height:0,style:"display: none",srcdoc:`<script>${s.renderer}<\/script>`});t.onload=l((function(){const o=t.contentWindow;o.Promise.resolve(o.render(s,{sendMessage:c,mkFrame:n},r)).then((()=>c(e,{event:"adRenderSucceeded"})),d)})),r.document.body.appendChild(t)}}))}}(window)})();</script>

<script>
pbRender({
Expand Down
5 changes: 3 additions & 2 deletions libraries/liveIntentId/idSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const EVENTS_TOPIC = 'pre_lips';

export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME});
const calls = {
ajaxGet: (url, onSuccess, onError, timeout) => {
ajaxGet: (url, onSuccess, onError, timeout, headers) => {
ajaxBuilder(timeout)(
url,
{
Expand All @@ -33,7 +33,8 @@ const calls = {
undefined,
{
method: 'GET',
withCredentials: true
withCredentials: true,
customHeaders: headers
}
)
},
Expand Down
34 changes: 17 additions & 17 deletions 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"fun-hooks": "^0.9.9",
"gulp-wrap": "^0.15.0",
"klona": "^2.0.6",
"live-connect-js": "^6.7.3"
"live-connect-js": "^7.1.0-alpha-2b73ebd.0"
},
"optionalDependencies": {
"fsevents": "^2.3.2"
Expand Down
37 changes: 33 additions & 4 deletions test/spec/modules/liveIntentExternalIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('LiveIntentExternalId', function() {
},
{
clientRef: {},
sourceEvent: { hash: '123' },
sourceEvent: { emailHash: '123' },
type: 'collect'
}])
});
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('LiveIntentExternalId', function() {

expect(window.liQHub[1]).to.eql({
clientRef: {},
sourceEvent: { hash: '58131bc547fb87af94cebdaf3102321f' },
sourceEvent: { emailHash: '58131bc547fb87af94cebdaf3102321f' },
type: 'collect'
})

Expand Down Expand Up @@ -179,7 +179,7 @@ describe('LiveIntentExternalId', function() {
},
{
clientRef: {},
sourceEvent: { hash: '123' },
sourceEvent: { emailHash: '123' },
type: 'collect'
}])
});
Expand All @@ -205,7 +205,36 @@ describe('LiveIntentExternalId', function() {
},
{
clientRef: {},
sourceEvent: { hash: '123' },
sourceEvent: { emailHash: '123' },
type: 'collect'
}])
});

it('should include the identifier data if it is present in config', function() {
const configParams = {
params: {
...defaultConfigParams.params,
distributorId: 'did-1111',
emailHash: '123',
ipv4: 'foov4',
ipv6: 'foov6',
userAgent: 'bar'
}
}
liveIntentExternalIdSubmodule.decode({}, configParams);
expect(window.liQHub).to.eql([{
clientDetails: { name: 'prebid', version: '$prebid.version$' },
clientRef: {},
collectSettings: { timeout: DEFAULT_AJAX_TIMEOUT },
consent: {},
integration: { distributorId: 'did-1111', publisherId: defaultConfigParams.params.publisherId, type: 'custom' },
partnerCookies: new Set(),
resolveSettings: { identityPartner: 'did-1111', timeout: DEFAULT_AJAX_TIMEOUT },
type: 'register_client'
},
{
clientRef: {},
sourceEvent: { emailHash: '123', ipv4: 'foov4', ipv6: 'foov6', userAgent: 'bar' },
type: 'collect'
}])
});
Expand Down
15 changes: 15 additions & 0 deletions test/spec/modules/liveIntentIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,21 @@ describe('LiveIntentId', function() {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should include ip4,ip6,userAgent if it\'s present', function(done) {
liveIntentIdSubmodule.getId({ params: {
...defaultConfigParams,
ipv4: 'foov4',
ipv6: 'foov6',
userAgent: 'boo'
}});
setTimeout(() => {
let request = rpRequests()[0];
expect(request.url).to.match(/^https:\/\/rp\.liadm\.com\/j?.*pip=.*&pip6=.*$/)
expect(request.requestHeaders['X-LI-Provided-User-Agent']).to.be.eq('boo')
done();
}, 300);
});

it('should send an error when the cookie jar throws an unexpected error', function() {
getCookieStub.throws('CookieError', 'A message');
liveIntentIdSubmodule.getId({ params: defaultConfigParams });
Expand Down

0 comments on commit 0f03912

Please sign in to comment.