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

symmetrics

v1.2.0

Published

**Know your website, not your users.** It’s time to make the move away from Google Analytics. With **Symmetrics**, you own the data. Enjoy powerful visualization tools, full developer freedom, and happy users: Privacy is our top priority.

Downloads

17

Readme

Symmetrics

Know your website, not your users. It’s time to make the move away from Google Analytics. With Symmetrics, you own the data. Enjoy powerful visualization tools, full developer freedom, and happy users: Privacy is our top priority.

Start your free 7-day trial on https://getsymmetrics.com.

npm i symmetrics

Browser usage

Loading the signal

Retrieve your symmetricsId from the Symmetrics website. Then import the script in your browser package:

import symmetrics from 'symmetrics';
symmetrics('tmMJXR6YvKK0iWnAItxRcQVubNYXzXDATQn3ae');

You can add an options object as the second argument, like this:

symmetrics('tmMJXR6YvKK0iWnAItxRcQVubNYXzXDATQn3ae', {
	automaticallySendPageViewEvent: false
});

Read more about signal options here.

Sending custom events

Ensure you’ve included and ran the above script before sending custom events.

import {signal} from 'symmetrics';
signal('event', 'order_complete');

Read more about sending custom events here.

Server or non-browser usage

Retrieve your Symmetrics user ID and an authentication key from the Symmetrics website. Then import the package:

import client from 'symmetrics/client';
const symmetrics = client('ac76c1a2-79ff-4a5f-88fe-9b543182acad', 'JfJ0V8jiNEevhI5TDECja5Lw0wYVh0B48e1u');

The first argument is your Symmetrics user ID, the second is the authentication key. The third is an optional options object.

Options

timezoneOffset (optional)

When using timestamps in queries, ensure the observer (client or server) timezone offset in relation to GMT is also provided. For GMT+2, the timezoneOffset would be +7200000, eg. two hours ahead.

const symmetrics = client(userId, authenticationKey, {
	timezoneOffset: 1000 * 60 * 60 * 2
});

You can set the current timezone offset like this:

const symmetrics = client(userId, authenticationKey, {
	timezoneOffset: new Date().getTimezoneOffset() * 60 * 1000 * -1
});

This setting can be overridden per query.

query: Performing queries

Write queries using JsonQl to extract the data you need.

import client from 'symmetrics/client';
const symmetrics = client(userId, authenticationKey);

// Using promises
symmetrics.query('unique event')
	.then((results) => console.log(results))
	.catch((error) => console.error(error));

// Using async
try {
	const results = await symmetrics.query('unique event');
	console.log(results);
} catch (error) {
	console.error(error);
}

Query options

A second argument queryOptions can be passed to the query function as an object.

timezoneOffset (optional)

When using timestamps in queries, ensure the observer (client or server) timezone offset in relation to GMT is also provided. For GMT+2, the timezoneOffset would be +7200000, eg. two hours ahead.

symmetrics.query('where timestamp > 1601052331102', {
	timezoneOffset: 1000 * 60 * 60 * 2
});

You can add the current timezone offset like this:

symmetrics.query('where timestamp > 1601052331102', {
	timezoneOffset: new Date().getTimezoneOffset() * 60 * 1000 * -1
});

This setting overrides the top level client options timezoneOffset.

signal: Sending custom events

Use the built-in signal function to send custom events.

import client from 'symmetrics/client';
const symmetrics = client(userId, authenticationKey);

// Using promises
symmetrics.signal('event', 'user_login')
	.then((results) => console.log(results))
	.catch((error) => console.error(error));

// Using async
try {
	const results = await symmetrics.signal('event', 'server_restart');
	console.log(results);
} catch (error) {
	console.error(error);
}

Read more about sending custom events here.

Apps

apps.tweets: Retrieving tweets about your websites

import client from 'symmetrics/client';
const symmetrics = client(userId, authenticationKey);

// Using promises
symmetrics.apps.tweets()
	.then((results) => console.log(results))
	.catch((error) => console.error(error));

// Using async
try {
	const results = await symmetrics.apps.tweets();
	console.log(results);
} catch (error) {
	console.error(error);
}

You can also provide an options object with startTimestamp and/or endTimestamp to filter the output.

symmetrics.apps.tweets({
	startTimestamp: 1600103109877,
	endTimestamp: 1600103109879
});