@txlemetry/types
v1.396.0
Published
Type definitions for the Txlemetry JavaScript SDK
Downloads
222
Readme
@txlemetry/types
Type definitions for the Txlemetry JavaScript SDK.
When to Use This Package
✅ You Need This Package If:
You're loading Txlemetry via a <script> tag and want TypeScript types for window.txlemetry.
<!-- You load Txlemetry like this -->
<script>
!function(t,e){...}(document,window.txlemetry||[]);
txlemetry.init('your-api-key', { api_host: 'https://app.txlemetry.com' })
</script>❌ You Don't Need This Package If:
You're installing any Txlemetry library via npm/yarn/pnpm. The types are already included:
txlemetry-js- Browser SDK (includes all types)txlemetry-node- Node.js SDKtxlemetry-react-native- React Native SDK@txlemetry/react- React hooks and components
// Types are already available when you install txlemetry-js
import txlemetry from 'txlemetry-js'
txlemetry.init('your-api-key')
txlemetry.capture('my_event') // ✅ Fully typedInstallation
npm install @txlemetry/types
# or
yarn add @txlemetry/types
# or
pnpm add @txlemetry/typesUsage
Typing window.txlemetry (Script Tag Usage)
Create a type declaration file to type window.txlemetry:
// txlemetry.d.ts
import type { Txlemetry } from '@txlemetry/types'
declare global {
interface Window {
txlemetry?: Txlemetry
}
}
export {}Now you can use window.txlemetry with full type safety:
// Your code
window.txlemetry?.capture('button_clicked', { button_id: 'signup' })
window.txlemetry?.identify('user-123', { email: '[email protected]' })
const flagValue = window.txlemetry?.getFeatureFlag('my-flag')
if (flagValue === 'variant-a') {
// ...
}Typing Configuration Objects
import type { TxlemetryConfig, Properties } from '@txlemetry/types'
// Type your configuration
const config: Partial<TxlemetryConfig> = {
api_host: 'https://app.txlemetry.com',
autocapture: true,
capture_pageview: 'history_change',
}
// Type event properties
const eventProps: Properties = {
button_id: 'signup',
page: '/pricing',
}Version Synchronization
This package's version is synchronized with txlemetry-js. They are always released together with matching version numbers.
License
MIT
