export function upgradeFeedbackSurvey(form: FormTs) {
// Post-Upgrade Feedback Survey for SaaS/Subscription Products
// Demonstrates: Dropdown, StarRating, Slider, EmojiRating, CheckboxList, RadioButton, MatrixQuestion
// Advanced: Conditional visibility, Dynamic labels, Value perception analysis, Expectation matching
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'How is Your Upgrade Going?',
computedValue: () => "You recently upgraded your plan. We'd love to hear about your experience so far.",
customStyles: {
backgroundColor: '#059669',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Upgrade Details
// ============================================
const upgradeSection = form.addSubform('upgradeSection', {
title: 'Your Upgrade'
});
upgradeSection.addRow(row => {
row.addDropdown('previousPlan', {
label: 'What plan were you on before?',
options: [
{ id: 'free', name: 'Free / Trial' },
{ id: 'starter', name: 'Starter' },
{ id: 'basic', name: 'Basic' },
{ id: 'professional', name: 'Professional' },
{ id: 'business', name: 'Business' },
{ id: 'other', name: 'Other' }
],
placeholder: 'Select your previous plan'
}, '1fr');
row.addDropdown('currentPlan', {
label: 'What plan are you on now?',
options: [
{ id: 'starter', name: 'Starter' },
{ id: 'basic', name: 'Basic' },
{ id: 'professional', name: 'Professional' },
{ id: 'business', name: 'Business' },
{ id: 'enterprise', name: 'Enterprise' },
{ id: 'other', name: 'Other' }
],
placeholder: 'Select your current plan'
}, '1fr');
});
upgradeSection.addSpacer({ height: '16px' });
upgradeSection.addRow(row => {
row.addRadioButton('upgradeReason', {
label: 'What was the main reason for upgrading?',
options: [
{ id: 'features', name: 'Needed specific features' },
{ id: 'limits', name: 'Hit usage limits' },
{ id: 'team', name: 'Team/user growth' },
{ id: 'support', name: 'Better support options' },
{ id: 'security', name: 'Security/compliance needs' },
{ id: 'value', name: 'Better value at higher tier' },
{ id: 'other', name: 'Other reason' }
],
orientation: 'vertical'
});
});
upgradeSection.addRow(row => {
row.addTextbox('upgradeReasonOther', {
label: 'Please specify:',
placeholder: 'What was your reason for upgrading?',
isVisible: () => upgradeSection.radioButton('upgradeReason')?.value() === 'other',
isRequired: () => upgradeSection.radioButton('upgradeReason')?.value() === 'other'
});
});
// ============================================
// SECTION 2: Initial Satisfaction
// ============================================
const satisfactionSection = form.addSubform('satisfactionSection', {
title: 'Overall Satisfaction',
customStyles: () => {
const satisfaction = satisfactionSection.emojiRating('upgradeSatisfaction')?.value();
if (satisfaction === 'excellent' || satisfaction === 'good') {
return { backgroundColor: '#ecfdf5', padding: '20px', borderRadius: '10px' };
}
if (satisfaction === 'bad' || satisfaction === 'very-bad') {
return { backgroundColor: '#fef2f2', padding: '20px', borderRadius: '10px' };
}
return { backgroundColor: '#f8fafc', padding: '20px', borderRadius: '10px' };
}
});
satisfactionSection.addRow(row => {
row.addEmojiRating('upgradeSatisfaction', {
label: 'How satisfied are you with your upgrade so far?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
// Conditional follow-up based on satisfaction
satisfactionSection.addSpacer({ height: '16px' });
satisfactionSection.addRow(row => {
row.addTextarea('satisfactionReason', {
label: () => {
const satisfaction = satisfactionSection.emojiRating('upgradeSatisfaction')?.value();
if (satisfaction === 'excellent' || satisfaction === 'good') {
return "Great to hear! What's been the best part of upgrading?";
}
if (satisfaction === 'bad' || satisfaction === 'very-bad') {
return "We're sorry to hear that. What hasn't met your expectations?";
}
return "What's been your experience with the upgrade?";
},
placeholder: 'Share your thoughts...',
rows: 3,
autoExpand: true,
isVisible: () => satisfactionSection.emojiRating('upgradeSatisfaction')?.value() != null
});
});
// ============================================
// SECTION 3: Expectations vs Reality
// ============================================
const expectationsSection = form.addSubform('expectationsSection', {
title: 'Expectations vs Reality',
isVisible: () => satisfactionSection.emojiRating('upgradeSatisfaction')?.value() != null
});
expectationsSection.addRow(row => {
row.addRatingScale('metExpectations', {
preset: 'likert-5',
label: 'How well has the upgrade met your expectations?',
lowLabel: 'Far below',
highLabel: 'Far exceeded',
size: 'md',
alignment: 'center'
});
});
expectationsSection.addSpacer({ height: '16px' });
expectationsSection.addRow(row => {
row.addMatrixQuestion('expectationMatrix', {
label: 'How do specific aspects compare to what you expected?',
rows: [
{ id: 'features', label: 'Feature quality', description: 'Compared to what was promised' },
{ id: 'performance', label: 'Performance/Speed', description: 'System responsiveness' },
{ id: 'usability', label: 'Ease of use', description: 'Of the new features' },
{ id: 'support', label: 'Support quality', description: 'If you\'ve used support' },
{ id: 'value', label: 'Overall value', description: 'For the price paid' }
],
columns: [
{ id: 'worse', label: 'Worse' },
{ id: 'as-expected', label: 'As Expected' },
{ id: 'better', label: 'Better' },
{ id: 'na', label: 'N/A' }
],
selectionMode: 'single',
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 4: New Features Experience
// ============================================
const featuresSection = form.addSubform('featuresSection', {
title: 'New Features',
isVisible: () => satisfactionSection.emojiRating('upgradeSatisfaction')?.value() != null
});
featuresSection.addRow(row => {
row.addCheckboxList('valuedFeatures', {
label: 'Which new features have been most valuable to you?',
options: [
{ id: 'analytics', name: 'Advanced analytics/reporting' },
{ id: 'integrations', name: 'Additional integrations' },
{ id: 'automation', name: 'Automation capabilities' },
{ id: 'collaboration', name: 'Team collaboration features' },
{ id: 'storage', name: 'Increased storage/limits' },
{ id: 'customization', name: 'Customization options' },
{ id: 'support', name: 'Priority support' },
{ id: 'security', name: 'Enhanced security features' },
{ id: 'api', name: 'API access' },
{ id: 'other', name: 'Other' }
],
orientation: 'vertical'
});
});
featuresSection.addSpacer({ height: '16px' });
featuresSection.addRow(row => {
row.addRadioButton('featureDiscovery', {
label: 'How easy was it to discover and start using the new features?',
options: [
{ id: 'very-easy', name: 'Very easy - intuitive' },
{ id: 'easy', name: 'Easy - minimal learning' },
{ id: 'moderate', name: 'Moderate - some exploration needed' },
{ id: 'difficult', name: 'Difficult - needed help' },
{ id: 'very-difficult', name: 'Very difficult - still figuring out' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 5: Value Perception
// ============================================
const valueSection = form.addSubform('valueSection', {
title: 'Value for Money',
isVisible: () => satisfactionSection.emojiRating('upgradeSatisfaction')?.value() != null,
customStyles: { backgroundColor: '#f8fafc', padding: '20px', borderRadius: '10px' }
});
valueSection.addRow(row => {
row.addSlider('valueRating', {
label: 'How would you rate the value for money of your new plan?',
min: 1,
max: 10,
step: 1,
showValue: true,
defaultValue: 5
});
});
valueSection.addSpacer({ height: '8px' });
valueSection.addRow(row => {
row.addTextPanel('valueScale', {
computedValue: () => {
const value = valueSection.slider('valueRating')?.value();
if (value == null) return '1 = Poor value, 10 = Excellent value';
if (value <= 3) return 'You feel the price is too high for what you get';
if (value <= 5) return 'You feel the value is about fair';
if (value <= 7) return 'You feel you\'re getting good value';
return 'You feel you\'re getting excellent value!';
},
customStyles: () => {
const value = valueSection.slider('valueRating')?.value();
const baseStyles = { fontSize: '13px', textAlign: 'center', padding: '8px' };
if (value != null && value <= 3) return { ...baseStyles, color: '#dc2626' };
if (value != null && value >= 8) return { ...baseStyles, color: '#059669' };
return { ...baseStyles, color: '#64748b' };
}
});
});
valueSection.addSpacer({ height: '16px' });
valueSection.addRow(row => {
row.addStarRating('priceJustification', {
label: 'Is the price difference between plans justified?',
tooltip: 'Do you feel the additional cost is worth the additional features?',
maxStars: 5,
size: 'lg',
showCounter: true,
alignment: 'center'
});
});
// ============================================
// SECTION 6: Upgrade Process
// ============================================
const processSection = form.addSubform('processSection', {
title: 'Upgrade Process',
isVisible: () => satisfactionSection.emojiRating('upgradeSatisfaction')?.value() != null
});
processSection.addRow(row => {
row.addStarRating('upgradeEase', {
label: 'How easy was the upgrade process?',
tooltip: 'From decision to activation',
maxStars: 5,
size: 'lg',
showCounter: true,
alignment: 'left'
}, '1fr');
row.addStarRating('dataTransition', {
label: 'How smooth was the data/settings transition?',
tooltip: 'Were your settings and data preserved?',
maxStars: 5,
size: 'lg',
showCounter: true,
alignment: 'left'
}, '1fr');
});
// ============================================
// SECTION 7: Future Outlook
// ============================================
const futureSection = form.addSubform('futureSection', {
title: 'Looking Forward',
isVisible: () => satisfactionSection.emojiRating('upgradeSatisfaction')?.value() != null
});
futureSection.addRow(row => {
row.addRadioButton('likelyToStay', {
label: 'How likely are you to stay on this plan?',
options: [
{ id: 'definitely', name: 'Definitely staying' },
{ id: 'probably', name: 'Probably staying' },
{ id: 'unsure', name: 'Not sure yet' },
{ id: 'considering-down', name: 'Considering downgrading' },
{ id: 'considering-up', name: 'Considering upgrading further' }
],
orientation: 'vertical'
});
});
futureSection.addSpacer({ height: '16px' });
futureSection.addRow(row => {
row.addRatingScale('recommendPlan', {
preset: 'nps',
label: 'How likely are you to recommend this plan to others?',
showCategoryLabel: true,
showSegmentColors: true,
size: 'sm',
alignment: 'center'
});
});
// ============================================
// SECTION 8: Additional Feedback
// ============================================
const additionalSection = form.addSubform('additionalSection', {
title: 'Additional Feedback',
isVisible: () => satisfactionSection.emojiRating('upgradeSatisfaction')?.value() != null
});
additionalSection.addRow(row => {
row.addTextarea('improvements', {
label: 'What improvements would make this plan even better?',
placeholder: 'Share any features or improvements you\'d like to see...',
rows: 3,
autoExpand: true
});
});
// ============================================
// SECTION 9: Summary
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Your Feedback Summary',
isVisible: () => satisfactionSection.emojiRating('upgradeSatisfaction')?.value() != null
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const prevPlan = upgradeSection.dropdown('previousPlan')?.value();
const currPlan = upgradeSection.dropdown('currentPlan')?.value();
const satisfaction = satisfactionSection.emojiRating('upgradeSatisfaction')?.value();
const expectations = expectationsSection.ratingScale('metExpectations')?.value();
const valueRating = valueSection.slider('valueRating')?.value();
const priceJust = valueSection.starRating('priceJustification')?.value();
const upgradeEase = processSection.starRating('upgradeEase')?.value();
const recommend = futureSection.ratingScale('recommendPlan')?.value();
const likelyToStay = futureSection.radioButton('likelyToStay')?.value();
if (!satisfaction) return '';
let emoji = '📊';
if (satisfaction === 'excellent' || satisfaction === 'good') emoji = '🎉';
else if (satisfaction === 'bad' || satisfaction === 'very-bad') emoji = '⚠️';
let summary = `${emoji} Upgrade Feedback Summary\n`;
summary += `${'═'.repeat(28)}\n\n`;
if (prevPlan && currPlan) {
summary += `📈 Upgrade: ${prevPlan} → ${currPlan}\n`;
}
const satisfactionLabels: Record<string, string> = {
'very-bad': 'Very Dissatisfied',
'bad': 'Dissatisfied',
'neutral': 'Neutral',
'good': 'Satisfied',
'excellent': 'Very Satisfied'
};
summary += `\n😊 Satisfaction: ${satisfactionLabels[satisfaction] || satisfaction}`;
if (expectations != null) {
const expLabels = ['Far Below', 'Below', 'Met', 'Exceeded', 'Far Exceeded'];
summary += `\n📋 Expectations: ${expLabels[expectations - 1] || expectations}`;
}
if (valueRating != null) {
summary += `\n💰 Value Rating: ${valueRating}/10`;
}
if (priceJust != null) {
summary += `\n⚖️ Price Justified: ${priceJust}/5`;
}
if (upgradeEase != null) {
summary += `\n🔧 Upgrade Ease: ${upgradeEase}/5`;
}
if (likelyToStay) {
const stayLabels: Record<string, string> = {
'definitely': 'Definitely Staying',
'probably': 'Probably Staying',
'unsure': 'Unsure',
'considering-down': 'Considering Downgrade',
'considering-up': 'Considering Further Upgrade'
};
summary += `\n\n🔄 Retention: ${stayLabels[likelyToStay] || likelyToStay}`;
}
if (recommend != null) {
summary += `\n📣 NPS: ${recommend}/10`;
}
return summary;
},
customStyles: () => {
const satisfaction = satisfactionSection.emojiRating('upgradeSatisfaction')?.value();
const baseStyles = {
padding: '20px',
borderRadius: '10px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '13px',
lineHeight: '1.6'
};
if (satisfaction === 'excellent' || satisfaction === 'good') {
return { ...baseStyles, backgroundColor: '#ecfdf5', borderLeft: '4px solid #10b981' };
} else if (satisfaction === 'bad' || satisfaction === 'very-bad') {
return { ...baseStyles, backgroundColor: '#fef2f2', borderLeft: '4px solid #ef4444' };
}
return { ...baseStyles, backgroundColor: '#fffbeb', borderLeft: '4px solid #f59e0b' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Upgrade Feedback',
isVisible: () => satisfactionSection.emojiRating('upgradeSatisfaction')?.value() != null
});
form.configureCompletionScreen({
type: 'text',
title: () => {
const satisfaction = satisfactionSection.emojiRating('upgradeSatisfaction')?.value();
if (satisfaction === 'excellent' || satisfaction === 'good') {
return "We're Glad You're Enjoying Your Upgrade!";
}
if (satisfaction === 'bad' || satisfaction === 'very-bad') {
return "We Want to Make This Right";
}
return "Thank You for Your Feedback!";
},
message: () => {
const satisfaction = satisfactionSection.emojiRating('upgradeSatisfaction')?.value();
if (satisfaction === 'bad' || satisfaction === 'very-bad') {
return "We're sorry the upgrade hasn't met your expectations. Our customer success team will reach out within 24 hours to discuss how we can help.";
}
return "Your feedback helps us improve our plans and pricing. We appreciate you taking the time to share your upgrade experience with us.";
}
});
}