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

FTRACK USER ID MODULE: tweaking the createEidsArray() method to accept two schema patterns #9123

Merged

Conversation

ftxmoJason
Copy link
Contributor

@ftxmoJason ftxmoJason commented Oct 17, 2022

Type of change

  • Bugfix
  • Refactoring (no functional changes, no api changes)

Description of change

A partner was attempting to use the FTRACK User ID module and they were getting errors in the createEidsArray method. The issue was the JSON schema being passed into the method did not match the schema we wrote the code for. The change this PR addresses is the JSON parsing logic was tweaked to accept both schema patterns while also checking value type (string|array) before pushing to the eids array that is returned

};
const IDS = bidRequestUserId.ftrackId.hasOwnProperty('ext') ? bidRequestUserId.ftrackId.ext : bidRequestUserId.ftrackId;

for (let id in IDS) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To whom it may review.

  1. The original logic expected bidRequestUserId.ftrackId to be the following schema.
ftrackId: {
  HHID: ['household_test_id'],
  DeviceID: ['device_test_id'],
  SingleDeviceID: ['single_device_test_id']
}
  1. But during testing, we actually were seeing:
ftrackId: {
  uid: 'device_test_id',
  ext: {
    HHID: 'household_test_id',
    DeviceID: 'device_test_id',
    SingleDeviceID: 'single_device_test_id'
  }
}

This code change allows both JSON schema's to work correctly, but its not clear to me if both are needed. Do we know why the schema's are different and/or if one is incorrect?

Thanks!

Copy link
Collaborator

@dgirardi dgirardi Oct 17, 2022

Choose a reason for hiding this comment

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

The ftrack ID module is what wraps the result in ext:

return {
ftrackId: {
uid: value.DeviceID && value.DeviceID[0],
ext
}
}

#8678

To me that looks odd, maybe unintentional - it'd make more sense to return {ftrackId: {hhid, deviceId, singleDeviceId}}; but in the end what matters is that the callers (including the eid conversion logic) know what to expect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that is intentional. Thanks for connecting those dots for me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

then I think you can simplify this to E_ID.ext = bidRequestUserId.ftrackId.ext; I don't see a need to handle other cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @dgirardi , I concur. Our decode method is already doing that work so its def redundant at this step. I'll make those changes and ping when they are up. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dgirardi @mmoschovas This PR has been updated. Thanks

@@ -48,20 +48,36 @@ export const ftrackIdSubmodule = {
* similar to the module name and ending in id or Id
*/
decode (value, config) {
if (!value) { return }
const ext = {}
value = value || {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's better to keep the short circuit (if (!value) return). From what I understand value should always be present here, but if it isn't, it's not correct to default to {}: it will cause this logic to return an incomplete object, which would then be translated to essentially gibberish in eids.

If this returns undefined, the caller will filter it out from the userID map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @dgirardi reverted this code

@ftxmoJason
Copy link
Contributor Author

@patmmccann @mmoschovas @dgirardi I forget, do I need to do something now or is the next step on your side? Thanks

@patmmccann patmmccann merged commit b90ee91 into prebid:master Oct 19, 2022
@ftxmoJason
Copy link
Contributor Author

Thanks @patmmccann @mmoschovas @dgirardi

JacobKlein26 pushed a commit to nextmillenniummedia/Prebid.js that referenced this pull request Feb 9, 2023
…t two schema patterns (prebid#9123)

* JDB-563: tweaking the createEidsArray() method to accept two schema patterns

* JDB-563: further cleanup now that I understand the the decode method should be used to prepare the data

* JDB-563: adding shortcircuit back into decode method

Co-authored-by: Jason Lydon <jason.lydon@flashtalking.com>
jorgeluisrocha pushed a commit to jwplayer/Prebid.js that referenced this pull request May 23, 2023
…t two schema patterns (prebid#9123)

* JDB-563: tweaking the createEidsArray() method to accept two schema patterns

* JDB-563: further cleanup now that I understand the the decode method should be used to prepare the data

* JDB-563: adding shortcircuit back into decode method

Co-authored-by: Jason Lydon <jason.lydon@flashtalking.com>
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.

4 participants