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

Andrew s/dev week #38

Merged
merged 44 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bfd413c
Enable non-personalized Ads (#1)
carlos-algms Apr 4, 2019
78dc729
Increase the bundle-size to accept the new amount of code
Apr 4, 2019
63391a4
Changed the place where NPA is set
Apr 9, 2019
67b147e
Merge pull request #97 from carlos-algms/master
miblanchard Apr 12, 2019
d814395
Update Bling.js
tamagokun Mar 26, 2021
e8968ad
Merge pull request #149 from tamagokun/patch-1
miblanchard Mar 26, 2021
2917f92
Bump to 2.0.2
miblanchard Mar 26, 2021
13c4c60
chore: Update package.json
andrewb Jan 17, 2019
383b66f
chore: Update API list
andrewb Jan 17, 2019
4811c9d
chore: Add prettier config (#3)
andrewb Jan 17, 2019
c4c3fa7
Fixing things
andrew-sotiriou Dec 18, 2023
c97c6cd
fix: Don't setState on unmounted ad (#5)
andrewb Jan 17, 2019
0e35bca
fix: Fix undefined function if apiNotReady (#6)
andrewb Jan 17, 2019
af3ebcd
fix: Replace hasOwnProperty with more reliable check (#7)
andrewb Jan 17, 2019
9fd005d
fix: Do not refresh all ads when new component loads (#8)
andrewb Jan 18, 2019
327fd47
refactor: Check for updateCorrelator (#9)
andrewb Jan 18, 2019
5702587
build: Update radium (#10)
andrewb Jan 18, 2019
0d00da5
Fixing things
andrew-sotiriou Dec 18, 2023
170ee56
fix: Stop multiple refresh on mq change (#11)
andrewb Jan 22, 2019
f77e8a0
Merge it
andrew-sotiriou Dec 18, 2023
b1a1217
feat: Add support for custom refresh function (#14)
andrewb Jan 28, 2019
962f64e
work this time
andrew-sotiriou Dec 18, 2023
1833544
perf: Use googletag.cmd.push instead of timeout to process queue (#16)
andrewb Feb 5, 2019
c788a4c
work this time
andrew-sotiriou Dec 18, 2023
d4e9980
Update all instances of googletagservices gpt url to securepubads gpt…
andrew-sotiriou Feb 16, 2022
5f9ddae
update linking instructions; some cleanup (#21)
andrewb Feb 16, 2022
f98adc0
remove enableServices timeout from GPT mock (#22)
andrewb Feb 16, 2022
fac9ddc
Release 2.1.2 (#24)
andrewb Feb 22, 2022
875678f
Remove deprecated ContentService (#23)
andrewb Feb 24, 2022
4728d10
update changelog and version in package.json (#25)
andrew-sotiriou Feb 24, 2022
3011556
Ton of MI updates (#26)
andrew-sotiriou May 3, 2022
24149c0
change release and update changelog (#27)
andrew-sotiriou May 3, 2022
63dbf2a
Gregt/negative viewable threshold (#28)
Engywook2005 May 16, 2022
dcc9bf6
Changed version and updated changelog (#29)
Engywook2005 May 16, 2022
c813c5f
Andrew s/neg vt issue (#30)
andrew-sotiriou May 27, 2022
a5f34da
Release 2 1 6 (#31)
andrew-sotiriou May 27, 2022
9fc1d04
add prepare script
stephensauceda Feb 23, 2023
61aa1ac
Revert "add prepare script"
stephensauceda Feb 23, 2023
ca8b6a5
React v17 support (#32)
stephensauceda Mar 3, 2023
21e8b05
release branch (#33)
andrew-sotiriou Mar 3, 2023
5fcb651
Remove console log (#34)
andrew-sotiriou Mar 3, 2023
f043ef7
Update package and remove console log (#35)
andrew-sotiriou Mar 3, 2023
45a4ea3
Gregt/lazy load (#36)
Engywook2005 May 10, 2023
3ff08d3
Merge branch 'nfl-master' into andrew-s/dev-week
andrew-sotiriou Dec 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"bundlesize": [
{
"path": "./dist/react-gpt.min.js",
"maxSize": "8.5 kB"
"maxSize": "8.53 kB"
}
]
}
49 changes: 42 additions & 7 deletions src/Bling.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,17 @@ class Bling extends React.Component {
*
* @property style
*/
style: PropTypes.object
style: PropTypes.object,
/**
* An optional property to control non-personalized Ads.
* https://support.google.com/admanager/answer/7678538
*
* Set to `true` to mark the ad request as NPA, and to `false` for ad requests that are eligible for personalized ads
* It is `false` by default, according to Google's definition.
*
* @property npa
*/
npa: PropTypes.bool
};

/**
Expand All @@ -222,7 +232,13 @@ class Bling extends React.Component {
* @property reRenderProps
* @static
*/
static reRenderProps = ["adUnitPath", "slotSize", "outOfPage", "content"];
static reRenderProps = [
"adUnitPath",
"slotSize",
"outOfPage",
"content",
"npa"
];
/**
* An instance of ad manager.
*
Expand Down Expand Up @@ -456,10 +472,9 @@ class Bling extends React.Component {
this.props,
nextProps
);
const shouldRender = !propsEqual(
reRenderProps.props,
reRenderProps.nextProps
);
const shouldRender =
!this._adSlot ||
!propsEqual(reRenderProps.props, reRenderProps.nextProps);
const shouldRefresh =
!shouldRender &&
!propsEqual(refreshableProps.props, refreshableProps.nextProps);
Expand Down Expand Up @@ -656,10 +671,12 @@ class Bling extends React.Component {
}

defineSlot() {
const {adUnitPath, outOfPage} = this.props;
const { adUnitPath, outOfPage, npa } = this.props;
const divId = this._divId;
const slotSize = this.getSlotSize();

this.handleSetNpaFlag(npa);

if (!this._adSlot) {
// May need additional OOP logic later
if (outOfPage) {
Expand Down Expand Up @@ -830,6 +847,24 @@ class Bling extends React.Component {

return <div id={this._divId} style={style} />;
}

/**
* Call pubads and set the non-personalized Ads flag, if it is not undefined.
*
* @param {boolean} npa
*/
handleSetNpaFlag(npa) {
if (npa === undefined) {
return;
}

Bling._adManager.pubadsProxy({
method: "setRequestNonPersonalizedAds",
args: [npa ? 1 : 0],
resolve: null,
reject: null
});
}
}

// proxy pubads API through Bling
Expand Down
39 changes: 39 additions & 0 deletions test/Bling.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,45 @@ describe("Bling", () => {
);
});

it("call pubads API to set non-personalized Ads when npa prop is set", done => {
const spy = sinon.stub(Bling._adManager, "pubadsProxy");
const expectedParamTrue = {
method: "setRequestNonPersonalizedAds",
args: [1],
resolve: null,
reject: null
};
const expectedParamFalse = {
...expectedParamTrue,
args: [0]
};

Bling.once(Events.RENDER, () => {
expect(spy.calledWith(expectedParamTrue)).to.be.true;
expect(spy.calledWith(expectedParamFalse)).to.be.true;
spy.restore();
done();
});

// Render once to test with non-personalized ads
ReactTestUtils.renderIntoDocument(
<Bling
adUnitPath="/4595/nfl.test.open"
npa={true}
slotSize={["fluid"]}
/>
);

// Render a second time to test re-enable personalized ads
ReactTestUtils.renderIntoDocument(
<Bling
adUnitPath="/4595/nfl.test.open"
npa={false}
slotSize={["fluid"]}
/>
);
});

it("fires once event", done => {
const events = Object.keys(Events).map(key => Events[key]);

Expand Down