Skip to content
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 hooks to Sophi requests #257

Merged
merged 7 commits into from
Apr 29, 2022
Merged

Add hooks to Sophi requests #257

merged 7 commits into from
Apr 29, 2022

Conversation

cadic
Copy link
Contributor

@cadic cadic commented Apr 29, 2022

Description of the Change

This PR introducing new hooks to remote requests:

Hooks for Site Automation

sophi_request_args filter: Filters the arguments used in Sophi HTTP request.
sophi_request_result filter: Filters a Sophi HTTP request immediately after the response is received.

Used in: SophiWP\SiteAutomation\Request::request() and SophiWP\SiteAutomation\Auth::request_access_token()

Hooks for event tracker

sophi_tracking_data filter: Filters the data used in Sophi track event request.
sophi_tracking_result action: Fires after tracker sends the request.

Since the entire $data array is sent to Snowplow, looks it not safe to add new attributes to the array (f.e. for debugging). That's why we add the Snowplow\Tracker\Tracker $tracker object as a reference in both filters.

Used in: SophiWP\ContentSync\send_track_event()

sophi_tracker_emitter_debug filter: Allows to enable debug mode in the emitter to save responses and analyse them later.

Used in: SophiWP\ContentSync\init_tracker()

Closes #255

Possible Drawbacks

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Changelog Entry

Added - Filter sophi_request_args filters arguments used in Sophi HTTP request.
Added - Filter sophi_request_result filters a Sophi HTTP request immediately after the response is received.
Added - Filter sophi_tracking_data filters the data used in Sophi track event request.
Added - Action sophi_tracking_result fires after tracker sends the request.
Added - Filter sophi_tracker_emitter_debug allows to enable debug mode in the tracking emitter.

Credits

Props @cadic

@cadic cadic self-assigned this Apr 29, 2022
@cadic cadic added this to the 1.0.14 milestone Apr 29, 2022
@cadic
Copy link
Contributor Author

cadic commented Apr 29, 2022

Related to #219

@jeffpaul
Copy link
Contributor

@oscarssanchez @felipeelia @iamdharmesh @Sidsector9 @dinhtungdu looking for a quick review from one of you on this one to get merged in to support Max's work on the debug bar integration.

@sonarcloud
Copy link

sonarcloud bot commented Apr 29, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@iamdharmesh iamdharmesh left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add filters before and after the remote request
3 participants