feat: add 4 new survey templates#4018
Conversation
|
@jonas-hoebenreich is attempting to deploy a commit to the formbricks Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Rate limit exceeded@jobenjada has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 24 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThis pull request introduces significant modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Thank you for following the naming conventions for pull request titles! 🙏 |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- packages/lib/templates.ts (3 hunks)
🔇 Additional comments (3)
packages/lib/templates.ts (3)
5326-5607: Overall implementation looks good!The new HR survey templates are well-implemented with clear questions and consistent structure. The templates will provide valuable insights into employee satisfaction and engagement. The suggested improvements around rating scale standardization and template organization are minor and can be addressed in a follow-up PR if desired.
5326-5395: 🛠️ Refactor suggestionConsider standardizing rating scales across templates
While the template is well-structured, it uses a 10-point rating scale while many other templates use a 5-point scale. Consider standardizing the rating scale across all HR-related templates for consistency in data collection and analysis.
#!/bin/bash # Check rating scales across templates rg 'range: \d+,' -A 2
5259-5259: Consider the impact of broadening industry categoriesThe expansion of industries to include "saas", "eCommerce", and "other" aligns with the PR discussion about simplifying industry categories. However, this change should be consistent across all HR-related templates for uniformity.
| professionalDevelopmentGrowth(), | ||
| recognitionAndReward(), | ||
| alignmentAndEngagement(), | ||
| supportiveWorkCulture(), |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Consider grouping related templates in the export array
The HR-related templates could be grouped together in the export array for better organization. Consider adding a comment separator or reordering the array to keep similar templates adjacent to each other.
Example organization:
export const templates: TTemplate[] = [
// Customer Feedback Templates
cartAbandonmentSurvey(),
siteAbandonmentSurvey(),
// ... other customer templates
// HR & Employee Templates
+ employeeSatisfaction(),
+ employeeWellBeing(),
+ professionalDevelopmentGrowth(),
+ recognitionAndReward(),
+ alignmentAndEngagement(),
+ supportiveWorkCulture(),
// ... other templates
];Committable suggestion was skipped due to low confidence.
|
I like the idea of adding "People Manager" :) wanna implement that and add the other two HR templates? we'll keep the industries for now 🤓 but i do see your point! // updated the PR labels with points |
|
@jobenjada, sure I can add "People Manager". Do you want me to add this to the on boarding as well? |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/lib/templates.ts (1)
Line range hint
1-5778: Consider splitting templates into separate files by categoryThe file is growing quite large with many templates. Consider refactoring to:
- Split templates into separate files by category (e.g., HR templates, customer feedback templates, etc.)
- Create an index file to export all templates
- Group related templates together
This would improve:
- Code maintainability
- File organization
- Developer experience when working with specific template categories
Example structure:
// templates/hr/index.ts export { employeeWellBeing } from './employee-well-being'; export { longTermRetentionCheckIn } from './long-term-retention'; // ... other HR templates // templates/index.ts export * from './hr'; export * from './customer-feedback'; // ... other categories
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- packages/lib/templates.ts (3 hunks)
🔇 Additional comments (2)
packages/lib/templates.ts (2)
5326-5730: Well-structured HR survey templates with comprehensive question sets!The new HR-focused templates are well-designed with:
- Clear and focused questions that follow survey design best practices
- Appropriate use of different question types (Rating, OpenText, MultipleChoice)
- Consistent structure matching existing templates
- Good validation and logic flow
5774-5778: LGTM - Templates properly added to the export array!The new templates are correctly added to the
templatesarray, maintaining consistency with the existing pattern.
|
@jobenjada |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
packages/types/templates.ts (1)
12-18: Consider adding JSDoc documentation for the role enum.Adding documentation would help clarify the intended use case for each role, particularly the new "peopleManager" role.
+/** + * Defines the various roles that can be associated with templates + * @enum {string} + * @property {string} productManager - For product-related templates + * @property {string} customerSuccess - For customer success templates + * @property {string} marketing - For marketing-focused templates + * @property {string} sales - For sales-related templates + * @property {string} peopleManager - For HR and people management templates + */ export const ZTemplateRole = z.enum([packages/ui/components/TemplateList/components/TemplateTags.tsx (1)
Line range hint
16-31: Consider refactoring role styling for better maintainability.While the current implementation works well, here are two suggestions for future improvements:
- Consider moving the role-color mappings to a centralized theme configuration. This would make it easier to maintain consistent styling across the application.
- As more roles are added, consider replacing the switch statement with a lookup object or map for better maintainability.
Example approach:
const ROLE_STYLES = { productManager: "border-blue-300 bg-blue-50 text-blue-500", peopleManager: "border-pink-300 bg-pink-50 text-pink-500", // ... other roles } as const; const getRoleBasedStyling = (role: TTemplateRole | undefined): string => ROLE_STYLES[role] ?? "border-slate-300 bg-slate-50 text-slate-500";
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- packages/lib/templates.ts (4 hunks)
- packages/types/templates.ts (1 hunks)
- packages/ui/components/TemplateList/components/TemplateTags.tsx (1 hunks)
- packages/ui/components/TemplateList/lib/utils.ts (1 hunks)
🔇 Additional comments (7)
packages/types/templates.ts (1)
12-18: LGTM! Verify handling of the new role across the codebase.The addition of "peopleManager" to ZTemplateRole is well-structured and aligns with the PR objectives for HR-focused templates.
Let's verify that all switch statements and role handlers are updated:
✅ Verification successful
Let me analyze the findings:
- Found a switch statement in
TemplateTags.tsxthat handles role-based styling but doesn't include the new "peopleManager" role- Found
roleMappinginutils.tsthat already includes "peopleManager" with proper label- Other role-related conditionals are about membership roles ("admin", "owner", "viewer") which are unrelated to template roles
Let's verify the switch statement implementation:
Let me try a different pattern to get the switch statement implementation:
Let me try one final approach to get the complete file content:
All role-related code has been properly updated to handle the new "peopleManager" role
The verification shows that:
- The
getRoleBasedStylingswitch statement includes the "peopleManager" case with appropriate styling- The
roleMappingin utils.ts (from previous results) already includes the "peopleManager" with proper label- All template role-related code handles the new role correctly
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potential missing cases in switch statements and role handlers # Test 1: Look for switch statements or if-else chains handling roles rg -A 5 "switch.*role|if.*role.*===" # Test 2: Look for role-related styling or mapping functions rg -A 5 "getRoleBasedStyling|roleMapping"Length of output: 7794
Script:
#!/bin/bash # Get the full implementation of getRoleBasedStyling function ast-grep --pattern 'const getRoleBasedStyling = (role: $_) => { switch (role) { $$$ } }'Length of output: 98
Script:
#!/bin/bash # Get the full implementation using ripgrep with context rg -U --multiline --context 10 'switch \(role\) \{.*?\}' packages/ui/components/TemplateList/components/TemplateTags.tsxLength of output: 122
Script:
#!/bin/bash # Get the complete file content to analyze the switch statement cat packages/ui/components/TemplateList/components/TemplateTags.tsxLength of output: 4038
packages/ui/components/TemplateList/lib/utils.ts (1)
56-56: LGTM! Addition of People Manager role is well-implemented.The new role mapping entry follows the established pattern and is consistent with the type system.
Let's verify the coordinated changes across related files:
✅ Verification successful
✅ People Manager role implementation is complete and properly integrated
The verification confirms that:
- The
peopleManagerrole is properly defined in theZTemplateRoleenum inpackages/types/templates.ts- The role is actively used in multiple templates in
packages/lib/templates.tsfor HR-focused surveys- No styling-specific implementation was required as roles use the default styling system
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all necessary files have been updated to support the new peopleManager role # Test 1: Check if the role is properly defined in types echo "Checking role definition in types..." rg -l "peopleManager.*TTemplateRole" # Test 2: Check templates using this role echo "Checking templates using peopleManager role..." rg -l "role.*peopleManager" # Test 3: Check UI styling for the new role echo "Checking UI styling implementation..." rg -l "getRoleBasedStyling.*peopleManager"Length of output: 410
Script:
#!/bin/bash # Let's try a more comprehensive verification approach # Check type definitions with broader pattern echo "Checking type definitions..." rg -l "type.*TTemplateRole|interface.*TTemplateRole" # Check the actual implementation in templates.ts echo "Checking templates.ts implementation..." rg -A 5 "peopleManager" packages/lib/templates.ts # Check for any styling related files echo "Checking styling files..." fd -e ts -e tsx getRoleBasedStyling # If styling file exists, check its content if [ -f "packages/ui/components/TemplateList/lib/styling.ts" ]; then echo "Checking styling implementation..." cat "packages/ui/components/TemplateList/lib/styling.ts" fiLength of output: 2028
Script:
#!/bin/bash # Let's check the type definition content and styling implementation # Check the actual type definition echo "Checking TTemplateRole type definition..." rg -A 5 "TTemplateRole" packages/types/templates.ts # Check for styling in the TemplateList component directory echo "Checking styling in TemplateList component..." fd -t f . packages/ui/components/TemplateList | grep -i "style\|theme" if [ $? -eq 0 ]; then for file in $(fd -t f . packages/ui/components/TemplateList | grep -i "style\|theme"); do echo "Content of $file:" cat "$file" done fiLength of output: 507
Script:
#!/bin/bash # Let's check the actual type definition for peopleManager and ZTemplateRole # Check the ZTemplateRole definition echo "Checking ZTemplateRole definition..." rg -B 5 -A 5 "ZTemplateRole" packages/types/templates.ts # Check if peopleManager is properly included in the role validation echo "Checking role validation..." rg "z\.enum.*peopleManager" packages/types/templates.ts # Let's also check if there are any styling utilities in the ui package echo "Checking for styling utilities..." fd -t f . packages/ui | grep -i "style\|theme"Length of output: 1507
packages/ui/components/TemplateList/components/TemplateTags.tsx (1)
26-27: LGTM! The styling for peopleManager role is well implemented.The pink color scheme provides good visual distinction from other roles while maintaining consistency with the existing styling patterns.
Let's verify that this role is properly defined in the types:
✅ Verification successful
Let me verify the type definition with a corrected regex:
The peopleManager role is properly defined and consistently used across the codebase
The verification confirms:
- The role is correctly defined in the Zod enum
ZTemplateRoleinpackages/types/templates.ts- It's consistently used across the codebase:
- Type definition in
packages/types/templates.ts- Styling in
packages/ui/components/TemplateList/components/TemplateTags.tsx- Label mapping in
packages/ui/components/TemplateList/lib/utils.ts- Multiple template definitions in
packages/lib/templates.ts🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify peopleManager role is properly defined in types # and used consistently across the codebase # Check if peopleManager is defined in templates types echo "Checking template types definition..." rg -A 5 "export.*TTemplateRole.*=.*{" # Check all usages of peopleManager role echo "Checking peopleManager role usage..." rg "peopleManager"Length of output: 903
Script:
#!/bin/bash # Check if peopleManager is defined in templates types with fixed regex echo "Checking template types definition..." rg -A 5 "export.*type.*TTemplateRole" # Get the full content of the types file echo "Content of templates.ts:" cat packages/types/templates.tsLength of output: 1996
packages/lib/templates.ts (4)
1956-1957: LGTM: Role updates align with template purposeThe change of role from "productManager" to "peopleManager" for HR-focused templates is appropriate and improves template categorization.
Also applies to: 5258-5259
5326-5447: LGTM: Well-structured retention check-in templateThe longTermRetentionCheckIn template effectively measures user satisfaction and loyalty with a comprehensive set of questions covering various aspects of product usage and user experience.
5449-5518: LGTM: HR-focused templates are well-designedThe new HR templates (professionalDevelopmentGrowth, recognitionAndReward, alignmentAndEngagement, supportiveWorkCulture) are well-structured with:
- Clear and focused questions
- Appropriate rating scales
- Good mix of quantitative and qualitative questions
- Consistent structure across templates
Also applies to: 5520-5590, 5592-5660, 5662-5730
5774-5778: LGTM: Template array updates are correctThe new templates have been properly added to the templates array export, maintaining the existing structure and organization.
|
Awarding jonas-hoebenreich: 750 points 🕹️ Well done! Check out your new contribution on oss.gg/jonas-hoebenreich |

What does this PR do?
This PR template adds 4 new survey templates targeting 4 main areas in HR. The questions in this template have been inspired by Peakon Employee Voice
One question: these templates are currently set to role: productManager. What do you think about adding the role People Manager?
And just my personal opinion: I would completely remove industries. I think they don't solve any real issue, are not easy to understand for the typical user and reducing the onboarding by one step probably increases CVR.
Fixes # (issue)
How should this be tested?
Checklist
Required
pnpm buildconsole.logsgit pull origin mainAppreciated
Summary by CodeRabbit