vince icon indicating copy to clipboard operation
vince copied to clipboard

Fix crash of the stats page with goals

Open edarchis opened this issue 2 months ago • 2 comments

See issue #77 for details but in a nutshell:

  • create a goal "toto"
  • trigger the event from your web page (note that the documentation mixes plausible-event-name and vince-event-name but only the plausible one works)
  • go to the stats page => page blows up with an exception e.length on undefined e.

That's because the event doesn't have a .name, only .event. I supported both in list.js and shielded trimUrl that was starting with url.length...

I didn't find a previous PR with updates to the Javascript and since the JS artefacts seem to be manually generated, I included them in a separate commit. Feel free to exclude it, cherry pick the rest and regenerate it yourself, or ask me to remove it if necessary. I know that I didn't (intentionally) include any malicious code in there but I wouldn't trust a stranger to include minified JS code like that in my projects. Maybe adding a Github action would be useful ?

I also removed some deprecated .substr() in the same file.

edarchis avatar Nov 06 '25 17:11 edarchis

Sure, I updated my branch to include only the minimal JS fix. You should be able to review just that.

The .substr probably isn't worth a PR of its own, maybe one day if I feel like going the whole codebase to chase all of them. It was just my IDE warning about it.

Regarding the issue itself, when I visit the page, I have a first event:

{"n":"pageview","u":"https://www.xxx.com/","d":"xxx.com","r":null}

Then when I click the button with the goal:

{"n":"Homepage_button","u":"https://www.xxx.com/","d":"xxx.com","r":null,"p":{"url":"https://app.xxx.com/secure/register"}}

Seems fair.

The api request on the stats page is then:

https://vince.xxx.com/api/stats/xxx.com/conversions/?period=day&date=2025-11-07&filters=[]&with_imported=true&limit=9

yielding:

{"results":[{"conversion_rate":6,"event":"Homepage_button","events":0,"visitors":1}]}

The issue might be that the backend doesn't return a name in the events/conversions but I'm not sure and it wasn't immediately obvious to me when reading the Go code.

@gernest, some opinion on this would help avoid wasting time in the wrong direction. Thanks.

edarchis avatar Nov 07 '25 10:11 edarchis

Thanks , I will take a look tomorrow. I want to see if we can resolve this on the backend first before accepting this patch, since the issue is very clear here.

Goals can be tied to event name or path, still need to investigate further in case this can be triggered by path as well which will mean something is broken with the backend.

gernest avatar Nov 07 '25 16:11 gernest