3.0.6939 • Published 5 years ago

fyipe-log-js-staging v3.0.6939

Weekly downloads
2
License
ISC
Repository
github
Last release
5 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.addToTimeline(
    '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.addToTimeline(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.captureException(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.6939

5 years ago

3.0.6915

5 years ago

3.0.6905

5 years ago

3.0.6909

5 years ago

3.0.6900

5 years ago

3.0.6878

5 years ago

3.0.6825

5 years ago

3.0.6779

5 years ago

3.0.6777

5 years ago

3.0.6775

5 years ago

3.0.6733

5 years ago

3.0.6730

5 years ago

3.0.6723

5 years ago

3.0.6725

5 years ago

3.0.6656

5 years ago

3.0.6629

5 years ago

3.0.6624

5 years ago

3.0.6621

5 years ago

3.0.6562

5 years ago

3.0.6557

5 years ago

3.0.6510

5 years ago

3.0.6507

5 years ago

3.0.6504

5 years ago

3.0.6482

5 years ago

3.0.6455

5 years ago

3.0.6442

5 years ago

3.0.6413

5 years ago

3.0.6422

5 years ago

3.0.6378

5 years ago

3.0.6364

5 years ago

3.0.6324

5 years ago

3.0.6321

5 years ago

3.0.6319

5 years ago

3.0.6293

5 years ago

3.0.6289

5 years ago

3.0.6287

5 years ago

3.0.6237

5 years ago

3.0.6212

5 years ago

3.0.6194

5 years ago

3.0.6172

5 years ago

3.0.6135

5 years ago

3.0.6133

5 years ago

3.0.6082

5 years ago

3.0.6065

5 years ago

3.0.6067

5 years ago

3.0.6057

5 years ago

3.0.6056

5 years ago

3.0.6050

5 years ago

3.0.6045

5 years ago

3.0.6005

5 years ago

3.0.6003

5 years ago

3.0.5968

5 years ago

3.0.5961

5 years ago

3.0.5948

5 years ago

3.0.5926

5 years ago

3.0.5909

5 years ago

3.0.5903

5 years ago

3.0.5858

5 years ago

3.0.5880

5 years ago

3.0.5847

5 years ago

3.0.5829

5 years ago

3.0.5799

5 years ago

3.0.5758

5 years ago

3.0.5756

5 years ago

3.0.5755

5 years ago

3.0.5753

5 years ago

3.0.5752

5 years ago

3.0.5722

5 years ago

3.0.5707

5 years ago

3.0.5696

5 years ago

3.0.5677

5 years ago

3.0.5673

5 years ago

3.0.5657

5 years ago

3.0.5625

5 years ago

3.0.5617

5 years ago

3.0.5587

5 years ago

3.0.5544

5 years ago

3.0.5481

5 years ago

3.0.5476

5 years ago

3.0.5468

5 years ago

3.0.5407

5 years ago

3.0.5386

5 years ago

3.0.5378

5 years ago

3.0.5371

5 years ago

3.0.5365

5 years ago

3.0.5346

5 years ago

3.0.5339

5 years ago

3.0.5307

5 years ago

3.0.5301

5 years ago

3.0.5281

5 years ago

3.0.5255

5 years ago

3.0.5246

5 years ago

3.0.5237

5 years ago

3.0.5195

5 years ago

3.0.5179

5 years ago

3.0.5081

5 years ago

3.0.5077

5 years ago

3.0.5023

5 years ago

3.0.4982

5 years ago

3.0.4969

5 years ago

3.0.4946

5 years ago

3.0.4862

5 years ago

3.0.4843

5 years ago

3.0.4834

5 years ago

3.0.4764

5 years ago

3.0.4749

5 years ago

3.0.4729

5 years ago

3.0.4728

5 years ago

3.0.4727

5 years ago

3.0.4724

5 years ago

3.0.4722

5 years ago

3.0.4720

5 years ago

3.0.4719

5 years ago

3.0.4718

5 years ago

3.0.4673

5 years ago

3.0.4666

5 years ago

3.0.4634

5 years ago

3.0.4620

5 years ago

3.0.4621

5 years ago

3.0.4619

5 years ago

3.0.4425

5 years ago

3.0.4407

5 years ago

3.0.4339

5 years ago

3.0.4335

5 years ago

3.0.4340

5 years ago

3.0.4228

5 years ago

3.0.4137

5 years ago

3.0.4087

5 years ago

3.0.4060

5 years ago

3.0.3803

5 years ago

3.0.3678

5 years ago

3.0.3608

5 years ago

3.0.3609

5 years ago

3.0.3600

5 years ago

3.0.3596

5 years ago

3.0.3593

5 years ago

3.0.3594

5 years ago

3.0.3589

5 years ago

3.0.3592

5 years ago

3.0.3590

5 years ago

3.0.3586

5 years ago

3.0.3512

5 years ago

3.0.3509

5 years ago

3.0.3508

5 years ago

3.0.3507

5 years ago

3.0.3506

5 years ago

3.0.3504

5 years ago

3.0.3505

5 years ago

3.0.3503

5 years ago

3.0.3501

5 years ago

3.0.3500

5 years ago

3.0.3494

5 years ago

3.0.3469

5 years ago

3.0.3486

5 years ago

1.0.0

5 years ago

3.0.0

5 years ago

3.0.3432

5 years ago

3.0.3368

5 years ago

3.0.3320

5 years ago

3.0.3300

5 years ago

3.0.3274

5 years ago

3.0.3272

5 years ago

3.0.3215

5 years ago

3.0.3213

5 years ago

3.0.3206

5 years ago