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

CMCD tests failing on Xbox One #4072

Closed
joeyparrish opened this issue Mar 28, 2022 · 4 comments · Fixed by #4073 or #4009
Closed

CMCD tests failing on Xbox One #4072

joeyparrish opened this issue Mar 28, 2022 · 4 comments · Fixed by #4073 or #4009
Labels
priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@joeyparrish
Copy link
Member

Test output on Xbox One:

Edge 18.22000 (Xbox One) CmcdManager Query serialization produces correctly serialized data FAILED
        Error: Expected 'br=52317,bs,cid="xyz",com.test-exists,com.test-hello="world",com.test-testing=1234,com.test-token=undefined,d=6067,mtp=10000,nor="..%2Ftesting%2F3.m4v",nrr="0-99",sid="c936730c-031e-4a73-976f-92bc34039c60"' to be 'br=52317,bs,cid="xyz",com.test-exists,com.test-hello="world",com.test-testing=1234,com.test-token=s,d=6067,mtp=10000,nor="..%2Ftesting%2F3.m4v",nrr="0-99",sid="c936730c-031e-4a73-976f-92bc34039c60"'.
            at <Jasmine>
           at Anonymous function (test/util/cmcd_manager_unit.js:41:7 <- test/util/cmcd_manager_unit.js:37:7)
            at <Jasmine>

It seems that the cause is the code to handle Symbols:

      // Serialize the key/value pair
      const type = typeof value;
      let result;

      if (type === 'string' && key !== 'ot' && key !== 'sf' && key !== 'st') {
        result = `${key}=${JSON.stringify(value)}`;
      } else if (type === 'boolean') {
        result = key;
      } else if (type === 'symbol') {
        result = `${key}=${value.description}`;
      } else {
        result = `${key}=${value}`;
      }

On Xbox One, it seems that description is unimplemented somehow:

const s = Symbol('s');
console.log(s.description);  // prints undefined

While that is clearly a bug in the platform's JavaScript environment, @littlespex, is it necessary or useful to have Symbol support here? I don't understand when someone would use that.

@joeyparrish joeyparrish added type: bug Something isn't working correctly priority: P3 Useful but not urgent labels Mar 28, 2022
@github-actions github-actions bot added this to the Backlog milestone Mar 28, 2022
@littlespex
Copy link
Collaborator

littlespex commented Mar 28, 2022

Symbols are used to define custom CMCD token values. That said, there is currently no way to define custom CMCD fields (that feature is mentioned in the original ticket but not yet implemented). The symbol else if could be removed for now, or a fallback could be added:

result = `${key}=${value.description || value.toString().slice(7, -1)}`;

@avelad
Copy link
Collaborator

avelad commented Mar 29, 2022

I created a PR with another solution

@joeyparrish
Copy link
Member Author

What are "custom CMCD token values", and why are Symbols the solution?

@littlespex
Copy link
Collaborator

The CMCD spec contains 4 value types: string, number, boolean and token. One example of a token type is the Object Type field. Token values are serialized without quotes.

The spec also allows for custom key/value pairs to sent with each request. The original serialization code this is based off of from used Symbols to represent token values to create a one to one relationship between JS primitives and CMCD values types.

https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf

joeyparrish added a commit that referenced this issue Mar 29, 2022
Close #4072

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
joeyparrish added a commit that referenced this issue Apr 21, 2022
Close #4072

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
@avelad avelad modified the milestones: Backlog, v4.0 May 4, 2022
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label May 28, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P3 Useful but not urgent status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
3 participants