Skip to content

Commit 804c754

Browse files
authored
Merge pull request #5681 from segmentio/add-disable-api
add disable documentation
2 parents 71531dd + 31267d5 commit 804c754

File tree

1 file changed

+15
-0
lines changed
  • src/connections/sources/catalog/libraries/website/javascript

1 file changed

+15
-0
lines changed

src/connections/sources/catalog/libraries/website/javascript/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,21 @@ For example:
577577
analytics.load('writekey', { highEntropyValuesClientHints: ['architecture', 'bitness', 'model', 'platformVersion', 'uaFullVersion', 'fullVersionList', 'wow64'] })
578578
```
579579

580+
#### Disabling
581+
For testing or staging environments, it can be useful to disable your SDK to ensure no events send.
582+
583+
If `disable: true` is passed, all analytics method calls will be a no-op, and no network calls will be initiated.
584+
585+
```ts
586+
analytics.load('writekey', { disable: true })
587+
```
588+
589+
For wrapper/plugin authors: if you have a use case where you need special access to the CDN Settings (for example, consent management), you can also pass a function. This API waits for `cdnSettings` to be fetched. Keep in mind that `cdnSettings` is an _unstable_ object.
590+
591+
```ts
592+
analytics.load('writekey', { disable: (cdnSettings) => true })
593+
```
594+
580595
## Retries
581596

582597
When enabled, Analytics.js automatically retries network and server errors. With persistent retries, Analytics.js can:

0 commit comments

Comments
 (0)