-
Notifications
You must be signed in to change notification settings - Fork 1
feat: log custom event logging for selectPlacement #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: log custom event logging for selectPlacement #52
Conversation
There was a problem hiding this 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
logSelectPlacementsEventfunction that logs custom events with both original and final attributes as JSON strings - Modified
selectPlacementsto accept and trackdevPassedAttributesparameter - 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.
There was a problem hiding this 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.
…y object and update tests
There was a problem hiding this 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.
…butes to finalAttributes
There was a problem hiding this 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 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // limitations under the License. | ||
|
|
||
| var name = 'Rokt'; | ||
| var moduleId = 181; |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event name 'selectplacements' is all lowercase without spaces. Consider using a more conventional format like 'Select Placements' (Title Case), 'selectPlacements' (camelCase), or 'select_placements' (snake_case) for better readability and consistency with typical event naming conventions. If this specific format is intentional (e.g., for compatibility with external systems), consider adding a comment explaining why.
| var moduleId = 181; | |
| var moduleId = 181; | |
| // The event name must remain in this exact lowercase format to match Rokt's expected event identifier. |
| } | ||
|
|
||
| function stringifyIfObject(value) { | ||
| return isObject(value) ? JSON.stringify(value) : '{}'; |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON.stringify can throw an error if the object contains circular references or other non-serializable values. Consider wrapping this in a try-catch block to handle such cases gracefully, or document that the caller should ensure attributes are JSON-serializable.
| return isObject(value) ? JSON.stringify(value) : '{}'; | |
| if (!isObject(value)) { | |
| return '{}'; | |
| } | |
| try { | |
| return JSON.stringify(value); | |
| } catch (e) { | |
| return '{}'; | |
| } |
Summary
Testing Plan