Skip to content

Commit 62363e9

Browse files
Merge pull request #1083 from Codeinwp/dev/tracking
- Refactor the final onboarding step to include an opt-in tracking consent mechanism - Integrate tracking disclosure into the email subscription workflow - Transmit user preference selection from the initial step alongside subscription events - Implement telemetry for first import creation and execution lifecycle events - Monitor import execution frequency - Configure uninstall hook to capture initial usage metrics before teardown - Implement creation/deletion event tracking for Feedzy Classic, Loop, and RSS components with increment/decrement counters for retention analytics
2 parents a93f6eb + 4e78ca1 commit 62363e9

10 files changed

+798
-282
lines changed

includes/abstract/feedzy-rss-feeds-admin-abstract.php

Lines changed: 81 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,46 @@ public function get_usage_data( $data ) {
8686
$categories = count( $terms );
8787
}
8888
// imports.
89-
$imports = array();
9089
$license = 'free';
90+
91+
$imports = array(
92+
// how many active imports are created.
93+
'publish' => count(
94+
get_posts(
95+
array(
96+
'post_type' => 'feedzy_imports',
97+
'post_status' => 'publish',
98+
'numberposts' => 99,
99+
'fields' => 'ids',
100+
)
101+
)
102+
),
103+
// how many draft imports are created.
104+
'draft' => count(
105+
get_posts(
106+
array(
107+
'post_type' => 'feedzy_imports',
108+
'post_status' => 'draft',
109+
'numberposts' => 99,
110+
'fields' => 'ids',
111+
)
112+
)
113+
),
114+
// how many posts were imported by the imports.
115+
'imported' => count(
116+
get_posts(
117+
array(
118+
'post_type' => 'post',
119+
'post_status' => array( 'publish', 'private', 'draft', 'trash' ),
120+
'numberposts' => 2999, //phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_numberposts
121+
'fields' => 'ids',
122+
'meta_key' => 'feedzy', //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
123+
'meta_value' => 1, //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
124+
)
125+
)
126+
),
127+
);
128+
91129
if ( feedzy_is_pro() ) {
92130
$license = 'pro';
93131
if ( apply_filters( 'feedzy_is_license_of_type', false, 'agency' ) ) {
@@ -107,70 +145,57 @@ public function get_usage_data( $data ) {
107145
}
108146
}
109147

110-
$imports = apply_filters(
111-
'feedzy_usage_data',
112-
array(
113-
// how many active imports are created.
114-
'publish' => count(
115-
get_posts(
116-
array(
117-
'post_type' => 'feedzy_imports',
118-
'post_status' => 'publish',
119-
'numberposts' => 99,
120-
'fields' => 'ids',
121-
)
122-
)
123-
),
124-
// how many draft imports are created
125-
'draft' => count(
126-
get_posts(
127-
array(
128-
'post_type' => 'feedzy_imports',
129-
'post_status' => 'draft',
130-
'numberposts' => 99,
131-
'fields' => 'ids',
132-
)
133-
)
134-
),
135-
// how many posts were imported by the imports
136-
'imported' => count(
137-
get_posts(
138-
array(
139-
'post_type' => 'post',
140-
'post_status' => array( 'publish', 'private', 'draft', 'trash' ),
141-
'numberposts' => 2999, //phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_numberposts
142-
'fields' => 'ids',
143-
'meta_key' => 'feedzy', //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
144-
'meta_value' => 1, //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
145-
)
146-
)
147-
),
148-
// integrations
149-
'integrations' => $integrations,
150-
)
151-
);
148+
$imports['integrations'] = $integrations;
152149
}
153150

154-
$settings = apply_filters( 'feedzy_get_settings', null );
155-
$config = array();
156-
if ( $settings ) {
157-
$proxy = isset( $settings['proxy'] ) && is_array( $settings['proxy'] ) && ! empty( $settings['proxy'] ) ? array_filter( $settings['proxy'] ) : array();
158-
if ( ! empty( $proxy ) ) {
159-
$config[] = 'proxy';
160-
}
161-
}
151+
$imports = wp_parse_args( Feedzy_Rss_Feeds_Usage::get_instance()->get_usage_stats(), $imports );
152+
$imports = apply_filters( 'feedzy_usage_data', $imports );
162153

163154
// how many posts contain the shortcode
164155
global $wpdb;
165156
$shortcodes = $wpdb->get_var( "SELECT count(*) FROM {$wpdb->prefix}posts WHERE post_status IN ('publish', 'private') AND post_content LIKE '%[feedzy-rss %'" ); //phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
157+
166158
$data = array(
167-
'categories' => $categories,
168-
'imports' => $imports,
169-
'shortcodes' => $shortcodes,
170-
'license' => $license,
171-
'config' => $config,
159+
'categories' => $categories,
160+
'imports' => $imports,
161+
'shortcodes' => $shortcodes,
162+
'license' => $license,
172163
);
173164

165+
$settings = apply_filters( 'feedzy_get_settings', null );
166+
167+
if ( ! is_array( $settings ) || empty( $settings ) ) {
168+
return $data;
169+
}
170+
171+
$general_settings = array();
172+
$config = array();
173+
174+
$proxy = isset( $settings['proxy'] ) && is_array( $settings['proxy'] ) && ! empty( $settings['proxy'] ) ? array_filter( $settings['proxy'] ) : array();
175+
if ( ! empty( $proxy ) ) {
176+
$config[] = 'proxy';
177+
}
178+
179+
if ( isset( $settings['header'], $settings['header']['user-agent'] ) && ! empty( $settings['header']['user-agent'] ) ) {
180+
$config[] = 'custom-user-agent';
181+
}
182+
183+
if ( ! empty( $config ) ) {
184+
$data['config'] = $config;
185+
}
186+
187+
if ( is_array( $settings['general'] ) && ! empty( $settings['general'] ) ) {
188+
foreach ( $settings['general'] as $key => $value ) {
189+
if ( ! empty( $value ) ) {
190+
$general_settings[ $key ] = $value;
191+
}
192+
}
193+
194+
if ( ! empty( $general_settings ) ) {
195+
$data['general'] = $general_settings;
196+
}
197+
}
198+
174199
return $data;
175200
}
176201

includes/admin/feedzy-rss-feeds-admin.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,12 @@ public function save_feedzy_post_type_meta( $post_id, $post ) {
769769
$feedzy_category_feed = preg_replace( '/\s*,\s*|\R/', ',', $feedzy_category_feed );
770770
$category_meta['feedzy_category_feed'] = $feedzy_category_feed;
771771
}
772+
773+
if ( empty( get_post_meta( $post_id, 'usage_counted', true ) ) ) {
774+
Feedzy_Rss_Feeds_Usage::get_instance()->track_import_creation();
775+
update_post_meta( $post_id, 'usage_counted', 'yes' );
776+
}
777+
772778
if ( $post->post_type === 'revision' ) {
773779
return true;
774780
} else {
@@ -1766,6 +1772,16 @@ private function setup_wizard_subscribe_process() {
17661772
);
17671773
}
17681774
if ( $with_subscribe && is_email( $email ) ) {
1775+
update_option( 'feedzy_rss_feeds_logger_flag', 'yes' );
1776+
1777+
$extra_data = array(
1778+
'segment' => $segment,
1779+
);
1780+
1781+
if ( ! empty( $integrate_with ) ) {
1782+
$extra_data['integration_scope_onboarding'] = $integrate_with;
1783+
}
1784+
17691785
$request_res = wp_remote_post(
17701786
FEEDZY_SUBSCRIBE_API,
17711787
array(
@@ -1780,9 +1796,7 @@ private function setup_wizard_subscribe_process() {
17801796
'slug' => 'feedzy-rss-feeds',
17811797
'site' => home_url(),
17821798
'email' => $email,
1783-
'data' => array(
1784-
'segment' => $segment,
1785-
),
1799+
'data' => $extra_data
17861800
)
17871801
),
17881802
)

includes/admin/feedzy-rss-feeds-import.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,8 @@ public function run_cron( $max = 100, $job_id = 0 ) {
13871387
* @access private
13881388
*/
13891389
private function run_job( $job, $max ) {
1390+
Feedzy_Rss_Feeds_Usage::get_instance()->track_rss_import();
1391+
13901392
global $themeisle_log_event;
13911393
$source = get_post_meta( $job->ID, 'source', true );
13921394
$inc_key = get_post_meta( $job->ID, 'inc_key', true );
@@ -3352,6 +3354,7 @@ private function wizard_import_feed() {
33523354
'post_status' => 'publish',
33533355
)
33543356
);
3357+
Feedzy_Rss_Feeds_Usage::get_instance()->track_import_creation();
33553358
}
33563359

33573360
if ( ! is_wp_error( $job_id ) ) {

0 commit comments

Comments
 (0)