@memfault/js-cloud
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

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}`);
    });

Readme

Keywords

none

Package Sidebar

Install

npm i @memfault/js-cloud

Weekly Downloads

2

Version

0.0.5

License

SEE LICENSE IN License.txt

Unpacked Size

187 kB

Total Files

18

Last publish

Collaborators

  • chrisc11
  • martijnthe
  • memfault-ci
  • sirlantis