# @kaname-png/plugin-influxdb

> Plugin for @sapphire/framework to track analytics on influxDB.

Latest version **1.4.1** (published 2024-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @kaname-png/plugin-influxdb
pnpm add @kaname-png/plugin-influxdb
yarn add @kaname-png/plugin-influxdb
bun add @kaname-png/plugin-influxdb
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2024-10-16 |
| First published | 2023-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.6.0 |
| Dependencies | 1 |
| Unpacked size | 122.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | @kaname-png |
| Maintainers | kaname-png |
| Keywords | sapphiredev, plugin, bot, typescript, ts, yarn, discord, sapphire, influxdb |

## Links

- npm: https://www.npmjs.com/package/@kaname-png/plugin-influxdb
- Repository: https://github.com/kaname-png/neko-plugins
- Homepage: https://github.com/kaname-png/neko-plugins/tree/main/packages/influxdb
- Issues: https://github.com/kaname-png/neko-plugins/issues
- npm.io page: https://npm.io/package/@kaname-png/plugin-influxdb

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.8.0

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 1.4.1 (latest) — 2024-10-16
- 1.4.5-next.77b7a6a (next) — 2024-10-27
- 1.4.4-next.5fd14b2 — 2024-10-20
- 1.4.3-next.373d27b — 2024-10-16
- 1.4.2-next.9038d77 — 2024-10-16
- 1.4.1-next.151f5bd.0 — 2024-10-16
- 1.4.1-next.059a4e1.0 — 2024-09-08
- 1.4.1-next.a71fc21.0 — 2024-08-21
- 1.4.1-next.9ff3427.0 — 2024-08-21
- 1.4.1-next.f9481fb.0 — 2024-07-30
- 1.4.1-next.217a2f3.0 — 2024-07-30
- 1.4.1-next.2ad830a.0 — 2024-07-30
- 1.4.1-next.b2c2bb2.0 — 2024-07-30
- 1.4.1-next.9ea2382.0 — 2024-07-07
- 1.4.1-next.44d866f.0 — 2024-07-06
- … 66 more at https://npm.io/package/@kaname-png/plugin-influxdb/versions

## README

<div align="center">

![Neko Plugins Logo](https://raw.githubusercontent.com/kaname-png/neko-plugins/main/assets/logo.png)

# @kaname-png/plugin-influxdb

**Plugin for
   [`@sapphire/framework`](https://github.com/sapphiredev/framework) to publish stats to an
   [`InfluxDB`](https://www.influxdata.com) instance.**

[![GitHub](https://img.shields.io/github/license/kaname-png/neko-plugins)](https://github.com/kaname-png/neko-plugins/blob/main/LICENSE.md)
[![codecov](https://codecov.io/gh/sawa-ko/neko-plugins/branch/main/graph/badge.svg?token=7B0AVB4YG6)](https://codecov.io/gh/kaname-png/neko-plugins)
[![npm (scoped)](https://img.shields.io/npm/v/@kaname-png/plugin-influxdb?color=crimson&logo=npm)](https://www.npmjs.com/package/@kaname-png/plugin-influxdb)
[![npm](https://img.shields.io/npm/dt/@kaname-png/plugin-influxdb?color=crimson&logo=npm)](https://www.npmjs.com/package/@kaname-png/plugin-influxdb)

</div>

## Description

This plugin lets you send your bot's statistics to InfluxDB 

More information about InfluxDB can be found on its [website](https://www.influxdata.com).

## Features

- Fully ready for TypeScript!
- Includes ESM ready entrypoint
- Easy to use

## Installation

`@kaname-png/plugin-influxDB` depends on the following packages. Be sure to install these along with this package!

- [`@sapphire/framework`](https://www.npmjs.com/package/@sapphire/framework)
- [`@influxdata/influxdb-client`](https://www.npmjs.com/package/@influxdata/influxdb-client)
- [`discord.js`](https://www.npmjs.com/package/discord.js)

You can use the following command to install this package, or replace `npm install` with your package manager of choice.

```sh
npm install @influxdata/influxdb-client  @sapphire/framework discord.js
```
PS: You can view events by default [here](#the-default-listeners).

---

## Usage

If your register the plugin:

```typescript
import '@kaname-png/plugin-influxdb/register'

const client = new SapphireClient({
	/* your bot options */
	analytics: {
		loadDefaultListeners: true, // (Optional) Load the default events .
		// option to passed influxdb deps
	}
});

async function main() {
	await client.login();
}

void main();
````

OR

The first step, is to import the Client from the package:

```typescript
import { Client } from '@kaname-png/plugin-influxdb';
```

You can choose between defining the options explicitly, in the following manner:

```typescript
const client = new Client({ url: 'https://example.org', token: 'my-secret-token' });
```

Or defining the options via environment variables, they are:

**Client**:
- `INFLUX_OPTIONS_STRING`: A connection string, overrides all the options below.
- `INFLUX_URL`: `ConnectionOptions.url`, the base URL to be used.
- `INFLUX_PROXY_URL`: `ConnectionOptions.proxyUrl`, the full HTTP web proxy URL including schema.
- `INFLUX_TIMEOUT`: `ConnectionOptions.timeout`, the socket timeout, defaults to 10 seconds. If defined, this will be parsed and validated to a number.
- `INFLUX_TOKEN`: `ConnectionOptions.token`, the authentication token.

**API**:
- `INFLUX_ORG`: `Client.Options.org`, the organization to use for the query and write APIs.
- `INFLUX_WRITE_BUCKET`: `Client.Options.writeBucket`, the bucket to write to in the write API.
- `INFLUX_WRITE_PRECISION`: `Client.Options.writePrecision`, the write precision to use in the write API.

> **Note**: If `Client.Options.org` is unset, none of the APIs will be created.
> **Note**: If `Client.Options.writeBucket` is unset, the Write API will not be created.


----
### **The default listeners: 
- [`plugin-api`](https://github.com/sapphiredev/plugins/tree/main/packages/api): "error"
- [`plugin-subcommands`](https://github.com/sapphiredev/plugins/tree/main/packages/subcommands): "MessageSubcommandError", "chatInputSubcommandError"
- [`plugin-scheduled-tasks`](https://github.com/sapphiredev/plugins/tree/main/packages/scheduled-tasks): "scheduledTaskError"
- [`framework`](https://github.com/sapphiredev/framework): "messageCommandError", "chatInputCommandError", "contextMenuCommandError", "commandAutocompleteInteractionError", "error", "listenerError" and "interactionHandlerError"
----

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tr>
    <td align="center"><a href="https://kaname.netlify.app"><img src="https://avatars.githubusercontent.com/u/56084970?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaname</b></sub></a><br /><a href="https://github.com/kaname-png/neko-plugins/commits?author=kaname-png" title="Code">💻</a> <a href="https://github.com/kaname-png/neko-plugins/issues?q=author%3Akaname-png" title="Bug reports">🐛</a> <a href="https://github.com/kaname-png/neko-plugins/commits?author=kaname-png" title="Documentation">📖</a> <a href="#infra-kaname-png" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-kaname-png" title="Maintenance">🚧</a> <a href="https://github.com/kaname-png/neko-plugins/pulls?q=is%3Apr+reviewed-by%3Akaname-png" title="Reviewed Pull Requests">👀</a></td>
  </tr>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification.
Contributions of any kind welcome!

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