npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mothership-js

v1.1.0

Published

Mothership JavaScript Library for logging errors

Downloads

3

Readme

Mothership JS

About

Mothership JS allows you to log client-side errors to your Mothership account where you can gather and organize logs in addition to performing backups, healthchecks, and sync your devlopment box with your various environments in seconds.

Once you've signed up let's get started!

Installing

JS Module

To import mothership js logs as a module include it an initialize with your logging token at https://mothership.app/ > Project > Project Settings > Log Settings

yarn add mothership-js
npm install mothership-js --save
import MothershipJs from 'mothership-js'
...
var mjs = new MothershipJs({apiKey: 'XXXXXXXX'});

Do note that you will need Mothership JS to init pretty early in your page load to catch all the errors so ensure it's bundled in something that loads towards the top of the head before any other libraries that you may want to debug

Library

Download mothership-js.lib.js and place it in your javascript directory (the example below we assume it's called "js").

Drop the following into your <head> as close to the top as you can and populate the apiKey with your logging token at https://mothership.app/ > Project > Project Settings > Log Settings

<script>
  window.MothershipConfig = { apiKey: "XXXXXX" };
</script>
<script src="js/mothership-js.lib.js"></script>

This will create window.MothershipJs which you can access from anywhere to change configuration or execute errors in your try/catch or anywhere you need to log something.

Options

Here are the default options

apiKey: "", // required
enabled: true, // enables or disables logging entirely
environment: null, // String defining the environment
version: null, // String defining the version
minimumErrorLevel: "debug", // The minimum error level to log (must be at least "error" to capture uncaught exceptions)
customPayload: {}, // An object of any custom information
allowedDomains: [], // Array of strings of domains that should be logged
disallowedDomains: [], // Array of strings of domains that shouldn't be logged
disableIPCapture: false, // Tells Mothership not to store the IP Address of the client logging
captureUncaught: true // If disabled will not capture uncaught exceptions

They can be set on the library install like-a-so:

<script>
  window.MothershipConfig={
    apiKey: "XXXXXX",
    disallowedDomains: ['google.com', 'whatever.com'],
    ...etc...
  }
</script>
<script src="/main.js"></script>

Or, on when using it as a js module:

new MothershipJs({
  apiKey: 'XXXXXXXX',
  disableIPCapture: true,
  ...
});

You can also set individual settings like so:

Setting options from the library instance

window.MothershipJs.environment = "production";
window.MothershipJs.version = "1.0.3";

Setting options from js module instance

mjs.environment = "production";
mjs.version = "1.0.3";

Usage

Out of the box Mothership JS will automatically submit all uncaught errors that happen. If you would like to log errors that are caught you can use the following methods:

Example from Library Install

window.MothershipJs.critical("Woah, we messed up");
window.MothershipJs.error("Like... really messed up");
window.MothershipJs.warn("I mean... not that bad");
window.MothershipJs.info("We just wanted to know");
window.MothershipJs.debug("This was all a test");

Example when using the JS Module

mjs.critical("Woah, we messed up");
mjs.error("Like... really messed up");
mjs.warn("I mean... not that bad");
mjs.info("We just wanted to know");
mjs.debug("This was all a test");

Development and Testing

Build

This will build both the library and the js module packages

yarn build-lib
npm run build-lib

Development

yarn serve
npm run serve

Testing

yarn test
npm run test