BentoLabs SDK for user session recording and analytics
npm install @bentolabs/sdkA TypeScript SDK for user session recording and analytics using rrweb.



``bash`
npm install @bentolabs/sdk
This project includes a streamlined CI/CD pipeline with:
- ✅ Release-Triggered Builds - Only runs when you create a GitHub release
- ✅ Automated Testing on Node.js 18.x
- ✅ Code Quality Checks (ESLint, Prettier, TypeScript)
- ✅ Automated Build and validation
- ✅ Automated NPM Publishing on releases
- ✅ Dependency Management with Dependabot
1. Set NPM Token: Add NPM_TOKEN to GitHub repository secrets
2. Create Release: Tag and release on GitHub to automatically build, test, and publish to npm
See DEPLOYMENT.md for detailed setup instructions.
`typescript
import { BentoLabsSDK } from '@bentolabs/sdk';
// Create SDK instance
const sdk = new BentoLabsSDK();
// Initialize with your API key
sdk.init('your-api-key', {
endpoint: 'https://api.bentolabs.ai',
debug: true,
});
// Check status
console.log('Session ID:', sdk.getSessionId());
console.log('Recording:', sdk.isRecordingActive());
`
#### init(apiKey: string, options?: SDKOptions)
Initialize the SDK with your API key and optional configuration.
Parameters:
- apiKey (string): Your BentoLabs API keyoptions
- (SDKOptions, optional): Configuration options
Options:
`typescript`
interface SDKOptions {
endpoint?: string; // API endpoint URL (default: 'https://api.bentolabs.ai')
debug?: boolean; // Enable debug logging (default: false)
}
Example:
`typescript`
sdk.init('your-api-key', {
endpoint: 'https://custom-endpoint.com',
debug: true,
});
#### getSessionId(): string
Returns the current session ID.
`typescript`
const sessionId = sdk.getSessionId();
console.log('Current session:', sessionId); // sess_xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
#### isRecordingActive(): boolean
Check if recording is currently active.
`typescript`
if (sdk.isRecordingActive()) {
console.log('Recording user interactions...');
}
#### getConfig(): Omit
Get current configuration with masked API key for security.
`typescript`
const config = sdk.getConfig();
console.log(config);
// {
// apiKey: 'your-api...',
// endpoint: 'https://api.bentolabs.ai',
// debug: false
// }
`typescript
import React, { useEffect, useState } from 'react';
import { BentoLabsSDK } from '@bentolabs/sdk';
function App() {
const [sdk] = useState(() => new BentoLabsSDK());
const [sessionId, setSessionId] = useState('');
useEffect(() => {
sdk.init('your-api-key', { debug: true });
setSessionId(sdk.getSessionId());
}, [sdk]);
return (
Session: {sessionId}
Recording: {sdk.isRecordingActive() ? 'Active' : 'Inactive'}
$3
`html
`Examples Directory
Check out the examples directory for complete working examples:
- React Example: Comprehensive React application with interactive demo
- Vanilla JS Example: Simple HTML/JavaScript integration
Development
$3
`bash
Clone the repository
git clone https://github.com/bentolabs/bentolabs-sdk.git
cd bentolabs-sdkInstall dependencies
npm installBuild the project
npm run buildRun tests
npm testRun tests with coverage
npm run test:coverageStart development mode
npm run dev
`$3
-
npm run build - Build the TypeScript project
- npm run dev - Start TypeScript compiler in watch mode
- npm test - Run all tests
- npm run test:watch - Run tests in watch mode
- npm run test:coverage - Run tests with coverage report
- npm run lint - Run ESLint
- npm run format - Format code with Prettier$3
`
bentolabs-sdk/
├── src/ # Source code
│ └── index.ts # Main SDK implementation
├── tests/ # Test files
│ ├── BentoLabsSDK.test.ts
│ └── integration.test.ts
├── examples/ # Example applications
│ └── react-example/ # React example
├── dist/ # Built files (generated)
├── coverage/ # Test coverage (generated)
└── .github/ # GitHub Actions workflows
`Contributing
1. Fork the repository
2. Create a feature branch:
git checkout -b feature/my-feature
3. Make your changes and add tests
4. Run tests: npm test
5. Run linting: npm run lint
6. Commit your changes: git commit -am 'Add my feature'
7. Push to the branch: git push origin feature/my-feature
8. Submit a pull requestPublishing
$3
1. Create a GitHub release with a version tag (e.g.,
v1.0.0)
2. GitHub Actions will automatically publish to npm$3
1. Push changes to the
develop` branchMIT License - see LICENSE file for details.
- 📖 Documentation
- 🐛 Issue Tracker
- 💬 Discussions