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 missing node to the parsing #444

Merged
merged 16 commits into from Apr 27, 2023
Merged

Add missing node to the parsing #444

merged 16 commits into from Apr 27, 2023

Conversation

Rapha0511
Copy link
Contributor

@Rapha0511 Rapha0511 commented Mar 14, 2023

Description

  • The mergeWrapperAdData function has been modified to keep track of the <icon> elements contained in a wrapper's creative. If a creative contain <icon>, the whole creative will be included in the final response.

  • Since the VASTTracker allow users to convert seconds to timecode with the convertToTimecode function, the parseDuration function has been exposed publicly as a VASTParser method to allow users to convert timecode to seconds if needed

  • xmlEncoded is now considered as an attribute of the <adParameters> node, instead of a node by itself. The value of <adParameters> is now an Object of type {value: String, xmlEncoded: String}.

  • The type attribute of the <survey> node has been added to the parsing. The value of survey is now an Object of type {value: String, type: String}.

  • <iconClickFallbackImages> node has been added to the parsing as an array of Object of type {url: String, width: String, height: String}.

  • Tests have been added for changes and the addition of the missing nodes. Some of them have been moved from Mocha to Jest

  • For companions, the parameter adSlotID has been modified to adSlotId to follow the VAST specs

VAST 4.3 features

Type

  • Breaking change
  • Enhancement
  • Fix
  • Documentation
  • Tooling

Copy link
Contributor

@ZacharieTFR ZacharieTFR left a comment

Choose a reason for hiding this comment

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

Hello, thanks for your work👍 I left some comments

Comment on lines 419 to 442

### parseDuration(duration)

Parses a duration in the format `HH:MM:SS`, `HH:MM:SS.mmm` or `SS` and returns a duration in seconds.

```javascript

const a = parseDuration('00:01:30.000');
console.log(a); // output: 90

const b = parseDuration('30');
console.log(b); // output: 30

const c = parseDuration(30);
console.log(c); // output: 30

const d = parseDuration('thirty');
console.log(d); // output -1

```

#### Parameter

- **`duration: String`** - The duration represented as a string.
Copy link
Contributor

Choose a reason for hiding this comment

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

You should move this to the public methods section above

type: 'image/jpeg',
staticResource: 'link',
htmlResource:
'<!DOCTYPE html>\r\n <html lang="en">\r\n <head>\r\n <meta charset="UTF-8">\r\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\r\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\r\n <title>Document</title>\r\n </head>\r\n <body>\r\n <h1>titre</h1>\r\n </body>\r\n </html>',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you replace the htmlResource with a dummy value to make it easier to read ?

type: 'image/jpeg',
staticResource: 'link',
htmlResource:
'<!DOCTYPE html>\r\n <html lang="en">\r\n <head>\r\n <meta charset="UTF-8">\r\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\r\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\r\n <title>Document</title>\r\n </head>\r\n <body>\r\n <h1>titre</h1>\r\n </body>\r\n </html>',
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

)
.forEach((iconClickFallbackImageElement, id) => {
icon.iconClickFallbackImages.push({
id,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why adding the id attribute ? As there is no reference to it in the VAST specs

Comment on lines 226 to 229
## iconClickFallbackImages <a name="iconclickfallbackimages"></a>

- `id: Number`
- `url: String`
Copy link
Contributor

Choose a reason for hiding this comment

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

This is missleading as iconClickFallbackImages is an array and the object correspond to the iconClickFallbackImage (singular)
Also, can the url equal to null or will it be an empty string ?

Comment on lines 52 to 56
<IconClickFallbackImages>
<IconClickFallbackImage width="10px" height="10px">
<![CDATA[http://adserver.com/fallback.png]]>
</IconClickFallbackImage>
</IconClickFallbackImages>
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need a use case with multiple to fully cover use cases

Comment on lines 216 to 226
## adParameters<a name="adparameters"></a>

- `value: String`
- `xmlEncoded: String|null`

## survey<a name="survey"></a>

- `value: String`
- `type: String|null`

## iconClickFallbackImage <a name="iconclickfallbackimage"></a>
Copy link
Contributor

Choose a reason for hiding this comment

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

To stay coherent with other sections can you put titles in uppercase ? 🙏

src/parser/parser_utils.js Show resolved Hide resolved
@@ -27,6 +27,7 @@ export class VASTParser extends EventEmitter {
constructor() {
super();

this.parseDuration = parserUtils.parseDuration;
Copy link
Contributor

Choose a reason for hiding this comment

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

One discutions we had about exposing/exporting util functions is that we can either do like you did but then we need to create a new instance of vastParser otherwise the second solution would be to export utils function as a standalone then we could use it without creating a new instance and in addition if we don't use it we could benefit from tree-shaking

Copy link
Contributor

@ZacharieTFR ZacharieTFR left a comment

Choose a reason for hiding this comment

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

LGTM ! Just a small nitpicking

Comment on lines 384 to 385


Copy link
Contributor

Choose a reason for hiding this comment

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

Too many breaklines here 😅

Suggested change

Copy link
Contributor

@clementFrancon clementFrancon left a comment

Choose a reason for hiding this comment

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

LGTM ! Great work !

@ZacharieTFR ZacharieTFR merged commit cee0051 into master Apr 27, 2023
1 check passed
@ZacharieTFR ZacharieTFR deleted the add-missing-node branch April 27, 2023 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants