-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat(web): Auto open livechat if query param present #17223
Conversation
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options. WalkthroughThe changes in this pull request modify the Changes
Possibly related PRs
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
Documentation and Community
|
Datadog ReportBranch report: ✅ 0 Failed, 84 Passed, 0 Skipped, 24.72s Total Time |
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
🧹 Outside diff range and nitpick comments (2)
apps/web/components/ChatPanel/LiveChatIncChatPanel/LiveChatIncChatPanel.tsx (2)
41-46
: Refactor complex condition for better readabilityThe current condition is complex and uses double negation. Consider extracting the logic into a more readable form.
- const queryParam = new URLSearchParams(window.location.search).get('wa_lid') - if ( - !hasButtonBeenClicked && - !showLauncher && - !(queryParam && ['t10', 't11'].includes(queryParam)) - ) { + const queryParam = new URLSearchParams(window.location.search).get('wa_lid') + const shouldAutoOpenChat = queryParam && ['t10', 't11'].includes(queryParam) + const shouldInitializeWidget = hasButtonBeenClicked || showLauncher || shouldAutoOpenChat + + if (!shouldInitializeWidget) {
41-46
: Add TypeScript type safety for query parameter valuesDefine a type for the allowed query parameter values to ensure type safety throughout the component.
+type AutoOpenQueryValue = 't10' | 't11' +const AUTO_OPEN_VALUES: AutoOpenQueryValue[] = ['t10', 't11'] + export const LiveChatIncChatPanel = ({ license, group, showLauncher, pushUp, }: LiveChatIncChatPanelProps) => {Then use these types in the condition:
- !(queryParam && ['t10', 't11'].includes(queryParam)) + !(queryParam && AUTO_OPEN_VALUES.includes(queryParam as AutoOpenQueryValue))
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/components/ChatPanel/LiveChatIncChatPanel/LiveChatIncChatPanel.tsx
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/web/components/ChatPanel/LiveChatIncChatPanel/LiveChatIncChatPanel.tsx (1)
Pattern apps/**/*
: "Confirm that the code adheres to the following:
- NextJS best practices, including file structure, API routes, and static generation methods.
- Efficient state management and server-side rendering techniques.
- Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (1)
apps/web/components/ChatPanel/LiveChatIncChatPanel/LiveChatIncChatPanel.tsx (1)
41-46
: Verify the query parameter handling
Let's verify that the query parameter handling works as expected across different pages and routing scenarios.
✅ Verification successful
Let me generate another script to check for the specific usage pattern and context around the wa_lid
parameter.
Query parameter handling is consistent and properly implemented
The verification shows that the wa_lid
parameter is consistently handled across chat components (LiveChatIncChatPanel and WatsonChatPanel) and is used as intended for specific chat functionality. The parameter is used to:
- Control chat visibility based on specific link IDs ('t10', 't11')
- Configure page link behavior in Watson chat
- Handle chat initialization in the Utlendingastofnun theme
The implementation in LiveChatIncChatPanel.tsx aligns with these established patterns and follows the same URL parameter handling approach used throughout the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistent query parameter handling across the codebase
# Check if the query parameter is used elsewhere
echo "Checking for other uses of wa_lid parameter:"
rg -l "wa_lid" --type ts --type tsx
# Check for other URL parameter handling patterns
echo "Checking for other URL parameter handling patterns:"
ast-grep --pattern 'new URLSearchParams($$$)'
Length of output: 16017
Script:
#!/bin/bash
# Check for the specific pattern of wa_lid usage with context
echo "Checking wa_lid usage patterns with context:"
rg "wa_lid" -B 2 -A 2 --type-add "tsx:*.tsx" --type tsx
# Check for any test files related to these components
echo -e "\nChecking for related test files:"
fd "LiveChatIncChatPanel|WatsonChatPanel" -e test.tsx -e spec.tsx
Length of output: 2582
apps/web/components/ChatPanel/LiveChatIncChatPanel/LiveChatIncChatPanel.tsx
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17223 +/- ##
=======================================
Coverage 35.74% 35.75%
=======================================
Files 6937 6935 -2
Lines 148167 148115 -52
Branches 42250 42236 -14
=======================================
- Hits 52969 52952 -17
+ Misses 95198 95163 -35
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 7 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Auto open livechat if query param present
What
For the IBM Watson web chat we've got a way so that it auto opens if wa_lid=t10|t11 is present in the url. Here we are adding similar functionality for livechat
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes