A lightweight JavaScript SDK for collecting user feedback with a beautiful, customizable widget.
- π¨ Customizable Design - Full control over colors, fonts, and layout
- π± Responsive - Works perfectly on desktop and mobile devices
- β‘ Lightweight - Minimal bundle size with no external dependencies
- π§ Easy Integration - Simple API with comprehensive documentation
- π― Multiple Feedback Types - Rating, text feedback, and categories
- π Secure - Built with security best practices
- π Cross-Browser - Works in all modern browsers
- βΏ Accessible - WCAG compliant with keyboard navigation support
- π§ Development Mode - Automatic detection and simulation for local development
- π TypeScript Support - Full type definitions included
- β Robust Validation - Comprehensive configuration validation
- π‘οΈ Error Handling - Graceful error handling and recovery
<script src="https://cdn.Shiply.com/sdk/Shiply.min.js"></script>npm install Shiply-sdkimport Shiply from 'Shiply-sdk';The SDK automatically detects development environments and provides helpful features:
- Automatic Detection: Detects localhost, demo API keys, and development flags
- Simulated API Calls: No real API requests in development mode
- Enhanced Logging: Detailed console logs for debugging
- Error Simulation: Safe error handling without breaking your app
Development mode is automatically enabled when:
- Running on localhost or 127.0.0.1
- Using demo API keys (
demo-api-key,test-key) - Adding
?Shiply-dev=trueto your URL
// Initialize Shiply
const Shiply = new Shiply({
apiKey: 'your-api-key',
websiteId: 'your-website-id'
});
// Initialize and show the widget
Shiply.init().show();const Shiply = new Shiply({
// Required
apiKey: 'your-api-key',
websiteId: 'your-website-id',
// Optional
apiUrl: 'https://api.Shiply.com',
timeout: 10000,
// Widget appearance
theme: {
primaryColor: '#007bff',
backgroundColor: '#ffffff',
textColor: '#333333',
borderColor: '#e1e5e9',
borderRadius: '8px',
fontFamily: 'system-ui, -apple-system, sans-serif',
fontSize: '14px'
},
// Widget position and size
position: {
bottom: '20px',
right: '20px'
},
size: {
width: '350px',
height: '500px'
},
zIndex: 9999,
// Trigger button
trigger: {
icon: 'π¬',
size: '60px',
iconSize: '24px'
},
// Text content
text: {
title: 'Share Your Feedback',
ratingLabel: 'How would you rate your experience?',
feedbackLabel: 'Tell us more (optional)',
feedbackPlaceholder: 'Share your thoughts...',
submitButton: 'Submit',
cancelButton: 'Cancel'
},
// Features
categories: [
{ value: 'bug', label: 'Bug Report' },
{ value: 'feature', label: 'Feature Request' },
{ value: 'general', label: 'General Feedback' }
],
// User information
user: {
id: 'user-123',
email: 'user@example.com',
name: 'John Doe'
}
});Initialize the SDK with configuration.
Shiply.init({
apiKey: 'your-api-key',
websiteId: 'your-website-id'
});Show the feedback widget.
Shiply.show();Hide the feedback widget.
Shiply.hide();Toggle the feedback widget visibility.
Shiply.toggle();Set user information for feedback context.
Shiply.setUser({
id: 'user-123',
email: 'user@example.com',
name: 'John Doe'
});Track custom events.
Shiply.track('page_view', {
page: '/products',
category: 'electronics'
});Submit feedback programmatically.
Shiply.submitFeedback({
rating: 5,
text: 'Great product!',
category: 'general'
});Get current configuration.
const config = Shiply.getConfig();Update configuration.
Shiply.updateConfig({
theme: {
primaryColor: '#28a745'
}
});Destroy the SDK instance and clean up.
Shiply.destroy();const Shiply = new Shiply({
apiKey: 'your-api-key',
websiteId: 'your-website-id',
theme: {
primaryColor: '#e74c3c',
backgroundColor: '#2c3e50',
textColor: '#ecf0f1',
borderRadius: '12px',
fontFamily: 'Arial, sans-serif'
}
});// Track when feedback is submitted
Shiply.track('feedback_submitted', {
rating: 5,
hasText: true,
category: 'general'
});
// Track widget interactions
Shiply.track('widget_opened');
Shiply.track('widget_closed');// Submit feedback without showing the widget
Shiply.submitFeedback({
rating: 4,
text: 'Good experience overall',
category: 'general',
metadata: {
page: window.location.pathname,
referrer: document.referrer
}
});If you're seeing errors like "Access to fetch at 'https://api.shiply.com/api/feedback' from origin 'https://yourdomain.com' has been blocked by CORS policy", this means your API server needs to be configured to allow cross-origin requests.
Symptoms:
- Network requests fail with CORS errors in browser console
- Feedback submissions don't work from your website
- Browser blocks requests to the API
Solution: Your API server (where you host the Shiply API endpoints) needs to include proper CORS headers. Here's what your API routes should include:
// Example for Next.js API routes
export async function POST(request) {
const origin = request.headers.get('origin');
// Your API logic here...
const response = NextResponse.json({
success: true,
message: 'Feedback submitted successfully'
});
// Add CORS headers
response.headers.set('Access-Control-Allow-Origin', origin || '*');
response.headers.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
response.headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With');
response.headers.set('Access-Control-Allow-Credentials', 'true');
return response;
}
// Handle preflight requests
export async function OPTIONS() {
return new Response(null, {
status: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With',
'Access-Control-Allow-Credentials': 'true',
},
});
}For other frameworks:
Express.js:
const cors = require('cors');
app.use(cors({
origin: ['https://yourdomain.com', 'https://www.yourdomain.com'],
credentials: true
}));Vercel:
// In your API route
export default function handler(req, res) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With');
if (req.method === 'OPTIONS') {
res.status(200).end();
return;
}
// Your API logic here...
}Symptoms:
"Shiply is not defined"error- Widget doesn't appear on page
- Console shows module loading errors
Solutions:
- Check script loading order: Make sure the SDK script loads before your initialization code
- Verify CDN URL: Ensure the CDN URL is correct and accessible
- Check network connectivity: Verify the SDK can be downloaded from the CDN
<!-- Correct loading order -->
<script src="https://cdn.shiply.com/sdk/shiply.min.js"></script>
<script>
// Your Shiply initialization code here
const shiply = new Shiply({
apiKey: 'your-api-key',
websiteId: 'your-website-id'
});
</script>Symptoms:
- No feedback button visible
- Widget doesn't show when triggered
- Console shows initialization errors
Solutions:
- Check configuration: Ensure
apiKeyandwebsiteIdare provided - Verify CSS: Make sure no CSS is hiding the widget (check
z-index,display: none, etc.) - Check console errors: Look for JavaScript errors that might prevent initialization
// Debug configuration
const shiply = new Shiply({
apiKey: 'your-api-key', // Required
websiteId: 'your-website-id', // Required
zIndex: 9999, // Ensure it's above other elements
position: {
bottom: '20px',
right: '20px'
}
});
// Check if initialized
console.log('Shiply initialized:', shiply.isInitialized());Symptoms:
- Feedback submissions fail silently
- Network tab shows failed requests
- Console shows API errors
Solutions:
- Check API endpoint: Verify the
apiUrlis correct - Validate API key: Ensure your API key is valid and has proper permissions
- Check request format: Verify the request payload matches expected format
// Enable development mode for debugging
const shiply = new Shiply({
apiKey: 'your-api-key',
websiteId: 'your-website-id',
apiUrl: 'https://api.shiply.com', // Verify this URL
timeout: 10000 // Increase timeout if needed
});
// Check network requests in browser dev tools
// Look for 400/401/403/500 status codesSymptoms:
- Widget looks broken or unstyled
- Custom themes not applying
- Mobile responsiveness issues
Solutions:
- Check CSS conflicts: Ensure no other CSS is overriding widget styles
- Verify theme configuration: Check that theme properties are valid
- Test on different devices: Verify responsive design works
// Debug theme configuration
const shiply = new Shiply({
apiKey: 'your-api-key',
websiteId: 'your-website-id',
theme: {
primaryColor: '#007bff', // Valid hex color
backgroundColor: '#ffffff', // Valid hex color
borderRadius: '8px', // Valid CSS value
fontSize: '14px' // Valid CSS value
}
});If you're still experiencing issues:
- Check the console: Look for error messages in browser developer tools
- Enable development mode: Add
?shiply-dev=trueto your URL for enhanced logging - Test in isolation: Create a minimal test page with just the SDK
- Check network tab: Verify API requests are being made correctly
Debug mode:
// Add this to your URL for enhanced debugging
// https://yourdomain.com?shiply-dev=true
// Or enable programmatically
const shiply = new Shiply({
apiKey: 'your-api-key',
websiteId: 'your-website-id',
// Development mode will be auto-detected
});- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
- Internet Explorer 11 (with polyfills)
git clone https://github.com/nkalpakis21/Shiply-sdk.git
cd Shiply-sdk
npm install# Development build
npm run build:dev
# Production build
npm run buildnpm run devnpm test- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- π§ Email: support@Shiply.com
- π Documentation: https://docs.Shiply.com
- π Issues: https://github.com/nkalpakis21/Shiply-sdk/issues
- π¬ Discussions: https://github.com/nkalpakis21/Shiply-sdk/discussions
- Initial release
- Basic feedback widget functionality
- Customizable themes and styling
- API integration
- User management
- Event tracking