Skip to content

Conversation

@jaissica12
Copy link
Contributor

@jaissica12 jaissica12 commented Nov 17, 2025

Background

  • Added hashSha256 method and related helpers to provide SHA-256 hashing functionality for advertisers using the mParticle Web SDK without requiring the Rokt Kit dependency.
  • Code reference: attribute-service , hash-string, rokt-docs

What Has Changed

  • Added hashSha256 method
  • Added unit tests for hashing. Referred the same test cases from sdk-webto compare the hashed values

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)

@jaissica12 jaissica12 marked this pull request as ready for review November 17, 2025 16:28
@jaissica12 jaissica12 requested a review from rmi22186 November 17, 2025 16:30
*/
public async hashSha256(attribute: string | number | boolean | undefined | null): Promise<string> {
if (attribute === undefined || attribute === null) {
throw new Error('Value cannot be null or undefined');
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. i worry this will cause more harm than good in crashing the current loop/thread. our typical pattern would be to log an error or warning.
  2. I would also make the argument that there's nothing wrong with passing a null or undefined into this particular method. The method is able to act on the value passed in - it should just respond with the attribute (which is either null or undefined).

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 for the feedback about logging pattern. Updated the code:

  • For null/undefined inputs: Returns the value as-is with a logger.warning
  • For hash failures: Returns undefined with a logger.error

@jaissica12 jaissica12 requested a review from samdozor November 20, 2025 17:08
}

/**
* Hashes an attribute using SHA-256
Copy link
Member

Choose a reason for hiding this comment

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

One of the acceptance criteria is to embed the wSDK hashAttributes on line 255 for advertisers since they don't have the Rokt kit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

@sonarqubecloud
Copy link

@jaissica12 jaissica12 requested a review from rmi22186 November 24, 2025 20:35
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.

4 participants