pluginkollektiv / statify

Statify – statistics plugin for WordPress
https://wordpress.org/plugins/statify/
GNU General Public License v3.0
75 stars 22 forks source link

statify__visit_saved filter is not executed if JS tracking is active #114

Open Zodiac1978 opened 5 years ago

Zodiac1978 commented 5 years ago

If the JS tracking is enabled the action hook statify__visit_saved is not executed.

Therefore it couldn't be used to gather more information at the moment, because if the user is using JS tracking no information will be saved.

Zodiac1978 commented 5 years ago

Maybe this is fixed with #109 @stklcode ?

stklcode commented 5 years ago

Just checked with your UA extension, the hook is fired correctly when AJAX tracking is active. Didn't investigate yet, why it's not with the 1.6 default version.

stklcode commented 5 years ago

OK, now I tested with vanilla 1.6.3... To be honest, I cannot reproduce the problem, hook is fired. :neutral_face:

Tested with WP 4.9.8 and 5.0-alpha-43673, both PHP 7.2.10 FPM handler with Chrome and Firefox browsers. Even moved hook callbacks to different places to evaluate if it depends on the order code is loaded.

Zodiac1978 commented 5 years ago

Hmm. I tested on localhost. Is there a condition which leads to not tracking localhost for JS tracking?

stklcode commented 1 year ago

I just re-tested this on some sites:

All working as expected. AJAX (or API) tracking is called and the custom action fires.

Using a dummy action like this:

add_action( 'statify__visit_saved', fn( $data, $id ) => print( json_encode( $data ) ), 10, 2 );

I was able to reproduce this issue by accident in the following scenario:

I believe the latter scenario is not likely to happen in production and subject for errors anyway. So is there any real issue left that we should tackle in this case?

Edit: What just came to my mind... maybe the action is defined in some place that is not actually called when doing AJAX?