Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

retention

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retention

Build retention matrix, render table or chart with data

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Retention - build retention matrix, render table or chart with data

Screenshot

Installation

$ npm i retention

D3 and C3 libraries are not included in the bundle, you have to install them separately.

ES6 modules
import { buildMatrix, renderTable, renderChart } from 'retention';
CommonJS
const { buildMatrix, renderTable, renderChart } = require('retention');

Notice: Because CJS modules are almost always used in NodeJS backend code (Webpack or Rollup should automatically use UMD or ESM version), this version includes only buildMatrix function, no rendering functions. If you want those you should probably explicitly include the UMD version:

const {
  buildMatrix,
  renderTable,
  renderChart
} = require('retention/dist/retention.umd.js');
Browser
<script src="https://cdn.jsdelivr.net/npm/retention"></script>
<script>
    const { buildMatrix, renderTable, renderChart } = Retention;
</script>

Sample

Clone the repo, install dependencies, build the bundle, and start a simple web server with these commands:

git clone https://github.com/marszall87/retention.git
cd retention
npm install
npm run build
npm run sample

Navigate to http://localhost:5000 and you should see a sample retention chart and table.

API

buildMatrix(opts)

Returns promise with retention matrix object.

opts.startingDate - Date object, defines the end of the last week used to calculate retention, you probably want to use today or yesterday here

opts.numberOfWeeks - number of weeks you want to generate retention for

opts.getInitialEvents - function that should return a promise with Array of objects with two props: date and id, date represents

opts.getActivity - function or object in form of { eventsA: () => {...}, eventsB: () => {...} }, functions take three args: start date, end date and index of a given time range, should return an Array of ids that were active in that range

renderTable(opts)

opts.container - container in which the table will be rendered

opts.matrix - retention matrix as returned by buildMatrix()

renderChart(opts)

opts.container - container in which the chart will be rendered

opts.matrix - retention matrix as returned by buildMatrix()

License

MIT © Michał Nykiel

FAQs

Package last updated on 17 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc