feat: Add hashAttributes method#24
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a hashedAttributes method to pass attributes directly to the Rokt launcher's hashedAttributes function and adds an isInitialized helper to ensure the kit is ready. Key changes include new tests for the hashedAttributes functionality, error logging when the kit is not initialized, and integration of the new method into the kit.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/src/tests.js | Added tests for verifying the hashedAttributes behavior and error logging. |
| src/Rokt-Kit.js | Introduced the hashedAttributes method and isInitialized helper into the kit. |
Comments suppressed due to low confidence (1)
test/src/tests.js:257
- Consider storing the original console.error and restoring it after the test to prevent side effects in other tests.
window.console.error = function (message) {
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new hashAttributes method to support server-side hashing of attributes via the Rokt Web SDK and improves kit initialization handling. Key changes include:
- Adding the hashAttributes method and its tests for various initialization states.
- Introducing a new isInitialized helper to validate kit readiness.
- Adjusting the kit and launcher integration to gracefully handle uninitialized states.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/src/tests.js | New test cases for hashAttributes covering initialized and error states. |
| src/Rokt-Kit.js | New hashAttributes method and reordering of callback assignments to integrate it. |
…ethods with relevant links and parameter details
Co-authored-by: Robert Ing <ring@mparticle.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements a new hashAttributes method that passes attribute objects to the Rokt launcher for client-side hashing while ensuring proper kit initialization through a new helper.
- Added hashAttributes method and isInitialized helper in Rokt-Kit.js
- Introduced comprehensive tests in test/src/tests.js covering various initialization scenarios
- Added error handling for cases where the kit is uninitialized or the launcher is missing
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/src/tests.js | Added tests to validate the behavior of hashAttributes under different initialization states |
| src/Rokt-Kit.js | Implemented the hashAttributes method and the helper isInitialized to manage kit readiness |
Files not reviewed (1)
- package.json: Language not supported
Comments suppressed due to low confidence (1)
src/Rokt-Kit.js:272
- [nitpick] Consider renaming the helper function isInitialized() to differentiate it from the self.isInitialized property to avoid potential confusion.
function isInitialized() {
# [1.3.0](v1.2.1...v1.3.0) (2025-04-22) ### Features * Add hashAttributes method ([#24](#24)) ([8418e83](8418e83))
Summary
Requires mParticle/mparticle-web-sdk#1021 to be released.
Testing Plan
Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)