Skip to content

Conversation

@jaissica12
Copy link
Contributor

Background

  • Added check to skip hashing arrays

What Has Changed

  • in hashAttributes function added a check to skip hashing arrays.

Screenshots/Video

  • {Include any screenshots or video demonstrating the new feature or fix, if applicable}

Checklist

  • I have performed a self-review of my own code.
  • [] I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

  • {Any additional information or context relevant to this PR}

Reference Issue (For employees only. Ignore if you are an outside contributor)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the hashAttributes function to properly handle array values by skipping the hashing process for them, addressing an issue where arrays were being incorrectly processed.

Changes:

  • Added array type check in hashAttributes to skip hashing for array values
  • Updated comment to clarify the new behavior
  • Added comprehensive test coverage for array handling (both empty and non-empty arrays)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/roktManager.ts Added Array.isArray() check to skip hashing array values and return null for hashedValue; updated inline comment
test/jest/roktManager.spec.ts Added new test case verifying that array values (both empty and non-empty) are preserved without creating hashed versions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jaissica12 and others added 2 commits January 21, 2026 14:44
fix typo

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
remove type assertion

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jaissica12 jaissica12 requested a review from Copilot January 21, 2026 19:50
@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +280 to +283
const attributeValue = attributes[key];
if (Array.isArray(attributeValue)) {
return { key, attributeValue, hashedValue: null };
}
Copy link
Member

Choose a reason for hiding this comment

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

@jaissica12
what happens when you call hashAttributes on a value that's an arry using the Rokt SDK? we want to make sure the behavior is the same. something to flag to Matt if it's doing it improperly there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rmi22186 In Rokt SDK when an array is passed for hashing, it is converted to a string using JavaScript String() coercion, which joins array elements with commas and then hashes them.

Example:

  • Input: { favorite_colors: ['blue', 'green'] }
  • String(['blue', 'green']) → 'blue,green'
  • Calls hashString('blue,green') → SHA256 hash
  • Output: { favorite_colorssha256: '' }

@mattbodle So as of now, both the Core SDK and the Rokt SDK allow hashing of arrays by implicitly converting them to strings. I’ve created this PR in core sdk to skip hashing when the value is an array.
Do we want to officially support hashing arrays, given that it currently just converts the array to a comma-separated string before hashing?

@jaissica12 jaissica12 requested a review from rmi22186 January 21, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants