Skip to content

feat: add 4 new survey templates#4018

Merged
jobenjada merged 7 commits intoformbricks:mainfrom
jonas-hoebenreich:template-growth
Oct 31, 2024
Merged

feat: add 4 new survey templates#4018
jobenjada merged 7 commits intoformbricks:mainfrom
jonas-hoebenreich:template-growth

Conversation

@jonas-hoebenreich
Copy link
Contributor

@jonas-hoebenreich jonas-hoebenreich commented Oct 24, 2024

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?

  • check out new survey templates
    image

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues
  • First PR at Formbricks? Please sign the CLA! Without it we wont be able to merge it 🙏

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

Summary by CodeRabbit

  • New Features
    • Added five new survey templates: Long Term Retention Check-In, Professional Development Growth, Recognition and Reward, Alignment and Engagement, and Supportive Work Culture.
    • Expanded the Employee Well-Being template to include additional industries: SaaS, eCommerce, and Other.
    • Introduced support for the "People Manager" role in various components and styling options.
  • Improvements
    • Enhanced existing templates to better assess various aspects of employee engagement, satisfaction, and alignment with company values.

@vercel
Copy link

vercel bot commented Oct 24, 2024

@jonas-hoebenreich is attempting to deploy a commit to the formbricks Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 0f258aa and 03aeef0.

Walkthrough

This pull request introduces significant modifications to the packages/lib/templates.ts file, adding several new survey templates and updating an existing one. The employeeWellBeing template's role has been changed to "peopleManager," and its industries field has been expanded to include "saas," "eCommerce," and "other." New templates such as longTermRetentionCheckIn, professionalDevelopmentGrowth, recognitionAndReward, alignmentAndEngagement, and supportiveWorkCulture have been added, each designed to assess various aspects of employee engagement and satisfaction while maintaining a consistent structure for feedback collection.

Changes

File Path Change Summary
packages/lib/templates.ts - Updated employeeWellBeing template's role to "peopleManager" and expanded industries field to include "saas," "eCommerce," and "other".
- Added new templates: longTermRetentionCheckIn, professionalDevelopmentGrowth, recognitionAndReward, alignmentAndEngagement, and supportiveWorkCulture.
packages/types/templates.ts - Updated ZTemplateRole enum to include "peopleManager" as a valid role.
packages/ui/components/TemplateList/components/TemplateTags.tsx - Updated getRoleBasedStyling function to support the "peopleManager" role.
packages/ui/components/TemplateList/lib/utils.ts - Updated roleMapping to include { value: "peopleManager", label: "People Manager" }.

Possibly related PRs

Suggested labels

🕹️ 300 points

Suggested reviewers

  • jobenjada

🐇 In the meadow, we hop with glee,
New templates sprout, as bright as can be!
For growth and rewards, we gather 'round,
Engaging our team, with joy profound.
With every question, insights will flow,
In this garden of feedback, watch our spirits grow! 🌼


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2024

Thank you for following the naming conventions for pull request titles! 🙏

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f56f08e and 5e6c29a.

📒 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 suggestion

Consider 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 categories

The 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.

Comment on lines +5651 to +5654
professionalDevelopmentGrowth(),
recognitionAndReward(),
alignmentAndEngagement(),
supportiveWorkCulture(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ 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.

@mattinannt mattinannt requested a review from jobenjada October 25, 2024 05:10
@jobenjada
Copy link
Member

jobenjada commented Oct 25, 2024

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 jobenjada added 🕹️ oss.gg Community issue via oss.gg hacktoberfest complete these issues to gather points for Hacktoberfest 🕹️ 750 points labels Oct 26, 2024
@jonas-hoebenreich
Copy link
Contributor Author

@jobenjada, sure I can add "People Manager". Do you want me to add this to the on boarding as well?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 category

The file is growing quite large with many templates. Consider refactoring to:

  1. Split templates into separate files by category (e.g., HR templates, customer feedback templates, etc.)
  2. Create an index file to export all templates
  3. 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

📥 Commits

Files that changed from the base of the PR and between 5e6c29a and ee08764.

📒 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 templates array, maintaining consistency with the existing pattern.

@jonas-hoebenreich
Copy link
Contributor Author

@jobenjada
I've added the role :)

image

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Consider moving the role-color mappings to a centralized theme configuration. This would make it easier to maintain consistent styling across the application.
  2. 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

📥 Commits

Files that changed from the base of the PR and between ee08764 and 0f258aa.

📒 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:

  1. Found a switch statement in TemplateTags.tsx that handles role-based styling but doesn't include the new "peopleManager" role
  2. Found roleMapping in utils.ts that already includes "peopleManager" with proper label
  3. 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:

  1. The getRoleBasedStyling switch statement includes the "peopleManager" case with appropriate styling
  2. The roleMapping in utils.ts (from previous results) already includes the "peopleManager" with proper label
  3. 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.tsx

Length of output: 122


Script:

#!/bin/bash
# Get the complete file content to analyze the switch statement
cat packages/ui/components/TemplateList/components/TemplateTags.tsx

Length 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 peopleManager role is properly defined in the ZTemplateRole enum in packages/types/templates.ts
  • The role is actively used in multiple templates in packages/lib/templates.ts for 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"
fi

Length 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
fi

Length 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 ZTemplateRole in packages/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.ts

Length of output: 1996

packages/lib/templates.ts (4)

1956-1957: LGTM: Role updates align with template purpose

The 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 template

The 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-designed

The 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 correct

The new templates have been properly added to the templates array export, maintaining the existing structure and organization.

Copy link
Member

@jobenjada jobenjada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool, thanks :)

@jobenjada jobenjada enabled auto-merge October 31, 2024 03:02
@jobenjada jobenjada added this pull request to the merge queue Oct 31, 2024
Merged via the queue into formbricks:main with commit 280a9a4 Oct 31, 2024
@oss-gg
Copy link

oss-gg bot commented Oct 31, 2024

Awarding jonas-hoebenreich: 750 points 🕹️ Well done! Check out your new contribution on oss.gg/jonas-hoebenreich

@coderabbitai coderabbitai bot mentioned this pull request Nov 4, 2024
12 tasks
@coderabbitai coderabbitai bot mentioned this pull request Nov 13, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest complete these issues to gather points for Hacktoberfest 🕹️ oss.gg Community issue via oss.gg 🕹️ 750 points

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants