counterscale icon indicating copy to clipboard operation
counterscale copied to clipboard

Option to bypass Electron and empty host check

Open Halyul opened this issue 11 months ago • 6 comments

Hi, I have a very special case where I want to track file:// urls. As there is a check in trackPageview, I would like to know if an option to bypass the check can be added in the future.

Halyul avatar Jan 28 '25 09:01 Halyul

Yep, I think we can figure this out.

benvinegar avatar Jan 29 '25 20:01 benvinegar

@Halyul Looked at this and thought it best just to remove the check entirely. Thoughts on #156?

benvinegar avatar Feb 04 '25 21:02 benvinegar

@Halyul Sorry for the slow reply on this – I wanted to break out Electron and verify the behavior myself.

I put together a "Hello, World" Electron app with a minimal HTML file, loaded up tracker.js, and it seems ... to work?

I don't think I read this code correctly, initially:

if (r.host === "" && navigator.userAgent.indexOf("Electron") < 0)
    return;

If host is an empty string, and the user agent includes Electron, it allows the pageview request to go forward (it only returns if "Electron" is not present). Basically this is a carve out to ensure host-less pageviews are allowed as long as it's an Electron environment.

If you're seeing differently, could you provide a repro case?

benvinegar avatar Mar 21 '25 14:03 benvinegar

If host is an empty string, and the user agent includes Electron, it allows the pageview request to go forward (it only returns if "Electron" is not present). Basically this is a carve out to ensure host-less pageviews are allowed as long as it's an Electron environment.

I believe this is the case. My case is that I wanna track file:// urls opened in chrome, which is empty host and not Electron, causing return at this line. So I make this request to provide an option to bypass this

Halyul avatar Mar 22 '25 00:03 Halyul

Ah, oops, I'd totally misunderstood this ticket from the very beginning. I'd presumed the Electron code was blocking your Electron app. Got it now.

benvinegar avatar Mar 22 '25 14:03 benvinegar

Testing comment retrieval

benvinegar avatar Apr 10 '25 02:04 benvinegar