Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Podcast: write Jetpack Activity Log entries on podcast publish. One per-site `podcast_show_launched` on the first episode, plus a `podcast_episode_published` entry on every episode publish, so WPcom downstream listeners can surface them.
1 change: 1 addition & 0 deletions projects/packages/podcast/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"require": {
"php": ">=7.2",
"automattic/jetpack-status": "@dev",
"automattic/jetpack-sync": "@dev",
"automattic/jetpack-wp-build-polyfills": "@dev"
},
"require-dev": {
Expand Down
53 changes: 52 additions & 1 deletion projects/packages/podcast/src/class-tracks.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Automattic\Jetpack\Podcast;

use Automattic\Jetpack\Podcast\Feed\Customize_Feed;
use Automattic\Jetpack\Sync\Activity_Log_Event;
use Throwable;
use WP_Post;
use WP_Query;
Expand Down Expand Up @@ -109,6 +110,8 @@ public static function record_episode_published( $post_id, $post, $update, $post
self::identity_for_post( $post )
);

self::record_episode_published_activity( $post );

// Atomic INSERT — only one concurrent caller per site wins, so
// `show_launched` fires exactly once per site.
if ( $is_first && add_option( 'podcast_show_launched_tracked', time(), '', false ) ) {
Expand All @@ -117,6 +120,8 @@ public static function record_episode_published( $post_id, $post, $update, $post
array( 'post_id' => (int) $post->ID ),
self::identity_for_post( $post )
);

self::record_show_launched_activity( $post );
}
} catch ( Throwable $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
// Tracks is best-effort — never break a publish.
Expand Down Expand Up @@ -349,6 +354,53 @@ private static function maybe_record_status_change( int $old_value, int $new_val
do_action( 'jetpack_bump_stats_extras', 'wpcom-podcasting-status', $status );
}

/**
* Write a `podcast_show_launched` entry to the Jetpack Activity Log. The
* entry syncs to WPcom as a `jp_act_log_event` post, which downstream
* listeners (e.g. the `#podcast-alerts` Slack notifier in the wpcom
* podcasting mu-plugin) hook to surface the launch.
*
* @param WP_Post $post First episode that triggered the launch.
*/
private static function record_show_launched_activity( WP_Post $post ): void {
Activity_Log_Event::create(
array(
'title' => __( 'Podcast show launched', 'jetpack-podcast' ),
'content' => sprintf(
/* translators: 1: episode post ID, 2: episode title. */
__( 'First episode published (post %1$d): %2$s', 'jetpack-podcast' ),
(int) $post->ID,
$post->post_title
),
'source' => 'podcast_show_launched',
'severity' => 'success',
)
);
}

/**
* Write a `podcast_episode_published` entry to the Jetpack Activity Log.
* Fires for every podcast episode publish (after all the same gates as
* the `wpcom_podcast_episode_published` tracks event).
*
* @param WP_Post $post Episode that triggered the event.
*/
private static function record_episode_published_activity( WP_Post $post ): void {
Activity_Log_Event::create(
array(
'title' => __( 'Podcast episode published', 'jetpack-podcast' ),
'content' => sprintf(
/* translators: 1: episode post ID, 2: episode title. */
__( 'Episode published (post %1$d): %2$s', 'jetpack-podcast' ),
(int) $post->ID,
$post->post_title
),
'source' => 'podcast_episode_published',
'severity' => 'info',
)
);
}

/**
* Identity for the publish event. Scheduled/cron publishes have no
* logged-in user — fall back to the post author.
Expand Down Expand Up @@ -423,7 +475,6 @@ private static function record_event( string $event_name, array $properties, ?WP
}

if ( class_exists( '\Automattic\Jetpack\Tracking' ) ) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding automattic/jetpack-sync as a podcast package dep transitively pulls in automattic/jetpack-connection (Sync requires it), so \Automattic\Jetpack\Tracking resolves for Phan from this package now. Restoring the @phan-suppress-next-line PhanUndeclaredClassMethod would itself be flagged as an unused suppression. Leaving it removed is correct in the new dep state.

// @phan-suppress-next-line PhanUndeclaredClassMethod -- Provided by the connection package on Atomic; not a hard dep.
return ( new \Automattic\Jetpack\Tracking() )->tracks_record_event( $user, $event_name, $properties );
}
} catch ( Throwable $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Updated package dependencies.
3 changes: 2 additions & 1 deletion projects/plugins/jetpack/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
3 changes: 2 additions & 1 deletion projects/plugins/mu-wpcom-plugin/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

Updated package dependencies.
3 changes: 2 additions & 1 deletion projects/plugins/wpcomsh/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading