-
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.
| var eventAttributes = { | ||
| devPassedAttributes: JSON.stringify(devPassedAttributes || {}), | ||
| selectPlacementsAttributes: JSON.stringify( | ||
| selectPlacementsAttributes || {} | ||
| ), | ||
| }; | ||
|
|
||
| window.mParticle.logEvent( | ||
| EVENT_NAME_SELECT_PLACEMENTS, | ||
| EVENT_TYPE_OTHER, | ||
| eventAttributes | ||
| ); |
Copilot
AI
Jan 16, 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 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);
}| 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); | |
| } |
Summary
Testing Plan