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

ant-lab-logger-test

v0.0.43

Published

Log information to an external API.

Downloads

13

Readme

Ant Lab Logger


The Anthroware Laboratory (Ant Lab) Logger is a node framework to log information to a self hosted or Anthroware hosted external API.

Dependencies


  • jest - We use Jest as our primary testing framework
  • axios - For any network calls, Axios is used
  • axios-mock-adapter - Mocking Axios requests when testing
  • flow - Static type checking

Logger

1. Installation

Install the library using npm.

npm install --save ant-lab-logger

2. Initialize the SDK

The SDK needs to be initialized. It will also fetch the logging level from the API.

Logger.Init ( apiToken, metaInfo, deviceInfo )

3. Log using the SDK

The SDK exposes the Logger.debug( logInfo, metaInfo, deviceInfo ) method for sending off debug level logs to the webservice.


Models

Log

Log object sent to the API resource.

Fields:

  • date DateTime of the when the log was created
  • category What grouping of logs this falls under
  • description What happened? For example, the Logout button brought the user to the AreYouSure page
  • jsonOne Field for dumping information. Ordered by priority.
  • jsonTwo Field for dumping information.
  • jsonThree Field for dumping information.
  • jsonFour Field for dumping information.
  • additionalInfo Field for dumping information.
  • userName User who owns the information inside the application

Type information:

Log: {
    date: Date,
    category: string,
    description: string,
    jsonOne: Object,
    jsonTwo: Object,
    jsonThree: Object,
    jsonFour: Object,
    additionalInfo: string,
    username: string,
}

Device Info

Device specific information. Currently using react-native-device-infofor fetching the information. Implementation may vary depending on how and what information is fetched.

Fields:

  • Uuid Unique device identifier
  • manufacturer Manufacturer of the device e.g. 'Apple'
  • brand The brand of the device e.g. 'Apple/htc'
  • model The model of the device e.g. 'iPhone 5'
  • deviceId The device's id or for Android the board e.g. 'iPhone 6' or 'goldfish'
  • systemName The operating system name e.g. 'iOS'
  • systemVersion The numbered version of the operating system e.g. '4.4.2'
  • bundleId Namespace of the bundle e.g. 'com.example.mobileapp'
  • buildNumber Version of the application on the phone e.g. '1.1.0.40'
  • userAgent Combined information of current OS user.
  • userName User's username
  • locale Locale set in the operating system e.g. en-US
  • timeZone Current time of the user
  • appInEmulator Is the application running inside of an emulator?
  • pinOrFingerprintSet Is the pin or fingerprint set for the user?

Type information:

DeviceInfo: {
    uuid: string,
    manufacturer: string,
    brand: string,
    model: string,
    deviceId: string,
    systemName: string,
    systemVersion: string,
    bundleId: string,
    buildNumber: string,
    userAgent: string,
    locale: string,
    timeZone: string,
    appInEmulator: boolean,
    pinOrFingerprintSet: boolean,
}

MetaInfo

Information about the application, SDK, and current user.

Fields:

  • apiKey Uuid that authenticates the SDK for every API call
  • sessionId Uuid that lives for the lifetime of the application
  • sdkVersion Version of the SDK itself
  • applicationVersion Version of the application that is consuming the SDK

Type information:

MetaInfo: {
    apiKey: string,
    sessionId: string,
    sdkVersion: string,
    applicationVersion: string,
}

Example Usage

Ths example imports the logger, initialize with an Api Token and logs a debug log.

import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View } from     'react-native';
import Logger from './log/resource/Logger';

export default class logger extends Component {
  render() {
    var deviceInfo = {
      Uuid: 'sample string 1',
      Manufacturer: 'sample string 2',
      Brand: 'sample string 3',
      Model: 'sample string 4',
      DeviceId: 'sample string 5',
      SystemName: 'sample string 6',
      SystemVersion: 'sample string 7',
      BundleId: 'sample string 8',
      BuildNumber: 'sample string 9',
      UserAgent: 'sample string 10',
      Locale: 'sample string 11',
      TimeZone: 'sample string 12',
      AppInEmulator: true,
      PinOrFingerprintSet: true,
    };
    const metaInfo = {
      apiKey: 'sample string 1',
      sessionId: 'sample string 2',
      sdkVersion: 'sample string 3',
      applicationVersion: 'sample string 6',
    };
    const log = {
      date: new Date(),
      category: 'sample string 1',
      description: 'sample string 2',
      jsonOne: { k: 100 },
      jsonTwo: { k: 100 },
      jsonThree: { k: 100 },
      jsonFour: { k: 100 },
      additionalInfo: 'sample string 3',
      userName: 'sample string 4',
    };
    Logger.init('apitoken', metaInfo, deviceInfo);
    Logger.debug(log, metaInfo, deviceInfo)
      .then(success => {
        console.log('success', success);
      })
      .catch(e => {
        console.log('error', e);
      });
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome to React   Native!</Text>
        <Text style={styles.instructions}>
          To get started, edit index.ios.js
        </Text>
        <Text style={styles.instructions}>
          Press Cmd+R to reload,{'\n'}
          Cmd+D or shake for dev menu
        </Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('logger', () => logger);