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

Fix/renaming api name #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Fix/renaming api name #5

wants to merge 3 commits into from

Conversation

jaoaustero
Copy link

@jaoaustero jaoaustero commented Oct 3, 2024

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.

This will lead to breaking changes since all APIs will be renamed, need to include in the changelog and update our application also

Summary by CodeRabbit

  • New Features

    • Enhanced naming convention for event handlers and methods in the Tawk Messenger component and service for improved clarity.
  • Documentation

    • Updated API documentation to reflect new method names, ensuring consistency and clarity for users. Example code snippets have also been revised to align with the new naming conventions.

@jaoaustero jaoaustero added the enhancement New feature or request label Oct 3, 2024
@jaoaustero jaoaustero self-assigned this Oct 3, 2024
Copy link

coderabbitai bot commented Oct 3, 2024

Walkthrough

The 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 TawkMessengerComponent class has updated event listener references to a new naming convention, while the TawkMessenger service has renamed its public methods to include a tawk prefix. The API documentation reflects these changes, ensuring consistency across the codebase and documentation without altering the underlying functionality.

Changes

File Change Summary
addon/components/tawk-messenger.js Renamed event listener properties in mapListeners method from this.args.on<Event> to this.args.tawkOn<Event> for various events (e.g., tawkLoad, tawkStatusChange, etc.). Constructor validates propertyId and widgetId, then calls load.
addon/services/tawk-messenger.js Renamed public methods to include tawk prefix (e.g., maximize() to tawkMaximize(), minimize() to tawkMinimize(), etc.).
docs/api-reference.md Updated API documentation to reflect the renaming of methods and properties to include tawk prefix (e.g., onLoad to tawkOnLoad, maximize to tawkMaximize, etc.). Example code snippets updated accordingly.

Poem

🐇 In the meadow where bunnies play,
Tawk's new names brighten the day.
With tawk prefix, clear and bright,
Our chats will now take flight!
Hopping along with joy and glee,
Consistency is the key! 🌼


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 62b9c1d and 798209c.

📒 Files selected for processing (1)
  • addon/services/tawk-messenger.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • addon/services/tawk-messenger.js

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

@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 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 tawkvisitor which should be tawkVisitor for consistency.

These changes introduce breaking changes to the API, as all method names have been modified. Please ensure that:

  1. The changelog is updated to reflect these breaking changes.
  2. The documentation is updated to reflect the new method names.
  3. Any code that uses these methods is updated accordingly.

To minimize the impact of these breaking changes, consider:

  1. Implementing a deprecation strategy where both old and new method names are supported for a transition period.
  2. Providing a migration guide for users of the library.
  3. 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:

  1. All event handler properties have been consistently renamed.
  2. The changes align with the PR objectives and are applied uniformly throughout the file.
  3. These modifications introduce breaking changes that will require updates in the application code.

Recommendations:

  1. Update the changelog to clearly communicate these breaking changes to users of the library.
  2. Provide migration guidelines in the documentation to assist users in updating their code.
  3. Consider bumping the major version number of the package to signal the breaking changes.
  4. Run the provided verification scripts across the entire codebase to ensure all usages of the old property names are updated.
  5. 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 for tawkVisitor explanation.

The renaming of visitor to tawkVisitor is 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 tawkVisitor object.

🧰 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

📥 Commits

Files that changed from the base of the PR and between 8e18f7e and 62b9c1d.

📒 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 maximize to tawkMaximize, 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 minimize to tawkMinimize, 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 toggle to tawkToggle, 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 popup to tawkPopup, 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 showWidget to tawkShowWidget, 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 hideWidget to tawkHideWidget, 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 toggleVisibility to tawkToggleVisibility, 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 endChat to tawkEndChat, 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 getWindowType to tawkGetWindowType, 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 getStatus to tawkGetStatus, 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 isChatMaximized to tawkIsChatMaximized, 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 isChatMinimized to tawkIsChatMinimized, 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 isChatHidden to tawkIsChatHidden, 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 isChatOngoing to tawkIsChatOngoing, 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 isVisitorEngaged to tawkIsVisitorEngaged, 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 onLoaded to tawkOnLoaded, 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 onBeforeLoaded to tawkOnBeforeLoaded, 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 widgetPosition to tawkWidgetPosition, 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 setAttributes to tawkSetAttributes, 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 addEvent to tawkAddEvent, 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 addTags to tawkAddTags, 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 removeTags to tawkRemoveTags, 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 onStatusChange to tawkOnStatusChange is 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:

  • onBeforeLoad to tawkOnBeforeLoad
  • onChatMaximized to tawkOnChatMaximized
  • onChatMinimized to tawkOnChatMinimized
  • onChatHidden to tawkOnChatHidden
  • onChatStarted to tawkOnChatStarted
  • onChatEnded to tawkOnChatEnded
  • onPrechatSubmit to tawkOnPrechatSubmit
  • onOfflineSubmit to tawkOnOfflineSubmit
  • onChatMessageVisitor to tawkOnChatMessageVisitor
  • onChatMessageAgent to tawkOnChatMessageAgent
  • onChatMessageSystem to tawkOnChatMessageSystem
  • onAgentJoinChat to tawkOnAgentJoinChat
  • onAgentLeaveChat to tawkOnAgentLeaveChat
  • onChatSatisfaction to tawkOnChatSatisfaction
  • onVisitorNameChanged to tawkOnVisitorNameChanged
  • onFileUpload to tawkOnFileUpload
  • onTagsUpdated to tawkOnTagsUpdated
  • onUnreadCountChanged to tawkOnUnreadCountChanged

These 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
done

This 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 onLoad to tawkOnLoad aligns 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 onLoad to tawkOnLoad has 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
done

Length 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
done

Length 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 tawkVisitor object is correctly used in the secure mode example, maintaining consistency with the renamed API.

addon/services/tawk-messenger.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants