Skip to content

feat: add multi-org domain tracking #40938

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

Merged
merged 5 commits into from
Jun 16, 2025
Merged

Conversation

jacquesikot
Copy link
Contributor

@jacquesikot jacquesikot commented Jun 15, 2025

🏢 Multi-Org Domain Tracking System

🎯 Problem Statement

Users with access to multiple Appsmith organizations often forget the exact domain names of their different workspaces (e.g., company1.appsmith.com, team2.appsmith.com). This creates friction during login as users need to remember or guess the specific subdomain for each organization they belong to.

✨ Solution Overview

This PR implements a lightweight domain tracking system that remembers the organization domains users have successfully accessed in the last 30 days. When users visit login.appsmith.com or signup pages, they can see and quickly navigate to their recently visited organizations.

🏗️ Technical Approach

Why Cookies Over localStorage?

We chose cookies with .appsmith.com domain over localStorage for the following critical reasons:

Feature Cookies localStorage Winner
Cross-subdomain access .appsmith.com ❌ Origin-specific 🍪 Cookies
Built-in expiration ✅ 30-day TTL ❌ Manual cleanup 🍪 Cookies
Storage requirements ✅ Small domains only ✅ Large capacity 🤝 Both adequate
Browser support ✅ Universal ✅ Universal 🤝 Both good

🛠️ Implementation Details

Core Utility (utils/multiOrgDomains.ts)

// Key configuration:
const COOKIE_NAME = "appsmith_recent_domains";
const EXPIRY_DAYS = 30;
const MAX_DOMAINS = 10;

interface DomainEntry {
  domain: string;      // e.g., "company.appsmith.com"
  timestamp: number;   // Unix timestamp
}

📊 Domain Tracking Logic

  • ⏰ When: Automatically triggered when users successfully reach /applications page
  • 📝 What: Current domain (e.g., company.appsmith.com) + timestamp
  • 🔍 Filtering: Only tracks multi-org domains (excludes login.appsmith.com)
  • 🔄 Deduplication: Prevents duplicate entries, moves existing domains to top

Automation

/ok-to-test tags="@tag.Authentication, @tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/15676451597
Commit: 935ccef
Cypress dashboard.
Tags: @tag.Authentication, @tag.Sanity
Spec:


Mon, 16 Jun 2025 09:43:36 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Introduced tracking and display of recently visited organization domains for users, allowing quick access to previously signed-in organizations.
    • Added a section in the sign-up page to show recent domains with organization names and direct login options.
  • Enhancements
    • Improved messaging related to user sign-in and account status.
    • Enabled multi-organization domain tracking on the applications page for better domain management.
  • Chores
    • Updated internal messaging constants for consistency and future use.

@jacquesikot jacquesikot requested a review from trishaanand June 15, 2025 21:04
@jacquesikot jacquesikot self-assigned this Jun 15, 2025
@jacquesikot jacquesikot added the ok-to-test Required label for CI label Jun 15, 2025
Copy link
Contributor

coderabbitai bot commented Jun 15, 2025

Walkthrough

This update introduces a cookie-based mechanism for tracking recently visited multi-organization domains, integrates recent domain suggestions into the sign-up page, and updates UI constants for sign-in messaging. The Applications page now tracks the current domain on mount. No existing exports or logic were removed or modified.

Changes

File(s) Change Summary
app/client/src/ce/constants/messages.ts Added two new exported message constants for UI: USING_APPSMITH and YOU_VE_ALREADY_SIGNED_INTO.
app/client/src/ce/pages/Applications/index.tsx Imported and invoked trackCurrentDomain() in componentDidMount to enable domain tracking.
app/client/src/pages/UserAuth/SignUp.tsx Enhanced sign-up page to display recent domains and updated footer logic for cloud billing scenarios.
app/client/src/utils/multiOrgDomains.ts New module for tracking, retrieving, and clearing recent multi-org domains using cookies; exposes four new utility functions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SignUpPage
    participant multiOrgDomainsUtils

    User->>SignUpPage: Loads SignUp page
    SignUpPage->>multiOrgDomainsUtils: getRecentDomains()
    multiOrgDomainsUtils-->>SignUpPage: Returns recent domains list
    SignUpPage-->>User: Displays recent domains section (if applicable)
    User->>SignUpPage: Clicks "Open" on a domain
    SignUpPage->>User: Redirects to selected domain's login page
Loading
sequenceDiagram
    participant ApplicationsPage
    participant multiOrgDomainsUtils

    ApplicationsPage->>multiOrgDomainsUtils: trackCurrentDomain()
    multiOrgDomainsUtils->>multiOrgDomainsUtils: Update recent domains cookie
Loading

Suggested reviewers

  • ankitakinger
  • trishaanand

Poem

Domains remembered, cookies set,
Recent orgs you won’t forget.
A sign-up page with friendly flair,
Suggestions waiting for you there.
With every click, a journey anew—
Appsmith tracks, just for you!
🍪✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57f216d and 935ccef.

📒 Files selected for processing (1)
  • app/client/src/pages/UserAuth/SignUp.tsx (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/pages/UserAuth/SignUp.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-unit-tests / client-unit-tests
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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 github-actions bot added the Enhancement New feature or request label Jun 15, 2025
@jacquesikot jacquesikot requested a review from ankitakinger June 15, 2025 21:04
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

🔭 Outside diff range comments (1)
app/client/src/pages/UserAuth/SignUp.tsx (1)

69-80: ⚠️ Potential issue

Defer getRecentDomains() until after module load

getRecentDomains() touches window/document at module top-level.
This breaks when the file is required in a non-browser context (SSR, Jest without JSDOM) and also freezes the list for the entire lifetime of the bundle.

-const recentDomains = getRecentDomains();
+// inside the component so that `window` is guaranteed to exist
+const recentDomains = useMemo(() => getRecentDomains(), []);

Place it right after the other React hooks in SignUp.

🧹 Nitpick comments (2)
app/client/src/ce/constants/messages.ts (1)

90-91: Check trailing space/punctuation for multi-org login messages.
YOU_VE_ALREADY_SIGNED_INTO returns "You've already signed into" without a trailing space or punctuation. When appending domain names, this could lead to text like You've already signed intomyorg.com. Consider including a space or colon at the end:

-export const YOU_VE_ALREADY_SIGNED_INTO = () => `You've already signed into`;
+export const YOU_VE_ALREADY_SIGNED_INTO = () => `You've already signed into: `;
app/client/src/pages/UserAuth/SignUp.tsx (1)

253-265: Minor: inline tailwind-style string escapes are noisy

The literal text-[color:var(--ads-v2\-color-fg)] class works, but the escaped backslash breaks readability and is easy to mistype.
Consider extracting a CSS module or styled-component instead.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dea1c03 and 6b079f1.

📒 Files selected for processing (4)
  • app/client/src/ce/constants/messages.ts (1 hunks)
  • app/client/src/ce/pages/Applications/index.tsx (2 hunks)
  • app/client/src/pages/UserAuth/SignUp.tsx (7 hunks)
  • app/client/src/utils/multiOrgDomains.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
app/client/src/ce/pages/Applications/index.tsx (1)
app/client/src/utils/multiOrgDomains.ts (1)
  • trackCurrentDomain (55-78)
app/client/src/pages/UserAuth/SignUp.tsx (5)
app/client/src/utils/multiOrgDomains.ts (1)
  • getRecentDomains (80-89)
app/client/packages/design-system/widgets/src/components/Text/src/Text.tsx (1)
  • Text (66-66)
app/client/src/ce/constants/messages.ts (6)
  • YOU_VE_ALREADY_SIGNED_INTO (91-91)
  • USING_APPSMITH (90-90)
  • SIGN_IN_TO_AN_EXISTING_ORGANISATION (92-93)
  • ALREADY_HAVE_AN_ACCOUNT (86-86)
  • SIGNUP_PAGE_LOGIN_LINK_TEXT (83-83)
  • SIGNUP_PAGE_TITLE (74-74)
app/client/packages/design-system/widgets/src/components/Button/src/Button.tsx (1)
  • Button (86-86)
app/client/src/constants/routes/baseRoutes.ts (2)
  • ORG_LOGIN_PATH (32-32)
  • AUTH_LOGIN_URL (25-25)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (3)
app/client/src/utils/multiOrgDomains.ts (2)

36-43: Consider adding the Secure attribute when possible

The cookie is always scoped to .appsmith.com and marked SameSite=Lax, which is great.
However, it is never marked Secure, so it will also be sent over plain-HTTP connections if such endpoints ever exist. That weakens the protection we gain from SameSite.

-  document.cookie = `${COOKIE_NAME}=${cookieValue}; expires=${expires.toUTCString()}; domain=.appsmith.com; path=/; SameSite=Lax`;
+  const secure = window.location.protocol === "https:" ? "; Secure" : "";
+  document.cookie = `${COOKIE_NAME}=${cookieValue}; expires=${expires.toUTCString()}; domain=.appsmith.com; path=/; SameSite=Lax${secure}`;

(Bump the same flag in clearRecentDomains() for symmetry.)
[ suggest_essential_refactor ]


55-78: Filter expired entries before enforcing MAX_DOMAINS

domains.slice(0, MAX_DOMAINS) is executed before the 30-day expiry filter.
If the top N items are stale, the final list can end up shorter than intended and the fresh entry might be pushed out.

-  domains = domains.slice(0, MAX_DOMAINS);
-
-  const thirtyDaysAgo = currentTime - 30 * 24 * 60 * 60 * 1000;
-  domains = domains.filter((entry) => entry.timestamp > thirtyDaysAgo);
+  const THIRTY_DAYS_MS = EXPIRY_DAYS * 24 * 60 * 60 * 1000;
+
+  // prune old entries first
+  domains = domains.filter(
+    (entry) => currentTime - entry.timestamp < THIRTY_DAYS_MS,
+  );
+
+  // then cap the list length
+  domains = domains.slice(0, MAX_DOMAINS);

This keeps the list dense with live domains and avoids an unnecessary cookie write churn.
[ suggest_optional_refactor ]

app/client/src/ce/pages/Applications/index.tsx (1)

143-156: Import + invocation look good

trackCurrentDomain() is imported once and invoked inside componentDidMount, guaranteeing a single write per page visit – fits the intended tracking cadence.
No further action required.

@jacquesikot
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/15672926050.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 40938.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-40938.dp.appsmith.com

@jacquesikot jacquesikot merged commit a93521b into release Jun 16, 2025
45 checks passed
@jacquesikot jacquesikot deleted the feat/muti-org-domain-persist branch June 16, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants