-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/renaming api name #5
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
Conversation
WalkthroughThe changes involve a comprehensive renaming of event handler properties and public methods in the Tawk Messenger component and service, as well as updates to the API documentation. The Changes
Poem
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
npm error Exit handler never called! ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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 (5)
addon/services/tawk-messenger.js (1)
Line range hint
1-113: Overall assessment: Changes successfully address the PR objective with one minor inconsistency.The changes in this file successfully address the PR objective of adding the "tawk" prefix to all API names to prevent naming collisions. All methods have been renamed consistently, with the exception of
tawkvisitorwhich should betawkVisitorfor consistency.These changes introduce breaking changes to the API, as all method names have been modified. Please ensure that:
- The changelog is updated to reflect these breaking changes.
- The documentation is updated to reflect the new method names.
- Any code that uses these methods is updated accordingly.
To minimize the impact of these breaking changes, consider:
- Implementing a deprecation strategy where both old and new method names are supported for a transition period.
- Providing a migration guide for users of the library.
- Bumping the major version number of the package to indicate breaking changes, following semantic versioning principles.
addon/components/tawk-messenger.js (1)
Line range hint
1-183: Summary: Comprehensive API renaming implemented successfully.The changes in this file successfully implement the PR objective of adding the "tawk" prefix to all event handler properties in the TawkMessengerComponent. This renaming enhances the API's uniqueness and mitigates the risk of naming collisions.
Key points:
- All event handler properties have been consistently renamed.
- The changes align with the PR objectives and are applied uniformly throughout the file.
- These modifications introduce breaking changes that will require updates in the application code.
Recommendations:
- Update the changelog to clearly communicate these breaking changes to users of the library.
- Provide migration guidelines in the documentation to assist users in updating their code.
- Consider bumping the major version number of the package to signal the breaking changes.
- Run the provided verification scripts across the entire codebase to ensure all usages of the old property names are updated.
- Update any relevant documentation, examples, or test cases that may be using the old property names.
By following these recommendations, you can ensure a smooth transition to the new API naming convention while minimizing potential issues for users of the library.
docs/api-reference.md (3)
Line range hint
443-455: Minor improvement suggestion fortawkVisitorexplanation.The renaming of
visitortotawkVisitoris consistent with the overall strategy. However, to improve clarity, consider updating the first sentence of the explanation:-Object used to set the visitor name and email. +Object used to set the visitor name and email for the tawk.to chat widget.This change provides more context about the purpose of the
tawkVisitorobject.🧰 Tools
🪛 LanguageTool
[uncategorized] ~448-~448: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...ail will not be available on load time (eg single page app, ajax login), then use ...(E_G)
🪛 Markdownlint
448-448: null
Link fragments should be valid(MD051, link-fragments)
367-368: Improve gender-neutral language.To make the documentation more inclusive, consider updating the following sentence:
-Callback function invoked when the visitor manually changes his name. +Callback function invoked when the visitor manually changes their name.This change uses gender-neutral language, which is more appropriate for a general audience.
🧰 Tools
🪛 LanguageTool
[style] ~368-~368: Since a “visitor” is neither male nor female, the better pronoun might be “their”.
Context: ...voked when the visitor manually changes his name. The visitorName is passed to the ...(SOMEBODY_NEUTRAL)
448-448: Correct abbreviation usage.Please update the following text to use the correct abbreviation format:
-If the name and email will not be available on load time (eg single page app, ajax login), then use the [setAttributes](#setAttributes) function instead. +If the name and email will not be available on load time (e.g., single page app, ajax login), then use the [setAttributes](#setAttributes) function instead.This change ensures proper usage of the abbreviation "e.g." (exempli gratia).
🧰 Tools
🪛 LanguageTool
[uncategorized] ~448-~448: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...ail will not be available on load time (eg single page app, ajax login), then use ...(E_G)
🪛 Markdownlint
448-448: null
Link fragments should be valid(MD051, link-fragments)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- addon/components/tawk-messenger.js (1 hunks)
- addon/services/tawk-messenger.js (1 hunks)
- docs/api-reference.md (32 hunks)
🧰 Additional context used
🪛 LanguageTool
docs/api-reference.md
[style] ~368-~368: Since a “visitor” is neither male nor female, the better pronoun might be “their”.
Context: ...voked when the visitor manually changes his name. The visitorName is passed to the ...(SOMEBODY_NEUTRAL)
[uncategorized] ~448-~448: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...ail will not be available on load time (eg single page app, ajax login), then use ...(E_G)
🪛 Markdownlint
docs/api-reference.md
448-448: null
Link fragments should be valid(MD051, link-fragments)
🔇 Additional comments (28)
addon/services/tawk-messenger.js (22)
16-18: LGTM: Method renamed correctly.The method has been renamed from
maximizetotawkMaximize, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
20-22: LGTM: Method renamed correctly.The method has been renamed from
minimizetotawkMinimize, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
24-26: LGTM: Method renamed correctly.The method has been renamed from
toggletotawkToggle, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
28-30: LGTM: Method renamed correctly.The method has been renamed from
popuptotawkPopup, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
32-34: LGTM: Method renamed correctly.The method has been renamed from
showWidgettotawkShowWidget, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
36-38: LGTM: Method renamed correctly.The method has been renamed from
hideWidgettotawkHideWidget, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
40-42: LGTM: Method renamed correctly.The method has been renamed from
toggleVisibilitytotawkToggleVisibility, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
44-46: LGTM: Method renamed correctly.The method has been renamed from
endChattotawkEndChat, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
51-53: LGTM: Method renamed correctly.The method has been renamed from
getWindowTypetotawkGetWindowType, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
55-57: LGTM: Method renamed correctly.The method has been renamed from
getStatustotawkGetStatus, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
59-61: LGTM: Method renamed correctly.The method has been renamed from
isChatMaximizedtotawkIsChatMaximized, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
63-65: LGTM: Method renamed correctly.The method has been renamed from
isChatMinimizedtotawkIsChatMinimized, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
67-69: LGTM: Method renamed correctly.The method has been renamed from
isChatHiddentotawkIsChatHidden, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
71-73: LGTM: Method renamed correctly.The method has been renamed from
isChatOngoingtotawkIsChatOngoing, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
75-77: LGTM: Method renamed correctly.The method has been renamed from
isVisitorEngagedtotawkIsVisitorEngaged, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
79-81: LGTM: Method renamed correctly.The method has been renamed from
onLoadedtotawkOnLoaded, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
83-85: LGTM: Method renamed correctly.The method has been renamed from
onBeforeLoadedtotawkOnBeforeLoaded, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
87-89: LGTM: Method renamed correctly.The method has been renamed from
widgetPositiontotawkWidgetPosition, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
98-100: LGTM: Method renamed correctly.The method has been renamed from
setAttributestotawkSetAttributes, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
102-104: LGTM: Method renamed correctly.The method has been renamed from
addEventtotawkAddEvent, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
106-108: LGTM: Method renamed correctly.The method has been renamed from
addTagstotawkAddTags, which is consistent with the PR objective of adding the "tawk" prefix to all API names.
110-112: LGTM: Method renamed correctly.The method has been renamed from
removeTagstotawkRemoveTags, which is consistent with the PR objective of adding the "tawk" prefix to all API names.addon/components/tawk-messenger.js (3)
70-71: Approved: Consistent renaming of event handler.The renaming of
onStatusChangetotawkOnStatusChangeis consistent with the previous change and aligns with the PR objective.As mentioned in the previous comment, this is a breaking change. Please ensure that all usages of this component in the application are updated accordingly.
76-179: Approved: Consistent renaming of all event handlers.All event handler properties have been consistently renamed by adding the "tawk" prefix, which aligns with the PR objective. This includes:
onBeforeLoadtotawkOnBeforeLoadonChatMaximizedtotawkOnChatMaximizedonChatMinimizedtotawkOnChatMinimizedonChatHiddentotawkOnChatHiddenonChatStartedtotawkOnChatStartedonChatEndedtotawkOnChatEndedonPrechatSubmittotawkOnPrechatSubmitonOfflineSubmittotawkOnOfflineSubmitonChatMessageVisitortotawkOnChatMessageVisitoronChatMessageAgenttotawkOnChatMessageAgentonChatMessageSystemtotawkOnChatMessageSystemonAgentJoinChattotawkOnAgentJoinChatonAgentLeaveChattotawkOnAgentLeaveChatonChatSatisfactiontotawkOnChatSatisfactiononVisitorNameChangedtotawkOnVisitorNameChangedonFileUploadtotawkOnFileUploadonTagsUpdatedtotawkOnTagsUpdatedonUnreadCountChangedtotawkOnUnreadCountChangedThese changes enhance the uniqueness of the API and help prevent potential naming collisions.
As these are breaking changes, it's crucial to update all usages of this component in the application. Run the following script to check for any remaining usages of the old property names:
#!/bin/bash # Search for any remaining usage of the old property names old_properties=( "onBeforeLoad" "onChatMaximized" "onChatMinimized" "onChatHidden" "onChatStarted" "onChatEnded" "onPrechatSubmit" "onOfflineSubmit" "onChatMessageVisitor" "onChatMessageAgent" "onChatMessageSystem" "onAgentJoinChat" "onAgentLeaveChat" "onChatSatisfaction" "onVisitorNameChanged" "onFileUpload" "onTagsUpdated" "onUnreadCountChanged" ) for prop in "${old_properties[@]}"; do echo "Searching for usage of $prop:" rg --type=handlebars --type=javascript "$prop=[{]" -g '!addon/components/tawk-messenger.js' echo doneThis script will help identify any instances where the old property names are still being used, allowing for a comprehensive update of the application code.
64-65: Approved: Event handler renamed as per PR objective.The renaming of
onLoadtotawkOnLoadaligns with the PR objective of adding the "tawk" prefix to API names. This change enhances the uniqueness of the API and helps prevent potential naming collisions.Please note that this is a breaking change. Ensure that all usages of this component in the application are updated accordingly. Run the following script to check for any remaining usages of the old property name:
✅ Verification successful
Verified: All old event handler properties have been successfully renamed.
The search confirmed that there are no remaining usages of the old property names in the codebase. This ensures that the renaming from properties like
onLoadtotawkOnLoadhas been thoroughly applied without leaving any legacy references.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any remaining usage of the old 'onLoad' property rg --type=handlebars --type=javascript 'onLoad=[{]' -g '!addon/components/tawk-messenger.js'Length of output: 5292
Script:
#!/bin/bash # Search for any remaining usage of old properties in JavaScript and Handlebars files old_properties=("onBeforeLoad" "onChatMaximized" "onChatMinimized" "onChatHidden" "onChatStarted" "onChatEnded" "onPrechatSubmit" "onOfflineSubmit" "onChatMessageVisitor" "onChatMessageAgent" "onChatMessageSystem" "onAgentJoinChat" "onAgentLeaveChat" "onChatSatisfaction" "onVisitorNameChanged" "onFileUpload" "onTagsUpdated" "onUnreadCountChanged") for prop in "${old_properties[@]}" do echo "Searching for usage of $prop:" rg "$prop=" -g '*.hbs' -g '*.js' -g '!addon/components/tawk-messenger.js' echo doneLength of output: 4302
Script:
#!/bin/bash # Search for any remaining usage of old properties in JavaScript and Handlebars files without exclusions old_properties=("onBeforeLoad" "onChatMaximized" "onChatMinimized" "onChatHidden" "onChatStarted" "onChatEnded" "onPrechatSubmit" "onOfflineSubmit" "onChatMessageVisitor" "onChatMessageAgent" "onChatMessageSystem" "onAgentJoinChat" "onAgentLeaveChat" "onChatSatisfaction" "onVisitorNameChanged" "onFileUpload" "onTagsUpdated" "onUnreadCountChanged") for prop in "${old_properties[@]}" do echo "Searching for usage of $prop:" rg "$prop=" -g '*.hbs' -g '*.js' echo doneLength of output: 3564
docs/api-reference.md (3)
13-55: Table of contents updated correctly.The table of contents has been consistently updated with the new "tawk" prefix for all method names. This change aligns well with the PR objective of renaming API methods to prevent collisions.
Line range hint
460-922: API methods consistently renamed and examples updated.All API methods have been correctly renamed with the "tawk" prefix, and the corresponding code examples have been updated to reflect these changes. This consistent renaming aligns with the PR objective and should help prevent naming collisions in the future.
Line range hint
936-941: Secure mode example correctly updated.The
tawkVisitorobject is correctly used in the secure mode example, maintaining consistency with the renamed API.
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 (3)
addon/components/tawk-messenger.js(1 hunks)addon/services/tawk-messenger.js(1 hunks)docs/api-reference.md(33 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- addon/components/tawk-messenger.js
- addon/services/tawk-messenger.js
🧰 Additional context used
🪛 LanguageTool
docs/api-reference.md
[uncategorized] ~296-~296: Possible missing article found.
Context: ...geSystem Callback function invoked when message is sent by the system. The message is p...
(AI_HYDRA_LEO_MISSING_A)
[style] ~372-~372: Since a “visitor” is neither male nor female, the better pronoun might be “their”.
Context: ...voked when the visitor manually changes his name. The visitorName is passed to the ...
(SOMEBODY_NEUTRAL)
[uncategorized] ~452-~452: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...ail will not be available on load time (eg single page app, ajax login), then use ...
(E_G)
[uncategorized] ~575-~575: Possible missing comma found.
Context: ...etWindowType Returns the current widget type whether it’s inline or embed. ```js th...
(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~783-~783: Possible missing article found.
Context: ...tawkWidgetPosition Returns a string for current position of the widget. ```js this.taw...
(AI_HYDRA_LEO_MISSING_THE)
🪛 markdownlint-cli2 (0.17.2)
docs/api-reference.md
452-452: Link fragments should be valid
null
(MD051, link-fragments)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Floating Dependencies
- GitHub Check: Tests
🔇 Additional comments (3)
docs/api-reference.md (3)
13-58: TOC Updated with 'tawk' Prefixes
The table of contents has been updated to prefix all API and event names with "tawk", matching the implementation changes. The link targets appear correctly normalized.
67-443: All component HBS examples have been consistently updated to use the@tawkOn*event bindings. No issues detected.🧰 Tools
🪛 LanguageTool
[uncategorized] ~296-~296: Possible missing article found.
Context: ...geSystem Callback function invoked when message is sent by the system. The message is p...(AI_HYDRA_LEO_MISSING_A)
[style] ~372-~372: Since a “visitor” is neither male nor female, the better pronoun might be “their”.
Context: ...voked when the visitor manually changes his name. The visitorName is passed to the ...(SOMEBODY_NEUTRAL)
455-973: All service usage examples (e.g.,tawkStart(),tawkShutdown(),tawkSetAttributes(), etc.) consistently reflect the new "tawk" prefix convention. No issues detected.🧰 Tools
🪛 LanguageTool
[uncategorized] ~575-~575: Possible missing comma found.
Context: ...etWindowType Returns the current widget type whether it’s inline or embed. ```js th...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~783-~783: Possible missing article found.
Context: ...tawkWidgetPosition Returns a string for current position of the widget. ```js this.taw...(AI_HYDRA_LEO_MISSING_THE)
[grammar] ~840-~840: Did you mean “lowed”, “lowered”?
Context: ... not alphanumeric or dash (keys will be lower case) 1. CONTAINS_INVALID_VALUE: Custom...(MUST_BE_DO)
[uncategorized] ~841-~841: Use a comma before “or” if it connects two independent clauses (unless they are closely connected and short).
Context: ...INS_INVALID_VALUE: Custom value is empty or the total length is more than 255 chara...(COMMA_COMPOUND_SENTENCE_2)
[style] ~841-~841: This phrasing could be wordy, so try replacing it with something more concise.
Context: ...stom value is empty or the total length is more than 255 characters ```js this.tawkMessenge...(MORE_THAN_EXCEEDS)
|
|
||
| Setting or changing the values after the widget script has been downloaded will not send the values to the dashboard. | ||
|
|
||
| If the name and email will not be available on load time (eg single page app, ajax login), then use the [setAttributes](#setAttributes) function instead. |
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.
🛠️ Refactor suggestion
Fix broken anchor link for setAttributes
The in-text reference [setAttributes](#setAttributes) does not match the actual section anchor, which should be #tawksetattributes. Please update it to [setAttributes](#tawksetattributes).
🧰 Tools
🪛 LanguageTool
[uncategorized] ~452-~452: The abbreviation “e.g.” (= for example) requires two periods.
Context: ...ail will not be available on load time (eg single page app, ajax login), then use ...
(E_G)
🪛 markdownlint-cli2 (0.17.2)
452-452: Link fragments should be valid
null
(MD051, link-fragments)
🤖 Prompt for AI Agents
In docs/api-reference.md at line 452, the anchor link for setAttributes is
incorrect as it uses #setAttributes instead of the correct #tawksetattributes.
Update the link to use [setAttributes](#tawksetattributes) to fix the broken
anchor reference.
Summary
There are users reported collision of provider keys since we use generic naming on our API. I added prefix tawk in all actions, getters, listeners, and setters.
Summary by CodeRabbit
New Features
Documentation