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

primednodejs

v2.1.1

Published

PrimedIO API wrapper for server-side NodeJS

Downloads

9

Readme

primednodejs

Create a personalized web application that is unique and relevant for each and every user with Primed.io.

Use

Installation

npm install primednodejs

Example

var PRIMEDIO = require('primednodejs');

// Instantiate PRIMEDIO, api_url, public key
// and secret key are provided by PrimedIO
var pio = new PRIMEDIO({
	api_url: "https://primed.io",
	public_key: 'xxxxxxxxxxxxxxxxxxxxxxxx', 
	secret_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
});

// Perform the personalise call,
// which returns a 'promise'
var promise = pio.personalise({
	campaign: 'frontpage.article.bottom',
	signals: { 
		'article_id': '2578346', 
		'tod-dow': 'Fri_15-18'
	},
	limit_results: 10
});

// Deal with the results as they are returned
// by Primed. 
promise.then(function(response) {
	// 'response' is a wrapper object,
	// calling 'response.all()' returns
	// the list of results which can then be
	// used to render the page
	var results = response.all();
	
	// simulate a click -- 'conversion'
	var clicked = response.first();

	// mark the clicked result as converted
	// by using the `.uuid` property
	pio.convert(clicked.uuid);
}).catch(function (err) {
	console.log('Personalize failed: ' + err);
});

// Converting clicks.
// Each result comes with a guaranteed
// random UUID (Result UUID). This UUID can be sent 
// back to PrimedIO to mark a result as having been
// converted. This in turn allows the system
// to evaluate the performance (as CTR) of the
// underlying Model (blend).
pio.convert({
	ruuid: "df3870dc-b277-11e7-abc4-cec278b6b50a"
}); 

Initialization

PRIMED.init({
	api_url: "https://primed.io",
	public_key: "xxxxxxxxxxxxxxxxxxxxxxxx",
	secret_key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
});

| arg | type | required | description | example | | --- | ---- | -------- | ------ | ------- | | api_url | string | Yes | sets the Primed.io API url | "https://primed.io"`` | | public_key | string | Yes | sets the public key | "xxxxxxxxxxxxxxxxxxxxxxxx"| | secret_key | string | Yes | sets the secret key |"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"` |

Personalisation

Personalisation requires at least a campaign key (NB, this is not the campaign name), e.g. frontpage.recommendations.

pio.personalize({
	campaign: "frontpage.recommendations",
	signals: { itemId: '2503001'},
	limit: 5,
	abvariant: 'A'
});

| arg | type | required | description | example | | --- | ---- | -------- | ------ | ------- | | campaign | string | Yes | campaign key for which personalisation is retrieved | frontpage.recommendations | | signals | dictionary | No (defaults to {}) | key, value pairs of signals (itemId currently being viewed, deviceId, location, etc.) | {itemId: '1234', userId: 'xyz'} | | limit | integer | No (defaults to 5) | number of desired results | 10 | | abvariant | string | No (defaults to WRANDOM assignment) | specify A/B variant for which to retrieve personalisation | __CONTROL__ |

Conversion

Upon successful personalisation, a list of results will be returned. Each result will contain a variable payload: the idea here is that PrimedIO is generic and supports freeform Targets, which can be item ID's (usually used in lookups after the personalize call), URL's, Boolean values, and any combination of these. Additionally, each result will contain a unique RUUID (Result UUID), randomly generated for this particular call and Target. It is used to track the conversion of this particular outcome, which we use to identify which of the A/B variants performed best. Conversion is also generic, but generally we can associate this with clicking a particular outcome. In order for PrimedIO to register this feedback, another call needs to be made upon conversion. This in turn allows the system to evaluate the performance (as CTR) of the underlying Model (blend).

pio.convert({
	ruuid: "6d2e36d1-1b58-4fbc-bea8-868e3ec11c87",
	data: { heartbeat: 0.1 }
});

| arg | type | required | description | example | | --- | ---- | -------- | ------ | ------- | | ruuid | string | Yes | ruuid for which to register conversion | "6d2e36d1-1b58-4fbc-bea8-868e3ec11c87" | | data | dictionary | No | freeform data payload | { heartbeat: 0.1 } |