@@ -693,7 +693,7 @@ describe('PredictAnalytics', () => {
693693 } ) ;
694694 } ) ;
695695
696- it ( 'tracks feed viewed with session end defaulting to false ' , ( ) => {
696+ it ( 'tracks feed viewed with session fields when provided ' , ( ) => {
697697 predictAnalytics . trackFeedViewed ( {
698698 sessionId : 's1' ,
699699 feedTab : 'trending' ,
@@ -702,6 +702,7 @@ describe('PredictAnalytics', () => {
702702 numPagesViewed : 3 ,
703703 sessionTime : 98 ,
704704 entryPoint : 'carousel' ,
705+ isSessionEnd : false ,
705706 portfolioModuleEnabled : true ,
706707 } ) ;
707708
@@ -771,39 +772,6 @@ describe('PredictAnalytics', () => {
771772 } ) ;
772773 } ) ;
773774
774- it ( 'tracks category clicked with category name and entry point' , ( ) => {
775- predictAnalytics . trackCategoryClicked ( {
776- categoryName : 'politics' ,
777- entryPoint : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
778- } ) ;
779-
780- const event = getTrackedEvent ( ) ;
781-
782- expect ( event . name ) . toBe (
783- MetaMetricsEvents . PREDICT_CATEGORY_CLICKED . category ,
784- ) ;
785- expect ( event . properties ) . toMatchObject ( {
786- category_name : 'politics' ,
787- entry_point : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
788- } ) ;
789- } ) ;
790-
791- it ( 'tracks category clicked without an entry point' , ( ) => {
792- predictAnalytics . trackCategoryClicked ( {
793- categoryName : 'sports' ,
794- } ) ;
795-
796- const event = getTrackedEvent ( ) ;
797-
798- expect ( event . name ) . toBe (
799- MetaMetricsEvents . PREDICT_CATEGORY_CLICKED . category ,
800- ) ;
801- expect ( event . properties ) . toMatchObject ( {
802- category_name : 'sports' ,
803- } ) ;
804- expect ( event . properties ) . not . toHaveProperty ( 'entry_point' ) ;
805- } ) ;
806-
807775 it ( 'tracks share action with optional market fields' , ( ) => {
808776 predictAnalytics . trackShareAction ( {
809777 status : PredictShareStatus . SUCCESS ,
@@ -916,5 +884,171 @@ describe('PredictAnalytics', () => {
916884 entry_point : 'home_section' ,
917885 } ) ;
918886 } ) ;
887+
888+ it ( 'tracks generic feed viewed with feed/tab/filter ids and no session fields' , ( ) => {
889+ predictAnalytics . trackFeedViewed ( {
890+ feedId : 'sports' ,
891+ tabId : 'basketball' ,
892+ filterId : 'live' ,
893+ entryPoint : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
894+ } ) ;
895+
896+ const feedEvent = getTrackEventMock ( ) . mock . calls [ 0 ] [ 0 ] as TrackedEvent ;
897+
898+ expect ( feedEvent . name ) . toBe (
899+ MetaMetricsEvents . PREDICT_FEED_VIEWED . category ,
900+ ) ;
901+ expect ( feedEvent . properties ) . toMatchObject ( {
902+ feed_id : 'sports' ,
903+ tab_id : 'basketball' ,
904+ filter_id : 'live' ,
905+ entry_point : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
906+ } ) ;
907+ // Lightweight one-shot path omits every session-only field.
908+ expect ( feedEvent . properties ) . not . toHaveProperty ( 'session_id' ) ;
909+ expect ( feedEvent . properties ) . not . toHaveProperty ( 'is_session_end' ) ;
910+ expect ( feedEvent . properties ) . not . toHaveProperty ( 'predict_feed_tab' ) ;
911+ expect ( feedEvent . properties ) . not . toHaveProperty (
912+ 'num_feed_pages_viewed_in_session' ,
913+ ) ;
914+ } ) ;
915+
916+ it ( 'tracks home viewed with entry point' , ( ) => {
917+ predictAnalytics . trackHomeViewed ( {
918+ entryPoint : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
919+ } ) ;
920+
921+ const event = getTrackedEvent ( ) ;
922+
923+ expect ( event . name ) . toBe ( MetaMetricsEvents . PREDICT_HOME_VIEWED . category ) ;
924+ expect ( event . properties ) . toEqual ( {
925+ entry_point : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
926+ } ) ;
927+ } ) ;
928+
929+ it ( 'tracks home viewed with no properties when entry point is unknown' , ( ) => {
930+ predictAnalytics . trackHomeViewed ( { } ) ;
931+
932+ const event = getTrackedEvent ( ) ;
933+
934+ expect ( event . name ) . toBe ( MetaMetricsEvents . PREDICT_HOME_VIEWED . category ) ;
935+ expect ( event . properties ) . toEqual ( { } ) ;
936+ } ) ;
937+
938+ it ( 'tracks a home section viewed impression' , ( ) => {
939+ predictAnalytics . trackHomeSectionInteraction ( {
940+ sectionId : PredictEventValues . SECTION_ID . TRENDING ,
941+ actionType : PredictEventValues . ACTION_TYPE . VIEWED ,
942+ entryPoint : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
943+ } ) ;
944+
945+ const event = getTrackedEvent ( ) ;
946+
947+ expect ( event . name ) . toBe (
948+ MetaMetricsEvents . PREDICT_HOME_SECTION_INTERACTION . category ,
949+ ) ;
950+ expect ( event . properties ) . toEqual ( {
951+ section_id : PredictEventValues . SECTION_ID . TRENDING ,
952+ action_type : PredictEventValues . ACTION_TYPE . VIEWED ,
953+ entry_point : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
954+ } ) ;
955+ } ) ;
956+
957+ it ( 'tracks a home section see-all tap' , ( ) => {
958+ predictAnalytics . trackHomeSectionInteraction ( {
959+ sectionId : PredictEventValues . SECTION_ID . LIVE_NOW ,
960+ actionType : PredictEventValues . ACTION_TYPE . SEE_ALL ,
961+ entryPoint : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
962+ } ) ;
963+
964+ const event = getTrackedEvent ( ) ;
965+
966+ expect ( event . properties ) . toMatchObject ( {
967+ section_id : PredictEventValues . SECTION_ID . LIVE_NOW ,
968+ action_type : PredictEventValues . ACTION_TYPE . SEE_ALL ,
969+ } ) ;
970+ } ) ;
971+
972+ it ( 'tracks a categories tile tap with category_name and no filter fields' , ( ) => {
973+ predictAnalytics . trackHomeSectionInteraction ( {
974+ sectionId : PredictEventValues . SECTION_ID . CATEGORIES ,
975+ actionType : PredictEventValues . ACTION_TYPE . CLICKED ,
976+ categoryName : 'politics' ,
977+ entryPoint : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
978+ } ) ;
979+
980+ const event = getTrackedEvent ( ) ;
981+
982+ expect ( event . name ) . toBe (
983+ MetaMetricsEvents . PREDICT_HOME_SECTION_INTERACTION . category ,
984+ ) ;
985+ expect ( event . properties ) . toEqual ( {
986+ section_id : PredictEventValues . SECTION_ID . CATEGORIES ,
987+ action_type : PredictEventValues . ACTION_TYPE . CLICKED ,
988+ category_name : 'politics' ,
989+ entry_point : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
990+ } ) ;
991+ expect ( event . properties ) . not . toHaveProperty ( 'filter_id' ) ;
992+ expect ( event . properties ) . not . toHaveProperty ( 'is_dynamic_filter' ) ;
993+ } ) ;
994+
995+ it ( 'tracks a dynamic-filter chip tap with filter id and is_dynamic_filter' , ( ) => {
996+ predictAnalytics . trackHomeSectionInteraction ( {
997+ sectionId : PredictEventValues . SECTION_ID . POPULAR_TODAY ,
998+ actionType : PredictEventValues . ACTION_TYPE . CLICKED ,
999+ filterId : 'elections' ,
1000+ isDynamicFilter : true ,
1001+ entryPoint : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
1002+ } ) ;
1003+
1004+ const event = getTrackedEvent ( ) ;
1005+
1006+ expect ( event . properties ) . toMatchObject ( {
1007+ section_id : PredictEventValues . SECTION_ID . POPULAR_TODAY ,
1008+ action_type : PredictEventValues . ACTION_TYPE . CLICKED ,
1009+ filter_id : 'elections' ,
1010+ is_dynamic_filter : true ,
1011+ } ) ;
1012+ } ) ;
1013+
1014+ it ( 'tracks a feed tab change' , ( ) => {
1015+ predictAnalytics . trackFeedTabChanged ( {
1016+ feedId : 'sports' ,
1017+ tabId : 'tennis' ,
1018+ entryPoint : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
1019+ } ) ;
1020+
1021+ const event = getTrackedEvent ( ) ;
1022+
1023+ expect ( event . name ) . toBe (
1024+ MetaMetricsEvents . PREDICT_FEED_TAB_CHANGED . category ,
1025+ ) ;
1026+ expect ( event . properties ) . toMatchObject ( {
1027+ feed_id : 'sports' ,
1028+ tab_id : 'tennis' ,
1029+ entry_point : PredictEventValues . ENTRY_POINT . HOME_SECTION ,
1030+ } ) ;
1031+ } ) ;
1032+
1033+ it ( 'tracks a feed filter change with is_dynamic_filter false for a static filter' , ( ) => {
1034+ predictAnalytics . trackFeedFilterChanged ( {
1035+ feedId : 'sports' ,
1036+ tabId : 'tennis' ,
1037+ filterId : 'live' ,
1038+ isDynamicFilter : false ,
1039+ } ) ;
1040+
1041+ const event = getTrackedEvent ( ) ;
1042+
1043+ expect ( event . name ) . toBe (
1044+ MetaMetricsEvents . PREDICT_FEED_FILTER_CHANGED . category ,
1045+ ) ;
1046+ expect ( event . properties ) . toMatchObject ( {
1047+ feed_id : 'sports' ,
1048+ tab_id : 'tennis' ,
1049+ filter_id : 'live' ,
1050+ is_dynamic_filter : false ,
1051+ } ) ;
1052+ } ) ;
9191053 } ) ;
9201054} ) ;
0 commit comments