Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Custom webVitals Endpoint in performance-relayer.ts #18907

Closed
simonireilly opened this issue Nov 6, 2020 · 3 comments
Closed

Allow Custom webVitals Endpoint in performance-relayer.ts #18907

simonireilly opened this issue Nov 6, 2020 · 3 comments

Comments

@simonireilly
Copy link

Feature request

This feature request is to allow for a custom URL in the vitalsUrl in performance-relayer.ts

Is your feature request related to a problem? Please describe.

The use case for this is to aggregate the webVitals from NextJS in any third-party tool using the efficient code path already present in the NextJS framework.

Describe the solution you'd like

An ideal solution would be to allow the URL to be set in the next.config.js so that it can be statically configured before the build.

module.exports = {
  vitalsUrl: '/api/v1/vitals'
}

Describe alternatives you've considered

Alternative 1

You can alternatively just engage analytics and monkey-patch through webpack:

module.exports = (phase, { defaultConfig }) => {
  defaultConfig.analyticsId = 'custom-id-for-application'

  defaultConfig.webpack = (config, options) => {
    config.module.rules.push(      {
      test: /performance-relayer\.js$/,
      loader: 'string-replace-loader',
      options: {
        search: 'https://vitals.vercel-analytics.com/v1/vitals',
        replace: '/api/v1/vitals',
        flags: 'g'
      }
    })

    return config
  }

  return defaultConfig
}

Alternative 2

You can follow the steps in https://nextjs.org/docs/advanced-features/measuring-performance to set up a custom implementation. This seems suboptimal given the best practices baked into performance-relayer.ts

Additional context

N/A

Thanks, I would of course understand if this is to remain a private API to allow for feature development.

@Timer
Copy link
Member

Timer commented Nov 6, 2020

We intentionally designed this in such a way that it is code eliminated when unused. Exposing this as a public API would prevent us from iterating on it in the future, as we'd need to keep semver-compliance.

Any custom analytics reporting should be introduced via reportWebVitals, which is semver stable.

There is nothing we do that you cannot do with the above method. Plus, you'll be able to send things in the exact shape you want (or ignore TTFB, etc)!

@Timer Timer closed this as completed Nov 6, 2020
@simonireilly
Copy link
Author

@Timer that makes a great deal of sense, thanks for your response 👍

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants