New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add source parameter to event logging #2700
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works great! 👍
Out of curiosity I cherry-picked these commits on top of #2687. One thing is for CPT related events, events from the block editor will trigger |
Yes, I thought this would probably crop up. @donnapep is this going to be an issue for querying? One option, if it makes it easier, would be to add another source for |
That sounds good, although it would be good to timebox the effort in case it gets complicated. If it does, then I wouldn't worry about it for now. |
Ok, this is going to be trickier than I thought. I guess I assumed that there would be some simple way for us to detect whether the REST API request is coming from the block editor, but after digging into the requests, they are almost indistinguishable from any other REST API request. If this is an important distinction for us to make in the
Given that, I'm thinking that the "I wouldn't worry about it for now" suggestion sounds like the way to go 🙂 That said, option 1 above would likely not take long to implement if we wanted to see a proof-of-concept. |
I'm down with leaving it as-is. I don't think it's a big enough deal to warrant the extra work. |
As per our Slack conversation, this PR aims to provide a
source
parameter to all logged events that we can later use for querying.Currently, these sources are logged:
wp-admin
(includes all AJAX requests)rest-api
(note that events fired through direct interaction with the block editor may have this source)frontend
data-import
js-event
(for JS calls tosensei_log_event
)Testing instructions
wp-admin
Create a module from WP Admin. Use both the Module page, and the Course page metabox. Ensure the
source
for the events iswp-admin
.rest-api
Add the following code snippet:
Perform a REST API request (e.g.
http://my.site.com/wp-json/wp/v2/courses
). Ensure the source for thesensei_rest_api_request
event isrest-api
.frontend
Add a call to
sensei_log_event
to a template and then load that template (e.g. addsensei_log_event( 'rendering_course' );
tosingle-course.php
and then view a course). Ensure the source isfrontend
.data-import
Import data with modules (here is a data file you can use #). Ensure the
sensei_module_add
event is tracked twice (once for each module) and that the source isdata-import
.js-event
View the Sensei settings page. Ensure that the event logged has source
js-event
.