Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic company logo fetching during workspace creation #9158

Merged
merged 7 commits into from
Dec 22, 2024

Conversation

samyakpiya
Copy link
Contributor

Closes #9151

Description

This PR automatically sets a workspace's logo based on the user's work email domain during signup. When a user creates a new workspace using their work email (e.g., @airbnb.com), the system will fetch and set their company logo from twenty-icons.com as the default workspace logo.

Implementation Details

  • Added a new CompanyEnrichmentService to handle company-related data enrichment
  • Created a modular architecture that supports future enrichment features (e.g., company name, details)
  • Integrated with existing work email detection
  • Maintains user ability to override the logo later

Testing

twenty-9151.mp4

I tested the following scenarios:

  • Signing up with a work email (e.g., @company.com) → Logo is automatically set
  • Signing up with a personal email (e.g., @gmail.com) → No logo is set
  • User can still upload a custom logo after automatic setting

Technical Notes

  • Uses existing isWorkEmail utility
  • Structured for future extensibility (additional company data enrichment)
  • No breaking changes to existing functionality

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR introduces automatic company logo fetching during workspace creation by integrating a new CompanyEnrichmentService that uses twenty-icons.com to fetch logos based on work email domains.

  • Added new CompanyEnrichmentService in /packages/twenty-server/src/engine/core-modules/company-enrichment/company-enrichment.service.ts with extensible architecture for future enrichment features
  • Integrated logo fetching in SignInUpService.signUpOnNewWorkspace() to automatically set workspace logos during creation
  • Service uses existing isWorkEmail utility to validate work domains before fetching logos
  • Added placeholder for future company data enrichment methods in CompanyEnrichmentService
  • Service follows twenty-icons.com URL pattern: https://twenty-icons.com/{domain}

💡 (2/5) Greptile learns from your feedback when you react with 👍/👎!

4 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 15 to 17
const domain = getDomainNameByEmail(email);

return `${this.TWENTY_ICONS_BASE_URL}/${domain}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: No error handling if domain extraction fails. Should wrap in try/catch to handle potential errors from getDomainNameByEmail.


const domain = getDomainNameByEmail(email);

return `${this.TWENTY_ICONS_BASE_URL}/${domain}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: URL should be URI encoded to handle special characters in domain names.

Comment on lines 338 to 339
const logoUrl =
await this.companyEnrichmentService.getCompanyLogoUrl(email);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: consider adding error handling here in case the logo fetch fails to prevent workspace creation from failing

Copy link

github-actions bot commented Dec 19, 2024

Fails
🚫

node failed.

Log

�[31mError: �[39m RequestError [HttpError]: You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 881F:34C3ED:1402D726:27CA728C:6767CCF5.
    at /home/runner/work/twenty/twenty/node_modules/�[4m@octokit�[24m/request/dist-node/index.js:86:21
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m {
  status: �[33m403�[39m,
  response: {
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Asamyakpiya%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    status: �[33m403�[39m,
    headers: {
      �[32m'access-control-allow-origin'�[39m: �[32m'*'�[39m,
      �[32m'access-control-expose-headers'�[39m: �[32m'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'�[39m,
      connection: �[32m'close'�[39m,
      �[32m'content-encoding'�[39m: �[32m'gzip'�[39m,
      �[32m'content-security-policy'�[39m: �[32m"default-src 'none'"�[39m,
      �[32m'content-type'�[39m: �[32m'application/json; charset=utf-8'�[39m,
      date: �[32m'Sun, 22 Dec 2024 08:25:25 GMT'�[39m,
      �[32m'referrer-policy'�[39m: �[32m'origin-when-cross-origin, strict-origin-when-cross-origin'�[39m,
      server: �[32m'github.com'�[39m,
      �[32m'strict-transport-security'�[39m: �[32m'max-age=31536000; includeSubdomains; preload'�[39m,
      �[32m'transfer-encoding'�[39m: �[32m'chunked'�[39m,
      vary: �[32m'Accept-Encoding, Accept, X-Requested-With'�[39m,
      �[32m'x-content-type-options'�[39m: �[32m'nosniff'�[39m,
      �[32m'x-frame-options'�[39m: �[32m'deny'�[39m,
      �[32m'x-github-api-version-selected'�[39m: �[32m'2022-11-28'�[39m,
      �[32m'x-github-media-type'�[39m: �[32m'github.v3; format=json'�[39m,
      �[32m'x-github-request-id'�[39m: �[32m'881F:34C3ED:1402D726:27CA728C:6767CCF5'�[39m,
      �[32m'x-ratelimit-limit'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-remaining'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-reset'�[39m: �[32m'1734855985'�[39m,
      �[32m'x-ratelimit-resource'�[39m: �[32m'search'�[39m,
      �[32m'x-ratelimit-used'�[39m: �[32m'1'�[39m,
      �[32m'x-xss-protection'�[39m: �[32m'0'�[39m
    },
    data: {
      documentation_url: �[32m'https://docs.github.com/free-pro-team@latest/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits'�[39m,
      message: �[32m'You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 881F:34C3ED:1402D726:27CA728C:6767CCF5.'�[39m
    }
  },
  request: {
    method: �[32m'GET'�[39m,
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Asamyakpiya%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    headers: {
      accept: �[32m'application/vnd.github.v3+json'�[39m,
      �[32m'user-agent'�[39m: �[32m'octokit-rest.js/18.12.0 octokit-core.js/3.6.0 Node.js/18.20.5 (linux; x64)'�[39m,
      authorization: �[32m'token [REDACTED]'�[39m
    },
    request: { hook: �[36m[Function: bound bound register]�[39m }
  }
}
danger-results://tmp/danger-results-8d190f85.json

Generated by 🚫 dangerJS against 3c1c7f0

@FelixMalfait
Copy link
Member

Hey, this is a great PR. What you did was perfectly in line with the initial issue, but I kind of changed my mind halfway while reviewing your code. It might be over-engineering to introduce this enrichment service now and therefore I removed the company service to simplify things

@samyakpiya
Copy link
Contributor Author

Thanks for the review @FelixMalfait! I understand the decision to simplify the implementation. I've tested your simplified version and confirmed the logo appears correctly during sign-up.

Is there anything else needed from my side, or is this ready to be merged?

Let me know if there's anything else you'd like me to help with! 👍

@FelixMalfait
Copy link
Member

Thanks for testing it again @samyakpiya

Feel free to DM me on Discord, happy to point you to different things we're working on!

Copy link
Member

@FelixMalfait FelixMalfait left a comment

Choose a reason for hiding this comment

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

Great work!

@samyakpiya
Copy link
Contributor Author

Thanks Felix! Really enjoyed working on this feature. I've sent you a DM on Discord to discuss other areas where I can contribute. Looking forward to working on more issues! 🚀

@FelixMalfait FelixMalfait merged commit 2651379 into twentyhq:main Dec 22, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Load logo automatically during workspace
2 participants