3.0.6657 • Published 3 years ago

fyipe-log-js v3.0.6657

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago

npm

Fyipe Application Logger

A fyipe application logger that can be used to send logs about your applications created on your fypie dashboard. It also provides a way to track errors in your application.

Installation

NPM Install

You can install to use in your project:

$ cd project
$ npm install fyipe-log-js

Basic Usage

In a Node.js Project

import { FyipeLogger } from 'fyipe-log-js';

// constructor

// set up tracking configurations
const options = {
    maxTimeline: 10,
};
const logger = new FyipeLogger(
    'API_URL', // https://fyipe.com/api
    'APPLICATION_LOG_ID',
    'APPLICATION_LOG_KEY',
    options // Optional Field
);

// Sending a string log to the server
const item = 'This is a simple log';

logger.log(item); // returns a promise

// Sending a JSON object log to the server
const item = {
    user: 'Test User',
    page: {
        title: 'Landing Page',
        loadTime: '6s',
    },
};

logger.log(item); // returns a promise

// Alternatively, Logs can be tagged with either a string or an array of strings
const item = 'This is a simple log';
const tags = ['server', 'script', 'dev'];
logger.log(item, tags);

const tag = 'testing';
logger.log(item, tag);

In the Browser

<script src="https://unpkg.com/fyipe-log-js"></script>
<script>
    function logError() {
        // constructor
        const logger = new FyipeLogger(
            'API_URL', // https://fyipe.com/api
            'APPLICATION_LOG_ID',
            'APPLICATION_LOG_KEY'
        );

        // Sending a string log to the server
        const item = 'This is a simple log';

        logger.log(item); // returns a promise

        // Alternatively, Logs can be tagged with either a string or an array of strings
        const item = 'This is a simple log';
        const tags = ['server', 'monitor'];
        logger.log(item, tags);
    }
</script>

Error Tracking APIs

import { FyipeTracker } from 'fyipe-log-js';

// constructor

// set up tracking configurations
const options = {
    maxTimeline: 10,
};
const tracker = new FyipeTracker(
    'API_URL', // https://fyipe.com/api
    'ERROR_TRACKER_ID',
    'ERROR_TRACKER_KEY',
    options // Optional Field
);

// capturing a timeline manually
tracker.addTimeline(
    'payment',
    { account: 'debit', amount: '6000.00', userId: 401 },
    'info'
);

// setting custom tags
tracker.setTag('category', 'Customer'); // a single tag
tracker.setTags([
    { key: 'type', value: 'notice' },
    { key: 'location', value: 'online' },
]); // an array of tags

// capturing error exception authomatically
NonExistingMethodCall(); // this is authomatically captured and sent to your fyipe dashboard

// capturing error exception manually
try {
    // your code logic
    NonExistingMethodCall();
} catch (error) {
    tracker.captureException(error);
}

// capturing error message
tracker.captureMessage('Message');

API Documentation

Main API to send logs to the server.

Author: HackerBay, Inc.

new FyipeLogger(apiUrl, applicationId, applicationKey)

Create a constructor from the class, which will be used to send logs to the server.

Kind: Constructor Returns: null

ParamTypeDescription
apiUrlstringThe Server URL.
applicationIdstringThe Application Log ID.
applicationKeystringThe Application Log Key.

new FyipeTracker(apiUrl, errorTrackerId, errorTrackerKey, options)

Create a constructor from the class, which will be used to track events and exceptions to be sent to the server.

Kind: Constructor Returns: null

ParamTypeDescription
apiUrlstringThe Server URL.
errorTrackerIdstringThe Error Tracker ID.
errorTrackerKeystringThe Error Tracker Key.
optionsobjectSet of configuration to be used for error tracking.

logger.log(log, tags)

Logs a request of type info to the server.

Kind: method of new FyipeLogger Returns: Promise - A promise response of a success or failure.

ParamTypeDescription
logstring | ObjectThe content to the logged on the server.
tagsstring | ArrayThe tag(s) to be attached to the logged item on the server.

logger.warning(log, tags)

Logs a request of type warning to the server.

Kind: method of new FyipeLogger Returns: Promise - A promise response of a success or failure.

ParamTypeDescription
logstring | ObjectThe content to the logged on the server.
tagsstring | ArrayThe tag(s) to be attached to the logged item on the server.

logger.error(log, tags)

Logs a request of type error to the server.

Kind: method of new FyipeLogger Returns: Promise - A promise response of a success or failure.

ParamTypeDescription
logstring | ObjectThe content to the logged on the server.
tagsstring | ArrayThe tag(s) to be attached to the logged item on the server.

tracker.setTag(key, value)

Set a tag for the error to be captured.

Kind: method of new FyipeTracker Returns: null

ParamTypeDescription
keystringThe key for the tag.
valuestringThe value for thr tag.

tracker.setTags({key, value})

Set an array of tags for the error to be captured.

Kind: method of new FyipeTracker Returns: null

ParamTypeDescription
keystringThe key for the tag.
valuestringThe value for the tag.

tracker.setFingerprint(fingerprint)

Set fingerprint for the next error to be captured.

Kind: method of new FyipeTracker Returns: null

ParamTypeDescription
fingerprintstring | array of stringsThe set of string used to group error messages on the server.

tracker.addTimeline(category, content, type)

Add a custom timeline element to the next error to be sent to the server

Kind: method of new FyipeTracker Returns: null

ParamTypeDescription
categorystringThe category of the timeline event.
contentstring | ObjectThe content of the timeline event.
typestringThe type of timeline event.

tracker.captureMessage(message)

Capture a custom error message to be sent to the server

Kind: method of new FyipeTracker Returns: null

ParamTypeDescription
messagestringThe message to be sent to the server.

tracker.captureExceptio(error)

Capture a custom error object to be sent to the server

Kind: method of new FyipeTracker Returns: null

ParamTypeDescription
errorobjectThe Error Object to be sent to the server.

Contribution

  • Clone repository
  • run npm i to install dependencies
  • run npm run test to run tests
  • run npm run build to build for production.
3.0.6657

3 years ago

3.0.6630

3 years ago

3.0.6563

3 years ago

3.0.6559

3 years ago

3.0.6483

3 years ago

3.0.6457

3 years ago

3.0.6423

4 years ago

3.0.6067

4 years ago

3.0.6051

4 years ago

3.0.6047

4 years ago

3.0.6010

4 years ago

3.0.5973

4 years ago

3.0.5972

4 years ago

3.0.5971

4 years ago

3.0.5949

4 years ago

3.0.5928

4 years ago

3.0.5910

4 years ago

3.0.5882

4 years ago

3.0.5835

4 years ago

3.0.5762

4 years ago

3.0.5726

4 years ago

3.0.5708

4 years ago

3.0.5678

4 years ago

3.0.5674

4 years ago

3.0.5618

4 years ago

3.0.5628

4 years ago

3.0.5588

4 years ago

3.0.5547

4 years ago

3.0.5480

4 years ago

3.0.5469

4 years ago

3.0.5408

4 years ago

3.0.5383

4 years ago

3.0.5385

4 years ago

3.0.5379

4 years ago

3.0.5287

4 years ago

3.0.5284

4 years ago

3.0.5258

4 years ago

3.0.5199

4 years ago

3.0.5196

4 years ago

3.0.4634

4 years ago

3.0.4622

4 years ago

3.0.4619

4 years ago

3.0.4535

4 years ago

3.0.4540

4 years ago

3.0.4519

4 years ago

3.0.4342

4 years ago

3.0.4336

4 years ago

3.0.3807

4 years ago

3.0.3806

4 years ago

3.0.3805

4 years ago

3.0.3608

4 years ago

3.0.3609

4 years ago

3.0.3600

4 years ago

3.0.3596

4 years ago

3.0.3594

4 years ago

3.0.3593

4 years ago

3.0.3589

4 years ago

3.0.3588

4 years ago

3.0.3512

4 years ago

3.0.3511

4 years ago

3.0.3510

4 years ago

3.0.3509

4 years ago

3.0.3507

4 years ago

3.0.3508

4 years ago

3.0.3506

4 years ago

3.0.3505

4 years ago

3.0.3504

4 years ago

3.0.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago