Skip to content

autoplay-technologies/graphable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Graphable Node.js Library

The Graphable Node library provides convenient access to the Graphable API from client applications written in JavaScript.

Documentation

See the graphable API docs for Node.js.

Installation

Install the package with:

npm install graphable
# or
yarn add graphable

Usage

Graphable functions require a config object containing information about the client app and current version. Config objects are available in the Graphable Dashboard.

const config = {
    api_key: 'test_key-...',
    app_id: 'app-...',
    project_id: 'proj-...',
};
const graphable = require('graphable')(config);

graphable.logScreenChange({
  screen_id: 'home',
})
  .then(event => console.log(event.created_at))
  .catch(error => console.error(error));

Or using ES modules and async/await:

import Graphable from 'graphable';
const config = {
    api_key: 'test_key-...',
    app_id: 'app-...',
    project_id: 'proj-...',
};
const graphable = new Graphable(config);

(async () => {
  try {
      const event = await graphable.logScreenChange({
        screen_id: 'home',
      });
    
      console.log(event.created_at);
  }
  catch (error) {
      console.error(error);
  }
})();

Usage with TypeScript

Graphable maintains types for the latest API version.

Import Graphable as a default import (not * as Graphable, unlike the DefinitelyTyped version) and instantiate it as new Graphable().

import Graphable from 'graphable';
const config = {
    api_key: 'test_key-...',
    app_id: 'app-...',
    project_id: 'proj-...'
};
const graphable = new Graphable(config);

const createScreenChangeEvent = async () => {
  const params: Graphable.ScreenChangeEventCreateParams = {
    screen_id: 'home',
  };

  const event: Graphable.ScreenChangeEvent = await graphable.logScreenChange(params);

  console.log(event.created_at);
};
createScreenChangeEvent();

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published