Send Idea Hub activities on certain Idea Hub post interactions
See original GitHub issueThe Idea Hub API offers a platforms.properties.ideaActivities.create
endpoint which expects information about activities related to an idea and content creation. The API is currently being finalized, so this issue is pending that work - ACs will be added as soon as possible.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The Google API client services library should be updated to at least a version so that it includes the latest state of the Idea Hub API
platforms.properties.ideaActivities.create
endpoint. This work may overlap with #3916, pending whether the Beta update comes in the same release as the API enhancements needed here. - For the following Idea Hub interactions, a POST request to the above endpoint (
https://ideahub.googleapis.com/v1alpha/{parent=platforms/*/properties/*}/ideaActivities
) should be sent using the respective Google API client services method (the class will likely bePlatformsPropertiesIdeaActivities
and the method will likely becreate
; aparent
value will need to be specified similar to the ideas endpoint):- When an idea draft post is created, the request should include the respective idea ID and the
POST_DRAFTED
activity. - When an idea post is published, the request should include the respective idea ID and the
POST_PUBLISHED
activity, including the published post URL. - When an idea post is published, the request should include the respective idea ID and the
POST_UNPUBLISHED
activity. - When an idea post is deleted, the request should include the respective idea ID and the
POST_DELETED
activity.
- When an idea draft post is created, the request should include the respective idea ID and the
- In all cases, the data to send in the API request needs to be in the following shape:
{
"ideas": [
"Idea ID goes in here (not the full idea name, just the ID part)"
],
"topics": [],
"type": "one of POST_DRAFTED, POST_PUBLISHED, POST_UNPUBLISHED, POST_DELETED",
"uri": "public post URL if available (depends on the activity type, e.g. a draft post doesn't have a public URL)"
}
Implementation Brief
- Upgrade the
google/apiclient-services
dependency to >=0.210 version.- Verify functionality of existing modules to make sure nothing is broken after the upgrade.
- Edit the
Idea_Hub
class:- Create a new private method
track_idea_activity( $post_id, $type )
:- Get the associated idea name. Return early if the post doesn’t have the associated idea.
- Create a new instance of the
GoogleSearchIdeahubV1alphaIdeaActivity
class.- Set ideas (using
setIdeas
method) passing an array with the idea ID extracted from the post idea name. - Set idea topics (using
setTopics
method) passing an empty array. - Set the activity type (using
setType
method) passing the incoming$type
variable. - If the post is published, set the post URI (using
setUri
method).
- Set ideas (using
- Get the parent slug using the
$this->get_parent_slug()
method. - Create an activity entry by calling
$this->get_service( 'ideahub' )->platforms_properties_ideaActivities->create( $parent, $activity )
method.
- Update the
on_idea_hub_post_status_transition
method to call thetrack_idea_activity
method with:POST_PUBLISHED
type if the new status ispublished
and it doesn’t equal the old status.POST_UNPUBLISHED
type if the old status ispublished
and it doens’t equal the new status.
- Update the
POST:create-idea-draft-post
case in thecreate_data_request
method to call thetrack_idea_activity
method with thePOST_DRAFTED
type. - Add a new hook for the
pre_delete_post
action in theregister
method (if the module is connected) that calls thetrack_idea_activity
method with thePOST_DELETED
type.
- Create a new private method
Test Coverage
- N/A
Visual Regression Changes
- N/A
QA Brief
- Enable errors logging on your local machine using WP_DEBUG and WP_DEBUG_LOG constants.
- Update the following lines to save the response in the debug.log file: https://github.com/google/site-kit-wp/blob/48e8fe4b54b7990cb243ad66d39506957222dc4c/includes/Modules/Idea_Hub.php#L1061-L1063
You can do it something like this:
$response = $this->get_service( 'ideahub' ) ->platforms_properties_ideaActivities ->create( $parent, $activity ); error_log( var_export( $response, true ) );
- Now repeat interactions defined in AC and verify that you see the correct responses in your debug.log file.
Changelog entry
- Use Idea Hub activities endpoint when drafting, publishing or deleting a post.
Issue Analytics
- State:
- Created 2 years ago
- Comments:18 (8 by maintainers)
Top Results From Across the Web
IDEA Hub Projects - Creighton University
The IDEA Hub has a large variety of projects that come to us through different avenues to help create a stronger more impactful...
Read more >What is Idea Hub? | WordPress.org
Idea Hub is a new feature coming to Site Kit that will provide clients with ideas for new content to create. It'll suggest...
Read more >Xbox Idea Hub - Reddit - Dive into anything
An Idea Drive is a structured method for collecting ideas and suggestions from our most passionate fans across Windows and Xbox console. Here's...
Read more >Idea Sharing: How To Share Ideas In The Workplace
Bouncing ideas of colleagues, sharing insights as well as offering different experiences and feedback can result in breakthrough thinking.
Read more >How do I create a new idea conversation in the Ins...
The Community platform automatically searches for similar ideas using keywords in your idea subject. If you see a similar idea, click the idea...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@eugene-manuilov Hi, posting on behalf of API team here, we’ve just had a push to prod and the URI should no longer be required.
@rzhw I can confirm that the existing functionality in
v0.210.0
works correctly on my local machine. I get correct responses for all activities and it doesn’t require URI for non-published posts anymore.