Skip to content

ShardlensOptions

Defined in: packages/discordjs/src/options.ts:7

Options for createShardlens(client, options). Every one is optional.

optional apiKey?: string

Defined in: packages/discordjs/src/options.ts:14

Ingest-only API key (slk_ingest_…).


optional auditIncludeProfile?: boolean

Defined in: packages/discordjs/src/options.ts:30

Audit mode only: send each user’s username and avatar with their ID. Default true; false records IDs only. Nothing else about a user is ever collected.


optional captureOptionValues?: readonly string[]

Defined in: packages/discordjs/src/options.ts:49

Option names whose values may be recorded, for slash commands and for the optionValues you pass with message commands. Values of user, channel, role, mentionable and attachment options, and any value holding a Discord ID, are never recorded; strings are cut to 100 characters. Default none.


optional disable?: readonly MetricGroup[]

Defined in: packages/discordjs/src/options.ts:64

Turn off whole metric groups. 'interactions' also turns off message (prefix) commands.


optional dryRun?: boolean

Defined in: packages/discordjs/src/options.ts:62

Print events to the console instead of sending them.


optional endpoint?: string

Defined in: packages/discordjs/src/options.ts:12

Your collector’s URL, for example https://stats.example.com. HTTPS, or HTTP to localhost only. Leave out with apiKey to run with exporters only.


optional environment?: string

Defined in: packages/discordjs/src/options.ts:58

Separates staging from production. Default 'production'.


optional exporters?: readonly ShardlensExporter[]

Defined in: packages/discordjs/src/options.ts:19

In-process metrics exporters, such as prometheusExporter() from @shardlens/exporter-prometheus. They get every event before sampling, never with a user. Works with or without a collector.


optional fetch?: {(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

Defined in: packages/discordjs/src/options.ts:92

Override fetch (tests, proxies).

(input, init?): Promise<Response>

MDN Reference

URL | RequestInfo

RequestInit

Promise<Response>

(input, init?): Promise<Response>

MDN Reference

string | URL | Request

RequestInit

Promise<Response>


optional flushIntervalMs?: number

Defined in: packages/discordjs/src/options.ts:41

Flush interval. Default 5,000 ms.


optional logger?: Logger

Defined in: packages/discordjs/src/options.ts:66

Where SDK warnings go. Default console.


optional maxBatchSize?: number

Defined in: packages/discordjs/src/options.ts:43

Events per batch (max 499 plus one health event). Default 499.


optional maxQueueSize?: number

Defined in: packages/discordjs/src/options.ts:39

Memory ceiling, in events. Default 10,000.


optional mode?: "privacy" | "audit"

Defined in: packages/discordjs/src/options.ts:25

Whether users are hashed or identified. 'privacy' (default): user IDs are hashed in-process and never leave the bot. 'audit': also sends who ran each interaction (user ID, username and avatar), encrypted at rest; only takes effect when the collector is in audit mode too. See the audit-mode guide before turning it on.


optional normaliseCustomId?: (customId) => string

Defined in: packages/discordjs/src/options.ts:51

Replaces the default custom-ID normaliser (numbers and IDs become *).

string

string


optional onOptOutChange?: (userId, optedOut) => void

Defined in: packages/discordjs/src/options.ts:76

Called when a user opts out or back in, so you can persist the choice. It may be async: if it throws or its promise rejects, the failure is counted (see lens.on('error')), never thrown into your bot.

string

boolean

void


optional optedOut?: Iterable<string | bigint, any, any>

Defined in: packages/discordjs/src/options.ts:71

Users who opted out earlier (for example loaded from your database). Their events are dropped in-process. BigInt IDs, as some database clients return them, are accepted.


optional refreshGuildCounts?: boolean

Defined in: packages/discordjs/src/options.ts:90

Refresh each server’s approximate member count with GET /guilds/{id}?with_counts=true, one server every two seconds (30 a minute, on your bot’s REST budget), instead of only at startup and join. Presence counts are never read. Default false.


optional release?: string

Defined in: packages/discordjs/src/options.ts:60

Your bot’s version, to compare releases.


optional saltPeriod?: SaltPeriod

Defined in: packages/discordjs/src/options.ts:37

Has no effect: the collector decides the salt period (dashboard Settings → User identity), and the SDK hashes with the salts it is given. Still accepted so configurations that set it keep working.


optional sampleRate?: Readonly<Record<string, number>>

Defined in: packages/discordjs/src/options.ts:56

Sample rate per event type in (0, 1], for very large bots, such as { gauge_window: 0.5 }. Counts are re-weighted. Rates below 1/10,000 are raised to 1/10,000, the most one kept event can stand for.


optional spool?: object

Defined in: packages/discordjs/src/options.ts:84

Keep events on disk during long collector outages and across restarts: { dir: './shardlens-spool' }. Used when memory is half full while the collector is unreachable, and on shutdown() for anything unsent; replayed first when the collector is back. Capped at maxBytes (default 100 MB): at the cap the oldest batches are dropped first, and counted in stats().dropped.spool_evicted. Files hold hashed events only, never user IDs or audit-mode identities. Default: off (memory only).

dir: string

optional maxBytes?: number