Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

gaelreyrol/nuxt-rollbar-module

Repository files navigation

nuxt-rollbar-module

npm (scoped with tag) npm CircleCI Codecov Dependencies js-standard-style

Rollbar module for NuxtJS

Setup

  • Add nuxt-rollbar-module dependency using yarn or npm to your project
npm install --save nuxt-rollbar-module
yarn add nuxt-rollbar-module
  • Add nuxt-rollbar-module to modules section of nuxt.config.js
{
  modules: [
    // Simple usage
    'nuxt-rollbar-module',

    // With options
    [
      'nuxt-rollbar-module',
      {
        serverAccessToken: 'YOUR_ROLLBAR_SERVER_TOKEN',
        clientAccessToken: 'YOUR_ROLLBAR_CLIENT_TOKEN',
        config: {
          // Addtional config
        }
      }
    ]
  ]
}

Usage

Enter your project access tokens in the NuxtJS config file. See Rollbar javascript documentation for options.

Usage in Vue.js

Vue.rollbar.debug('Yohyo!')
// or in a vue component
this.$rollbar.debug('Yohyo!')

Usage in Nuxt.js

export default {
  asyncData(context) {
    // called by only server side
    context.$rollbar.debug('Yohyo!')
  },

  created() {
    // called by both server side and client side
    this.$rollbar.debug('Yohyo!')

    if (process.server) {
      this.$rollbar.debug('from server side')
    }

    if (process.client) {
      this.$rollbar.debug('from client side')
    }
  },

  mounted() {
    // called by only client side
    this.$rollbar.debug('Yohyo!')
  }
}

Options

Development

  • Clone this repository
  • Install dependencies using yarn install or npm install
  • Start development server using npm run dev

License

MIT License

Copyright (c) Gaël Reyrol me@gaelreyrol.com