Skip to content

Commit

Permalink
✨ [amp-ad smartadserver] Add schain attribute (#37522)
Browse files Browse the repository at this point in the history
* Update documentation

* Support schain parameter

* Fixing unit tests

* Fix formatting errors in documentation
  • Loading branch information
krzysztofequativ authored Feb 2, 2022
1 parent ca1c7d4 commit 2aa7095
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export class AmpAdNetworkSmartadserverImpl extends AmpA4A {
urlParams['hb_height'] = this.element.getAttribute('height');
}

const schain = this.element.getAttribute('data-schain');
if (schain) {
urlParams['schain'] = schain;
}

const formatId = this.element.getAttribute('data-format');
const tagId = 'sas_' + formatId;
return buildUrl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,42 @@ describes.realWin('amp-ad-network-smartadserver-impl', realWinConfig, (env) => {
);
});
});

it('should return proper url with schain value', async () => {
element = createElementWithAttributes(doc, 'amp-ad', {
'data-site': '1',
'data-format': '22',
'data-schain': 'some-sco-string',
});
doc.body.appendChild(element);
const viewer = Services.viewerForDoc(element);
env.sandbox.stub(viewer, 'getReferrerUrl');
return new AmpAdNetworkSmartadserverImpl(element)
.getAdUrl({}, null)
.then((url) => {
expect(url).to.match(
/^https:\/\/www\.smartadserver\.com\/ac\?siteid=1&fmtid=22&tag=sas_22&out=amp-hb&schain=some-sco-string&pgDomain=[a-zA-Z0-9.%]+&tmstp=[0-9]+$/
);
});
});

it('should not return chain parameter in url if empty value', async () => {
element = createElementWithAttributes(doc, 'amp-ad', {
'data-site': 10,
'data-format': '3',
'data-schain': '',
});
doc.body.appendChild(element);
const viewer = Services.viewerForDoc(element);
env.sandbox.stub(viewer, 'getReferrerUrl');
return new AmpAdNetworkSmartadserverImpl(element)
.getAdUrl({}, null)
.then((url) => {
expect(url).to.match(
/^https:\/\/www\.smartadserver\.com\/ac\?siteid=10&fmtid=3&tag=sas_3&out=amp-hb&pgDomain=[a-zA-Z0-9.%]+&tmstp=[0-9]+$/
);
});
});
});

describe('getNonAmpCreativeRenderingMethod', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ limitations under the License.
<table>
<tr>
<td class="col-fourty"><strong>Description</strong></td>
<td>The Smartadserver fast fetch implementation for serving AMP ads, using `<amp-ad>`.</td>
<td>The Smartadserver fast fetch implementation for serving AMP ads using <code>&lt;amp-ad&gt;</code></td>
</tr>
<tr>
<td class="col-fourty" width="40%"><strong>Availability</strong></td>
<td class="col-fourty" width="25%"><strong>Availability</strong></td>
<td>Launched</td>
</tr>
<tr>
Expand All @@ -31,11 +31,11 @@ limitations under the License.
</tr>
</table>

## Behavior
# Behavior

Smartadserver supports the Real Time Config (RTC) to preload configuration settings for ad placements. The RTC setup is optional.

## Supported parameters
# Supported parameters

Smartadserver largely uses the same tags as `<amp-ad>`. The following are required tags for special behaviors of existing ones:

Expand All @@ -47,9 +47,10 @@ Smartadserver largely uses the same tags as `<amp-ad>`. The following are requir
These attributes are optional:

- `data-target`: Targeting string
- `data-schain`: SupplyChain Object string
- `rtc-config`: Please refer to [RTC Documentation](https://github.com/ampproject/amphtml/blob/main/extensions/amp-a4a/rtc-documentation.md) for details

### Example configuration
## Example configuration

```html
<amp-ad width="300" height="250" type="smartadserver"
Expand Down
55 changes: 0 additions & 55 deletions extensions/amp-ad-network-smartadserver-impl/readme.md

This file was deleted.

0 comments on commit 2aa7095

Please sign in to comment.