Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

[EI-110] Wider edge_integrations_enabled checks #94

Merged
merged 9 commits into from
Apr 11, 2022

Conversation

jazzsequence
Copy link
Collaborator

@jazzsequence jazzsequence commented Apr 11, 2022

The edge_integrations_enabled check checks headers sent, but if we aren't sending headers (like we are in the admin) then this will return false.

This PR checks returned geo and interest headers first, then checks the headers that are sent (and if they get data back).

In most cases, checking sent headers and their returned responses will not be checked, as we skip it if we have geo or interest headers. However, if custom headers were sent, these will be checked after geo and interest. This is resolved by the addition of a new filter, pantheon.ei.get_custom_headers which should be used in a third-party function that returns the custom header data (similar to Geo\get_geo and Interest\get_interest) which will hook the third party code into edge_integrations_enabled.

@jazzsequence jazzsequence requested a review from a team as a code owner April 11, 2022 18:41
@jazzsequence jazzsequence self-assigned this Apr 11, 2022
Comment on lines +180 to +181
$geo = Geo\get_geo();
$interest = Interest\get_interest();

Choose a reason for hiding this comment

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

Is it possible to use a filter to remove geo or interest such that these will not work correctly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You can filter both things.
https://github.com/pantheon-systems/edge-integrations-wordpress-sdk/blob/main/docs/geo.md#pantheoneiparsed_geo_data
and
https://github.com/pantheon-systems/edge-integrations-wordpress-sdk/blob/main/docs/interest.md#pantheoneiparsed_interest_data

That's actually how the tests are working. However, I would expect if I was filtering either of those that I would be aware that I was potentially breaking/overriding the edge_integrations_enabled value.

Comment on lines +73 to +74
remove_all_filters( 'pantheon.ei.parsed_geo_data' );
remove_all_filters( 'pantheon.ei.parsed_interest_data' );

Choose a reason for hiding this comment

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

This is somewhat related to my question above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, both of those are there to ensure that when testing, we're not inheriting filtered values from other places (since we're not using a real WPUnit environment that clears out the instance in between test runs).

I defer to my initial statement that if you're filtering that stuff, you're modifying the data intentionally, so ymmv, but if there's a place in the documentation that we could be more explicit about the side effects, I'd be happy to update.

@jazzsequence jazzsequence merged commit 08348a0 into main Apr 11, 2022
@jazzsequence jazzsequence deleted the ei-110-broader-ei-enabled-check branch April 11, 2022 21:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants