Skip to main content

AnalyticsConfig

Upgather Analytics


Upgather Analytics / AnalyticsConfig

Interface: AnalyticsConfig

Main configuration for the Analytics client.

Remarks

This is the primary configuration interface for the analytics system. It combines all configuration options into a single object that can be passed to AnalyticsClientFactory.createClient().

All properties are optional and have reasonable defaults for most use cases.

Example

import {
AnalyticsConfig,
AnalyticsClientFactory
} from '@upgather/analytics';

const config: AnalyticsConfig = {
baseUrl: 'https://6xipdnwvd4.execute-api.us-east-1.amazonaws.com/dev',
validationEndpoint: 'https://ems.prod.upgather.com/api',
defaultEventId: 'aitalks26',
rateLimiting: {
enabled: true,
requestsPerSecond: 5
},
circuitBreaker: {
enabled: true,
failureThreshold: 3
}
};

const client = AnalyticsClientFactory.createClient(config);

Properties

apiKey?

optional apiKey: string

API key for tracking requests.

Remarks

When provided, this key is sent on all tracking requests as an x-api-key header. It takes precedence over authToken when both are configured.

Example

'da2-7ekeutfuafga5fqlowgydwsq2u'

authToken?

optional authToken: string

Bearer authentication token for tracking requests.

Remarks

When provided, this token is sent in the Authorization header using the Bearer scheme. apiKey takes precedence: if both are set, the x-api-key header is used and this token is ignored.

Authentication is not required for the default public tracking endpoint but may be needed for custom endpoints.

Example

'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'

baseUrl?

optional baseUrl: string

Base URL for the API.

Remarks

The root URL for all API requests. This should include the protocol (https://) and any base path, but not specific endpoints.

Default

'https://6xipdnwvd4.execute-api.us-east-1.amazonaws.com/dev'

circuitBreaker?

optional circuitBreaker: CircuitBreakerOptions

Circuit breaker configuration.

Remarks

Controls how the client handles consecutive failures to the API.

See

CircuitBreakerOptions for detailed configuration options


defaultEventId?

optional defaultEventId: string

Default event ID to use for all analytics tracking from this client.

Remarks

This is the identifier for the event or conference (e.g., 'aitalks26', 'fedtalks2023'). When specified, this ID will be used for all tracking unless explicitly overridden in individual tracking calls.

The eventId should be alphanumeric and can include hyphens, but should not include spaces or special characters.

Example

'aitalks26', 'fedtalks2023', 'tech-summit-fall'

endpoint?

optional endpoint: string

Custom endpoint path for tracking requests.

Remarks

Overrides the default path used by trackEvent, appended to the baseUrl. When omitted, trackEvent posts to /analytics/events. This does not affect trackEventLegacy, which always posts to /${eventId}/analytics.

Example

'/analytics/events', '/custom/analytics'

Default

'/analytics/events'

logging?

optional logging: LoggingOptions

Logging configuration.

Remarks

Controls the verbosity and content of logs produced by the client.

See

LoggingOptions for detailed configuration options


rateLimiting?

optional rateLimiting: RateLimitOptions

Rate limiting configuration.

Remarks

Controls how the client limits the rate of requests to the API.

See

RateLimitOptions for detailed configuration options


requestTimeout?

optional requestTimeout: number

Request timeout in milliseconds.

Remarks

The maximum time to wait for a response from the API before timing out. This helps prevent hanging requests in case of network or server issues.

Example

5000 (5 seconds)

Default

30000 (30 seconds)

validateEvents?

optional validateEvents: boolean

Whether to validate event IDs before tracking.

Remarks

When true, the client will validate event IDs against the validation endpoint before tracking events. This adds an extra API call but ensures that the event ID is valid.

Default

false

validationEndpoint?

optional validationEndpoint: string

URL for the event validation endpoint.

Remarks

This is the URL used for validating event IDs. If not provided, the baseUrl will be used.

Default

'https://ems.prod.upgather.com/api'