@@ -330,6 +330,7 @@ public function enqueue_scripts() {
330330
331331 $ added_services = $ services ->get_authenticated_services ();
332332 $ added_networks = 0 ;
333+ $ accounts_count = count ( $ added_services );
333334 if ( $ added_services ) {
334335
335336 $ uniq_auth_accounts = array ();
@@ -421,7 +422,29 @@ public function enqueue_scripts() {
421422 wp_deregister_script ( 'vue-libs ' );
422423 }
423424
424- $ this ->register_survey ();
425+ $ is_post_sharing_active = ( new Rop_Cron_Helper () )->get_status () ? 'yes ' : 'no ' ;
426+
427+ if ( ! defined ( 'TI_E2E_TESTING ' ) || ! TI_E2E_TESTING ) {
428+ add_filter (
429+ 'themeisle-sdk/survey/ ' . ROP_PRODUCT_SLUG ,
430+ function ( $ data , $ page_slug ) use ( $ accounts_count , $ is_post_sharing_active ) {
431+ $ data = $ this ->get_survey_metadata ();
432+
433+ $ extra_attributes = array (
434+ 'accounts_number ' => min ( 20 , $ accounts_count ),
435+ 'post_sharing_enabled ' => $ is_post_sharing_active ,
436+ );
437+
438+ $ data ['attributes ' ] = array_merge ( $ data ['attributes ' ], $ extra_attributes );
439+
440+ return $ data ;
441+ },
442+ 10 ,
443+ 2
444+ );
445+ }
446+ do_action ( 'themeisle_internal_page ' , ROP_PRODUCT_SLUG , 'dashboard ' );
447+
425448 if ( ! defined ( 'ROP_PRO_VERSION ' ) ) {
426449 do_action ( 'themeisle_sdk_load_banner ' , 'rop ' );
427450 }
@@ -1738,62 +1761,34 @@ public static function rop_check_reached_sharing_limit( $sharing_type = 'tw' ) {
17381761 * @return array The survey metadata.
17391762 */
17401763 public function get_survey_metadata () {
1741- $ license_data = get_option ( 'tweet_old_post_pro_license_data ' , array () );
1742- $ attributes = array ();
1743- $ user_id = 'rop_ ' . ( ! empty ( $ license_data ->key ) ? $ license_data ->key : preg_replace ( '/[^\w\d]*/ ' , '' , get_site_url () ) ); // Use a normalized version of the site URL as a user ID for free users.
1764+ $ license_status = apply_filters ( 'product_rop_license_status ' , 'invalid ' );
1765+ $ license_plan = apply_filters ( 'product_rop_license_plan ' , false );
1766+ $ license_key = apply_filters ( 'product_rop_license_key ' , false );
1767+
1768+ $ install_days_number = intval ( ( time () - get_option ( 'rop_first_install_date ' , time () ) ) / DAY_IN_SECONDS );
1769+
1770+ $ data = array (
1771+ 'environmentId ' => 'clwgcs7ia03df11mgz7gh15od ' ,
1772+ 'attributes ' => array (
1773+ 'license_status ' => $ license_status ,
1774+ 'free_version ' => $ this ->version ,
1775+ 'install_days_number ' => $ install_days_number ,
1776+ ),
1777+ );
17441778
1745- $ days_since_install = round ( ( time () - get_option ( 'rop_first_install_date ' , 0 ) ) / DAY_IN_SECONDS );
1746- $ install_category = 0 ; // Normalized value.
1747- if ( 0 === $ days_since_install || 1 === $ days_since_install ) {
1748- $ install_category = 0 ;
1749- } elseif ( 1 < $ days_since_install && 8 > $ days_since_install ) {
1750- $ install_category = 7 ;
1751- } elseif ( 8 <= $ days_since_install && 31 > $ days_since_install ) {
1752- $ install_category = 30 ;
1753- } elseif ( 30 < $ days_since_install && 90 > $ days_since_install ) {
1754- $ install_category = 90 ;
1755- } elseif ( 90 <= $ days_since_install ) {
1756- $ install_category = 91 ;
1779+ if ( ! empty ( $ license_plan ) ) {
1780+ $ data ['attributes ' ]['plan ' ] = strval ( $ license_plan );
17571781 }
17581782
1759- $ attributes ['days_since_install ' ] = strval ( $ install_category );
1760- $ attributes ['license_status ' ] = ! empty ( $ license_data ->license ) ? $ license_data ->license : 'invalid ' ;
1761- $ attributes ['free_version ' ] = $ this ->version ;
1762-
1763- if ( ! empty ( $ license_data ->plan ) ) {
1764- $ attributes ['plan ' ] = strval ( $ license_data ->plan );
1783+ if ( ! empty ( $ license_key ) ) {
1784+ $ data ['attributes ' ]['license_key ' ] = apply_filters ( 'themeisle_sdk_secret_masking ' , $ license_key );
17651785 }
17661786
17671787 if ( defined ( 'ROP_PRO_VERSION ' ) ) {
1768- $ attributes ['pro_version ' ] = ROP_PRO_VERSION ;
1769- }
1770-
1771- return array (
1772- 'userId ' => $ user_id ,
1773- 'attributes ' => $ attributes ,
1774- );
1775- }
1776-
1777- /**
1778- * Register the survey script.
1779- *
1780- * It does not register if we are in a testing environment.
1781- *
1782- * @return void
1783- */
1784- public function register_survey () {
1785-
1786- if ( defined ( 'TI_E2E_TESTING ' ) && TI_E2E_TESTING ) {
1787- return ;
1788- }
1789-
1790- $ survey_handler = apply_filters ( 'themeisle_sdk_dependency_script_handler ' , 'survey ' );
1791- if ( empty ( $ survey_handler ) ) {
1792- return ;
1788+ $ data ['attributes ' ]['pro_version ' ] = ROP_PRO_VERSION ;
17931789 }
17941790
1795- do_action ( 'themeisle_sdk_dependency_enqueue_script ' , 'survey ' );
1796- wp_localize_script ( $ survey_handler , 'ropSurveyData ' , $ this ->get_survey_metadata () );
1791+ return $ data ;
17971792 }
17981793
17991794 /**
0 commit comments