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

OptionTypeDescription
apiKeystringYour Metreek API key (starts with wk_)
baseUrlstringMetreek API endpoint URL

Optional Options

OptionTypeDefaultDescription
customerUidstring-Customer identifier for data isolation
theme'light' | 'dark' | 'auto''auto'UI theme for components
localestring'en'Language locale
debugbooleanfalseEnable debug logging
autoInitbooleantrueAuto-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
  }
})
OptionTypeDefaultDescription
enabledbooleantrueEnable/disable chat functionality
positionstring'bottom-right''bottom-right' | 'bottom-left' | 'top-right' | 'top-left'
analysisModestring'fast''fast' for quick responses, 'deep' for thorough analysis
chatIdstring-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
  }
}