@@ -421,7 +421,11 @@ public function enqueue_scripts() {
421421 wp_deregister_script ( 'vue-libs ' );
422422 }
423423
424- $ this ->register_survey ();
424+ if ( ! defined ( 'TI_E2E_TESTING ' ) || ! TI_E2E_TESTING ) {
425+ add_filter ( 'themeisle-sdk/survey/ ' . ROP_PRODUCT_SLUG , array ( $ this , 'get_survey_metadata ' ), 10 , 2 );
426+ }
427+ do_action ( 'themeisle_internal_page ' , ROP_PRODUCT_SLUG , 'dashboard ' );
428+
425429 if ( ! defined ( 'ROP_PRO_VERSION ' ) ) {
426430 do_action ( 'themeisle_sdk_load_banner ' , 'rop ' );
427431 }
@@ -1735,65 +1739,52 @@ public static function rop_check_reached_sharing_limit( $sharing_type = 'tw' ) {
17351739 /**
17361740 * Get the data used for the survey.
17371741 *
1742+ * @param array $data The data for survey in Formbricks format.
1743+ * @param string $page_slug The slug of the page.
1744+ *
17381745 * @return array The survey metadata.
17391746 */
1740- public function get_survey_metadata () {
1747+ public function get_survey_metadata ( $ data , $ page_slug ) {
17411748 $ 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.
17441749
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 ) {
1750+ $ install_days_number = intval ( ( time () - get_option ( 'rop_first_install_date ' , time () ) ) / DAY_IN_SECONDS );
1751+ $ install_category = 0 ; // Normalized value.
1752+
1753+ if ( 0 === $ install_days_number || 1 === $ install_days_number ) {
17481754 $ install_category = 0 ;
1749- } elseif ( 1 < $ days_since_install && 8 > $ days_since_install ) {
1755+ } elseif ( 1 < $ install_days_number && 8 > $ install_days_number ) {
17501756 $ install_category = 7 ;
1751- } elseif ( 8 <= $ days_since_install && 31 > $ days_since_install ) {
1757+ } elseif ( 8 <= $ install_days_number && 31 > $ install_days_number ) {
17521758 $ install_category = 30 ;
1753- } elseif ( 30 < $ days_since_install && 90 > $ days_since_install ) {
1759+ } elseif ( 30 < $ install_days_number && 90 > $ install_days_number ) {
17541760 $ install_category = 90 ;
1755- } elseif ( 90 <= $ days_since_install ) {
1761+ } elseif ( 90 <= $ install_days_number ) {
17561762 $ install_category = 91 ;
17571763 }
17581764
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 ;
1765+ $ data = array (
1766+ 'environmentId ' => 'clwgcs7ia03df11mgz7gh15od ' ,
1767+ 'attributes ' => array (
1768+ 'days_since_install ' => strval ( $ install_category ),
1769+ 'license_status ' => ! empty ( $ license_data ->license ) ? $ license_data ->license : 'invalid ' ,
1770+ 'free_version ' => $ this ->version ,
1771+ 'install_days_number ' => $ install_days_number ,
1772+ ),
1773+ );
17621774
17631775 if ( ! empty ( $ license_data ->plan ) ) {
1764- $ attributes ['plan ' ] = strval ( $ license_data ->plan );
1776+ $ data [ ' attributes ' ] ['plan ' ] = strval ( $ license_data ->plan );
17651777 }
17661778
1767- 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 ;
1779+ if ( ! empty ( $ license_data ->key ) ) {
1780+ $ data ['attributes ' ]['license_key ' ] = apply_filters ( 'themeisle_sdk_secret_masking ' , $ license_data ->key );
17881781 }
17891782
1790- $ survey_handler = apply_filters ( 'themeisle_sdk_dependency_script_handler ' , 'survey ' );
1791- if ( empty ( $ survey_handler ) ) {
1792- return ;
1783+ if ( defined ( 'ROP_PRO_VERSION ' ) ) {
1784+ $ data ['attributes ' ]['pro_version ' ] = ROP_PRO_VERSION ;
17931785 }
17941786
1795- do_action ( 'themeisle_sdk_dependency_enqueue_script ' , 'survey ' );
1796- wp_localize_script ( $ survey_handler , 'ropSurveyData ' , $ this ->get_survey_metadata () );
1787+ return $ data ;
17971788 }
17981789
17991790 /**
0 commit comments