3.0.6939 • Published 6 years ago

fyipe-log-js-staging v3.0.6939

Weekly downloads
2
License
ISC
Repository
github
Last release
6 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

6 years ago

3.0.6915

6 years ago

3.0.6905

6 years ago

3.0.6909

6 years ago

3.0.6900

6 years ago

3.0.6878

6 years ago

3.0.6825

6 years ago

3.0.6779

6 years ago

3.0.6777

6 years ago

3.0.6775

6 years ago

3.0.6733

6 years ago

3.0.6730

6 years ago

3.0.6723

6 years ago

3.0.6725

6 years ago

3.0.6656

6 years ago

3.0.6629

6 years ago

3.0.6624

6 years ago

3.0.6621

6 years ago

3.0.6562

6 years ago

3.0.6557

6 years ago

3.0.6510

6 years ago

3.0.6507

6 years ago

3.0.6504

6 years ago

3.0.6482

6 years ago

3.0.6455

6 years ago

3.0.6442

6 years ago

3.0.6413

6 years ago

3.0.6422

6 years ago

3.0.6378

6 years ago

3.0.6364

6 years ago

3.0.6324

6 years ago

3.0.6321

6 years ago

3.0.6319

6 years ago

3.0.6293

6 years ago

3.0.6289

6 years ago

3.0.6287

6 years ago

3.0.6237

6 years ago

3.0.6212

6 years ago

3.0.6194

6 years ago

3.0.6172

6 years ago

3.0.6135

6 years ago

3.0.6133

6 years ago

3.0.6082

6 years ago

3.0.6065

6 years ago

3.0.6067

6 years ago

3.0.6057

6 years ago

3.0.6056

6 years ago

3.0.6050

6 years ago

3.0.6045

6 years ago

3.0.6005

6 years ago

3.0.6003

6 years ago

3.0.5968

6 years ago

3.0.5961

6 years ago

3.0.5948

6 years ago

3.0.5926

6 years ago

3.0.5909

6 years ago

3.0.5903

6 years ago

3.0.5858

6 years ago

3.0.5880

6 years ago

3.0.5847

6 years ago

3.0.5829

6 years ago

3.0.5799

6 years ago

3.0.5758

6 years ago

3.0.5756

6 years ago

3.0.5755

6 years ago

3.0.5753

6 years ago

3.0.5752

6 years ago

3.0.5722

6 years ago

3.0.5707

6 years ago

3.0.5696

6 years ago

3.0.5677

6 years ago

3.0.5673

6 years ago

3.0.5657

6 years ago

3.0.5625

6 years ago

3.0.5617

6 years ago

3.0.5587

6 years ago

3.0.5544

6 years ago

3.0.5481

6 years ago

3.0.5476

6 years ago

3.0.5468

6 years ago

3.0.5407

6 years ago

3.0.5386

6 years ago

3.0.5378

6 years ago

3.0.5371

6 years ago

3.0.5365

6 years ago

3.0.5346

6 years ago

3.0.5339

6 years ago

3.0.5307

6 years ago

3.0.5301

6 years ago

3.0.5281

6 years ago

3.0.5255

6 years ago

3.0.5246

6 years ago

3.0.5237

6 years ago

3.0.5195

6 years ago

3.0.5179

6 years ago

3.0.5081

6 years ago

3.0.5077

6 years ago

3.0.5023

6 years ago

3.0.4982

6 years ago

3.0.4969

6 years ago

3.0.4946

6 years ago

3.0.4862

6 years ago

3.0.4843

6 years ago

3.0.4834

6 years ago

3.0.4764

6 years ago

3.0.4749

6 years ago

3.0.4729

6 years ago

3.0.4728

6 years ago

3.0.4727

6 years ago

3.0.4724

6 years ago

3.0.4722

6 years ago

3.0.4720

6 years ago

3.0.4719

6 years ago

3.0.4718

6 years ago

3.0.4673

6 years ago

3.0.4666

6 years ago

3.0.4634

6 years ago

3.0.4620

6 years ago

3.0.4621

6 years ago

3.0.4619

6 years ago

3.0.4425

6 years ago

3.0.4407

6 years ago

3.0.4339

6 years ago

3.0.4335

6 years ago

3.0.4340

6 years ago

3.0.4228

6 years ago

3.0.4137

6 years ago

3.0.4087

6 years ago

3.0.4060

6 years ago

3.0.3803

6 years ago

3.0.3678

6 years ago

3.0.3608

6 years ago

3.0.3609

6 years ago

3.0.3600

6 years ago

3.0.3596

6 years ago

3.0.3593

6 years ago

3.0.3594

6 years ago

3.0.3589

6 years ago

3.0.3592

6 years ago

3.0.3590

6 years ago

3.0.3586

6 years ago

3.0.3512

6 years ago

3.0.3509

6 years ago

3.0.3508

6 years ago

3.0.3507

6 years ago

3.0.3506

6 years ago

3.0.3504

6 years ago

3.0.3505

6 years ago

3.0.3503

6 years ago

3.0.3501

6 years ago

3.0.3500

6 years ago

3.0.3494

6 years ago

3.0.3469

6 years ago

3.0.3486

6 years ago

1.0.0

6 years ago

3.0.0

6 years ago

3.0.3432

6 years ago

3.0.3368

6 years ago

3.0.3320

6 years ago

3.0.3300

6 years ago

3.0.3274

6 years ago

3.0.3272

6 years ago

3.0.3215

6 years ago

3.0.3213

6 years ago

3.0.3206

6 years ago