@bangkeut-technology/supportdock-sdk
v0.5.0
Published
SupportDock SDK — submit feedback and manage FAQs from your React Native / Expo app
Downloads
68
Maintainers
Readme
@bangkeut-technology/supportdock-sdk
Official SDK for SupportDock — submit feedback and manage FAQs from your React Native / Expo app.
Install
npm install @bangkeut-technology/supportdock-sdkQuick Start
import { SupportDockClient } from '@bangkeut-technology/supportdock-sdk';
const sdk = new SupportDockClient({
apiKey: 'sdk_your_api_key',
});
// Submit feedback
await sdk.sendFeedback({
type: 'bug',
message: 'App crashes when opening settings',
email: '[email protected]',
metadata: { appVersion: '2.1.0', platform: 'ios' },
});
// List FAQs
const faqs = await sdk.listFAQs();React Hook (Expo / React Native)
import { useSupportDock } from '@bangkeut-technology/supportdock-sdk';
import { Platform } from 'react-native';
function FeedbackScreen() {
const { sendFeedback, loading, error, success } = useSupportDock({
apiKey: 'sdk_your_api_key',
defaultMetadata: {
appVersion: '2.1.0',
platform: Platform.OS,
},
});
const handleSubmit = async () => {
await sendFeedback({
type: 'bug',
message: 'Something went wrong',
email: userEmail,
});
};
if (success) return <Text>Thanks for your feedback!</Text>;
return (
<View>
<Button onPress={handleSubmit} disabled={loading} title="Send Feedback" />
{error && <Text style={{ color: 'red' }}>{error}</Text>}
</View>
);
}API
SupportDockClient
const sdk = new SupportDockClient({
apiKey: string; // Required — your app's API key (starts with sdk_)
baseUrl?: string; // Default: 'https://supportdock.io'
defaultMetadata?: Record<string, string>; // Merged into every feedback submission
timeout?: number; // Request timeout in ms (default: 10000)
});Feedback
// Submit feedback
await sdk.sendFeedback({
type: 'bug' | 'feature' | 'question' | 'general', // default: 'general'
message: string, // required
email?: string,
name?: string,
subject?: string, // auto-generated from type if omitted
metadata?: Record<string, string>,
source?: string, // default: 'mobile-app'
images?: string[], // up to 3 base64 data URLs (PNG/JPEG/WebP/GIF, each ≤ 2 MB)
videos?: string[], // up to 2 base64 data URLs (MP4/WebM/QuickTime, each ≤ 10 MB)
attachments?: { name: string; data: string }[], // up to 3 PDFs (each ≤ 5 MB)
});Attaching images
// Convert a local image to base64 (React Native example)
import * as FileSystem from 'expo-file-system';
const base64 = await FileSystem.readAsStringAsync(imageUri, {
encoding: FileSystem.EncodingType.Base64,
});
await sdk.sendFeedback({
type: 'bug',
message: 'UI is broken on this screen',
images: [`data:image/png;base64,${base64}`],
});Attaching videos
// Convert a local video to base64 (React Native example)
import * as FileSystem from 'expo-file-system';
const base64 = await FileSystem.readAsStringAsync(videoUri, {
encoding: FileSystem.EncodingType.Base64,
});
await sdk.sendFeedback({
type: 'bug',
message: 'Screen recording of the crash attached',
videos: [`data:video/mp4;base64,${base64}`],
});Attaching PDFs
// Convert a local PDF to base64 (React Native example)
import * as FileSystem from 'expo-file-system';
const base64 = await FileSystem.readAsStringAsync(pdfUri, {
encoding: FileSystem.EncodingType.Base64,
});
await sdk.sendFeedback({
type: 'bug',
message: 'Steps to reproduce are in the attached report',
attachments: [{ name: 'report.pdf', data: `data:application/pdf;base64,${base64}` }],
});FAQs
// List all FAQs
const faqs = await sdk.listFAQs();
// Create FAQ
const faq = await sdk.createFAQ({ question: '...', answer: '...', sortOrder: 0 });
// Update FAQ
await sdk.updateFAQ(faqId, { answer: 'Updated answer' });
// Delete FAQ
await sdk.deleteFAQ(faqId);Error Handling
import { SupportDockError } from '@bangkeut-technology/supportdock-sdk';
try {
await sdk.sendFeedback({ message: '...' });
} catch (err) {
if (err instanceof SupportDockError) {
console.log(err.message); // Error message from API
console.log(err.status); // HTTP status code (401, 429, etc.)
}
}Get Your API Key
- Go to your app dashboard on supportdock.io
- Click Generate API key
- Copy the key (starts with
sdk_)
Requires a Pro plan.
License
MIT
