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

trackify

v1.1.2

Published

Logs activity(routes, db, custom) of application in a file

Downloads

4

Readme

trackify

npm package to track activities of request, database, error or custom. Log all in txt file with timestamp.

npm GitHub repo size

See demo of logs.txt file

Installation

npm install trackify

Update

  • Version 1.1.0
    • Change in naming convention.
      • tracker.db_connection() -> tracker.db()
      • tracker.nosqldb_query() -> tracker.nosql_query()
      • tracker.relational_db_query() -> tracker.relational_query()
    • Change in argument passing in Init.
      • new trackify({infinity_ : true}) -> new trackify({app_name : "Your app name", infinity_ : true})

Initialization

const trackify = require('trackify');

API

Init

const tracker = new trackify({app_name : "Your app name",infinity_ : true});
  • It creates logs.txt in root folder.
  • {app_name : string} (default "App")
  • {infinity_ : boolean}(default false)
    • false : Clear previous records of file and write new records.
    • true : Don't clear previous records of file.

tracker.start() (Optional but recommended)

tracker.start();
  • Add to logs.txt that app started with timestamp

tracker.request(method:string, route:string)

tracker.request("get", "/api/json");
  • It logs method and route in logs.txt
    • method : get| post | put | delete. capital input also works.
    • route : /anything

good use

router.all('*', (request, response, next) => {
  tracker.request(request.method, request.url);
  next();
});

tracker.error(new Error(error:object))

fs.readFile('noexist.txt', (err) => {
  if(err) tracker.error(new Error(err));
});
  • It logs error and exit app.
  • Whenever you need to use throw new Error(err), use this function.

tracker.db(dbname:string)

MongoClient.connect(url, (err, db) => {
  if(err) tracker.error(new Error(err));
  tracker.db("MongoDB");
  
  // your code
  
});

tracker.nosql_query(table_name:string, operation:string, value:object, value_updated:object)

//select
let unique_key = {_id : "unique"};
db.find(unique_key, (err, doc) => {
  if(err) tracker.error(new Error(err));
  
  tracker.nosql_query("tablename", "select", unique_key); //two arguments
  
});

//update
let from = {_id : "unique"};
let to = {val : "updated value"};
db.update(from, to, (err, doc) => {
  if(err) tracker.error(new Error(err));
  
  tracker.nosql_query("tablename", "update", from, to); // three arguments
  
});

//insert
let insert_this = {_id : "uniqueid", name : "mayursinh"};
db.insert(insert_this, (err) => {
  if(err) tracker.error(new Error(err));
  
  tracker.nosql_query("tablename", "insert", insert_this);
  
});

//delete
let delete_this = {_id : "uniqueid"};
db.insert(delete_this, (err) => {
  if(err) tracker.error(new Error(err));
  
  tracker.nosql_query("tablename", "delete", delete_this);
  
});
  • It logs query to file. function for nosql databases like MongoDB
    • table_name : table name on which operation is being done.
    • operation : select | insert | update | delete. capital words also works.
    • value : key which is being operated on table.
    • value_updated : in case of update this argument should be passed.

tracker.relational_query(table_name:string, operation:string, query:string)

const sql = "INSERT INTO customers (name, address) VALUES ('Company Inc', 'Highway 37')";
con.query(sql, (err, result) => {
  if(err) tracker.error(new Error(err));
  tracker.relational_query("customers", "insert", sql);
});
  • It logs query to file. function for relational databases like MySQL, PostgreSQL
    • table_name and operation same as above.
    • query : query you passed to db.

tracker.custom(log:string, type:string)

setTimeout(() => {
  tracker.custom("5 second passed.", "Custom time tracking");
}, 5000);
  • You are free to logs your custom things :)
    • log : message you want to log.
    • type : (optional) default value is null, type of the log. Sometimes there are multiple logs with same types.