3.0.6939 • Published 3 years ago

fyipe-log-js-staging v3.0.6939

Weekly downloads
2
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.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

3 years ago

3.0.6915

3 years ago

3.0.6905

3 years ago

3.0.6909

3 years ago

3.0.6900

3 years ago

3.0.6878

3 years ago

3.0.6825

3 years ago

3.0.6779

3 years ago

3.0.6777

3 years ago

3.0.6775

3 years ago

3.0.6733

3 years ago

3.0.6730

3 years ago

3.0.6723

3 years ago

3.0.6725

3 years ago

3.0.6656

4 years ago

3.0.6629

4 years ago

3.0.6624

4 years ago

3.0.6621

4 years ago

3.0.6562

4 years ago

3.0.6557

4 years ago

3.0.6510

4 years ago

3.0.6507

4 years ago

3.0.6504

4 years ago

3.0.6482

4 years ago

3.0.6455

4 years ago

3.0.6442

4 years ago

3.0.6413

4 years ago

3.0.6422

4 years ago

3.0.6378

4 years ago

3.0.6364

4 years ago

3.0.6324

4 years ago

3.0.6321

4 years ago

3.0.6319

4 years ago

3.0.6293

4 years ago

3.0.6289

4 years ago

3.0.6287

4 years ago

3.0.6237

4 years ago

3.0.6212

4 years ago

3.0.6194

4 years ago

3.0.6172

4 years ago

3.0.6135

4 years ago

3.0.6133

4 years ago

3.0.6082

4 years ago

3.0.6065

4 years ago

3.0.6067

4 years ago

3.0.6057

4 years ago

3.0.6056

4 years ago

3.0.6050

4 years ago

3.0.6045

4 years ago

3.0.6005

4 years ago

3.0.6003

4 years ago

3.0.5968

4 years ago

3.0.5961

4 years ago

3.0.5948

4 years ago

3.0.5926

4 years ago

3.0.5909

4 years ago

3.0.5903

4 years ago

3.0.5858

4 years ago

3.0.5880

4 years ago

3.0.5847

4 years ago

3.0.5829

4 years ago

3.0.5799

4 years ago

3.0.5758

4 years ago

3.0.5756

4 years ago

3.0.5755

4 years ago

3.0.5753

4 years ago

3.0.5752

4 years ago

3.0.5722

4 years ago

3.0.5707

4 years ago

3.0.5696

4 years ago

3.0.5677

4 years ago

3.0.5673

4 years ago

3.0.5657

4 years ago

3.0.5625

4 years ago

3.0.5617

4 years ago

3.0.5587

4 years ago

3.0.5544

4 years ago

3.0.5481

4 years ago

3.0.5476

4 years ago

3.0.5468

4 years ago

3.0.5407

4 years ago

3.0.5386

4 years ago

3.0.5378

4 years ago

3.0.5371

4 years ago

3.0.5365

4 years ago

3.0.5346

4 years ago

3.0.5339

4 years ago

3.0.5307

4 years ago

3.0.5301

4 years ago

3.0.5281

4 years ago

3.0.5255

4 years ago

3.0.5246

4 years ago

3.0.5237

4 years ago

3.0.5195

4 years ago

3.0.5179

4 years ago

3.0.5081

4 years ago

3.0.5077

4 years ago

3.0.5023

4 years ago

3.0.4982

4 years ago

3.0.4969

4 years ago

3.0.4946

4 years ago

3.0.4862

4 years ago

3.0.4843

4 years ago

3.0.4834

4 years ago

3.0.4764

4 years ago

3.0.4749

4 years ago

3.0.4729

4 years ago

3.0.4728

4 years ago

3.0.4727

4 years ago

3.0.4724

4 years ago

3.0.4722

4 years ago

3.0.4720

4 years ago

3.0.4719

4 years ago

3.0.4718

4 years ago

3.0.4673

4 years ago

3.0.4666

4 years ago

3.0.4634

4 years ago

3.0.4620

4 years ago

3.0.4621

4 years ago

3.0.4619

4 years ago

3.0.4425

4 years ago

3.0.4407

4 years ago

3.0.4339

4 years ago

3.0.4335

4 years ago

3.0.4340

4 years ago

3.0.4228

4 years ago

3.0.4137

4 years ago

3.0.4087

4 years ago

3.0.4060

4 years ago

3.0.3803

4 years ago

3.0.3678

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.3593

4 years ago

3.0.3594

4 years ago

3.0.3589

4 years ago

3.0.3592

4 years ago

3.0.3590

4 years ago

3.0.3586

4 years ago

3.0.3512

4 years ago

3.0.3509

4 years ago

3.0.3508

4 years ago

3.0.3507

4 years ago

3.0.3506

4 years ago

3.0.3504

4 years ago

3.0.3505

4 years ago

3.0.3503

4 years ago

3.0.3501

4 years ago

3.0.3500

4 years ago

3.0.3494

4 years ago

3.0.3469

4 years ago

3.0.3486

4 years ago

1.0.0

4 years ago

3.0.0

4 years ago

3.0.3432

4 years ago

3.0.3368

4 years ago

3.0.3320

4 years ago

3.0.3300

4 years ago

3.0.3274

4 years ago

3.0.3272

4 years ago

3.0.3215

4 years ago

3.0.3213

4 years ago

3.0.3206

4 years ago