From 30ffaafb4941a9ade01c11073250ad6816ff54db Mon Sep 17 00:00:00 2001 From: namArora3112 Date: Tue, 2 Sep 2025 09:54:17 +0530 Subject: [PATCH 1/3] PropositionItem class added along with unified track functionality (#507) * proposition item classes, track funcitonality etc * proposition item uuid added * json proposition item removed * removed unused guide * added htmlProposition , jsonPropositon item class * removed unused apis of content card * generatePropositionInteractionXdm removed * ios implementation of track functionality * uuid vs proposition map added * MessagingProposition class fixes * get proposition for surfaces android fixes * ios get proposition for surface fixes * getproposition for surface updates * MessagingView commented code removed * removed proposition cache with parent * clear cache in update proposition * message util clean up * proposition Item tracking usage refactored * activityID extraction function reusable * white space fixes * added read me for track api usage * removed unnecessary checks before calling track api for android native * refactored extra null checks before calling track api at ios native side * Addeed ios and android logs for null cases * added comments and logs for android native code * marked the trackContentCardInteraction and trackContentCardDisplay as deprecated * added tests for propositionItem.track * read me updated for proposition Item track usage --------- Co-authored-by: Naman Arora --- .../app/MessagingView.tsx | 42 ++++- packages/messaging/README.md | 51 +++++++ .../__tests__/PropositionItemTests.ts | 84 ++++++++++ .../messaging/RCTAEPMessagingModule.java | 143 +++++++++++++++--- .../messaging/RCTAEPMessagingUtil.java | 2 +- packages/messaging/ios/src/RCTAEPMessaging.mm | 8 + .../messaging/ios/src/RCTAEPMessaging.swift | 104 ++++++++++++- .../ios/src/RCTAEPMessagingDataBridge.swift | 19 +++ packages/messaging/src/Messaging.ts | 21 ++- packages/messaging/src/index.ts | 18 ++- packages/messaging/src/models/ContentCard.ts | 13 +- .../messaging/src/models/HTMLProposition.ts | 21 ++- ...NPropositionItem.ts => JSONProposition.ts} | 21 ++- .../src/models/MessagingProposition.ts | 48 +++++- .../src/models/MessagingPropositionItem.ts | 8 +- .../messaging/src/models/PropositionItem.ts | 135 +++++++++++++++++ tests/jest/setup.ts | 1 + 17 files changed, 685 insertions(+), 54 deletions(-) create mode 100644 packages/messaging/__tests__/PropositionItemTests.ts rename packages/messaging/src/models/{JSONPropositionItem.ts => JSONProposition.ts} (62%) create mode 100644 packages/messaging/src/models/PropositionItem.ts diff --git a/apps/AEPSampleAppNewArchEnabled/app/MessagingView.tsx b/apps/AEPSampleAppNewArchEnabled/app/MessagingView.tsx index 270d5adbf..a53109f9b 100644 --- a/apps/AEPSampleAppNewArchEnabled/app/MessagingView.tsx +++ b/apps/AEPSampleAppNewArchEnabled/app/MessagingView.tsx @@ -13,13 +13,24 @@ governing permissions and limitations under the License. import React from 'react'; import {Button, Text, View, ScrollView} from 'react-native'; import {MobileCore} from '@adobe/react-native-aepcore'; -import {Messaging, PersonalizationSchema} from '@adobe/react-native-aepmessaging' +import { + Messaging, + PersonalizationSchema, + MessagingEdgeEventType, + PropositionItem, + Message, + ContentCard, + HTMLProposition, + JSONPropositionItem +} from '@adobe/react-native-aepmessaging' +import { MessagingProposition } from '@adobe/react-native-aepmessaging'; import styles from '../styles/styles'; import { useRouter } from 'expo-router'; const SURFACES = ['android-cbe-preview', 'cbe/json', 'android-cc']; const SURFACES_WITH_CONTENT_CARDS = ['android-cc']; + const messagingExtensionVersion = async () => { const version = await Messaging.extensionVersion(); console.log(`AdobeExperienceSDK: Messaging version: ${version}`); @@ -40,12 +51,10 @@ const setMessagingDelegate = () => { }); console.log('messaging delegate set'); }; - const getPropositionsForSurfaces = async () => { const messages = await Messaging.getPropositionsForSurfaces(SURFACES); console.log(JSON.stringify(messages)); }; - const trackAction = async () => { MobileCore.trackAction('tuesday', {full: true}); }; @@ -75,7 +84,8 @@ const trackContentCardInteraction = async () => { for (const proposition of propositions) { for (const propositionItem of proposition.items) { if (propositionItem.schema === PersonalizationSchema.CONTENT_CARD) { - Messaging.trackContentCardInteraction(proposition, propositionItem); + // Cast to ContentCard for the legacy tracking method + Messaging.trackContentCardInteraction(proposition, propositionItem as any); console.log('trackContentCardInteraction', proposition, propositionItem); } } @@ -93,7 +103,8 @@ const trackContentCardDisplay = async () => { for (const proposition of propositions) { for (const propositionItem of proposition.items) { if (propositionItem.schema === PersonalizationSchema.CONTENT_CARD) { - Messaging.trackContentCardDisplay(proposition, propositionItem); + // Cast to ContentCard for the legacy tracking method + Messaging.trackContentCardDisplay(proposition, propositionItem as any); console.log('trackContentCardDisplay', proposition, propositionItem); } } @@ -101,6 +112,26 @@ const trackContentCardDisplay = async () => { } } + +// Method demonstrating unified tracking using PropositionItem methods +const unifiedTrackingExample = async () => { + const messages = await Messaging.getPropositionsForSurfaces(SURFACES); + for (const surface of SURFACES) { + const propositions = messages[surface] || []; + + for (const proposition of propositions) { + const propositionWrapper = new MessagingProposition(proposition); + if (propositionWrapper.items.length > 0) { + const propositionItem = propositionWrapper.items[0]; + propositionItem.track(MessagingEdgeEventType.DISPLAY); + propositionItem.track('content_card_clicked', MessagingEdgeEventType.INTERACT, null); + } + } + } +} + + + function MessagingView() { const router = useRouter(); @@ -125,6 +156,7 @@ function MessagingView() {