Coder Social home page Coder Social logo

Getting 404 for `script.js` about analytics HOT 57 CLOSED

vercel avatar vercel commented on May 1, 2024 27
Getting 404 for `script.js`

from analytics.

Comments (57)

tobiaslins avatar tobiaslins commented on May 1, 2024 27

We're actively working on a solution for this issue. We'll keep you posted!

from analytics.

tobiaslins avatar tobiaslins commented on May 1, 2024 17

Hey everyone!
We just rolled out the fix for this issue.
You will have to redeploy your apps to make it work.

Let us know how it goes ๐Ÿ™Œ

from analytics.

bogy0 avatar bogy0 commented on May 1, 2024 13

Unfortunately, re-deploying my project is not solved the error log in my case.

from analytics.

valdemardev01 avatar valdemardev01 commented on May 1, 2024 13

Found out that mby if you use adblock, that will stop the script.js from running.

from analytics.

vojto avatar vojto commented on May 1, 2024 9

Same issue with SvelteKit.

from analytics.

JoshLittlewood avatar JoshLittlewood commented on May 1, 2024 7

Removing i18n from my next.config.js did resolve the issue for me.

from analytics.

frontsideair avatar frontsideair commented on May 1, 2024 5

I'm also having a similar problem. I don't get any analytics data on my dashboard though.

I added this to my Gatsby project by adding inject to gatsby-browser.js, which does its job and adds the script to the <head>. But the va/script.js gives a 404, which makes sense because there's no such file anywhere. Is Vercel supposed to intercept and serve this file?

I also have rewrites defined in my project so maybe this is overriding the hypothesized intercept. This may be an edge case.

from analytics.

GizmoRay avatar GizmoRay commented on May 1, 2024 5

+1 - facing the same issue. Some guidance on how best to handle both a 404 page + allowing the analytics package to come through would be great.

from analytics.

dglsparsons avatar dglsparsons commented on May 1, 2024 5

Okay, it seems like we still have some issues relating to i18n interfering with analytics. We're working on a fix for sites using i18n now. I believe sites without i18n should work fine though.

from analytics.

reevosolutions avatar reevosolutions commented on May 1, 2024 5

I think this happens when you integrate the analytics on your project without activating the analytics on Vercel

from analytics.

remisture avatar remisture commented on May 1, 2024 4

We're actively working on a solution for this issue. We'll keep you posted!

Any updates?

from analytics.

aprendendofelipe avatar aprendendofelipe commented on May 1, 2024 4

There seems to be an incompatibility with the i18n configuration in next.config.js.

from analytics.

dglsparsons avatar dglsparsons commented on May 1, 2024 4

Hi, further update here: we've shipped a change that should resolve any issues with i18n interference. You'll need to redeploy (again) to see the changes, but ๐Ÿคž this resolves any remaining issues! Let me know if it doesn't work :)

from analytics.

chriswdmr avatar chriswdmr commented on May 1, 2024 2

As @max correctly pointed out, the mentioned path /va/script.js will become available on your next deployment after you enabled the feature.

If you added the package before you enabled the feature, you can trigger a redeployment which has the same effect.

@bogy0 It seems like the error you're seeing is related to your browser as you already get data. Have you tried disabling all extensions/ad-blockers?

from analytics.

paulmwatson avatar paulmwatson commented on May 1, 2024 2

Happening on our NextJS site hosted on Vercel too. i18n worth more than analytics at the moment so will wait for official fix.

from analytics.

alex-grover avatar alex-grover commented on May 1, 2024 2

I got the analytics to work using the plain HTML approach in my project (didn't even need to install the NPM package). Thank you!

from analytics.

vacodoceo avatar vacodoceo commented on May 1, 2024 2

@tobiaslins I just checked again and it's working. I enabled audiences, redeployed, and it started working. It's strange because I redeployed a couple of times an hour ago and it didn't work, and I don't think enabling audiences was what fixed it.

Anyway, thanks for the support!

from analytics.

tobiaslins avatar tobiaslins commented on May 1, 2024 2

@vacodoceo we just rolled out a fix for i18n, it takes a while until it's available for everyone!
thanks for confirming ๐Ÿค—

from analytics.

tjkohli avatar tjkohli commented on May 1, 2024 2

It works with SvelteKit after redeploying! Thank you so much. ๐Ÿ™๐Ÿผ

from analytics.

tomegger avatar tomegger commented on May 1, 2024 2

It works now! ๐Ÿ™Œ

from analytics.

schnubor avatar schnubor commented on May 1, 2024 1

Having the same problem (script 404) on a Next 13 app (still using /pages) with a custom 404 page. disabled & enabled the feature in the vercel UI again and redeployed, still 404ing. Also not seeing any data in the Audience dashboard which I think is just a side effect. It says "Vercel Analytics is set up, but detected a non-production environment." on my local though, so it's at least trying to do something.

from analytics.

joulev avatar joulev commented on May 1, 2024 1

@tobiaslins Can confirm that it is working now for my Nuxt app (#5). I got another app (SvelteKit) working with a similar method too.

from analytics.

frontsideair avatar frontsideair commented on May 1, 2024 1

Works for me as well, thanks! As a docs suggestion, I added the inject script to gatsby-node.js for Gatsby, as it seemed like the correct place for it.

from analytics.

paulmwatson avatar paulmwatson commented on May 1, 2024 1

Thanks @dglsparsons, just did a re-deploy there (leaving analytics enabled) and same error.

from analytics.

vacodoceo avatar vacodoceo commented on May 1, 2024 1

@tobiaslins still having the same error with SvelteKit

from analytics.

Robin-w151 avatar Robin-w151 commented on May 1, 2024 1

I can confirm that it is now working for my SvelteKit app after I did a redeployment and leaving audiences enabled.

from analytics.

paulmwatson avatar paulmwatson commented on May 1, 2024 1

Excellent, it works now, thanks for the work

from analytics.

mehulmpt avatar mehulmpt commented on May 1, 2024 1

Works for us too ๐Ÿ™Œ

from analytics.

schnubor avatar schnubor commented on May 1, 2024 1

Works, thanks! :)

from analytics.

aprendendofelipe avatar aprendendofelipe commented on May 1, 2024 1

Now it's working with i18n. Thanks!

from analytics.

NuroDev avatar NuroDev commented on May 1, 2024

But the va/script.js gives a 404, which makes sense because there's no such file anywhere. Is Vercel supposed to intercept and serve this file?

Yeah same here. Have another site that has this package working & manually added the /va/script.js to my public/ directory but then got another error from failing to post to /va/view.

Does seem like it's usually expected that Vercel will add / intercept any requests to /va/... endpoint(s) but it isn't for some reason?

from analytics.

alex-grover avatar alex-grover commented on May 1, 2024

Seeing a 404 as well with an Astro project, using both the plain HTML approach as well as using inject().

from analytics.

max avatar max commented on May 1, 2024

Possibly not the reason y'all are seeing the error but I was also getting a 404 for the injected script when deploying @vercel/analytics. Turns out you first have to enable the feature in the dashboard and then deploy the library (a re-deploy fixed it for me).

from analytics.

tomegger avatar tomegger commented on May 1, 2024

Same problem here. Iยดve already tried all steps (re-deploying, enabling/disabling, etc.) but still have the same error as @bogy0.

from analytics.

chriswdmr avatar chriswdmr commented on May 1, 2024

Would you mind creating a minimal reproduction?

Ideally a small repo that gets deployed to Vercel so we can have a closer look!

from analytics.

bogy0 avatar bogy0 commented on May 1, 2024

will do later today

from analytics.

tomegger avatar tomegger commented on May 1, 2024

Iยดve also a simple app if you want to take a look

from analytics.

frontsideair avatar frontsideair commented on May 1, 2024

I also tried redeploying but didn't work in my case. It's not minimal but my blog, for which I want to use the analytics, is open-source.

from analytics.

chriswdmr avatar chriswdmr commented on May 1, 2024

I also tried redeploying but didn't work in my case. It's not minimal but my blog, for which I want to use the analytics, is open-source.

Thanks for providing an example!

It seems like that your custom 404 page is catching all routes โ€“ including the /va/script.js URL.
You have to instrument Gatsby in a way that it ignores this URL.

from analytics.

frontsideair avatar frontsideair commented on May 1, 2024

Thanks, I added the redirect manually to bypass Gatsby with the this config, which is transformed with gatsby-plugin-zeit-now plugin. This fixed the 404 issue and requests are actually sent and response is received, but my dashboard doesn't load any data.

from analytics.

chriswdmr avatar chriswdmr commented on May 1, 2024

@frontsideair the script is available behind your own domain and not via vercel.com.
Please change vercel.com to your own domain.

from analytics.

frontsideair avatar frontsideair commented on May 1, 2024

I understand and removed the redirect to vercel.com, I haven't found a good workaround so I'm giving up on this for now. Waiting for an official solution.

from analytics.

mehulmpt avatar mehulmpt commented on May 1, 2024

Same for us. With rewrites enabled the @vercel/analytics script throws 404.

from analytics.

pyronaur avatar pyronaur commented on May 1, 2024

I created a static blank /va/script.js on my Astro site in hopes that would get replaced, but looks like that didn't do anything either.

from analytics.

diffTed avatar diffTed commented on May 1, 2024

Same here (Next 13)

from analytics.

sgarcia22 avatar sgarcia22 commented on May 1, 2024

Same problem, I get a Uncaught SyntaxError: Unexpected token '<' (at script.js:1:1) and cannot access any analytics.

I'm using Vue v2, and tried injecting it with the inject() call in both the app.js mounted() callback, and in main.js when creating the Vue app.

Also tried using it in the HTML <script async src="/va/script.js"></script>.

In my routes I have this however, not sure if that is causing a problem like the comments above or how I would go about fixing that.

  {
    path: "/:catchAll(.*)",
    name: "NotFound",
    redirect: "/",
    meta: {title: "๐Ÿ˜” - 404"},
  },

from analytics.

paulmwatson avatar paulmwatson commented on May 1, 2024

Thanks @tobiaslins but I'm getting the same error. Re-enabled the analytics, updated the code, re-deployed, but same https://www.somersetstrikers.co.za/va/script.js 404 error.

from analytics.

dglsparsons avatar dglsparsons commented on May 1, 2024

Thanks @tobiaslins but I'm getting the same error. Re-enabled the analytics, updated the code, re-deployed, but same https://www.somersetstrikers.co.za/va/script.js 404 error.

Hi @paulmwatson, it looks like you enabled Analytics after deploying the project. It needs to be enabled before making the deployment. Could you re-deploy again and check? :)

from analytics.

darasus avatar darasus commented on May 1, 2024

Same, redeployed multiple times while analytics enabled and still seeing 404

from analytics.

tobiaslins avatar tobiaslins commented on May 1, 2024

@vacodoceo can you please share the last deployment url with us to take a closer look?

from analytics.

Dogtiti avatar Dogtiti commented on May 1, 2024

same issue

from analytics.

tobiaslins avatar tobiaslins commented on May 1, 2024

@FlatMapIO @Dogtiti can you please send me a deployment URL so I can take a look for you? Happy to dig deep!

from analytics.

Dogtiti avatar Dogtiti commented on May 1, 2024

@tobiaslins https://auto-agentgpt.com/

from analytics.

tobiaslins avatar tobiaslins commented on May 1, 2024

@Dogtiti It seems like you've already collected data once with that domain but currently Web Analytics for that project is disabled. Head over to the Analytics tab for this project, enable it & redeploy to start collecting data again!

from analytics.

Dogtiti avatar Dogtiti commented on May 1, 2024

from analytics.

rkreicbergs-sorsera avatar rkreicbergs-sorsera commented on May 1, 2024

We also get 404 errors in Datadog, but not sure it's the same issue.

  • We've enabled Analytics for our app and we actually see data in dashboard
  • we use the NPM package in our _app.tsx:
 import { Analytics } from "@vercel/analytics/react"; 
 [....]
<Analytics />
  • in DataDog we an error about 404 from https://vitals.vercel-insights.com/v1/view?dsn=vxVf....
    If I understand corretly, the plugin calls /_vercel/insights/view which gets the error and the logs it

  • as noted, we do see data in the dashbaord and this issue is intermittent, but seems to happen at least once in 2 days and we've done a bunch of new deployments since enabling it - the problem persists

  • last error today was for sorsera-bzouxhxkx-sorsera.vercel.app

Can any of this be explained by ad blockers? IIUC, that could not explain it - it would simple not call /_vercel/insights/view at all and thus we'd not get any errors, no?

Can this be explained by a crawler or smth accessing /_vercel/insights/view directly? if I open it manually, just got the same type of error in DataDog. Can I enable some input validation for that page or something? If nothing else, we'll just ignore all those logs completely, which doesn't seem like the right approach.

from analytics.

oucar avatar oucar commented on May 1, 2024

I got the exact same error, in my environment my ad blocker was causing the issue. Disabling it solved the problem.

from analytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.