This issue aims to coordinate our efforts to remove the connection dependency from the terms-of-service package in order to resolve the circular dependency issues that where introduced by the connection, tracking and terms-of-service packages:
The connection package requires the tracking package.
The tracking package requires the terms-of-service package.
The terms-of-service package requires the connection package.
[x] Remove connection dependency from terms-of-service package and corresponding connection related functionality
PR #16967
Add an additional check if the connection is active in all places where has_agreed method occurs:
Jetpack_Tracks_Client::record_event) https://github.com/Automattic/jetpack/blob/master/packages/tracking/legacy/class-jetpack-tracks-client.php#L72I noticed another use of Terms_Of_Service::has_agreed() in Jetpack_Tracks_Client::record_event(), and I鈥檝e added it to the list.
What do you think of just deleting Jetpack::jetpack_tos_agreed? It's been deprecated since 7.9, and it's not used in Jetpack. I also searched WP Directory and didn't find any uses there.
Thanks @kbrown9 ! As for the Jetpack_Tracks_Client::record_event - I haven't been able to find an instance where this method is used directly, but instead it's used from the Jetpack_Tracks_Event class, which in turn is used from the new Automattic\Jetpack\Tracking class, and the execution only happens there after the check that's fixed by #16979 .
I'm going to add a note about this in the class documentation, so that the class is not ever used directly.