Skip to content

Conversation

@jaissica12
Copy link
Contributor

@jaissica12 jaissica12 commented Jan 16, 2026

Summary

  • Adde mParticle custom event logging (Other type) every time selectPlacements is called
  • WILL CHANGE THE TARGET BRANCH WHEN MAIN AND DEVELOPMENT ARE IN SYNC

Testing Plan

  • Added unit tests

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 adds mParticle custom event logging to track every selectPlacements call for improved visibility and troubleshooting. Each time selectPlacements is invoked, a custom event of type "Other" (EventType 8) is logged with both the developer-passed attributes and the final merged attributes sent to Rokt.

Changes:

  • Added a new logSelectPlacementsEvent function that logs custom events with both original and final attributes as JSON strings
  • Modified selectPlacements to accept and track devPassedAttributes parameter
  • Added comprehensive unit tests for the new logging functionality

Reviewed changes

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

File Description
src/Rokt-Kit.js Added constant for event name, modified selectPlacements to capture devPassedAttributes, and implemented logSelectPlacementsEvent function
test/src/tests.js Added mParticle.logEvent mock and comprehensive test suite covering various scenarios for the new logging functionality

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

@jaissica12 jaissica12 changed the base branch from main to development January 16, 2026 22:02
@jaissica12 jaissica12 changed the base branch from development to main January 16, 2026 22:04
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 4 comments.


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

Comment on lines +293 to +304
var eventAttributes = {
devPassedAttributes: JSON.stringify(devPassedAttributes || {}),
selectPlacementsAttributes: JSON.stringify(
selectPlacementsAttributes || {}
),
};

window.mParticle.logEvent(
EVENT_NAME_SELECT_PLACEMENTS,
EVENT_TYPE_OTHER,
eventAttributes
);
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The JSON.stringify calls on lines 294 and 295-296 could potentially throw an error if the attributes objects contain circular references, BigInt values, or other non-serializable data. While this is unlikely in typical usage, consider wrapping these calls in a try-catch block to prevent the logging from breaking the selectPlacements flow.

For example:

try {
    var eventAttributes = {
        devPassedAttributes: JSON.stringify(devPassedAttributes || {}),
        selectPlacementsAttributes: JSON.stringify(selectPlacementsAttributes || {})
    };
    window.mParticle.logEvent(EVENT_NAME_SELECT_PLACEMENTS, EVENT_TYPE_OTHER, eventAttributes);
} catch (error) {
    console.error('Error logging selectPlacements event:', error);
}
Suggested change
var eventAttributes = {
devPassedAttributes: JSON.stringify(devPassedAttributes || {}),
selectPlacementsAttributes: JSON.stringify(
selectPlacementsAttributes || {}
),
};
window.mParticle.logEvent(
EVENT_NAME_SELECT_PLACEMENTS,
EVENT_TYPE_OTHER,
eventAttributes
);
try {
var eventAttributes = {
devPassedAttributes: JSON.stringify(devPassedAttributes || {}),
selectPlacementsAttributes: JSON.stringify(
selectPlacementsAttributes || {}
),
};
window.mParticle.logEvent(
EVENT_NAME_SELECT_PLACEMENTS,
EVENT_TYPE_OTHER,
eventAttributes
);
} catch (error) {
// Ensure logging issues do not break the selectPlacements flow
console.error('Rokt Kit: Error logging selectPlacements event:', error);
}

Copilot uses AI. Check for mistakes.
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.

2 participants