codefellows-slipup
v1.0.0
Published
401 Codefellows Midterm project using Javascript
Downloads
6
Readme
SlipUp
An npm package library that logs and saves error events in a PostgreSql database.
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
- [x] Powerpoint
- [x] List of installation steps
- [ ] Problem Domain Link
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
Getting started
- Install SlipUp library with the following commands. Note: must have npm installer.
$npm i codefellows-slipup
- 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.
- Postgres password.
Upon inputting Postgres username SlipUp will request Posgres password.
This will allow user to save error logs in Postgres.
- Choose port.
User is given the option to assign an env port. If no port is chosen SlipUp will assign default
port 5432.
- 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.
- 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.
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.
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
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