2.5.11 • Published 6 days ago

hubbleiq-services v2.5.11

Weekly downloads
-
License
ISC
Repository
github
Last release
6 days ago

HubbleSDK: A JavaScript library to easily measure and analyze internet performance for web applications. Improve user experience by identifying and troubleshooting network issues.

npm


A JavaScript library for measuring and analyzing internet performance.

Getting Started

Note: Node.js versions 18 and above are supported. We recommend using the latest stable version. It is also important for you to obtaining the API key and company key from the HubbleIQ admin panel before using this library.

Installation:

yarn add hubbleiq-services

or

npm install hubbleiq-services

Once installed, you can import the HubbleIQLib component into your React application as follows:

// import the component
import { HubbleIQLib } from "hubbleiq-services";

Configuration

To initialize the HubbleIQ SDK, you need to provide two objects: authData and options. Where authData contains:

{
  apiKey: 'your apiKey',
  companyKey: 'your companyKey'         
}

and options contains additional configuration data. These keys can be obtained from the admin panel after registering on HubbleIQ.

Configuration Options:

Property NameTypeDefault ValueDescription
optionsobjectNot setConfiguration object for the HubbleIQ library, example: { enablePageLoadCalculation: true, checkNetTimeOut: 2000 }

Examples:

const hubbleIQLib = new HubbleIQLib(
        {
          apiKey: "your apiKey",
          companyKey: "your companyKey"
        },
        options
      );

Usage Examples:

Explore the following code samples that demonstrate how to leverage HubbleIQ SDK’s functionalities within your application:

1. To use the SDK we should first initialize it. Create a file called hubbleIQLib.js:

import { HubbleIQLib } from "hubbleiq-services";

const options = {
  enablePageLoadCalculation: false,
  env: 'local'
};

// construct the library
const hubbleIQLib = new HubbleIQLib (
        {
          apiKey: 'c14aa742-5aac-41cf-abf9-45157df2d3ca',
          companyKey: 'mediumCompanyKey',
        },
        options
);

hubbleIQLib.init();

export default hubbleIQLib;

2. The next step is to create a functions that call the tests from hubbleIQLib:

async function callPocketLossTest() {
  await hubbleIQLib.calculatePacketLoss();
}

async function callInternetConnectionTest() {
  await hubbleIQLib.checkInternetConnection();
}

async function startTest() {
  await hubbleIQLib.run();
}

3. Each SDK method fires an event once the action is finished. We should declare them and save the data we receive from the events into our state using useEffect.

useEffect(() => {
  hubbleIQLib.on("connection-status", (status: string) => {
    // connection status
  });

  hubbleIQLib.on("upload-measurement", (data: IUploadAndDownloadData) => {
    // upload speed: data.ClientToServerSpeed
  });

  hubbleIQLib.on("download-measurement", (data: IUploadAndDownloadData) => {
    // downlod speed: data.ServerToClientSpeed
  });

  hubbleIQLib.on("complete", (data: ICompleteData) => {
    // latency and jitter: data.jitter && data.latency
  });

  hubbleIQLib.on("packet-loss", (data: number) => {
    // packet loss percentage
  });

  hubbleIQLib.on("connection-stability", (data: number) => {
    // heart beat data.
  });
}, []);

Events:

The library emits various events to communicate results. You can listen to these events to handle the data accordingly.

Event nameType of responsedescription
onstartstringFired when the library starts. Contains the name of the server being contacted.
completeobjectEmitted after a complete internet performance test is finished.
connection-statusstringIndicates the current internet connection status (online or offline).
connection-stabilityintConnection latency (ms).
connection-msgobjectProvides details about the current connection, including latency.
upload-measurementobjectContains results from an upload speed measurement.
download-measurementobjectContains results from a download speed measurement.
test-resultsobjectEmitted with the complete set of results after a full internet performance test.
packet-lossnumberProvides the measured packet loss percentage.

Dependencies:

The HubbleIQ library depends on the following external libraries:

@m-lab/ndt7: used for network speed testing.

crypto-browserify: provides cryptographic functionalities (used for security?).

form-data: used for constructing multipart form data for requests.

node-fetch: enables making HTTP requests in Node.js environments.

stream-browserify: used for handling data streams.

tslib: utility library for compatibility across environments.

web-worker: enables utilizing web workers for background tasks.

worker-plugin: a plugin for handling web workers.

Support:

If you encounter any issues, feel free to contact us by email at support@hubbleiq.com.

Additional Information:

Dependencies: Refer to the documentation for a list of dependencies.

Authors: Hubble Teams

License:

This project uses an API Key Licensing model. You are free to use the functionality provided by the API, but a valid API key is required for access.

2.5.11

6 days ago

2.5.10

9 days ago

2.5.9

21 days ago

2.5.8

24 days ago

2.5.7

28 days ago

2.5.6

29 days ago

2.5.5

1 month ago

2.5.4

1 month ago

2.5.3

1 month ago

2.5.2

1 month ago

2.5.1

1 month ago

2.5.0

1 month ago

2.4.6

2 months ago

2.4.5

2 months ago

2.4.4

2 months ago

2.4.2

2 months ago

2.4.1

2 months ago

2.4.0

2 months ago

2.3.4

3 months ago

2.3.6

3 months ago

2.3.5

3 months ago

2.3.8

3 months ago

2.3.7

3 months ago

2.3.0

3 months ago

2.3.2

3 months ago

2.3.1

3 months ago

2.3.3

3 months ago

2.2.1

4 months ago

2.2.0

4 months ago

2.2.3

4 months ago

2.2.2

4 months ago

2.1.9

5 months ago

1.1.9

6 months ago

1.1.8

6 months ago

1.1.7

6 months ago

1.1.6

7 months ago

1.1.5

7 months ago

1.1.4

7 months ago

1.1.3

7 months ago

1.1.2

10 months ago

1.1.1

12 months ago

1.1.0

12 months ago

1.0.90

1 year ago

1.0.81

1 year ago

1.0.80

1 year ago