Skip to content

feat: Add hashAttributes method#24

Merged
alexs-mparticle merged 8 commits into
developmentfrom
feat/SQDSDKS-7231-hashed-attributes
Apr 22, 2025
Merged

feat: Add hashAttributes method#24
alexs-mparticle merged 8 commits into
developmentfrom
feat/SQDSDKS-7231-hashed-attributes

Conversation

@alexs-mparticle
Copy link
Copy Markdown
Collaborator

@alexs-mparticle alexs-mparticle commented Apr 17, 2025

Summary

  • Direct passthrough to launcher's hashAttributes method
  • New isInitialized helper to ensure kit readiness
  • Comprehensive test coverage for initialization states
  • Error handling for uninitialized states

Requires mParticle/mparticle-web-sdk#1021 to be released.

Testing Plan

  • Verify direct passthrough of attributes when kit is fully initialized
  • Verify null return when launcher exists but kit is not initialized
  • Verify error logging when called before initialization
  • Verify null return when kit is initialized but launcher is missing
  • Verify return of hashed attributes from launcher

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

@alexs-mparticle alexs-mparticle requested a review from Copilot April 17, 2025 21:40
Copy link
Copy Markdown
Contributor

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 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) {

Comment thread src/Rokt-Kit.js Outdated
@alexs-mparticle alexs-mparticle marked this pull request as ready for review April 18, 2025 18:39
@alexs-mparticle alexs-mparticle changed the title feat: Add hashedAttributes method feat: Add hashAttributes method Apr 18, 2025
@alexs-mparticle alexs-mparticle changed the base branch from main to development April 18, 2025 18:46
@alexs-mparticle alexs-mparticle requested a review from Copilot April 18, 2025 18:48
Copy link
Copy Markdown
Contributor

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 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.

Comment thread src/Rokt-Kit.js Outdated
Copy link
Copy Markdown
Collaborator

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

minor nits

Comment thread src/Rokt-Kit.js Outdated
Comment thread test/src/tests.js Outdated
Comment thread test/src/tests.js
alexs-mparticle and others added 2 commits April 21, 2025 14:48
Co-authored-by: Robert Ing <ring@mparticle.com>
Copy link
Copy Markdown
Contributor

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 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() {

@alexs-mparticle alexs-mparticle merged commit 8418e83 into development Apr 22, 2025
4 checks passed
github-actions Bot pushed a commit that referenced this pull request Apr 22, 2025
# [1.3.0](v1.2.1...v1.3.0) (2025-04-22)

### Features

* Add hashAttributes method ([#24](#24)) ([8418e83](8418e83))
@alexs-mparticle alexs-mparticle deleted the feat/SQDSDKS-7231-hashed-attributes branch March 25, 2026 15:15
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