Burst-Statistics / burst

Burst Statistics by Really Simple Plugins
https://burst-statistics.com/
GNU General Public License v3.0
18 stars 6 forks source link

Ajax problem with translated URLs #17

Open FeIix opened 1 year ago

FeIix commented 1 year ago

Hi,

I'm using a translation plugin (translatepress) that is adding the current language in the url, like mysite/en and mysite/fr

Statistics in the dashboard are looking fine (= not empty), but there are errors while visiting the page, for example : An ajax query triggered by "burst_update_hit()" is sent to the translated wp-json url : mysite/fr/wp-json/burst/v1/track/?token=rlohksr&_locale=user (because it's using location.href)

but the actual wp-json route is defined as mysite/wp-json/burst/v1/track/?token=rlohksr&_locale=user so a 404 error is triggered in console, and in debug.log :

[29-Jan-2023 12:46:43 UTC] Burst Statistics: Endpoint error, does not respond with 200. Response given:

I sometimes also have a red warning about tracking in the dashboard status, but it's random.

Not sure how/why the stats are still updated 🤔

sviluppomania commented 1 year ago

Hi, this error looks similar to mine:

@hesseldj @rlankhorst

hesseldj commented 1 year ago

Hi @FeIix,

I assume (some of) the stats are still being updated because your main language website does not have an URL?

The error log "Burst Statistics: Endpoint error, ..." is for when the endpoint is tested. This would cause the REST API to be tested as a fallback. When the REST API does not work, you will get an error in the dashboard.

I have tried reproducing the issue, but it seems to work fine. See: https://ter-fiesta-lobi.instawp.xyz/fr/

Can you add an export of your translatePress settings? And can you tell me which Burst settings are used?

Also which versions of Burst and TranslatePress are you using?

Kind regards, Hessel

FeIix commented 1 year ago

Thanks for your answer,

For Burst all settings are disabled : image

The main language has also /fr/ in url, I think the problem appeared when we enabled this option

When loading the /en/ page, a query is still made to /fr/ (mysite/fr/wp-json/burst/v1/track/?token=merhdd&_locale=user)

TranslatePress is redirecting to /fr when no language is specified, I suspect this could be the problem

Will investigate more and come back

hesseldj commented 1 year ago

Hi @FeIix,

Have you tried saving the permalinks after changing that setting? Sometimes the REST API url's are not registered properly and saving permalinks again could help.

Kind regards, Hessel

FeIix commented 1 year ago

Yes, and I tried again just in case, but still the same

hesseldj commented 1 year ago

Hi @FeIix,

Can you share you're URL with us so that we can take a look?

Kind regards, Hessel

FeIix commented 1 year ago

Yes, thank you : URL