Giter Site home page Giter Site logo

companycam / companycam-vibe-check Goto Github PK

View Code? Open in Web Editor NEW
2.0 13.0 0.0 2.06 MB

Hardware logging library for CompanyCam

License: MIT License

Kotlin 6.31% JavaScript 10.81% Ruby 12.65% Java 21.77% C 0.31% Objective-C 7.22% Objective-C++ 3.52% Swift 8.47% TypeScript 16.69% Shell 12.25%

companycam-vibe-check's Introduction

@companycam/vibe-check

Hardware logging library for CompanyCam

Welcome to the CompanyCam Vibe Check repo.

This library is largely for exposing hardware information not readily available. Maintaining a high level of performance in our apps is a large priority. Sometimes we can compensate for these issues, and sometimes we cannot. This library aims to expose hardware information commonly related to performance issues.

This library exposes the following information, through the getCurrentVibes method:

{
  battery: {
    batteryLevel: 0.70202270953611340,
    batteryState: 'charging',
    lowPowerMode: false,
  },
  connectivity: {
    connection: {
      isConnected: true,
      isInternetReachable: true,
      type: 'cellular',
      details: {
        isConnectionExpensive: false,
        cellularGeneration: '4g',
      },
    },
  },
  memoryInUse: 83193856,
  thermalState: 'nominal',
};

Installation

yarn install @companycam/vibe-check
yarn add @companycam/vibe-check

System Requirements

iOS

iOS Version: 15.0

Android

minSdkVersion: 24

Usage

import { getCurrentVibes, FullVibeCheck } from '@companycam/vibe-check';

// ...elsewhere in your code

const vibes: FullVibeCheck = yield call(getCurrentVibes);

API

Methods

getCurrentVibes()

Gets the device's current hardware information. This method is the main entry point for this library. Returns all of the results from the other functions this library exposes.

import { getCurrentVibes, FullVibeCheck } from '@companycam/vibe-check';

const vibes: FullVibeCheck = yield call(getCurrentVibes);

This method will return an object very similar to the below JSON object:

{
  battery: {
    batteryLevel: 0.70202270953611340,
    batteryState: 'charging',
    lowPowerMode: false,
  },
  connectivity: {
    connection: {
      isConnected: true,
      isInternetReachable: true,
      type: 'cellular',
      details: {
        isConnectionExpensive: false,
        cellularGeneration: '4g',
      },
    },
  },
  memoryInUse: 83193856,
  thermalState: 'nominal',
};

getBatteryVibe()

Gets the device's current Battery information.

import { VibeChecker } from '@companycam/companycam-vibe-check';

const { battery } = await NativeModules.VibeChecker.getBatteryVibe();

This method will return an object very similar to the below JSON object:

  battery: {
    batteryLevel: 0.5,
    batteryState: 'unplugged',
    lowPowerMode: false,
    isBatteryCharging: false,
  }

getConnectionInfo()

Gets the device's current Network Connection information.

import { getConnectionInfo } from '@companycam/vibe-check';

const { connection } = await getConnectionInfo();

This method will return an object very similar to the below JSON object:

  connection: {
    isConnected: true,
    isInternetReachable: true,
    type: 'cellular',
    details: {
      isConnectionExpensive: false,
      cellularGeneration: '4g',
    },
  }

getRamUsage()

Gets the device's current RAM usage, as a percentage.

import { getRamUsage } from '@companycam/vibe-check';

const { ramUsage } = await getRamUsage();

This method will return an object very similar to the below JSON object:

ramUsage: 0.8; // <-- percentage

getThermalState()

Gets the device's current thermal state.

import { getThermalState } from '@companycam/vibe-check';

const { thermalState } = await getThermalState();

This method will return an object very similar to the below JSON object:

thermalState: 'fair';

๐Ÿ“ NOTE: Since iOS and Android expose different thermal states, we've normalized them. Currently we use iOS nomenclature for the different thermal states. Please refer to the table below.

thermalState iOS Value Android Value
nominal nominal THERMAL_STATUS_NONE / THERMAL_STATUS_LIGHT
fair fair THERMAL_STATUS_MODERATE
serious serious THERMAL_STATUS_SEVERE
critical critical THERMAL_STATUS_CRITICAL / THERMAL_STATUS_EMERGENCY
unknown unknown unknown

Return object potential values

Battery

Property Type Description
batteryLevel number The battery level on the device, from 0.0 to 1.0
batteryState string unknown, unplugged, charging, full
lowPowerMode bool Whether or not the device is in low power mode

Connectivity

Property Type Description
isConnected bool Whether or not the device is connected to the internet
isInternetReachable bool Whether or not the device is connected to the internet
type string none, unknown, cellular, wifi, bluetooth, ethernet, wimax, vpn
details object See below
Connectivity Details
Property Type Description
isConnectionExpensive bool Whether or not the connection is expensive
cellularGeneration string 2g, 3g, 4g, 5g, unknown

Thermal State

Property Type Description
thermalState string nominal, fair, serious, critical

RAM Usage

Property Type Description
ramUsage number RAM Usage on the device from 0.0 to 1.0

Contributing

This project uses conventional commits and semantic-release to automate the release process. Please follow the conventional commits format when making commits.

See the contributing guide to learn how to contribute to the repository and the development workflow.

Made with create-react-native-library

companycam-vibe-check's People

Contributors

stevenmcmanus-cocam avatar aisflat439 avatar jasongaare avatar

Stargazers

Christopher Lamm avatar  avatar

Watchers

Jeff McFadden avatar Joey Gordon avatar Jared Goertzen avatar Jeremy Stewart avatar Kevin Scully avatar  avatar Kait Beaudette avatar Alison Chan avatar Derek Dapp avatar  avatar Tifany Albrecht avatar  avatar  avatar

companycam-vibe-check's Issues

Dependabot Findings updated Apr. 22, 2024

NOTE: This issue was computer generated on Apr. 22, 2024. Comments may get lost. Issues are sorted by remediation deadline. Only dependabot alerts created on or after Feb. 01, 2024 are shown.

Create CPU Vibe info endpoint for iOS

Android does not allow this info to be grabbed from the OS anymore (since Android O). We probably should grab it for iOS though, since that's available.

Config Object for `vibes`

What if getVibes had a slightly different API, where the consumer was able to choose what they want from when they call getVibes.

const vibes = getVibes({
  batteryLevel: false
})

This would return everything except batteryLevel.

Clean up README

We have made a bunch of changes to the API since initial inception. Need to update the README to reflect those changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.