# gassian

> Tiny API wrapper for Atlassian Public Analytics aka GAS

Latest version **0.6.1** (published 2020-09-30) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install gassian
pnpm add gassian
yarn add gassian
bun add gassian
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.6.1 |
| Published | 2020-09-30 |
| First published | 2017-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 23.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Vitalii Saienko |
| Maintainers | modestfake |
| Keywords | atlassian, analytics, gas |

## Links

- npm: https://www.npmjs.com/package/gassian
- Repository: https://github.com/modestfake/gassian
- Homepage: https://github.com/modestfake/gassian#readme
- Issues: https://github.com/modestfake/gassian/issues
- npm.io page: https://npm.io/package/gassian

## Dependencies (2)

- [md5](https://npm.io/package/md5.md) ^2.3.0
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.0.6

## Recent versions

- 0.6.1 (latest) — 2020-09-30
- 0.6.0 — 2018-08-17
- 0.5.4 — 2018-04-03
- 0.5.3 — 2018-04-02
- 0.5.2 — 2018-03-31
- 0.5.1 — 2018-03-25
- 0.5.0 — 2018-03-25
- 0.4.2 — 2018-03-05
- 0.4.1 — 2018-02-06
- 0.4.0 — 2018-02-05
- 0.3.4 — 2018-02-05
- 0.3.3 — 2018-02-05
- 0.3.2 — 2018-02-04
- 0.3.1 — 2018-02-04
- 0.3.0 — 2018-02-03
- … 5 more at https://npm.io/package/gassian/versions

## README

# Gassian

[![Greenkeeper badge](https://badges.greenkeeper.io/modestfake/gassian.svg)](https://greenkeeper.io/)

[![Build Status](https://travis-ci.org/modestfake/gassian.svg?branch=master)](https://travis-ci.org/modestfake/gassian)
[![Coverage Status](https://coveralls.io/repos/github/modestfake/gassian/badge.svg?branch=master&service=github)](https://coveralls.io/github/modestfake/gassian?branch=master)

## Installation

```bash
npm install gassian
```

```javascript
// ES6 modules
import GAS from 'gassian'

// CommonJS modules
const GAS = require('gassian')
```

## Usage

### Initialize GAS

```javascript
const gas = new GAS({
  product: 'bitbucket',
  subproduct: 'addon-template',
  domain: 'prod.atlassian.com'
})
```

#### GAS constructor parameters

| Parameter | Required | Default | Type | Description |
| --- |:---:|:---:|:---:| --- |
| apiUrl | yes | | string | Removed from the library by security reason. You can take URL from [GAS documentation](https://hello.atlassian.net/wiki/spaces/ANALYTICS/pages/134329570/Public+Analytics+aka+GAS+GASv2) (Atlassian internal only). Don't forget to add version to URL |
| product | yes | | string | Product name (for add-ons main product name can be passed, e.g. jira or bitbucket) |
| subproduct | no | | string | Add-on name like `addon-template` |
| domain | yes | | string | Production domain. E.g. `prod.atlassian.com` |
| version | no | | string | '1.2.3' |
| prefix | no | false | boolean | It adds subproduct name to event name. E.g. `addon-template.project-config.visited` |
| hash | no | true | boolean | UserId and cloudId are hashed by default. Set to false if you need actual user data. |
| isServerOnProduction | yes (server only) | | boolean | We can detect actual URL in browser with `window.location.href`. But it's tricky on server-side. That's why we need it on server |
| logging | no | false | boolean | Logs prepared to send event to console. Remove this parameter in production

### Send event/events

```javascript
const event = {
  cloudId: 'Instance id or URL',
  user: 'User id or name',
  name: 'visited',
  page: 'project-config'
}

// To send one event pass event object to send method
gas.send(event)

// To send multiple events pass array of event objects
gas.send([event1, event2])

// Final event name is:
`project-config.visited`

// If prefix passed to constructor is true
`addon-template.project-config.visited`
```

#### Event payload

| Parameter | Required | Default | Type | Description |
| --- |:---:|:---:|:---:| --- |
| name | yes | | string | Event dotseparated name. E.g. `some-button.clicked` |
| page | no | | string | E.g. `project-config` which will included in event name as `project-config.some-button.clicked` |
| user | yes | '-' | string or integer | Unique user id which will be hashed (for not exposing private data) |
| cloudId | yes | | string or integer | Cloud id or cloud URL |
| properties | no | | object | One level nested object. Only primitive (int, float, string, bool) values are allowed |
| hash | no | | boolean or object | Enable or disabling hashing for one event. Also, it can accept object with `cloudId` or/and `user` with boolean to hash one of the values.

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