hubbleiq-sdk2 v1.0.63
HubbleSDK
Getting started
Note: v1.x
is compatible with Nodejs 18
. Please use latest versions.
Install with yarn
or npm
.
Yarn:
yarn add hubbleiq-sdk
npm:
npm install --save hubbleiq-sdk
And, use it like
// import the component
import { HubbleIQLib } from "hubbleiq-sdk";
// and just use it
const hubbleIQLib = new HubbleIQLib("yourKey: string");
Or you can work from local file package:
Step 1
Clone the repository to your computer from a web hosting service for software development projects that uses the Git version control system.
git clone https://gitlab.com/eligence/hubblesdk.git
Step 2
In your project open package.json
file and in dependencies add:
"dependencies": {
...
"hubbleiq-sdk": "file:pathToTheNewlyClonedRepository/hubblesdk",
...
}
Example:
"dependencies": {
...,
"hubbleiq-sdk": "file:../hubblesdk",
...
}
Step 3
In the console start the command:
Yarn:
yarn
npm:
npm install
Configuration Options:
When you create the object, you need to put two parameters.
const hubbleIQLib = new HubbleIQLib("your apiKey", "your companyKey");
prop | type | default | comments |
---|---|---|---|
apiKey | string | not | Take it in admin panel, after registration on hubbleiq. |
companyKey | string | not | Take it in admin panel, after registration on hubbleiq. |
Collaborate with your team
If you come across errors, please let us know so that we can improve our service.
Examples
Example with React. For start need import HubbleIQLib from "hubbleiq-sdk".
import { HubbleIQLib } from "hubbleiq-sdk";
const hubbleIQLib = new HubbleIQLib("yourKey: string");
Create constant for use in UI.
const [dSpeed, setDSpeed] = useState(0);
const [uSpeed, setUSpeed] = useState(0);
const [jitter, setJitter] = useState(0);
const [connectionStatus, setConnectionStatus] = useState("0");
Create use
useEffect(() => {
hubbleIQLib.init();
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("connection-status", (data) => {
console.log("🚀 ~ connection status at:", data);
setConnectionStatus(data);
});
}, []);
Next create function for button:
async function testInternet() {
setDSpeed(0);
setUSpeed(0);
setJitter(0);
await hubbleIQLib.run();
await hubbleIQLib.checkNet();
}
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to makeareadme.com for this template.
Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
Integrate with your tools
Functions
Create object:
const hubbleIQLib = new HubbleIQLib("yourKey: string");
Initialization object:
hubbleIQLib.init();
Run test:
await hubbleIQLib.run();
Check connection to internet:
await hubbleIQLib.checkNet();
Stop test:
await hubbleIQLib.stop();
Packet loss:
await hubbleIQLib.calculatePacketLoss();
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 name | type of response | description |
---|---|---|
onstart | string | Server name |
complete | object | complete |
connection-status | string | online or offline |
connection-latency | int | 50 |
upload-start | object | upload-start |
upload-measurement | object | upload-measurement |
upload-finished | object | upload-finished |
download-start | object | download-start |
download-measurement | object | download-measurement |
download-finished | object | download-finished |
test-results | object | test-results |
packet-loss | number | packet-loss |
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": 52076,
"s2cRate": 97488.23814151282,
"MaxRTT": "106",
"MinRTT": "69",
"SumRTT": "7333",
"CurRTO": "0",
"SndLimTimeCwnd": "0",
"SndLimTimeRwin": "0",
"SndLimTimeSender": "0",
"DataBytesOut": "0",
"DupAcksIn": "0",
"PktsOut": "86029",
"PktsRetrans": "0",
"Timeouts": "0",
"CountRTT": "101",
"CongestionSignals": "0",
"AckPktsIn": "0",
"MaxCwnd": "0",
"MaxRwinRcvd": "0",
"CurMSS": "1460",
"Sndbuf": "0",
"RcvWinScale": "0",
"SndWinScale": "0",
"TCPInfo.State": "1",
"TCPInfo.CAState": "0",
"TCPInfo.Retransmits": "0",
"TCPInfo.Probes": "0",
"TCPInfo.Backoff": "0",
"TCPInfo.Options": "6",
"TCPInfo.WScale": "120",
"TCPInfo.AppLimited": "0",
"TCPInfo.RTO": "284000",
"TCPInfo.ATO": "40000",
"TCPInfo.SndMSS": "1460",
"TCPInfo.RcvMSS": "585",
"TCPInfo.Unacked": "538",
"TCPInfo.Sacked": "0",
"TCPInfo.Lost": "0",
"TCPInfo.Retrans": "0",
"TCPInfo.Fackets": "0",
"TCPInfo.LastDataSent": "0",
"TCPInfo.LastAckSent": "0",
"TCPInfo.LastDataRecv": "10000",
"TCPInfo.LastAckRecv": "4",
"TCPInfo.PMTU": "1500",
"TCPInfo.RcvSsThresh": "64076",
"TCPInfo.RTT": "82635",
"TCPInfo.RTTVar": "19963",
"TCPInfo.SndSsThresh": "477",
"TCPInfo.SndCwnd": "548",
"TCPInfo.AdvMSS": "1460",
"TCPInfo.Reordering": "300",
"TCPInfo.RcvRTT": "0",
"TCPInfo.RcvSpace": "14600",
"TCPInfo.TotalRetrans": "2175",
"TCPInfo.PacingRate": "11618462",
"TCPInfo.MaxPacingRate": "-1",
"TCPInfo.BytesAcked": "121626598",
"TCPInfo.BytesReceived": "585",
"TCPInfo.SegsOut": "86029",
"TCPInfo.SegsIn": "9080",
"TCPInfo.NotsentBytes": "2474700",
"TCPInfo.MinRTT": "67366",
"TCPInfo.DataSegsIn": "1",
"TCPInfo.DataSegsOut": "86028",
"TCPInfo.DeliveryRate": "5446616",
"TCPInfo.BusyTime": "10000000",
"TCPInfo.RWndLimited": "116000",
"TCPInfo.SndBufLimited": "0",
"TCPInfo.Delivered": "83316",
"TCPInfo.DeliveredCE": "0",
"TCPInfo.BytesSent": "125581414",
"TCPInfo.BytesRetrans": "3169336",
"TCPInfo.DSackDups": "0",
"TCPInfo.ReordSeen": "390",
"TCPInfo.RcvOooPack": "0",
"TCPInfo.SndWnd": "16776704",
"NDTResult.S2C.UUID": "ndt-prjzt_1667239745_00000000002A1E01",
"NDTResult.S2C.ServerIP": "162.213.96.152",
"NDTResult.S2C.ServerPort": "35313",
"NDTResult.S2C.ClientIP": "212.28.87.243",
"NDTResult.S2C.ClientPort": "57226",
"NDTResult.S2C.StartTime": "2022-12-27 15:41:36.417848165 +0000 UTC m=+1760768.698956105",
"NDTResult.S2C.EndTime": "2022-12-27 15:41:46.488368709 +0000 UTC m=+1760778.769476663",
"NDTResult.S2C.MinRTT": "69ms",
"NDTResult.S2C.MaxRTT": "106ms",
"NDTResult.S2C.SumRTT": "7.333s",
"NDTResult.S2C.CountRTT": "101",
"NDTResult.S2C.Error": "",
"ServerToClientSpeed": 97.49,
"ClientToServerSpeed": 52.08,
"Jitter": 73.33,
"latency": 69
}
upload-start
upload-measurement
{
"ClientToServerSpeed": 38.54,
"ServerToClientSpeed": 0,
"Jitter": 0,
"latency": 0
}
upload-finished
download-start
download-measurement
{
"ClientToServerSpeed": 31.04,
"ServerToClientSpeed": 56.3,
"Jitter": 0,
"latency": 0
}
download-finished
test-results
{
"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 year ago