ShardlensOptions
Defined in: packages/discordjs/src/options.ts:7
Options for createShardlens(client, options). Every one is optional.
Properties
Section titled “Properties”apiKey?
Section titled “apiKey?”
optionalapiKey?:string
Defined in: packages/discordjs/src/options.ts:14
Ingest-only API key (slk_ingest_…).
auditIncludeProfile?
Section titled “auditIncludeProfile?”
optionalauditIncludeProfile?: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.
captureOptionValues?
Section titled “captureOptionValues?”
optionalcaptureOptionValues?: readonlystring[]
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.
disable?
Section titled “disable?”
optionaldisable?: readonlyMetricGroup[]
Defined in: packages/discordjs/src/options.ts:64
Turn off whole metric groups. 'interactions' also turns off message (prefix) commands.
dryRun?
Section titled “dryRun?”
optionaldryRun?:boolean
Defined in: packages/discordjs/src/options.ts:62
Print events to the console instead of sending them.
endpoint?
Section titled “endpoint?”
optionalendpoint?: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.
environment?
Section titled “environment?”
optionalenvironment?:string
Defined in: packages/discordjs/src/options.ts:58
Separates staging from production. Default 'production'.
exporters?
Section titled “exporters?”
optionalexporters?: readonlyShardlensExporter[]
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.
fetch?
Section titled “fetch?”
optionalfetch?: {(input,init?):Promise<Response>; (input,init?):Promise<Response>; }
Defined in: packages/discordjs/src/options.ts:92
Override fetch (tests, proxies).
Call Signature
Section titled “Call Signature”(
input,init?):Promise<Response>
Parameters
Section titled “Parameters”URL | RequestInfo
RequestInit
Returns
Section titled “Returns”Promise<Response>
Call Signature
Section titled “Call Signature”(
input,init?):Promise<Response>
Parameters
Section titled “Parameters”string | URL | Request
RequestInit
Returns
Section titled “Returns”Promise<Response>
flushIntervalMs?
Section titled “flushIntervalMs?”
optionalflushIntervalMs?:number
Defined in: packages/discordjs/src/options.ts:41
Flush interval. Default 5,000 ms.
logger?
Section titled “logger?”
optionallogger?:Logger
Defined in: packages/discordjs/src/options.ts:66
Where SDK warnings go. Default console.
maxBatchSize?
Section titled “maxBatchSize?”
optionalmaxBatchSize?:number
Defined in: packages/discordjs/src/options.ts:43
Events per batch (max 499 plus one health event). Default 499.
maxQueueSize?
Section titled “maxQueueSize?”
optionalmaxQueueSize?:number
Defined in: packages/discordjs/src/options.ts:39
Memory ceiling, in events. Default 10,000.
optionalmode?:"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.
normaliseCustomId?
Section titled “normaliseCustomId?”
optionalnormaliseCustomId?: (customId) =>string
Defined in: packages/discordjs/src/options.ts:51
Replaces the default custom-ID normaliser (numbers and IDs become *).
Parameters
Section titled “Parameters”customId
Section titled “customId”string
Returns
Section titled “Returns”string
onOptOutChange?
Section titled “onOptOutChange?”
optionalonOptOutChange?: (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.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
optedOut
Section titled “optedOut”boolean
Returns
Section titled “Returns”void
optedOut?
Section titled “optedOut?”
optionaloptedOut?: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.
refreshGuildCounts?
Section titled “refreshGuildCounts?”
optionalrefreshGuildCounts?: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.
release?
Section titled “release?”
optionalrelease?:string
Defined in: packages/discordjs/src/options.ts:60
Your bot’s version, to compare releases.
saltPeriod?
Section titled “saltPeriod?”
optionalsaltPeriod?: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.
sampleRate?
Section titled “sampleRate?”
optionalsampleRate?: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.
spool?
Section titled “spool?”
optionalspool?: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
maxBytes?
Section titled “maxBytes?”
optionalmaxBytes?:number