1.0.72 • Published 1 year ago

hubbleiq-sdk v1.0.72

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
1 year ago

HubbleSDK

npm


Getting started

Note: v1.x is compatible with Nodejs 18. Please use latest versions.

The SDK communicates with your application through events

NPM

Install with yarn or npm.

Yarn:

yarn add hubbleiq-sdk

npm:

npm install --save hubbleiq-sdk

Configuration Options:

When you create the object, you need to put two parameters.

// import the component
import { HubbleIQLib } from "hubbleiq-sdk";
// and just use it
const hubbleIQLib = new HubbleIQLib("your apiKey", "your companyKey");
proptypedefaultcomments
apiKeystringnotTake it in admin panel, after registration on hubbleiq.
companyKeystringnotTake it in admin panel, after registration on hubbleiq.

Collaborate with your team


Examples

Example with React. For start need import HubbleIQLib from "hubbleiq-sdk".

import { HubbleIQLib } from "hubbleiq-sdk";
const hubbleIQLib = new HubbleIQLib("apikey", "companyKey");

Create constant for use in UI.

const [dSpeed, setDSpeed] = useState(0);
const [uSpeed, setUSpeed] = useState(0);
const [jitter, setJitter] = useState(0);
const [customHtml, setCustomHtml] = useState("");
const [isp, setIsp] = useState < any > "";
const [ipAddress, setIpAddress] = useState < any > "";
const [connectionHealth, setConnectionHealth] = useState < any > "";
const [customHeadline, setCustomHeadline] = useState < any > "";
const [token, setToken] = useState < any > "";
const [statusBackgroundColorForMsg, setStatusBackgroundColorForMsg] =
  useState("0");
const [connectionMsg, setConnectionMsg] = useState("");
const [connectionMsgHeader, setConnectionMsgHeader] = useState("");
const [connectionStatus, setConnectionStatus] = useState("0");

Create use

useEffect(() => {
  hubbleIQLib.init();
  hubbleIQLib.checkInternetConnection();
  hubbleIQLib.on("upload-measurement", (data) => {
    setUSpeed(data.ClientToServerSpeed);
    setJitter(data.Jitter);
  });
  hubbleIQLib.on("download-measurement", (data) => {
    setDSpeed(data.ServerToClientSpeed);
    setJitter(data.Jitter);
  });
  hubbleIQLib.on("complete", (data) => {
    setDSpeed(data.ServerToClientSpeed);
    setUSpeed(data.ClientToServerSpeed);
    setJitter(data.Jitter);
  });
  hubbleIQLib.on("api-results", (data: any) => {
    setCustomHtml(data.body);
    setConnectionHealth(data.connectionHealth);
    setCustomHeadline(data.headline);
    setIsp(data.isp);
    setIpAddress(data.ip_address);
    setToken(data.token);
  });
  hubbleIQLib.on("connection-status", (data) => {
    setConnectionStatus(data);
  });
  hubbleIQLib.on("connection-msg", (data) => {
    setStatusBackgroundColorForMsg(data.color);
    setConnectionMsg(data.msg);
    setConnectionMsgHeader(data.header);
  });
}, []);

Aditional: you can also use listening to other necessary events from the list of events.

Next create function for button:

async function startTest() {
  if (dSpeed > 0 && uSpeed > 0 && jitter > 0) {
    setDSpeed(0);
    setUSpeed(0);
    setJitter(0);
    setLatency(0);
    await hubbleIQLib.stop();
  }
  await hubbleIQLib.run();
}

Integrate with your tools


Functions

Create object:

const hubbleIQLib = new HubbleIQLib("apiKey", "companyKey");

Initialization object:

hubbleIQLib.init();

Run test:

await hubbleIQLib.run();

Emit Events:

Stop test:

await hubbleIQLib.stop();

Check connection to internet:

This function must be started only once when the page is loaded, and it works continuously.

hubbleIQLib.checkInternetConnection();

Emit Events:

Packet loss:

The function that checks packet loss.

await hubbleIQLib.calculatePacketLoss();

Check Aplication:

await hubbleIQLib.checkApplication();

Support

If you have difficulties with the implementation, please contact us by email support@hubble.org


Events

The module interacts with the UI through events. You can listen to the events:

event nametype of responsedescription
onstartstringServer name
completeobjectcomplete
api-resultsobjectapi-results
connection-statusstringonline or offline
connection-stabilitynumberreturned ms, example: 50
connection-msgobjectconnection-msg
upload-startobjectupload-start
upload-measurementobjectupload-measurement
upload-finishedobjectupload-finished
download-startobjectdownload-start
download-measurementobjectdownload-measurement
download-finishedobjectdownload-finished
test-resultsobjecttest-results
packet-lossnumberexample: 0

Basic events:

  • onstart
  • complete
  • connection-status

Additional events:

  • upload-start
  • upload-measurement
  • upload-finished
  • download-start
  • download-measurement
  • download-finished

Dependencies

  • @m-lab/ndt7
  • crypto-browserify
  • form-data
  • node-fetch
  • stream-browserify
  • tslib
  • web-worker
  • worker-plugin

Authors

Hubble teams.

License

For open source projects, say how it is licensed.

Project status

The project is under development and testing.

Event object

complete

{
    "c2sRate": number,
    "s2cRate": number,
    "MaxRTT": string,
    "MinRTT": string,
    "SumRTT": string,
    "TCPInfo.Lost": string,
    "ServerToClientSpeed": number,
    "ClientToServerSpeed": number,
    "Jitter": number,
    "latency": number,
    "CurRTO": string,
    "SndLimTimeCwnd": string,
    "SndLimTimeRwin": string,
    ...
}

api-results

{
    "user_activity_id": number,
    "overallStatus": string,
    "status_description": string,
    "headline": string,
    "body": string (htmlformat),
    "token": string,
    "city": null,
    "isp": null,
    "ip_address": string,
    "company_key": string,
    "connectionHealth": {
        "hdStreaming": string,
        "streaming": string,
        "internetVoice": string,
        "screenSharing": string,
        "fileSharing": string
    }
}

Example api-results-example

connection-msg

{
  color: string,
  header: string,
  msg: string
}

upload-start

upload-measurement

{
    "ClientToServerSpeed": number,
    "ServerToClientSpeed": number,
    "Jitter": number,
    "latency": number
}

upload-finished

download-start

download-measurement

{
    "ClientToServerSpeed": number,
    "ServerToClientSpeed": number,
    "Jitter": number,
    "latency": number
}

download-finished

api-results-example

{
    "user_activity_id": 1,
    "overallStatus": "good",
    "status_description": "very_good",
    "headline": "Great internet connection...",
    "body": "<div class=\"ext-subtitle\" style=\"margin-bottom: 20px;\">Your connection to the internet is fast, stable, and sufficient for working and gaming.</div>\n  <div class=\"d-flex\">\n  </div>",
    "token": "user_token",
    "city": null,
    "isp": null,
    "ip_address": "Ip address",
    "company_key": "Company key",
    "connectionHealth": {
        "hdStreaming": "good",
        "streaming": "good",
        "internetVoice": "good",
        "screenSharing": "good",
        "fileSharing": "good"
    }
}

packet-loss

2% // percentages of packet loss
1.0.72

1 year ago

1.0.71

1 year ago

1.0.70

1 year ago

1.0.69

1 year ago

1.0.65

1 year ago

1.0.62

1 year ago

1.0.61

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.41

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago