statify
statify copied to clipboard
statify__visit_saved filter is not executed if JS tracking is active
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.
Maybe this is fixed with #109 @stklcode ?
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.
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.
Hmm. I tested on localhost. Is there a condition which leads to not tracking localhost for JS tracking?
I just re-tested this on some sites:
- WP 6.2-RC4, Statify 1.8.4, localhost (HTTP)
- WP 6.2-RC4, Statify 1.8.4, private domain (HTTPS)
- WP 6.2-RC4, Statify 2.0.0-SNAPSHOT, private domain (HTTPS)
- WP 6.1.1, Statify 1.8.4, localhost (HTTP)
- WP 6.1.1, Statify 2.0.0-SNAPSHOT, private domain (HTTPS)
- WP 6.1.1, Statify 1.8.4, public domain (HTTPS)
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:
- WP 6.2-RC4, Statify 2.0.0-SNAPSHOT with Caching enabled
- Visit home page anonymously (getting cached) => tracking works as expected here
- Downgrade to Statify 1.8.4 (just overwrite the files, not flushing the server cache)
- Visit cached home page again => no tracking
- Flush the server cache => works again
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?