newrelic-experimental / newrelic-nextjs-integration

NewRelic Browser and APM agent NextJs integration (front and back-end respectively)
Apache License 2.0
28 stars 22 forks source link

Make _document SSG newrelic agent connect promise typesafe #18

Open kavitalikesfajitas opened 1 year ago

kavitalikesfajitas commented 1 year ago

https://github.com/newrelic-experimental/newrelic-nextjs-integration/blob/9a447df66b90dc7ad1e4e403b41aad8c00800cc5/pages/_document.tsx#L28-L32

This should be:

    if (newrelic && newrelic?.agent && !newrelic?.agent?.collector.isConnected()) {
      await new Promise((resolve) => {
        newrelic?.agent?.on?("connected", resolve);
      });
    }

In the event that NEW_RELIC_ENABLED is false or even just to generate a static next build or even just to run this locally in development mode with new relic not enabled because newrelic will crash the entire application.