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

@chamaeleonidae/chmln

Package Overview
Dependencies
Maintainers
6
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chamaeleonidae/chmln - npm Package Compare versions

Comparing version 1.0.0-alpha.2 to 1.0.1

CHANGELOG.md

14

index.js

@@ -1,6 +0,6 @@

const initializeChameleonBuilder = (token, { forceOverride } = {}) => {
const init = (token, { fastUrl, forceOverride } = {}) => {
if (forceOverride) {
chmln = undefined;
} else if (typeof chmln !== 'undefined') {
console.log(`Failed to instantiate the global "chmln" variable to initiate the chameleon builder.\nPlease make sure you don\'t have anything assigned to that or use the force param to override any previous declaration.\n\ne.g. chmln.init('token', { forceOverride: true });`);
console.log(`The global variable \`chmln\` is already defined.\nPlease make sure you're not adding Chameleon to the page other than with this library. Alternatively, you can use the forceOverride option to remove any previous declaration.\n\ne.g. chmln.init('token', { forceOverride: true });`);
return;

@@ -13,5 +13,5 @@ }

c="chmln",m="identify alias track clear set show on off custom help _data".split(" "),
i=d.createElement("script");if(w[c]||(w[c]={}),!w[c].root){w[c].accountToken=t,w[c].location=w.location.href.toString(),
i=d.createElement("script");if(w[c]||(w[c]={}),!w[c].root){w[c].accountToken=t,w[c].location=w.location.href.toString(),w[c].fastUrl=fastUrl||'https://fast.trychameleon.com/',
w[c].now=new Date;for(var s=0;s<m.length;s++){!function(){var t=w[c][m[s]+"_a"]=[];w[c][m[s]]=function(){t.push(arguments);};}();}
i.src="https://fast.trychameleon.com/messo/"+t+"/messo.min.js",
i.src=w[c].fastUrl+"messo/"+t+"/messo.min.js",
i.async=!0,d.head.appendChild(i);}

@@ -22,3 +22,3 @@ }

if (!chmln || !chmln.identify) {
console.log(`Failed to identify the user [${id}] because the chameleon builder was not initialized correctly`);
console.log(`Failed to identify the user [${id}] because the chameleon.io script was not initialized yet.`);
return;

@@ -32,3 +32,3 @@ }

if (!chmln || !chmln.track) {
console.log(`Failed to track event [${eventName}] because the chameleon builder was not initialized correctly`);
console.log(`Failed to track event [${eventName}] because the chameleon.io script was not initialized yet.`);
return;

@@ -41,5 +41,5 @@ }

module.exports = {
init: initializeChameleonBuilder,
init,
identify,
track
};
{
"name": "@chamaeleonidae/chmln",
"version": "1.0.0-alpha.2",
"description": "The official Chameleon JavaScript browser client library",
"version": "1.0.1",
"description": "The official chameleon.io JavaScript client library",
"main": "index.js",

@@ -6,0 +6,0 @@ "license": "Apache-2.0",

@@ -5,7 +5,7 @@ # Chameleon JavaScript Library

The Chameleon JavaScript Library is a set of methods attached to a global `chmln` object intended to be used by websites wishing to display Chameleon Experiences to users.
The Chameleon JavaScript Library is a set of methods attached to a global `chmln` object intended to be used by applications to display Chameleon Experiences to users.
## Installation via NPM
This library is available as a package on NPM. to install into a project using NPM with a front-end packager such as Browserify or Webpack:
This library is available as a package on NPM. To install into a project using NPM with a front-end packager such as Webpack or Browserify:

@@ -16,3 +16,3 @@ ```

You can then require the lib like a standard Node.js module:
You can grab your [token](https://app.chameleon.io/setup/install) then require the lib like a standard Node.js module:

@@ -22,10 +22,24 @@ ```javascript

chmln.init('YOUR_TOKEN', { fastUrl: 'https://fast.chameleon.io/' });
```
> Note for accounts created before *2022-05-21* you must omit the fastUrl
> If you're unsure, verify your account-specific instructions on the [installation page](https://app.chameleon.io/setup/install).
```javascript
chmln.init('YOUR_TOKEN');
```
> To use Chameleon as first-party (i.e. via `chameleon.your-product.com`), first [contact us](https://app.chameleon.io/help) to set this up, then use this updated script with your custom domain.
```javascript
chmln.init('YOUR_TOKEN', { fastUrl: 'https://chameleon.your-product.com/' }); // << CHANGE ME
```
## Usage
First, follow the installation process above, the script loads asynchronously and won’t affect your page loading times.
First, follow the installation process above. The script loads asynchronously and won’t affect your page loading times.
Next, identify your users by sending a unique ID (this normally matches the UIDs from your database). Without this, Chameleon can’t display Experiences to users. You should also send additional user data (such as “email address”, “role”) or company data (such as “plan type”, “subdomain”) so you can target Experiences to the right users, at the right time.
Next, identify your users by sending a unique ID (this normally matches the UIDs from your database). Without this, Chameleon can’t display Experiences to users. You should also [send additional user data](https://help.trychameleon.com/en/articles/1226443-how-do-i-send-my-users-data-to-chameleon) (such as “email address”, “role”) or company data (such as “plan type”, “subdomain”) so you can target Experiences to the right users, at the right time.

@@ -32,0 +46,0 @@ ```javascript

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