<!--
 ⚠️  AUTO-GENERATED FILE - DO NOT EDIT MANUALLY
 This file is automatically generated by scripts/docs-generator.js
 To make changes, edit the source TypeScript files or update the generator script
-->

[agents](../../) / [Exports](../modules) / RemoteUsageStorage

# Class: RemoteUsageStorage

Remote storage implementation for usage statistics with batching

## Implements

- [`UsageStorage`](../interfaces/UsageStorage)

## Table of contents

### Constructors

- [constructor](RemoteUsageStorage#constructor)

### Methods

- [save](RemoteUsageStorage#save)
- [getStats](RemoteUsageStorage#getstats)
- [getAggregatedStats](RemoteUsageStorage#getaggregatedstats)
- [clear](RemoteUsageStorage#clear)
- [flush](RemoteUsageStorage#flush)
- [close](RemoteUsageStorage#close)

## Constructors

### constructor

• **new RemoteUsageStorage**(`apiUrl`, `_apiKey`, `_timeout`, `_headers?`, `batchSize?`, `flushInterval?`): [`RemoteUsageStorage`](RemoteUsageStorage)

#### Parameters

| Name            | Type                           | Default value |
| :-------------- | :----------------------------- | :------------ |
| `apiUrl`        | `string`                       | `undefined`   |
| `_apiKey`       | `string`                       | `undefined`   |
| `_timeout`      | `number`                       | `undefined`   |
| `_headers`      | `Record`\<`string`, `string`\> | `{}`          |
| `batchSize`     | `number`                       | `50`          |
| `flushInterval` | `number`                       | `60000`       |

#### Returns

[`RemoteUsageStorage`](RemoteUsageStorage)

#### Defined in

[packages/agents/src/plugins/usage/storages/remote-storage.ts:17](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/plugins/usage/storages/remote-storage.ts#L17)

## Methods

### save

▸ **save**(`entry`): `Promise`\<`void`\>

#### Parameters

| Name    | Type                                     |
| :------ | :--------------------------------------- |
| `entry` | [`UsageStats`](../interfaces/UsageStats) |

#### Returns

`Promise`\<`void`\>

#### Implementation of

[UsageStorage](../interfaces/UsageStorage).[save](../interfaces/UsageStorage#save)

#### Defined in

[packages/agents/src/plugins/usage/storages/remote-storage.ts:33](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/plugins/usage/storages/remote-storage.ts#L33)

---

### getStats

▸ **getStats**(`conversationId?`, `timeRange?`): `Promise`\<[`UsageStats`](../interfaces/UsageStats)[]\>

#### Parameters

| Name              | Type     |
| :---------------- | :------- |
| `conversationId?` | `string` |
| `timeRange?`      | `Object` |
| `timeRange.start` | `Date`   |
| `timeRange.end`   | `Date`   |

#### Returns

`Promise`\<[`UsageStats`](../interfaces/UsageStats)[]\>

#### Implementation of

[UsageStorage](../interfaces/UsageStorage).[getStats](../interfaces/UsageStorage#getstats)

#### Defined in

[packages/agents/src/plugins/usage/storages/remote-storage.ts:41](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/plugins/usage/storages/remote-storage.ts#L41)

---

### getAggregatedStats

▸ **getAggregatedStats**(`timeRange?`): `Promise`\<[`AggregatedUsageStats`](../interfaces/AggregatedUsageStats)\>

#### Parameters

| Name              | Type     |
| :---------------- | :------- |
| `timeRange?`      | `Object` |
| `timeRange.start` | `Date`   |
| `timeRange.end`   | `Date`   |

#### Returns

`Promise`\<[`AggregatedUsageStats`](../interfaces/AggregatedUsageStats)\>

#### Implementation of

[UsageStorage](../interfaces/UsageStorage).[getAggregatedStats](../interfaces/UsageStorage#getaggregatedstats)

#### Defined in

[packages/agents/src/plugins/usage/storages/remote-storage.ts:60](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/plugins/usage/storages/remote-storage.ts#L60)

---

### clear

▸ **clear**(): `Promise`\<`void`\>

#### Returns

`Promise`\<`void`\>

#### Implementation of

[UsageStorage](../interfaces/UsageStorage).[clear](../interfaces/UsageStorage#clear)

#### Defined in

[packages/agents/src/plugins/usage/storages/remote-storage.ts:93](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/plugins/usage/storages/remote-storage.ts#L93)

---

### flush

▸ **flush**(): `Promise`\<`void`\>

#### Returns

`Promise`\<`void`\>

#### Implementation of

[UsageStorage](../interfaces/UsageStorage).[flush](../interfaces/UsageStorage#flush)

#### Defined in

[packages/agents/src/plugins/usage/storages/remote-storage.ts:108](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/plugins/usage/storages/remote-storage.ts#L108)

---

### close

▸ **close**(): `Promise`\<`void`\>

#### Returns

`Promise`\<`void`\>

#### Implementation of

[UsageStorage](../interfaces/UsageStorage).[close](../interfaces/UsageStorage#close)

#### Defined in

[packages/agents/src/plugins/usage/storages/remote-storage.ts:141](https://github.com/woojubb/robota/blob/4f4c8a3197e92ddd43d12dc9186b0771983054c9/packages/agents/src/plugins/usage/storages/remote-storage.ts#L141)
