npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@livechat/developer-sdk

v2.0.152

Published

The `Developer-SDK` is a part of the Text Platform Developer Studio and its main purpose is to arm your project with tooling that optimizes usage of `Text Platform` ecosystem.

Downloads

1,695

Readme

Text Platform - Developer SDK

The Developer-SDK is a part of the Text Platform Developer Studio and its main purpose is to arm your project with tooling that optimizes usage of Text Platform ecosystem.

mit

Installation

To use the Developer SDK, you need to install it first. You can do this using npm or yarn:

npm install @livechat/developer-sdk

Developer App

The App is class that provides methods for initializing and configuring your developer application.

Config

In order to use the App class in your project first you need to define your AppConfig accordingly to shape:

interface AppConfig {
  /* 1 */ appId: string;
  /* 2 */ auth?: {
    clientId?: string;
    mode?: "popup" | "iframe" | "redirect";
  };
}

We suggest store config in dedicated file: livechat.config.json

// livechat.config.json
{
  ...
}

but you can also store in it variable:

const config: AppConfig = {
  // ...
};
  1. Developer App ID

A required property of AppConfig is appId - it can be obtained directly from Developer Console by extracting it from url:

https://platform.text.com/console/apps/{appId}/monitor
  1. Authorization

If your Developer App has authorization block you can use Developer-SDK to process authorization for you. You can find value for property clientId in your Authorization block in Developer Console. Second parameter is mode - use can use three different strategies: popup, iframe, redirect (default if not given).

Initialization

Use the App.init method to initialize your Developer App. It takes a AppConfig as its argument and returns a App instance:

import { App, AppConfig } from "@livechat/developer-sdk";
import lcConfig from "./livechat.config.json";

const config = lcConfig as AppConfig;
const app = App.init(config);

Authorization

In order to trigger authorization you can use authorize method on your app instance:

await app.authorize();

Keep in mind that authorize method behavior vary depending on authorization strategy:

  • for popup and iframe it resolves as soon as login process is finished and returns authorization data (also app.authorization is being filled)
  • for redirect it returns undefined, but it redirects to login process and when it's back authorize method has to be call again to finalize authorization

Usage:

React

Have a look at @livechat/developer-sdk to see how the App can be integrated into your react application.

Reporting

Developer app instance allows you to use Developer Console Reporting feature.

Usage:

await app.features.reporting.sendError("4xx");

Definition:

interface ReportingFeature {
  sendError(type: "4xx" | "5xx", payload?: string): Promise<void>;
}

API:

POST https://api.text.com/app_monitoring/${appId}/events
BODY
  required: true
    content:
      application/json:
        schema:
          type: object
          properties:
            organization_id:
              type: string
              format: uuid
              description: Organization ID associated with the event
              example: 3aa138c1-c137-41c6-6b26-cface5857378
            type:
              type: string
              description: "Event type. Supported types: 4xx, 5xx"
              example: "4xx"
            payload:
              type: string
              description: "Event payload. Max length: 1 kB."
              example: "{\"code\": 404, \"reason\": \"Not found\"}"