@memfault/js-cloud
v0.0.5
Published
Memfault JavaScript Cloud library
Downloads
8
Keywords
Readme
Memfault Cloud library
Note: this is a work in progress.
Adding this library to your project
$ npm install @memfault/js-cloud
or
$ yarn add @memfault/js-cloud
Creating a MemfaultCloud instance
Go to https://app.memfault.com/ and go to Settings to find your project key.
Then create a MemfaultCloud
instance in your JS code as follows:
const { MemfaultCloud } = require("@memfault/js-cloud");
const api = new MemfaultCloud({
projectKey: "<YOUR_PROJECT_KEY>",
});
Posting Status Events
const deviceInfo = {
appVersion: "1.0.0",
deviceId: "device-id-1234",
hwVersion: "proto",
};
api
.postStatusEvent("eventType", deviceInfo, {
myUserData: "foo",
someMoreUserData: "bar",
})
.then(console.log, console.error);
Getting Latest Release
const deviceInfo = {
appVersion: "1.0.0",
deviceId: "device-id-1234",
hwVersion: "proto",
};
api.downloadLatestReleaseForDevice(deviceInfo)
.then((release) => {
const { updateDisabled, latestRelease } = release;
if (!latestRelease) {
console.log(
`No new release to install, updateDisabled: ${updateDisabled}`
);
return;
}
console.log(latestRelease);
})
.catch((error) => {
console.log(`Unable to query latest release: ${error}`);
});