hubbleiq-sdk v1.0.72
HubbleSDK
Getting started
Note: v1.x
is compatible with Nodejs 18
. Please use latest versions.
The SDK communicates with your application through events
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");
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("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 name | type of response | description |
---|---|---|
onstart | string | Server name |
complete | object | complete |
api-results | object | api-results |
connection-status | string | online or offline |
connection-stability | number | returned ms, example: 50 |
connection-msg | object | connection-msg |
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 | example: 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