@@ -13,11 +13,12 @@ governing permissions and limitations under the License.
1313import React from 'react' ;
1414import { Button , Text , View , ScrollView } from 'react-native' ;
1515import { MobileCore } from '@adobe/react-native-aepcore' ;
16- import { Messaging } from '@adobe/react-native-aepmessaging'
16+ import { Messaging , PersonalizationSchema } from '@adobe/react-native-aepmessaging'
1717import styles from '../styles/styles' ;
1818import { useRouter } from 'expo-router' ;
1919
20- const SURFACES = [ 'android-cb-preview' ] ;
20+ const SURFACES = [ 'android-cbe-preview' , 'cbe/json' , 'android-cc' ] ;
21+ const SURFACES_WITH_CONTENT_CARDS = [ 'android-cc' ] ;
2122
2223const messagingExtensionVersion = async ( ) => {
2324 const version = await Messaging . extensionVersion ( ) ;
@@ -64,6 +65,42 @@ const getLatestMessage = async () => {
6465 console . log ( 'Latest Message:' , message ) ;
6566} ;
6667
68+ // this method can be used to track click interactions with content cards
69+ const trackContentCardInteraction = async ( ) => {
70+ const messages = await Messaging . getPropositionsForSurfaces ( SURFACES_WITH_CONTENT_CARDS ) ;
71+
72+ for ( const surface of SURFACES_WITH_CONTENT_CARDS ) {
73+ const propositions = messages [ surface ] || [ ] ;
74+
75+ for ( const proposition of propositions ) {
76+ for ( const propositionItem of proposition . items ) {
77+ if ( propositionItem . schema === PersonalizationSchema . CONTENT_CARD ) {
78+ Messaging . trackContentCardInteraction ( proposition , propositionItem ) ;
79+ console . log ( 'trackContentCardInteraction' , proposition , propositionItem ) ;
80+ }
81+ }
82+ }
83+ }
84+ }
85+
86+ // this method can be used to track display interactions with content cards
87+ const trackContentCardDisplay = async ( ) => {
88+ const messages = await Messaging . getPropositionsForSurfaces ( SURFACES_WITH_CONTENT_CARDS ) ;
89+
90+ for ( const surface of SURFACES_WITH_CONTENT_CARDS ) {
91+ const propositions = messages [ surface ] || [ ] ;
92+
93+ for ( const proposition of propositions ) {
94+ for ( const propositionItem of proposition . items ) {
95+ if ( propositionItem . schema === PersonalizationSchema . CONTENT_CARD ) {
96+ Messaging . trackContentCardDisplay ( proposition , propositionItem ) ;
97+ console . log ( 'trackContentCardDisplay' , proposition , propositionItem ) ;
98+ }
99+ }
100+ }
101+ }
102+ }
103+
67104function MessagingView ( ) {
68105 const router = useRouter ( ) ;
69106
@@ -86,6 +123,8 @@ function MessagingView() {
86123 < Button title = "getCachedMessages()" onPress = { getCachedMessages } />
87124 < Button title = "getLatestMessage()" onPress = { getLatestMessage } />
88125 < Button title = "trackAction()" onPress = { trackAction } />
126+ < Button title = "trackPropositionInteraction()" onPress = { trackContentCardInteraction } />
127+ < Button title = "trackContentCardDisplay()" onPress = { trackContentCardDisplay } />
89128 </ ScrollView >
90129 </ View >
91130 ) ;
0 commit comments