learning_ai_invt_trdg/shared/platform-clients.ts

36 lines
1.1 KiB
TypeScript

import { createKillSwitchClient } from '@bytelyst/kill-switch-client';
import { createWebTelemetry } from '@bytelyst/telemetry-client';
import { createRNPlatformSDK } from '@bytelyst/react-native-platform-sdk';
import { getRuntimeEnvironment } from './runtime.js';
import { productConfig } from './product.js';
export function createTradingKillSwitchClient(platform: 'web' | 'mobile') {
const runtime = getRuntimeEnvironment(platform);
return createKillSwitchClient({
baseUrl: runtime.platformApiUrl,
productId: runtime.productId,
platform,
});
}
export function createTradingWebTelemetry() {
const runtime = getRuntimeEnvironment('web');
return createWebTelemetry({
productId: runtime.productId,
channel: 'invttrdg_web',
baseUrl: runtime.platformApiUrl,
appVersion: productConfig.version,
releaseChannel: process.env.NODE_ENV === 'production' ? 'prod' : 'dev',
});
}
export function createTradingMobileSdk(getAccessToken: () => string | null) {
const runtime = getRuntimeEnvironment('mobile');
return createRNPlatformSDK({
baseURL: runtime.platformApiUrl,
productId: runtime.productId,
getAccessToken,
});
}