🚨 Shai-Hulud Strikes Again:More than 500 packages and 700+ versions compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@companycam/vibe-check

Package Overview
Dependencies
Maintainers
72
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@companycam/vibe-check

Hardware logging library for CompanyCam

npmnpm
Version
0.1.0
Version published
Weekly downloads
2K
24.77%
Maintainers
72
Weekly downloads
 
Created
Source

companycam-vibe-check

Hardware logging library for CompanyCam

Welcome to the CompanyCam Vibe Check repo. This library is largely for exposing hardware information in some key areas that an app may be known to slow down in. As we all know, the largest issues app developers are faced with stem from performance issues. Sometimes we can mitigate for these issues, and sometimes we cannot. This library aims to expose pertinent information related to areas in the hardware that can cause performance issues.

As of right now, this library exposes the following information, through the getCurrentVibes method:

{
  battery: {
    batteryLevel: 0.5,
    batteryState: 'unplugged',
    lowPowerMode: false,
    isBatteryCharging: false,
  },
  connectivity: {
    isConnected: true,
    isInternetReachable: true,
    type: 'cellular',
    details: {
      isConnectionExpensive: false,
      cellularGeneration: '4g',
    },
  },
  thermalState: 'fair',
  ramUsage: 20, // <-- percentage
  diskUsage: 80 // <-- percentage
}

Installation

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

System Requirements

iOS

iOS Version: 15.0

Android

minSdkVersion: 24

Usage

import { getCurrentVibes } from 'companycam-vibe-check';

// ...elsewhere in your code
const { vibes } = await NativeModules.VibeChecker.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 { VibeChecker } from '@companycam/companycam-vibe-check';

const { currentVibe } = await NativeModules.VibeChecker.getCurrentVibes();

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

{
  battery: {
    batteryLevel: 0.5,
    batteryState: 'unplugged',
    lowPowerMode: false,
    isBatteryCharging: false,
  },
  connectivity: {
    isConnected: true,
    isInternetReachable: true,
    type: 'cellular',
    details: {
      isConnectionExpensive: false,
      cellularGeneration: '4g',
    },
  },
  thermalState: 'fair',
  ramUsage: 20, // <-- percentage
  diskUsage: 80 // <-- percentage
}

setVibeTimeout() / getVibeTimeout()

This method allows you to customize how long the library caches the hardware information. Currently the default for the timeout is X seconds. Setting this value to 0 will query the hardware, in real time, instead of relying on the cached values.

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

await NativeModules.VibeChecker.setVibeTimeout(120);

const { vibeTimeout } = NativeModules.VibeChecker.getVibeTimeout();

The parameter for setVibeTimeout() is a number in seconds. The return value for getVibeTimeout() is a number in seconds.

📝 NOTE: In the future we may allow configuration on the time measurements (seconds vs. minutes, etc.)

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,
  }

getConnectionVibe()

Gets the device's current Network Connection information.

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

const { connection } = await NativeModules.VibeChecker.getConnectionVibe();

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',
    },
  }

getDiskUsage()

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

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

const { diskUsage } = await NativeModules.VibeChecker.getDiskUsage();

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

diskUsage: 80; // <-- percentage

getRamUsage()

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

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

const { ramUsage } = await NativeModules.VibeChecker.getRamUsage();

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

ramUsage: 80; // <-- percentage

getThermalState()

Gets the device's current thermal state.

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

const { thermalState } = await NativeModules.VibeChecker.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.

thermalStateiOS ValueAndroid Value
nominalnominalTHERMAL_STATUS_NONE / THERMAL_STATUS_LIGHT
fairfairTHERMAL_STATUS_MODERATE
seriousseriousTHERMAL_STATUS_SEVERE
criticalcriticalTHERMAL_STATUS_CRITICAL / THERMAL_STATUS_EMERGENCY

Return object potential values

Battery

PropertyTypeDescription
batteryLevelnumberThe battery level on the device, from 0.0 to 1.0
batteryStatestring'unknown', 'unplugged, 'charging'
lowPowerModeboolWhether or not the device is in low power mode
isChargingboolWhether or not the device is charging

Connectivity

PropertyTypeDescription
isConnectedboolWhether or not the device is connected to the internet
isInternetReachableboolWhether or not the device is connected to the internet
typestring'none', 'unknown', 'cellular', 'wifi', 'bluetooth', 'ethernet', 'wimax', 'vpn'
detailsobjectSee below
Connectivity Details
PropertyTypeDescription
isConnectionExpensiveboolWhether or not the connection is expensive
cellularGenerationstring'2g', '3g', '4g', '5g', 'unknown'

Thermal State

PropertyTypeDescription
thermalStatestring'nominal', 'fair', 'serious', 'critical'

RAM Usage

PropertyTypeDescription
ramUsagenumberRAM 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

Keywords

react-native

FAQs

Package last updated on 13 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts