Configuration
Learn all the configuration options available in the Metreek SDK.
Initialization
Initialize the SDK with MetreekSDK.init(config):
JavaScript
MetreekSDK.init({
// Required
apiKey: 'wk_YOUR_API_KEY',
baseUrl: 'https://api.metreek.com',
// Optional
customerUid: 'customer-123',
theme: 'auto',
locale: 'en',
debug: false,
autoInit: true,
// Chat settings
chat: {
enabled: true,
position: 'bottom-right',
analysisMode: 'fast'
}
})Configuration Reference
Required Options
| Option | Type | Description |
|---|---|---|
apiKey | string | Your Metreek API key (starts with wk_) |
baseUrl | string | Metreek API endpoint URL |
Optional Options
| Option | Type | Default | Description |
|---|---|---|---|
customerUid | string | - | Customer identifier for data isolation |
theme | 'light' | 'dark' | 'auto' | 'auto' | UI theme for components |
locale | string | 'en' | Language locale |
debug | boolean | false | Enable debug logging |
autoInit | boolean | true | Auto-detect and initialize components |
Chat Configuration
Configure the chat component via the chat option:
JavaScript
MetreekSDK.init({
apiKey: 'wk_YOUR_API_KEY',
baseUrl: 'https://api.metreek.com',
chat: {
enabled: true,
position: 'bottom-right', // Floating position
analysisMode: 'deep', // Thorough analysis
chatId: 'existing-chat-id' // Resume session
}
})| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | true | Enable/disable chat functionality |
position | string | 'bottom-right' | 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' |
analysisMode | string | 'fast' | 'fast' for quick responses, 'deep' for thorough analysis |
chatId | string | - | Reuse existing chat session |
Debug Mode
Enable comprehensive logging during development:
JavaScript
// Enable during initialization
MetreekSDK.init({
apiKey: 'wk_YOUR_API_KEY',
baseUrl: 'https://api.metreek.com',
debug: true // Enables all debug logging
})You can also toggle debug mode at runtime:
JavaScript
// Toggle at runtime window.__METREEK_DEBUG__(true) // Enable window.__METREEK_DEBUG__(false) // Disable // Check current state console.log(window.__METREEK_DEBUG_MODE__)
Production
Remember to disable debug mode in production to avoid console noise and potential performance overhead.
TypeScript Support
The SDK includes TypeScript definitions. Here's the full config interface:
types.d.ts
interface MetreekConfig {
// Required
apiKey: string
baseUrl: string
// Optional
customerUid?: string
theme?: 'light' | 'dark' | 'auto'
locale?: string
debug?: boolean
autoInit?: boolean
// Chat configuration
chat?: {
enabled?: boolean
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
analysisMode?: 'fast' | 'deep'
chatId?: string
}
}