-
Notifications
You must be signed in to change notification settings - Fork 123
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
Create process telemetry rest route #1684
Conversation
|
function get_telemetry_client_id(): string|null { | ||
/** | ||
* @TODO Upon saving the site's telemetry decision, if they accept, we'll | ||
* also need to generate a unique, anonymous client ID for them to be sent | ||
* with GA requests. | ||
* | ||
* If a string is returned, telemetry is enabled and a client id has been generated. | ||
* If this function returns null, either telemetry is off, or a client ID is not created. | ||
*/ | ||
return null; | ||
} |
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.
@TeresaGobble When we save a user's preferences for their telemetry opt-in, we'll also want to generate a unique id for them (something like a UUID) as GA requires this. You can take a look at our previous implementation in the CLI for inspiration on how this can be done.
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.
@blakewilson thoughts on using wp_generate_uuid4()
for this?
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.
@mindctrl I think that's perfect!
📦 Next.js Bundle Analysis for @faustwp/getting-started-exampleThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
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.
LGTM!
* Create process telemetry rest route (#1684) * Create tests * [Merl-1281] Add extra Google Analytics variables to Faust (#1689) * Feat: Add block_editor_utils and app-router versions in telemetry events. * Chore: Added changeset * MERL-1343/MERL-1342: API rewrite to WP plugin vs GA (#1687) * Removed telemetry from the CLI and moved it into the Faust WordPress plugin. --------- Co-authored-by: Blake Wilson <blake.wilson@wpengine.com> Co-authored-by: John Parris <john.parris@wpengine.com> * MERL-1339: add WP notice for anonymous telemetry opt-in (#1690) * Added checkbox for 'Enable Faust Telemetry' * Added telemetry prompt to user page options * Add `enable_telemetry` and `telemetry_reminder` to `sanitize_faustwp_settings()` * Load telemetry callbacks file * test: confirm `show_telemetry_prompt()` is hooked to `admin_notices` * Sanitize telemetry reminder settings value by ensuring it's an integer * Test telemetry prompt behavior * test: confirm behavior of `should_show_telemetry_prompt()` * fix: adjust CSS button styles to not style buttons in the telemetry prompt * chore: adjust button classes and add aria-label attributes * Register, enqueue, and localize telemetry script * Register telemetry decision REST route * test: confirm telemetry script is registered * UX: Toggle checkbox on settings page to match user's decision. Since this happens over REST via JS and we don't reload the page, this provides a better UX. * test: confirm `should_show_telemetry_prompt()` returns false when telemetry disabled * chore: add changeset --------- Co-authored-by: John Parris <john.parris@wpengine.com> * Generate UUID v4 for telemetry ID (#1693) * chore: change test namespace from Unit to Integration * chore: fix test class name to match file name * fix: return 204 if telemetry not enabled * test: confirm behavior of `generate_telemetry_client_id()` * Support `telemetry_client_id` in settings sanitization function * test: confirm generated and saved id matches retrieved id. --------- Co-authored-by: Blake Wilson <blake.wilson@wpengine.com> --------- Co-authored-by: Blake Wilson <blake.wilson@wpengine.com> Co-authored-by: Theofanis Despoudis <328805+theodesp@users.noreply.github.com> Co-authored-by: Matthew Wright <1815200+matthewguywright@users.noreply.github.com> Co-authored-by: Teresa Gobble <teresagobble@gmail.com>
Tasks
Description
This PR creates a REST endpoint that accepts a body from the CLI, merges that data with data from WordPress, and then sends it off to GA if the user has Faust telemetry activated on WordPress.
The body looks like:
Related Issue(s):
Testing
/wp-json/faustwp/v1/process_telemetry
and see the401
response since you didn't pass a secret keyx-faustwp-secret
and verify you got a204
response (no content).get_telemetry_client_id
function to return a string and notice a201
is returned (created).Screenshots
Documentation Changes
Dependant PRs