codefellows-slipup

1.0.0 • Public • Published

SlipUp

An npm package library that logs and saves error events in a PostgreSql database.

Version

Contributors: Ryan Geddes, Davee Sok, Ben Hill, Jonathon Lee.

Version: 0.0.7

Project Overview

Purpose of our application is provide user with an easy method to automatically log, filter, and search through their projects error events. The goal is to provide google functionality for error events. Our architecture is based off of splunk.

Architecture

Handles data pipeline through 3 distinct tiers.

- Forwarder
- Indexer
- Search Head

UML Diagram

Our UML diagram will give you insight on how SlipUp is wired. Click below for a whiteboard visual.

Project Tasks

Project notes

Every project needs a task list and notes for consistent progress and documentation. We used github projects do document our build progress. Link below will show you our progress notation.

Dependencies and Tools

JavaScript Node.js SQL npm postgres sql chalk npm chalk

Javascript ➡ Node.js ➡ Sql ➡ Inquirer ➡ PostgreSql ➡ Prisma ➡ Npm ➡ Chalk

Getting started

  1. Install SlipUp library with the following commands. Note: must have npm installer.
$npm i codefellows-slipup
  1. Input Postgres username.
Upon installation, SlipUp will request Postgres username. Note: User must have a Postgres account.
Note: Mac users should use mac login credentials.
  1. Postgres password.
Upon inputting Postgres username SlipUp will request Posgres password. 
This will allow user to save error logs in Postgres.
  1. Choose port.
User is given the option to assign an env port. If no port is chosen SlipUp will assign default 
port 5432.
  1. Name your Postgres db.
User is given the option to assign a Postgres database name. 
If a name is not chosen SlipUp will assign (Splunk) as the database name.
  1. Note on projects that use Postgres and .env files.
SlipUp uses Prisma as an interface with Postgres database. Prisma by default searches for a 
DATABASE_URL variable to connect to any env file it detects.
Note: Must reserve DATABASE_URL variable name in order for SlipUp to work.

Using SlipUp

Require SlipUp library Ex:

const slipUp = require('codefellows-slipup');


function test1(param) {
  try {
    let num = 123;
    return num.toUpperCase();
  } catch (error) {
    slipUp.logError(error, 'userId', param, 'enter custom note or identifier');
  }
}


SlipUp Exports a singleton that has a method called logError(). logError() accepts the following 4 parameters which will be uploaded automatically to a Sql database when it is called.

slipUp.logError(errorObject, userId, parameter, customNote);

Parameters
errorObject:
This parameter is required. This is the error object in your try catch block. It logs an error object to the database and expects a standard error object. Columns will automatically be created for each error objects in the database that contain the following properties:

  • Error name
  • Error message
  • Error stack

userId:
This parameter is required. It takes a string.
Note: This parameter is used to identify the userId for the programmer. This is used to identify a developer's userId to an error event.


*parameter:*
This parameter is required. It take a parameter variable.
Note: This parameter is used in the function. Purpose is to track which parameter initiated an error
*customNote:*
This parameter is required. It takes a string.
This gives the ability for a programmer to create custom notes for error events.

After getting started ➡ CLI commands:

These are command options we can use in our cli(command line interface/ terminal).
Entering the command line

cd into node_modules/codefellows-slipup

Note: In order to use a tag command we need to add two dashes -- before selecting each command. The following commands are valid in the command line.

- $node query get
- $node query update
- $node query delete

List of tag commands for get method Shows you a list of errors stored in your database

  --id
  --userid
  --date
  --errortype
  --userparam

An example of a get command in cli

- $node query get --userid=“userid124” --errortype=ReferenceError

List of tag commands for update method Allows users to update a note for an error. Update error based on recordId and new Note.

--id
--usernote

An example of a update command in cli

- $node query update --id=24 --usernote="this is the new updated note"

List of tag commands for delete method Allows users to delete based on record id.

--id

An example of a delete command in cli

- $node query delete --id=24 

Information about Prisma

Prisma is used to help with Postgres.

Prisma Install Instructions

Note: Prisma is automatically installed upon SlipUp installation. These links are purely for documentation purposes.

Sql cli database commands:

  • Enter: psql >>> Opens psql in terminal
  • \c into table >>> Lets you view a table
  • \dt describe table >>> lets you view whats in table.
  • Enter: CREATE DATABASE dbname; In .env:
`DATABASE_URL = postgres:localhost:5432/DATABASE-NAME`
To use schema file to start database:
`psql -f file.sql -d DATABASE-NAME`
Add to Heroku online, add this command to terminal:
`heroku pg:psql -f path/to/schema-file.sql --app your-heroku-app-name-here`

List of Common Commands:

- \l - to view all databases
- \c DATABASE-NAME - to navigate into your database
- \dt - to view the tables in your database
- \q to quit

Objectives

  • node.js documentation => access build in api methods

Explanation of Config Steps

  • Create database

  • Using Scripts

    postinstall: "rm ./prisma/.env && ln -s ./.env ./prisma/.env && npx prisma introspect && npx prisma generate",
    

post install remove prisma .env file, sym link to .env in node modules, then run prisma intro and generate steps

Readme

Keywords

none

Package Sidebar

Install

npm i codefellows-slipup

Weekly Downloads

19

Version

1.0.0

License

MIT

Unpacked Size

3.72 MB

Total Files

108

Last publish

Collaborators

  • ryangeddes