-
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
Open
jaissica12
wants to merge
6
commits into
main
Choose a base branch
from
feat/SDKE-786-log-custom-event-for-selectPlacements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
477b9ae
feat: log custom event logging for selectPlacement
jaissica12 2a0a5f3
add check in logSelectPlacementsEvent
jaissica12 f81b579
rename devPassedAttributes to debugAttributes, add helper to stringif…
jaissica12 5297654
fix typo and update tests
jaissica12 3bb1261
rename debugAttributes to initialAttributes and selectPlacementsAttri…
jaissica12 f76a5f9
cleanup EVENT_TYPE_OTHER var
jaissica12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| var name = 'Rokt'; | ||||||||||||||||||||||
| var moduleId = 181; | ||||||||||||||||||||||
| var EVENT_NAME_SELECT_PLACEMENTS = 'selectplacements'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var constructor = function () { | ||||||||||||||||||||||
| var self = this; | ||||||||||||||||||||||
|
|
@@ -199,10 +200,12 @@ var constructor = function () { | |||||||||||||||||||||
| * @param {Object} options - The options object for selecting placements containing: | ||||||||||||||||||||||
| * - identifier {string}: The placement identifier | ||||||||||||||||||||||
| * - attributes {Object}: Optional attributes to merge with existing attributes | ||||||||||||||||||||||
| * - initialAttributes {Object}: Original attributes passed by developer | ||||||||||||||||||||||
| * @returns {Promise<void>} A Promise resolving to the Rokt launcher's selectPlacements method with processed attributes | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| function selectPlacements(options) { | ||||||||||||||||||||||
| var attributes = (options && options.attributes) || {}; | ||||||||||||||||||||||
| var initialAttributes = (options && options.initialAttributes) || {}; | ||||||||||||||||||||||
alexs-mparticle marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| var placementAttributes = mergeObjects(self.userAttributes, attributes); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var filters = self.filters || {}; | ||||||||||||||||||||||
|
|
@@ -255,9 +258,46 @@ var constructor = function () { | |||||||||||||||||||||
| attributes: selectPlacementsAttributes, | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Log custom event for selectPlacements call | ||||||||||||||||||||||
| logSelectPlacementsEvent(initialAttributes, selectPlacementsAttributes); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return self.launcher.selectPlacements(selectPlacementsOptions); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Logs a custom event when selectPlacements is called | ||||||||||||||||||||||
| * This enables visibility and troubleshooting | ||||||||||||||||||||||
| * @param {Object} initialAttributes - The attributes passed by the developer | ||||||||||||||||||||||
| * @param {Object} selectPlacementsAttributes - The final merged attributes sent to Rokt | ||||||||||||||||||||||
| */ | ||||||||||||||||||||||
| function logSelectPlacementsEvent( | ||||||||||||||||||||||
| initialAttributes, | ||||||||||||||||||||||
| selectPlacementsAttributes | ||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| if ( | ||||||||||||||||||||||
| !window.mParticle || | ||||||||||||||||||||||
| typeof window.mParticle.logEvent !== 'function' | ||||||||||||||||||||||
jaissica12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| ) { | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var EVENT_TYPE_OTHER = window.mParticle.EventType.Other; | ||||||||||||||||||||||
jaissica12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Build event attributes with both passed and final attributes as JSON strings | ||||||||||||||||||||||
| // initialAttributes: attributes passed by the developer | ||||||||||||||||||||||
| // finalAttributes: final attributes sent to selectPlacements | ||||||||||||||||||||||
| var eventAttributes = { | ||||||||||||||||||||||
| initialAttributes: stringifyIfObject(initialAttributes), | ||||||||||||||||||||||
| finalAttributes: stringifyIfObject(selectPlacementsAttributes), | ||||||||||||||||||||||
| }; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| window.mParticle.logEvent( | ||||||||||||||||||||||
| EVENT_NAME_SELECT_PLACEMENTS, | ||||||||||||||||||||||
| EVENT_TYPE_OTHER, | ||||||||||||||||||||||
| eventAttributes | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
jaissica12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Enables optional Integration Launcher extensions before selecting placements | ||||||||||||||||||||||
| * @param {string} extensionName - Name of the extension to enable | ||||||||||||||||||||||
|
|
@@ -580,6 +620,10 @@ function isEmpty(value) { | |||||||||||||||||||||
| return value == null || !(Object.keys(value) || value).length; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| function stringifyIfObject(value) { | ||||||||||||||||||||||
| return isObject(value) ? JSON.stringify(value) : '{}'; | ||||||||||||||||||||||
|
||||||||||||||||||||||
| return isObject(value) ? JSON.stringify(value) : '{}'; | |
| if (!isObject(value)) { | |
| return '{}'; | |
| } | |
| try { | |
| return JSON.stringify(value); | |
| } catch (e) { | |
| return '{}'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.