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

Add TGT macro for targeting data in json #12707

Merged
merged 6 commits into from Jan 9, 2018
Merged

Add TGT macro for targeting data in json #12707

merged 6 commits into from Jan 9, 2018

Conversation

bradfrizzell
Copy link
Contributor

See #12374

@@ -741,6 +741,10 @@ export class AmpAdNetworkDoubleclickImpl extends AmpA4A {
return {
PAGEVIEWID: () => Services.documentInfoForDoc(this.element).pageViewId,
HREF: () => this.win.location.href,
TGT: () => {
const json = tryParseJson(this.element.getAttribute('data-json'));
Copy link
Contributor

Choose a reason for hiding this comment

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

TGT: () => (tryParseJson(this.element.getAttribute('data-json')) || {})['targeting'] || '',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

@@ -294,6 +297,7 @@ describes.realWin('DoubleClick Fast Fetch RTC', {amp: true}, env => {
'data-multi-size-validation': macros['data-multi-size-validation'],
'data-override-width': macros['data-OVERRIDE-width'],
'data-override-height': macros['data-override-HEIGHT'],
'data-json': JSON.stringify(json),
Copy link
Contributor

Choose a reason for hiding this comment

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

does your test coverage handle the case where data-json exists but without targeting key?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added test

@erwinmombay erwinmombay merged commit b5c44c1 into master Jan 9, 2018
@monish-chhadwa
Copy link
Contributor

monish-chhadwa commented Jan 16, 2018

Hey, @bradfrizzell
Should you be using this.element.dataset['json'] or this.element.getAttribute('json') ?
You will also have to JSON.stringify it

@bradfrizzell
Copy link
Contributor Author

@monish-chhadwa Good catch, follow up PR to fix here: #12841

@bradfrizzell bradfrizzell deleted the frizz-tgt branch January 16, 2018 16:44
gzgogo pushed a commit to gzgogo/amphtml that referenced this pull request Jan 26, 2018
* Add TGT macro for targeting data in json

* Respond to feedback

* golf

* Fix

* fix check-types

* fix
RanAbram pushed a commit to RanAbram/amphtml that referenced this pull request Mar 12, 2018
* Add TGT macro for targeting data in json

* Respond to feedback

* golf

* Fix

* fix check-types

* fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants