-
Notifications
You must be signed in to change notification settings - Fork 38
PropositionItem class added along with unified track functionality #507
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
Merged
namArora3112
merged 28 commits into
feat/messagingEnhancements-7.2.0
from
proposition-item-class
Sep 2, 2025
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
02a791a
proposition item classes, track funcitonality etc
af23662
proposition item uuid added
c8ccc75
json proposition item removed
a17849a
removed unused guide
3e36a29
added htmlProposition , jsonPropositon item class
8e5f825
removed unused apis of content card
1ef7a89
generatePropositionInteractionXdm removed
ef8977d
ios implementation of track functionality
fc21588
uuid vs proposition map added
cf02267
MessagingProposition class fixes
911271c
get proposition for surfaces android fixes
c116f69
ios get proposition for surface fixes
0fe8633
getproposition for surface updates
77a0b2d
MessagingView commented code removed
61c6c4d
removed proposition cache with parent
93c3d13
clear cache in update proposition
d70c369
message util clean up
13a2c87
proposition Item tracking usage refactored
1a78103
activityID extraction function reusable
b2c6bd0
white space fixes
d2f7f02
added read me for track api usage
2739a9e
removed unnecessary checks before calling track api for android native
b4ad0c2
refactored extra null checks before calling track api at ios native side
8a6c41e
Addeed ios and android logs for null cases
732db7d
added comments and logs for android native code
dd28137
marked the trackContentCardInteraction and trackContentCardDisplay as…
91d3dbc
added tests for propositionItem.track
4c4e2ec
read me updated for proposition Item track usage
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
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
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 |
|---|---|---|
|
|
@@ -201,6 +201,53 @@ for (let item in proposition.items) { | |
| } | ||
| ``` | ||
|
|
||
|
|
||
| ### PropositionItem.track | ||
|
|
||
| A unified tracking API is available for any proposition item (Content Cards, HTML, JSON, code-based items). You can use the same track() method regardless of content type, making your code more consistent and maintainable. | ||
|
|
||
| #### Using PropositionItem.track (recommended) | ||
|
|
||
| **Syntax** | ||
|
|
||
| ```javascript | ||
| // Track display event | ||
| propositionItem.track(MessagingEdgeEventType.DISPLAY); | ||
|
|
||
| // Track interaction with custom data + event + optional tokens | ||
| propositionItem.track( | ||
| interaction /* string | null */, | ||
| MessagingEdgeEventType.INTERACT /* enum value */, | ||
| [/* tokens */] /* string[] | null */ | ||
| ); | ||
| ``` | ||
|
|
||
| When using `getPropositionsForSurfaces`, the returned objects can be wrapped with `MessagingProposition` to get typed items and convenient tracking via `PropositionItem.track(...)`. | ||
|
|
||
| ```javascript | ||
| import { Messaging, MessagingProposition, MessagingEdgeEventType } from '@adobe/react-native-aepmessaging'; | ||
|
|
||
| const SURFACES = ['mobileapp://my-surface']; | ||
| const messages = await Messaging.getPropositionsForSurfaces(SURFACES); | ||
|
|
||
| for (const surface of SURFACES) { | ||
| const propositions = messages[surface] || []; | ||
|
|
||
| for (const proposition of propositions) { | ||
| const msgProp = new MessagingProposition(proposition); | ||
|
|
||
| if (msgProp.items.length > 0) { | ||
| const propositionItem = msgProp.items[0]; | ||
|
|
||
| // Track interaction with custom data | ||
| propositionItem.track('content_card_clicked', MessagingEdgeEventType.INTERACT, null); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: there is an extra space before They are not align with the next // Track .... |
||
| // Track with tokens for sub-item tracking | ||
| propositionItem.track('button_click', MessagingEdgeEventType.INTERACT, ['token-1', 'token-2']); | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### getLatestMessage | ||
|
|
||
| Retrieves the most recently displayed message object | ||
|
|
@@ -440,6 +487,8 @@ function otherWorkflowFinished() { | |
|
|
||
| ### trackContentCardDisplay | ||
|
|
||
| Deprecated: Use `PropositionItem.track(...)` instead. This API will be removed in a future release. | ||
|
|
||
| Tracks a Display interaction with the given ContentCard | ||
|
|
||
| **Syntax** | ||
|
|
@@ -449,6 +498,8 @@ Messaging.trackContentCardDisplay(proposition, contentCard); | |
|
|
||
| ### trackContentCardInteraction | ||
|
|
||
| Deprecated: Use `PropositionItem.track(...)` instead. This API will be removed in a future release. | ||
|
|
||
| Tracks a Click interaction with the given ContentCard | ||
|
|
||
| **Syntax** | ||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| /* | ||
| Copyright 2025 Adobe. All rights reserved. | ||
| This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. You may obtain a copy | ||
| of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under | ||
| the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| OF ANY KIND, either express or implied. See the License for the specific language | ||
| governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import { NativeModules } from 'react-native'; | ||
| import { MessagingEdgeEventType, PropositionItem, PropositionItemData, PersonalizationSchema } from '../src'; | ||
|
|
||
| describe('PropositionItem', () => { | ||
| const uuid = 'activity-uuid-123'; | ||
| const id = 'item-abc'; | ||
| const activityID = uuid; // mirrors native mapping | ||
|
|
||
| const baseData: PropositionItemData = { | ||
| id, | ||
| uuid, | ||
| activityID, | ||
| schema: PersonalizationSchema.CONTENT_CARD, | ||
| data: { foo: 'bar' }, | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('track(eventType) calls native with null interaction and tokens', () => { | ||
| const item = new PropositionItem(baseData); | ||
| item.track(MessagingEdgeEventType.DISPLAY); | ||
|
|
||
| expect(NativeModules.AEPMessaging.trackPropositionItem).toHaveBeenCalledWith( | ||
| activityID, | ||
| null, | ||
| MessagingEdgeEventType.DISPLAY, | ||
| null | ||
| ); | ||
| }); | ||
|
|
||
| it('track(interaction, eventType, tokens=null) forwards interaction', () => { | ||
| const item = new PropositionItem(baseData); | ||
| item.track('click', MessagingEdgeEventType.INTERACT, null); | ||
|
|
||
| expect(NativeModules.AEPMessaging.trackPropositionItem).toHaveBeenCalledWith( | ||
| activityID, | ||
| 'click', | ||
| MessagingEdgeEventType.INTERACT, | ||
| null | ||
| ); | ||
| }); | ||
|
|
||
| it('track(interaction, eventType, tokens[]) forwards tokens array', () => { | ||
| const item = new PropositionItem(baseData); | ||
| const tokens = ['t1', 't2']; | ||
| item.track('click', MessagingEdgeEventType.INTERACT, tokens); | ||
|
|
||
| expect(NativeModules.AEPMessaging.trackPropositionItem).toHaveBeenCalledWith( | ||
| activityID, | ||
| 'click', | ||
| MessagingEdgeEventType.INTERACT, | ||
| tokens | ||
| ); | ||
| }); | ||
|
|
||
| it('track(null, eventType, tokens[]) supports null interaction with tokens', () => { | ||
| const item = new PropositionItem(baseData); | ||
| const tokens = ['a']; | ||
| item.track(null, MessagingEdgeEventType.DISPLAY, tokens); | ||
|
|
||
| expect(NativeModules.AEPMessaging.trackPropositionItem).toHaveBeenCalledWith( | ||
| activityID, | ||
| null, | ||
| MessagingEdgeEventType.DISPLAY, | ||
| tokens | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
|
|
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.
If you plan to deprecate this method trackContentCardDisplay
let's just mark it and the we might also have to update the documentation
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.
yes have added in the typescript and also in documentation too