-
-
Notifications
You must be signed in to change notification settings - Fork 305
feat: add subscription and org details to Chatwoot support widget #3277
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds conditional logic in HelpMenu’s chat open flow to set Chatwoot widget attributes based on the user’s preferred organization and active cloud subscription, with defaults when absent, then toggles the widget. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant HelpMenu
participant Chatwoot as window.$chatwoot
User->>HelpMenu: Click "Help" / open chat
HelpMenu->>Chatwoot: initialize()
rect rgba(230, 245, 255, 0.5)
Note over HelpMenu: Prepare attributes
alt preferredOrganization exists
HelpMenu->>HelpMenu: Read activeCloudSubscription
HelpMenu->>Chatwoot: setAttributes({ plan, subscriptionStatus, organizationId, organizationName, enabledFeatures })
else no preferredOrganization
Note over HelpMenu: Use defaults (plan: "free", status: "inactive")
end
end
HelpMenu->>Chatwoot: toggle()
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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
Plan: Pro
📒 Files selected for processing (1)
webapp/src/component/HelpMenu.tsx
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (24)
- GitHub Check: E2E testing 🔎 (15, 12)
- GitHub Check: E2E testing 🔎 (15, 14)
- GitHub Check: E2E testing 🔎 (15, 9)
- GitHub Check: E2E testing 🔎 (15, 13)
- GitHub Check: E2E testing 🔎 (15, 11)
- GitHub Check: E2E testing 🔎 (15, 7)
- GitHub Check: E2E testing 🔎 (15, 10)
- GitHub Check: E2E testing 🔎 (15, 4)
- GitHub Check: E2E testing 🔎 (15, 6)
- GitHub Check: E2E testing 🔎 (15, 8)
- GitHub Check: E2E testing 🔎 (15, 3)
- GitHub Check: E2E testing 🔎 (15, 5)
- GitHub Check: E2E testing 🔎 (15, 0)
- GitHub Check: E2E testing 🔎 (15, 2)
- GitHub Check: E2E testing 🔎 (15, 1)
- GitHub Check: BT 🔎 (server-app:runWithoutEeTests)
- GitHub Check: BT 🔎 (data:test)
- GitHub Check: BT 🔎 (ktlint:test)
- GitHub Check: BT 🔎 (security:test)
- GitHub Check: BT 🔎 (server-app:runContextRecreatingTests)
- GitHub Check: BT 🔎 (server-app:runWebsocketTests)
- GitHub Check: BT 🔎 (server-app:runStandardTests)
- GitHub Check: BT 🔎 (ee-test:test)
- GitHub Check: Frontend static check 🪲
🔇 Additional comments (1)
webapp/src/component/HelpMenu.tsx (1)
129-139
: Implementation looks correct with appropriate fallbacks.The custom attributes are properly set with defensive fallbacks:
- Optional chaining prevents errors if
activeCloudSubscription
is undefined- Fallback values ('free', 'inactive') handle edge cases where support features exist but no active subscription is present
- Direct access to
enabledFeatures
is safe given the type guarantees (consistent with usage at lines 154, 157-158)The timing is correct—attributes are set after user initialization and before toggling the widget.
if (preferredOrganization) { | ||
const subscription = preferredOrganization.activeCloudSubscription; | ||
// @ts-ignore | ||
window.$chatwoot.setCustomAttributes({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this looks like potential issue when the $chatwoot
is not defined. I wouldn't use @ts-ignore
ignore here.
Also I would move this to separate hook usePrepareChatwootAttributes
. This component us already long enough.
Summary by CodeRabbit