@@ -49,7 +49,9 @@ Refer to the
4949for complete list of options and configurations you can pass to the Hive JavaScript Client of
5050choice.
5151
52- #### Client Information
52+ #### Usage reporting
53+
54+ ##### Client Information
5355
5456By default, the client information is retrieved by looking up the ` x-graphql-client-name ` and
5557` x-graphql-client-version ` headers in the HTTP request. For operations executed via the
@@ -82,9 +84,9 @@ useHive({
8284The context object is the context object as used within the GraphQL execution. Depending on your
8385server framework and GraphQL protocol, the context object may contain different properties.
8486
85- We recommend to always try to safely decode the context.
87+ We recommend to safely decode the context in order to avoid runtime errors .
8688
87- #### Excluding Operations
89+ ##### Excluding Operations
8890
8991You can pass a custom ` exclude ` array to the ` HivePluginOptions ` to ignore specific operations from
9092being reported to Hive.
@@ -97,9 +99,9 @@ useHive({
9799})
98100```
99101
100- #### Sampling
102+ ##### Sampling
101103
102- ##### Basic sampling
104+ ###### Basic sampling
103105
104106With ` sampleRate ` option, you're able to control the sampling rate of the usage reporting. Setting
105107it to ` 0.5 ` will result in 50% of the operations being sent to Hive. There is no guarantee that
@@ -116,7 +118,7 @@ useHive({
116118})
117119```
118120
119- ##### Dynamic sampling
121+ ###### Dynamic sampling
120122
121123GraphQL Hive client accepts a function that returns a number between 0 and 1. This allows you to
122124implement dynamic sampling based on the operation's context.
@@ -151,7 +153,7 @@ useHive({
151153})
152154```
153155
154- ##### At-least-once sampling
156+ ###### At-least-once sampling
155157
156158If you want to make sure that every operation is reported at least once, you can use the
157159` atLeastOnceSampler ` . Every operation is reported at least once, but every next occurrence is
@@ -321,6 +323,68 @@ useHive({
321323
322324</Tabs >
323325
326+ ##### Agent
327+
328+ The agent collects and schedules usage reporting call to the Hive Console usage reporting service.
329+ The configuration can be customized.
330+
331+ ###### ` maxRetries `
332+
333+ - Type: ` number `
334+ - Default: ` 3 `
335+
336+ Configure the maximum amount of retries per usage reporting batch before dropping the reporting
337+ attempts.
338+
339+ ###### ` maxSize `
340+
341+ - Type: ` number `
342+ - Default: ` 25 `
343+
344+ The maximum batch size of usage reports before sending the batch.
345+
346+ ###### ` sendInterval `
347+
348+ - Type: ` number `
349+ - Default: ` 10_000 `
350+
351+ The amount of time after which a pending usage reporting batch should be sent in case before the
352+ ` maxSize ` amount is reached.
353+
354+ ###### ` fetch `
355+
356+ - Type: [ ` Fetch ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch )
357+ - Default: ` fetch `
358+
359+ Provide a custom WHATWG ` fetch ` implementation
360+
361+ ###### ` circuitBreaker `
362+
363+ - Type: ` AgentCircuitBreakerConfiguration `
364+ - Default:
365+ ``` js
366+ {
367+ /**
368+ * Percentage after what the circuit breaker should kick in.
369+ * Default: 50
370+ */
371+ errorThresholdPercentage: 50 ,
372+ /**
373+ * Count of requests before starting evaluating.
374+ * Default: 10
375+ */
376+ volumeThreshold: 10 ,
377+ /**
378+ * After what time the circuit breaker is attempting to retry sending requests in milliseconds
379+ * Default: 30_000
380+ */
381+ resetTimeout: 30_000 ,
382+ }
383+ ```
384+
385+ Configure the curcuit breaker for temporarily suspending sending usage reports in case of network
386+ issues or outages to avoid exhausting the service from being overwhelmed with failing HTTP requests.
387+
324388#### Persisted Documents
325389
326390Hive client supports resolving persisted documents. For getting started please refer to our
@@ -397,6 +461,34 @@ useHive({
397461})
398462```
399463
464+ #### Logging
465+
466+ You can customize the logging level or provide your own (JSON) logger implementation.
467+
468+ ##### ` logger `
469+
470+ - Type: [ ` Logger ` ] ( /docs/logger ) or log level string
471+ - Default: ` info `
472+
473+ It is possible to provide the following options:
474+
475+ - ` 'trace' `
476+ - ` 'debug' `
477+ - ` 'info' ` default
478+ - ` 'warn' `
479+ - ` 'error' `
480+
481+ ``` ts filename="Example: Set debug level based on environment variable"
482+ import { createHive } from ' @graphql-hive/core'
483+
484+ const client = createHive ({
485+ logger: process .env .DEBUG === ' 1' ? ' debug' : ' info'
486+ })
487+ ```
488+
489+ Alternatively, you can also provide your own [ ` Logger ` ] ( /docs/logger ) (or any API-compatible
490+ implementation) to integrate Hive logs with your web server or logging solution.
491+
400492#### Custom Integration
401493
402494If your GraphQL server is not listed above, you can implement a custom integration. Start by
0 commit comments