UNPKG

snippet.js

Version:
49 lines (36 loc) 2.21 kB
# Chameleon snippet.js [![Build Status](https://semaphoreci.com/api/v1/projects/c0b396ff-cd22-49be-944e-97da670198e0/479935/shields_badge.svg)](https://semaphoreci.com/bnorton/snippet-js) [![Circle CI](https://circleci.com/gh/trychameleon/snippet.js.svg?style=svg)](https://circleci.com/gh/trychameleon/snippet.js) [![Code Climate](https://codeclimate.com/github/trychameleon/snippet.js/badges/gpa.svg)](https://codeclimate.com/github/trychameleon/snippet.js) [![npm version](https://badge.fury.io/js/snippet.js.svg)](http://badge.fury.io/js/snippet.js) #Getting started Use it ------ 1. Copy index.min.js 1. Replace `{{ACCOUNT_TOKEN}}` with yours from the Chameleon dashboard. 1. Include it on all HTML pages (before the closing `</head>` tag) 1. Include it *only* in production (even if you have a staging and/or test instances). 1. For all private pages, call `chmln.setup(userProperties)` 1. Deploy the app `chmln.setup` spec ------ The `chmln.setup` call specifies a user identity that you reference across the user's lifetime. Every `chmln.setup` call must have a user id (UID) and time that the user was created. | Property | Description | |---|---| | **uid** - _required_ | A unique identifier for the user in your database. | | **created** - _required_ | The date the user's account was first created. Any date format will work. | | **email** - _recommended_ | The email address of the user | | **plan** - _recommended_ | Which plan a user falls under (i.e `gold`, `startup`, `enterprise`) | | **role** - _recommended_ | The specific type of tasks this user can perform (i.e. `owner`, `admin`, `member`, `billing`) | | **spend** - _recommended_ | The amount of monthly revenue generated by the user's account | * Recommended properties are optional but are valuable. Examples ------ Setup with email, plan and role properties: ```javascript chmln.setup({uid: user.id, created: user.createdAt, email: user.email, plan: 'gold', role: 'admin'}); ``` ---------- Footnote: http://eschooltoday.com/ecosystems/scales-of-an-ecosystem.html Micro: A small scale ecosystem such as a pond, puddle, tree trunk, under a rock etc. Messo: A medium scale ecosystem such as a forest or a large lake.