Coder Social home page Coder Social logo

Comments (6)

chriswdmr avatar chriswdmr commented on May 1, 2024 1

Awesome!
Side note: we're going to ship it as mode instead of __mode.

You can disable those log messages by providing the debug property with false if your mode is development.

Please see our documentation around the debug property

from analytics.

hyunbinseo avatar hyunbinseo commented on May 1, 2024

Ability to provide a custom isBrowser and isDevelopment value would be a cross-framework solution.

For example, SvelteKit provides both of them:

import { browser, dev } from '$app/environment';

from analytics.

chriswdmr avatar chriswdmr commented on May 1, 2024

Hey @hyunbinseo! Thank you for this detailed issue report!

We just published 0.1.6-beta.0 – you can install it via @vercel/analytics@beta.

Version 0.1.6-beta.0 includes a new property called mode. It allows you to bypass the existing logic in case we can't figure it out automatically.

Possible values for mode:

  • auto: default value if not defined – uses the existing logic to determine the right environment
  • development: forces the local development mode – no data will be submitted
  • production: forces the production mode which sends data

Any chance you could give it a try?

from analytics.

hyunbinseo avatar hyunbinseo commented on May 1, 2024

Thank you for the quick fix. It works as expected.

import { browser, dev } from '$app/environment';
import { inject } from '@vercel/analytics';

inject({ __mode: dev ? 'development' : 'production' });

In a browser accessing a Vite dev server, the following message is logged.

[Vercel Analytics] Debug mode is enabled by default in development. No requests will be sent to the server.

I hope there is an option to override is-browser and is-development.

For example, SvelteKit provides both browser and dev boolean values.

import { browser, dev } from '$app/environment';
import { inject } from '@vercel/analytics';

inject({ browser, dev }); // example

If values are not explicitly provided, the library can decide on its own.

from analytics.

hyunbinseo avatar hyunbinseo commented on May 1, 2024

@chriswdmr v0.1.6 looks great.

Should this issue be closed? mode still seems to be a workaround.

If all Vite projects still require the mode property to be explicitly set,

  1. It should be clearly stated in the documentation's 'Other Frameworks' section
  2. or, the isDevelopment check should be improved to support Vite out of the box.

from analytics.

chriswdmr avatar chriswdmr commented on May 1, 2024

Perfect, thanks for confirmation.

Closing as it's resolved with v0.1.6

Documentation is already updated

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.