@ingrain/ingrain-client-js
v0.0.6
Published
Ingrain (ingrain.dev) client-side SDK
Downloads
8
Readme
Ingrain Client SDK
Ingrain (https://ingrain.dev) SDK for the browser.
Overview
This is the client-side Javascript SDK for Ingrain. Ingrain is a service that makes it easy for you to add user activity logging to your app in minutes.
UI Components Package
Ingrain also provides React UI Components that work out of the box. The components are part of the Ingrain React package.
Getting Started
Installation
npm i @ingrain/ingrain-client-js
or with yarn
:
yarn add @ingrain/ingrain-client-js
Usage
import { Ingrain } from '@ingrain/ingrain-client-js';
// Initialize Ingrain
const opts = {
publishableKey: 'your-publishable-key',
getUserJwtToken: async () => {
return "your-user's-jwt-token";
},
};
const ingrain = new Ingrain(opts);
// Log action
ingrain
.createUserEvent({
actorId: 'example-actor-id',
actorDisplayName: 'example-actor-id',
actorMetadata: {
// Can also be null for no metadata
any: 'any',
metadata: 'metadata',
here: 'here',
},
entityId: 'example-application',
entityName: 'Example Application',
entityDisplayLabel: `Example Application's settings`,
entityMetadata: null,
entityPropName: 'Settings', // Can be null
appUserOrgId: 'example-org-id',
action: Action.UPDATE,
oldValue: 'old-settings-value', // can be null
newValue: 'new-settings-value', // can be null
})
.catch((err) => {
console.error('Error creating user event', err);
});
// Get data
ingrain
.readUserEvents({
actorId: 'example-actor-id',
})
.then((resp) => {
const { data } = resp;
// Display the data
});
Documentation
You can start from Introduction or jump straight to Client JS SDK