Git Product home page Git Product logo

rollie's Introduction

Rollie

Rollie is a super-simple, small (some might even call it cute) Dust helper to aid with Rollbar integration. Rollie provides a simple way to include the client Rollbar snippet in your application.

Named after an amazing baseball player with an amazing mustache.

npm version

Installation

$ npm install rollie

Usage

Simply import or require the Rollie module, and let Rollie work its magic! Rollie will register itself as a helper under dust.helpers.

JavaScript

import 'rollie';

// the rest of your awesome application goes here

Once rollie is imported into your application, there are two ways to use it from within your Dust template:

Option 1 - rollbarConfig variable

<head>
    {@rollbar /}
</head>

With the first option, Rollie will look for a variable rollbarConfig within the current Dust context and attempt to parse it.

Option 2 - File path

<head>
    {@rollbar configPath="config/rollbar.json" /}
</head>

With the second option, Rollie will use the application's entry point by referencing require.main.filename and then attempt to resolve and parse the .json config file provided in the configPath parameter. This path should be relative to the root of your project.

Property Overrides

To allow for more dynamic setting of configuration properties, Rollie will automatically overwrite properties provided as params to the Dust helper that exist in the Rollbar configuration object. For example, take the following config. object / corresponding Dust template:

// config/rollbar.json
{
  "accessToken": "1234567890",
  "captureUncaught": true,
  "environment": "development",
  "payload": {
    // ...
  }
}
<head>
    {@rollbar configPath="config/rollbar.json" environment="test" /}
</head>

Will result in:

var _rollbarConfig = {
  accessToken: '1234567890',
  captureUncaught: true,
  environment: 'test',
  payload: {
    // ...
  }
};

Scrubbing Values

Often times, there are values that exist in your rollbar.json that you don't want to expose to the client, the serverAccessToken, for example. Rollie allows for an optional scrub parameter to be passed to the Dust helper. This parameter can either be a single value or an Array of values that represent the keys to be removed from the Rollbar configuration object before it is rendered to your Dust template. Take the example below:

// config/rollbar.json
{
  "SUPER_SECRET_INFO": "xxxxxxxx",
  "environment": "production",
  "captureUncaught": true
}
<head>
    {@rollbar configPath="config/rollbar.json" scrub="SUPER_SECRET_INFO" /};
</head>

Will result in:

var _rollbarConfig = {
  environment: 'production',
  captureUncaught: true
};

Note: Rollie doesn't make any attempt to validate your Rollbar configuration object! So take a look at their docs and follow the instructions!

Rollie Fingers

rollie's People

Contributors

eltonjuan avatar

Stargazers

Mike Delucchi avatar David Garcia avatar

Watchers

James Cloos avatar  avatar

rollie's Issues

Add a 'scrub' option.

In some cases, there are properties in your rollbar.json file that you don't want to be available in the client (e.g. your server access token). We should allow for users to specify either single properties or an array of properties that they would like to scrub before dust renders the Rollbar config to the outgoing template.

Test

I should probably write some tests

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.