Skip to content

Commit

Permalink
refactor(stats): added Xiaoyuzhou/Moon FM/Castro/watchOS
Browse files Browse the repository at this point in the history
  • Loading branch information
justinyanme committed Mar 26, 2021
1 parent efd400d commit 3aa4f6e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
13 changes: 11 additions & 2 deletions php/classes/class-ssp-stats-hit.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,24 @@ public function track_hit( $file = '', $episode = 0, $referrer = '' ) {
$referrer = 'overcast';
} else if ( stripos( $user_agent, 'Pocket Casts' ) !== false ) {
$referrer = 'pocketcasts';
} else if ( stripos( $user_agent, 'Android' ) !== false ) {
} else if ( stripos( $user_agent, 'Xiaoyuzhou' ) !== false ) {
// Put Xiaoyuzhou before 'android' otherwise 'Xiaoyuzhou Android' will miss match
$referrer = 'xiaoyuzhou';
} else if ( stripos( $user_agent, 'Android' ) !== false ) {
$referrer = 'android';
} else if ( stripos( $user_agent, 'PodcastAddict' ) !== false ) {
$referrer = 'podcast_addict';
} else if ( stripos( $user_agent, 'Player FM' ) !== false ) {
$referrer = 'playerfm';
} else if ( stripos( $user_agent, 'Google-Play' ) !== false ) {
$referrer = 'google_play';
}
} else if ( stripos( $user_agent, 'Moon FM' ) !== false ) {
$referrer = 'MoonFM';
} else if ( stripos( $user_agent, 'Castro' ) !== false ) {
$referrer = 'Castro';
} else if ( stripos( $user_agent, 'watchOS' ) !== false ) {
$referrer = 'watchOS';
}

// Get episode ID for database insert
$episode_id = $episode->ID;
Expand Down
30 changes: 29 additions & 1 deletion php/classes/class-ssp-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public function stats_meta_box_content( $post ) {

$html .= '<p class="episode-stat-data total-downloads">' . __( 'Total listens', 'seriously-simple-stats' ) . ': <b>' . $total_downloads . '</b></p>';

$itunes = $stitcher = $overcast = $pocketcasts = $direct = $new_window = $player = $android = $podcast_addict = $playerfm = $google_play = $unknown = 0;
$itunes = $stitcher = $overcast = $pocketcasts = $direct = $new_window = $player = $android = $podcast_addict = $playerfm = $google_play = $xiaoyuzhou = $moonFM = $castro = $watchOS = $unknown = 0;

foreach ( $stats as $stat ) {
$listeners[ $stat->ip_address ] = $stat->ip_address;
Expand Down Expand Up @@ -401,6 +401,18 @@ public function stats_meta_box_content( $post ) {
case 'google_play':
++ $google_play;
break;
case 'xiaoyuzhou':
++ $xiaoyuzhou;
break;
case 'MoonFM':
++ $moonFM;
break;
case 'Castro':
++ $castro;
break;
case 'watchOS':
++ $watchOS;
break;
default:
++ $unknown;
break;
Expand Down Expand Up @@ -443,6 +455,18 @@ public function stats_meta_box_content( $post ) {
if ( $playerfm ) {
$html .= '<li class="playerfm">' . __( 'Player FM', 'seriously-simple-stats' ) . ': <b>' . $playerfm . '</b></li>';
}
if ( $xiaoyuzhou ) {
$html .= '<li class="xiaoyuzhou">' . __( 'Xiaoyuzhou', 'seriously-simple-stats' ) . ': <b>' . $xiaoyuzhou . '</b></li>';
}
if ( $moonFM ) {
$html .= '<li class="moonFM">' . __( 'MoonFM', 'seriously-simple-stats' ) . ': <b>' . $moonFM . '</b></li>';
}
if ( $castro ) {
$html .= '<li class="castro">' . __( 'Castro', 'seriously-simple-stats' ) . ': <b>' . $castro . '</b></li>';
}
if ( $watchOS ) {
$html .= '<li class="watchOS">' . __( 'watchOS', 'seriously-simple-stats' ) . ': <b>' . $watchOS . '</b></li>';
}
// Commented out for now, could be used in the future
/*if( $google_play ){
$html .= '<li class="google_play">' . __( 'Google Play', 'seriously-simple-stats' ) . ': <b>' . $google_play . '</b></li>';
Expand Down Expand Up @@ -887,6 +911,10 @@ private function referrers_chart () {
'podcast_addict' => __( 'Podcast Addict', 'seriously-simple-stats' ),
'playerfm' => __( 'Player FM', 'seriously-simple-stats' ),
// 'google_play' => __( 'Google Play', 'seriously-simple-stats' ) //Commented out for now
'xiaoyuzhou' => __( 'Xiaoyuzhou', 'seriously-simple-stats' ),
'MoonFM' => __( 'MoonFM', 'seriously-simple-stats' ),
'Castro' => __( 'Castro', 'seriously-simple-stats' ),
'watchOS' => __( 'watchOS', 'seriously-simple-stats' ),
);

$data = array();
Expand Down

0 comments on commit 3aa4f6e

Please sign in to comment.