Giter Club home page Giter Club logo

netlify-plugin's Introduction

New Relic Experimental header

New Relic Netlify Plugin GitHub GitHub issues GitHub pull requests GitHub last commit npm (scoped) npm npms.io (quality) Libraries.io dependency status for latest release, scoped npm package Lines of code

Monitor your Netlify build process and Jamstack application performance with New Relic, without the need for lengthy manual set up.

Built for developers who want to know how their deploys are impacting site performance for users, the New Relic Plugin for Netlify enables you to:

  • Automatically install the New Relic browser agent and notify New Relic each time a build event occurs in Netlify. Get critical insights via Real User Monitoring (RUM) into the performance of your Jamstack application.
  • Understand how each deploy impacts your site’s performance metrics in production.
  • Measure Google Core Web vitals on your site like Largest Contentful Paint, First Input Delay, and Cumulative Layout shift.
  • Quickly discover and fix errors before they impact your users.
  • Explore your data using our custom-built dashboards and receive alerts/notifications when there’s an issue with your Netlify site. Installing the New Relic Netlify Plugin

Installation

To install the plugin, log into your New Relic account (or sign up for a free account), then create a New Relic ingest license key and a New Relic browser ingest license key.

UI Installation

UI installation is the quickest way to start using the plugin, and does not require any modifications to your project's code.

File-based Installation

Alternatively, to install with file-based installation, add the following lines to your netlify.toml files:

package = "@newrelic/netlify-plugin"

  [plugins.inputs]
    newrelicAccountId = "123456"
    newrelicLicenseKey = "12345678901234567890"
    newrelicBrowserLicenseKey = "ABCD-0987654321"
    newrelicAppId = "123456789"
    enableBrowserMonitoring = true

Replace the values for newrelicAccountId, newrelicLicenseKey, newrelicBrowserLicenseKey, and newrelicAppId with your New Relic Account ID, the ingest and browser ingest license key you, and your New Relic Browser App ID.

Install the Netlify quickstart

To get the most out of your Netlify integration you should also install the New Relic Netlify quickstart. You can find more information on the quickstart page on New Relic I/O.

Settings

The plugin allows for customisation of the following settings via environment variables or your netlify.toml.

netlify.toml key Environment variable name Description Required for Default value
failBuildOnPluginError FAIL_BUILD_ON_PLUGIN_ERROR Fail the whole build if the plugin has an error true
newrelicAccountId NEWRELIC_ACCOUNT_ID New Relic Account ID event tracking & browser monitoring undefined
newrelicRegion NEWRELIC_REGION New Relic Account Region (us or eu) event tracking us
newrelicLicenseKey NEWRELIC_INGEST_LICENSE_KEY New Relic Ingest License Key event tracking undefined
newrelicBrowserLicenseKey NEWRELIC_BROWSER_LICENSE_KEY New Relic Ingest License Key event tracking undefined
newrelicAppId NEWRELIC_APP_ID New Relic APM App ID browser monitoring undefined
recordEventsForPreviews RECORD_EVENTS_FOR_PREVIEWS Set this to true if you want to record events for deploy previews false
skipEvent.onPreBuild SKIP_PRE_BUILD_EVENT Set this to true to skip recording onPreBuild custom events false
skipEvent.onBuild SKIP_BUILD_EVENT Set this to true to skip recording onBuild custom events false
skipEvent.onPostBuild SKIP_POST_BUILD_EVENT Set this to true to skip recording onPostBuild custom events false
skipEvent.onSuccess SKIP_SUCCESS_EVENT Set this to true to skip recording onSuccess custom events false
skipEvent.onError SKIP_ERROR_EVENT Set this to true to skip recording onError custom events false
skipEvent.onEnd SKIP_END_EVENT Set this to true to skip recording onEnd custom events false
enableBrowserMonitoring ENABLE_BROWSER_MONITORING Attempt to inject the browser monitor script tag into any HTML pages false
enableBrowserMonitoringForPreviews ENABLE_BROWSER_MONITORING_FOR_PREVIEWS Set this to true if you want to enable browser monitoring for deploy previews false
distributedTracingEnabled DISTRIBUTED_TRACING_ENABLED Enable distributed tracing for browser requests true
cookiesEnabled COOKIES_ENABLED Enable cookies for browser monitoring true
htmlInjectionConcurrency HTML_INJECTION_CONCURRENCY Number of concurrently pending promises to use when injecting browser agent 5
revisionTemplate REVISION_TEMPLATE Deploy marker revision and release version id structure (EJS string) <% if(git.commits[0].message){ % ><%= git.commits[0].message.slice(0,25) % >-<% } % ><%= process.env.CONTEXT % >-<%= process.env.COMMIT_REF.slice(0, 7) % >-<%= process.env.DEPLOY_ID.slice(-6) % >-<%= process.env.BUILD_ID.slice(-6) % >

Support

The plugin is part of New Relic experimental. The project is being developed in the open and we welcome all feedback and contributions.

Please raise an issue or contact us via the New Relic Explorers Hub.

Contributing

We encourage your contributions to improve the New Relic Netlify Plugin!

Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.

If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at [email protected].

A note about vulnerabilities

As noted in our security policy, New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.

If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through HackerOne.

License

The New Relic Netlify plugin is licensed under the Apache 2.0 License.

netlify-plugin's People

Contributors

aaronbassett avatar bizob2828 avatar louisleungk avatar maicadk avatar ptahdunbar avatar sg60 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

netlify-plugin's Issues

Automate creation of New Relic license keys and IDs

Summary

From a discussion in New Relic internal Slack:

One of the features I would like to add is the ability for users to choose (via the config) to either:

Supply just an app name and a New Relic user key

The plugin would during the build use Nerd Graph to either find the required app ids/license keys, or if not found, create them.

Pro: requires less configuration by the user, more streamlined.
Con: there is no way to persist the keys between builds on Netlify so we would need to look up the keys each build adding a dependency between Netlify and New Relic in order for the build to complete successfully. Any network issues between us and them could cause delayed or even failed builds.

Supply the required ids/keys (the current method)

Same as it is now.

Pro: no dependency between us. No need to make network I/O during builds.
Con: requires more configuration by the user, they probably already need to be a New Relic user to be able to complete configuration smoothly

Tasks

Sum of Conditions will be retired on June 30th

This IO Starter will not create NRQL Alerts Conditions if it uses "Sum of" thresholds by June 30th.

Summary

This quick start creates NRQL Alert Conditions whose value function is "Sum of". Note that on June 30th, the Alerts team will disable creation of NRQL conditions using "Sum of" thresholds, and existing "Sum of" conditions will be converted to use Sliding Window Aggregation. https://discuss.newrelic.com/t/end-of-life-for-sum-of-query-results-thresholds/177975

Desired Behavior

Instead of creating "Sum of" conditions, it should create "Sliding window aggregation" conditions. There is a wizard in the Condition Builder showing what the conditions should look like.

Screen Shot 2022-04-25 at 10 25 23 AM

Possible Solution

  • Create Sliding window aggregation conditions instead of "Sum of" conditions.

Additional context

  • This Instant Observability plugin will not create NRQL Alert Conditions well if it continues to use "Sum of" thresholds.

Unhandled onError event during build

I installed the plugin through Netlify UI, configured all according to the blog post about the plugin, but I'm getting build error when deploying my site.

Description

As above.

Steps to Reproduce

I was following the steps from the blog post linked above.

The site is a Create React App project if that's relevant.

Expected Behavior

The build to not fail :)

But if there's a configuration error on my side (e.g. wrong ingest key?), surface that error.

Relevant Logs / Console output

1:12:12 PM: ────────────────────────────────────────────────────────────────
1:12:12 PM:   3. @newrelic/netlify-plugin (onBuild event)                   
1:12:12 PM: ────────────────────────────────────────────────────────────────
1:12:12 PM: ​
1:12:12 PM: ​
1:12:12 PM: ────────────────────────────────────────────────────────────────
1:12:12 PM:   4. @newrelic/netlify-plugin (onError event)                   
1:12:12 PM: ────────────────────────────────────────────────────────────────
1:12:12 PM: ​
1:12:12 PM: ​
1:12:12 PM: (@newrelic/netlify-plugin onError completed in 6ms)
1:12:12 PM: ​
1:12:12 PM: ────────────────────────────────────────────────────────────────
1:12:12 PM:   5. @newrelic/netlify-plugin (onEnd event)                     
1:12:12 PM: ────────────────────────────────────────────────────────────────
1:12:12 PM: ​
1:12:12 PM: ​
1:12:12 PM: (@newrelic/netlify-plugin onEnd completed in 8ms)
1:12:12 PM: ​
1:12:12 PM: ────────────────────────────────────────────────────────────────
1:12:12 PM:   Plugin "@newrelic/netlify-plugin" internal error              
1:12:12 PM: ────────────────────────────────────────────────────────────────
1:12:12 PM: ​
1:12:12 PM:   Error message
1:12:12 PM:   UnhandledRejection: a promise was rejected but not handled: Error: function httpAdapter(config) {
1:12:12 PM:     return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise)...<omitted>...
1:12:12 PM:   } could not be cloned.
1:12:12 PM:     return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise)...<omitted>...
1:12:12 PM:   } could not be cloned.
1:12:12 PM: ​
1:12:12 PM:   Plugin details
1:12:12 PM:   Package:        @newrelic/netlify-plugin
1:12:12 PM:   Version:        1.0.1
1:12:12 PM:   Repository:     git+https://github.com/newrelic-experimental/netlify-plugin.git
1:12:12 PM:   npm link:       https://www.npmjs.com/package/@newrelic/netlify-plugin
1:12:12 PM:   Report issues:  https://github.com/newrelic-experimental/netlify-plugin/issues
1:12:12 PM: ​
1:12:12 PM:   Error location
1:12:12 PM:   In "onBuild" event in "@newrelic/netlify-plugin" from Netlify app
1:12:12 PM:       at writeChannelMessage (node:internal/child_process/serialization:82:9)
1:12:12 PM:       at process.target._send (node:internal/child_process:839:17)
1:12:12 PM:       at process.target.send (node:internal/child_process:739:19)
1:12:12 PM:       at node:internal/util:360:7
1:12:12 PM:       at new Promise (<anonymous>)
1:12:12 PM:       at bound  (node:internal/util:346:12)
1:12:12 PM:       at sendEventToParent (file:///opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins/ipc.js:123:46)
1:12:12 PM:       at handleError (file:///opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins/child/error.js:13:9)
1:12:12 PM:       at Object.handleProcessError [as log] (file:///opt/buildhome/node-deps/node_modules/@netlify/build/src/plugins/child/error.js:31:9)
1:12:12 PM:       at logEvent (file:///opt/buildhome/node-deps/node_modules/log-process-errors/build/src/handle/common.js:53:12)
1:12:12 PM: ​
1:12:12 PM:   Resolved config
1:12:12 PM:   build:
1:12:12 PM:     command: npm run build
1:12:12 PM:     commandOrigin: ui
1:12:12 PM:     environment:
1:12:12 PM:       - ENABLE_BROWSER_MONITORING
1:12:12 PM:       - NEWRELIC_ACCOUNT_ID
1:12:12 PM:       - NEWRELIC_APP_ID
1:12:12 PM:       - NEWRELIC_BROWSER_LICENSE_KEY
1:12:12 PM:       - NEWRELIC_INGEST_LICENSE_KEY
1:12:12 PM:       - REACT_APP_COOKIES_DOMAIN
1:12:12 PM:       - REACT_APP_FB_PIXEL_ID
1:12:12 PM:       - REACT_APP_GRAPHQL_API_ENDPOINT
1:12:12 PM:       - REACT_APP_GRAPHQL_SUBSCRIPTIONS_API_ENDPOINT
1:12:12 PM:       - REACT_APP_GTM_TRACKING_ID
1:12:12 PM:       - REACT_APP_LIVE_MODE
1:12:12 PM:       - REACT_APP_REST_API_ENDPOINT
1:12:12 PM:       - REACT_APP_SEGMENT_API_KEY
1:12:12 PM:       - REACT_APP_SENTRY_DSN
1:12:12 PM:       - SENTRY_AUTH_TOKEN
1:12:12 PM:       - SENTRY_ORG
1:12:12 PM:       - SENTRY_PROJECT
1:12:12 PM:       - SKIP_PREFLIGHT_CHECK
1:12:12 PM:     publish: /opt/build/repo/build
1:12:12 PM:     publishOrigin: ui
1:12:12 PM:   headers:
1:12:12 PM:     - for: /static/*.woff
      values:
        Cache-Control: public, max-age=31536000, immutable
    - for: /static/*.woff2
      values:
        Cache-Control: public, max-age=31536000, immutable
    - for: /*
      values:
        Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
  headersOrigin: config
  plugins:
    - inputs: {}
      origin: ui
      package: '@newrelic/netlify-plugin'
  redirects:
    - from: /*
      status: 200
      to: /index.html

Your Environment

Additional context

[Repolinter] Open Source Policy Issues

Repolinter Report

🤖This issue was automatically generated by repolinter-action, developed by the Open Source and Developer Advocacy team at New Relic. This issue will be automatically updated or closed when changes are pushed. If you have any problems with this tool, please feel free to open a GitHub issue or give us a ping in #help-opensource.

This Repolinter run generated the following results:

❗ Error ❌ Fail ⚠️ Warn ✅ Pass Ignored Total
0 1 0 5 0 6

Fail #

readme-starts-with-experimental-header #

The README of an experimental project should have an experimental header at the start of the README. If you already have an experimental header and this rule is failing, your header may be out of date, and you should update your header with the suggested one below. For more information please visit https://opensource.newrelic.com/oss-category/. Below is a list of files or patterns that failed:

  • README.md: The first 5 lines do not contain the pattern(s): Open source experimental header (see https://opensource.newrelic.com/oss-category).
    • 🔨 Suggested Fix: prepend [![New Relic Experimental header](https://github.com/newrelic/opensource-website/raw/main/src/images/categories/Experimental.png)](https://opensource.newrelic.com/oss-category/#new-relic-experimental) to file

Passed #

Click to see rules

license-file-exists #

Found file (LICENSE). New Relic requires that all open source projects have an associated license contained within the project. This license must be permissive (e.g. non-viral or copyleft), and we recommend Apache 2.0 for most use cases. For more information please visit https://docs.google.com/document/d/1vML4aY_czsY0URu2yiP3xLAKYufNrKsc7o4kjuegpDw/edit.

readme-file-exists #

Found file (README.md). New Relic requires a README file in all projects. This README should give a general overview of the project, and should point to additional resources (security, contributing, etc.) where developers and users can learn further. For more information please visit https://github.com/newrelic/open-source-tools/tree/master/nerdpacks/oss-template.

readme-contains-link-to-security-policy #

Contains a link to the security policy for this repository (README.md). New Relic recommends putting a link to the open source security policy for your project (https://github.com/newrelic-experimental/<repo-name>/security/policy or ../../security/policy) in the README. For an example of this, please see the "a note about vulnerabilities" section of the Open By Default repository. For more information please visit https://nerdlife.datanerd.us/new-relic/security-guidelines-for-publishing-source-code.

code-of-conduct-should-not-exist-here #

New Relic has moved the CODE_OF_CONDUCT file to a centralized location where it is referenced automatically by every repository in the New Relic organization. Because of this change, any other CODE_OF_CONDUCT file in a repository is now redundant and should be removed. Note that you will need to adjust any links to the local CODE_OF_CONDUCT file in your documentation to point to the central file (README and CONTRIBUTING will probably have links that need updating). For more information please visit https://docs.google.com/document/d/1y644Pwi82kasNP5VPVjDV8rsmkBKclQVHFkz8pwRUtE/view. Did not find a file matching the specified patterns. All files passed this test.

third-party-notices-file-exists #

Found file (THIRD_PARTY_NOTICES.md). A THIRD_PARTY_NOTICES.md file can be present in your repository to grant attribution to all dependencies being used by this project. This document is necessary if you are using third-party source code in your project, with the exception of code referenced outside the project's compiled/bundled binary (ex. some Java projects require modules to be pre-installed in the classpath, outside the project binary and therefore outside the scope of the THIRD_PARTY_NOTICES). Please review your project's dependencies and create a THIRD_PARTY_NOTICES.md file if necessary. For JavaScript projects, you can generate this file using the oss-cli. For more information please visit https://docs.google.com/document/d/1y644Pwi82kasNP5VPVjDV8rsmkBKclQVHFkz8pwRUtE/view.

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.