-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathsettings.ts
More file actions
69 lines (67 loc) · 2.06 KB
/
settings.ts
File metadata and controls
69 lines (67 loc) · 2.06 KB
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
60
61
62
63
64
65
66
67
68
69
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: 10
*/
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.
*/
httpClient?: HTTPFetchFn | HTTPClient
/**
* Set up OAuth2 authentication between the client and Segment's endpoints
*/
oauthSettings?: OAuthSettings
/**
* Maximum total time (in seconds) a batch can spend retrying transient errors
* before being dropped. Default: 43200 (12 hours).
*/
maxTotalBackoffDuration?: number
/**
* Maximum total time (in seconds) the pipeline can stay in rate-limited state
* before dropping batches and resuming. Default: 43200 (12 hours).
*/
maxRateLimitDuration?: number
}
export const validateSettings = (settings: AnalyticsSettings) => {
if (!settings.writeKey) {
throw new ValidationError('writeKey', 'writeKey is missing.')
}
}