# idyll-analytics

> Tools to collect detailed usage analytics of [Idyll articles](https://idyll-lang.org).

Latest version **1.0.0** (published 2019-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install idyll-analytics
pnpm add idyll-analytics
yarn add idyll-analytics
bun add idyll-analytics
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-04-09 |
| First published | 2019-04-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | mathisonian |

## Links

- npm: https://www.npmjs.com/package/idyll-analytics
- npm.io page: https://npm.io/package/idyll-analytics

## Dependencies (1)

- [firebase](https://npm.io/package/firebase.md) ^5.9.3

## Recent versions

- 1.0.0 (latest) — 2019-04-09

## README

# idyll-analytics

Tools to collect detailed usage analytics of [Idyll articles](https://idyll-lang.org).

## Installation

To install the analytics package, run the following in your Idyll project:

```
$ npm install --save idyll-analytics
```

## Usage

This code is intended to be used as a custom runtime [plugin](https://github.com/idyll-lang/idyll-plugins) for Idyll. To use it, you need to create a custom context file and import the analytics code there. See the [idyll docs](https://idyll-lang.org/docs/advanced-configuration) for more information on custom contexts.

This plugin relies on [Firebase](https://firebase.google.com/) for data storage, and you'll need to have a Firebase database set up and credentials available in order to use it.

### Creating a custom context file

Create a new file called *context.js* in your Idyll project:

```js
const Analytics = require('./index');

// Fill out these credentials.
const firebaseConfig = {
  apiKey: "",
  authDomain: "",
  databaseURL: "",
  projectId: "",
  storageBucket: "",
  messagingSenderId: ""
};

module.exports = (context) => {
  const initialState = context.data();

  // Update this with a relevant identifier for your post.
  const analytics = new Analytics('my-post-title', firebaseConfig);

  analytics.onLoad(() => {
    analytics.updateState(initialState);
    context.onUpdate((newState) => {
      analytics.updateState(newState);
    });
  })
}
```

### Configuring Idyll to use the custom context

In your *package.json* file, update the `idyll` option to use your newly created context:

```js
{
  "idyll": {
    "context": "./context.js"
  }
}
```

---
_Source: https://npm.io/package/idyll-analytics · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
