-
Notifications
You must be signed in to change notification settings - Fork 141
/
settings.ts
59 lines (57 loc) · 1.72 KB
/
settings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { ValidationError } from '@segment/analytics-core'
import { HTTPClient, HTTPFetchFn } from '../lib/http-client'
import { OAuthSettings } from '../lib/types'
export interface AnalyticsSettings {
/**
* Key that corresponds to your Segment.io project
*/
writeKey: string
/**
* The base URL of the API. Default: "https://api.segment.io"
*/
host?: string
/**
* The API path route. Default: "/v1/batch"
*/
path?: string
/**
* The number of times to retry flushing a batch. Default: 3
*/
maxRetries?: number
/**
* The number of events to enqueue before flushing. Default: 15.
*/
flushAt?: number
/**
* @deprecated
* The number of events to enqueue before flushing. This is deprecated in favor of `flushAt`. Default: 15.
*/
maxEventsInBatch?: number
/**
* The number of milliseconds to wait before flushing the queue automatically. Default: 10000
*/
flushInterval?: number
/**
* The maximum number of milliseconds to wait for an http request. Default: 10000
*/
httpRequestTimeout?: number
/**
* Disable the analytics library. All calls will be a noop. Default: false.
*/
disable?: boolean
/**
* Supply a default http client implementation (such as one supporting proxy).
* Accepts either an HTTPClient instance or a fetch function.
* Default: an HTTP client that uses globalThis.fetch, with node-fetch as a fallback.
*/
httpClient?: HTTPFetchFn | HTTPClient
/**
* Set up OAuth2 authentication between the client and Segment's endpoints
*/
oauthSettings?: OAuthSettings
}
export const validateSettings = (settings: AnalyticsSettings) => {
if (!settings.writeKey) {
throw new ValidationError('writeKey', 'writeKey is missing.')
}
}