Have ideas to improve npm?Join in the discussion! »

    nextapm
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.0 • Public • Published

    Nextapm

    Monitor the nextjs application and serverless functions deployed in vercel platform.

    Installation

    npm i nextapm
    

    Instrument

    Include the following snippets in pages/_app.js file

    import { monitorNextApp } from 'nextapm'; // should be in first line
    ... your app imports...
    
    function MyApp({ Component, pageProps }) {
      ... your app code ...
    }
    
    MyApp.getInitialProps = async (context) => {
      monitorNextApp(context); // should be in the first line in this method
      ...your app code and return props or {}...
    }
    
    export default MyApp
    

    Serverless API

    Wrap actual serverless API handler in following way for all API's.

    import { monitorServerlessApi } from 'nextapm'; // should be in first line
    ... you imports...
    
    module.exports = monitorServerlessApi((req, res) => {
      ... your api code ...
    })
    

    Exception tracking

    Use following method top track exceptions

    import { trackErr } from 'nextapm';
    
    try {
      ... your app code .. 
    } catch (err) {
      trackErr(err);
    }
    

    Evnironment variables

    Configure following environment values, you can get it from https://app.nextapm.dev after creating monitor NEXTAPM_LICENSE_KEY NEXTAPM_PROJECT_ID

    Restart/ Redeploy

    Finally restart/redeploy the application and perform transaction and check metrics in https://app.nextapm.dev dashboard

    Install

    npm i nextapm

    DownloadsWeekly Downloads

    2

    Version

    1.1.0

    License

    ISC

    Unpacked Size

    46.1 kB

    Total Files

    53

    Last publish

    Collaborators

    • avatar