# @types/node-insights

> TypeScript definitions for node-insights

Latest version **1.1.3** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/node-insights
pnpm add @types/node-insights
yarn add @types/node-insights
bun add @types/node-insights
```

## Health

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

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2023-11-07 |
| First published | 2019-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51444 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/node-insights
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-insights
- npm.io page: https://npm.io/package/@types/node-insights

## Recent versions

- 1.1.3 (latest) — 2023-11-07
- 1.1.1 (ts3.6) — 2021-07-08
- 1.1.0 (ts2.2) — 2019-04-22
- 1.1.2 — 2023-10-18

## README

# Installation
> `npm install --save @types/node-insights`

# Summary
This package contains type definitions for node-insights (https://github.com/flightstats/node-insights#readme).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-insights.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-insights/index.d.ts)
````ts
interface Config {
    insertKey: string;
    queryKey: string;
    accountId: string;
    timerInterval?: number | undefined;
    maxPending?: number | undefined;
    defaultEventType?: string | undefined;
    enabled?: boolean | undefined;
    gzip?: boolean | undefined;
}

type CallbackFunc = (err: Error | null | undefined, responseBody: string) => void;

declare class Insights {
    static collectorHost: string;
    static collectorBaseURL: string;
    static queryBaseURL: string;

    enabled: boolean;
    queryKey: string;
    insertKey: string;

    /**
     * Insights
     */
    constructor(config: Config);

    /**
     * Add insights data to the queue.
     * It is sent when the queue reaches a max size or a period of time has elapsed
     */
    add(data: object, eventType?: string): void;

    /**
     * Build a nrql query string
     * @example
     *    nrql = insights.nrql({
     *      select: 'uniqueCount(session)',
     *      from: 'PageView',
     *      since: '1 week ago',
     *      until: '1 day ago',
     *      timeseries: '1 hour'
     *   });
     *   insights.query(nrql);
     */
    nrql(params: object): string;

    /**
     * nrql where clause builder
     */
    where(clause: string | string[] | object): string;

    /**
     * Execute a nrql query
     */
    query(query: string, callback: CallbackFunc): void;

    /**
     * Start the timer that will send insights after some interval of time
     * this is called implicitly when data is added via the add method
     */
    start(): void;

    /**
     * Stop the timer that will send insights after some interval of time
     * this is called implicitly when the amount of data exceeds maxPending and the queue is sent
     */
    stop(): void;

    /**
     * Stop the timer after flushing.
     */
    finish(): void;

    /**
     * Send accumulated insights data to new relic (if enabled)
     */
    send(done?: CallbackFunc): void;
}

export = Insights;

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 09:09:39 GMT
 * Dependencies: none

# Credits
These definitions were written by [Walter Rumsby](https://github.com/wrumsby).

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