Core SDK Methods
Complete reference for all Rise SDK methods.
Rise.init()
Initialize the Rise SDK. Must be called before using other methods.
Rise.init(config: RiseConfig): void
Parameters:
config(RiseConfig): Configuration object
Example:
Rise.init({
appKey: 'your-app-key'
});
See Configuration for all available options.
Rise.identify()
Associate a user ID with the current session for personalized experiences.
Rise.identify(userId: string): void
Parameters:
userId(string): Unique identifier for the user
Example:
// After user login
if (user?.id) {
Rise.identify(user.id);
}
Best Practices:
- Call after successful authentication
- Use consistent user IDs across sessions
- Don't use PII (email, name) as the user ID if possible
- Use the same ID format as your analytics tools for cross-referencing
Rise.showBubble()
Display the AI chat bubble.
Rise.showBubble(config?: BubbleConfig): void
Parameters:
config(BubbleConfig, optional): Bubble appearance configuration
Example:
// Show with default config
Rise.showBubble();
// Show with custom config
Rise.showBubble({
position: 'bottom-right',
primaryColor: '#000000'
});
Rise.hideBubble()
Hide the AI chat bubble.
Rise.hideBubble(): void
Example:
Rise.hideBubble();
Rise.isBubbleVisible()
Check if the bubble is currently visible.
Rise.isBubbleVisible(): boolean
Returns:
boolean:trueif visible,falseotherwise
Example:
if (Rise.isBubbleVisible()) {
console.log('Bubble is visible');
}
Rise.destroy()
Clean up SDK resources and stop all tracking. Useful for SPA route changes or user logout.
Rise.destroy(): void
Example:
// On user logout
function handleLogout() {
Rise.destroy();
// ... rest of logout logic
}
What gets cleaned up:
- Event listeners
- WebSocket connections
- Timers and observers
- DOM elements (bubble, overlays)
Rise.track()
Manually track a custom event (optional - Rise auto-tracks most events).
Rise.track(eventName: string, properties?: Record<string, any>): void
Parameters:
eventName(string): Name of the eventproperties(object, optional): Additional event properties
Example:
Rise.track('feature_used', {
featureName: 'export',
format: 'csv'
});
Note: Rise automatically tracks most user interactions. Manual tracking is only needed for custom business events.
Rise.setUserProperties()
Set or update properties for the identified user.
Rise.setUserProperties(properties: Record<string, any>): void
Parameters:
properties(object): User properties to set
Example:
Rise.setUserProperties({
plan: 'pro',
company: 'Acme Inc',
role: 'admin'
});
Common use cases:
- Update subscription tier
- Set user role or permissions
- Track user preferences
- Store cohort membership
Complete Example
import Rise from '@getrise-ai/web-sdk';
// Initialize on app load
Rise.init({
appKey: 'your-app-key',
isDevelopment: process.env.NODE_ENV === 'development'
});
// Identify user after login
function handleLogin(user) {
Rise.identify(user.id);
Rise.setUserProperties({
plan: user.subscription.plan,
role: user.role,
signupDate: user.createdAt
});
}
// Clean up on logout
function handleLogout() {
Rise.destroy();
}
// Manual event tracking (optional)
function handleExport(format) {
Rise.track('export_completed', {
format: format,
timestamp: new Date().toISOString()
});
}