-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat: add externalIds support for visitor identification #39535
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
Open
ricardogarim
wants to merge
41
commits into
develop
Choose a base branch
from
feat/whatsapp-usernames
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
986e803
feat: add IVisitorExternalIdentifier type for external visitor IDs
ricardogarim 303ece0
feat: add findOneByExternalId and addExternalId methods to LivechatVi…
ricardogarim 4203453
feat: add resolveVisitor for external ID lookup with progressive enri…
ricardogarim f386bbf
feat: add resolveVisitor method to ILivechatCreator
ricardogarim ca61b37
feat: display WhatsApp username alongside phone in contact info
ricardogarim bb87ace
eslint fix
ricardogarim 0c75e6b
chore: document createVisitor deprecation
ricardogarim 61b45f5
fix: change doResolveVisitor permission from read to write
ricardogarim 6b24b1f
fix: correct externalIds query and deduplication logic
ricardogarim b1faad2
refactor: change visitor externalIds from array to record structure
ricardogarim 7d79856
refactor: use findOneAndUpdate for phone lookup to save db roundtrip
ricardogarim 99da74e
add changeset
ricardogarim 3196fea
fix: prevent externalIds overwrite in registerGuest
ricardogarim 57ed43a
fix: bump core-typings and apps-engine to minor for new externalIds API
ricardogarim ed5c091
test: add E2E tests for resolveVisitor Apps-Engine API
ricardogarim ffe7c1c
feat: add ResolveVisitorContactData for flexible visitor lookup fallback
ricardogarim b51e47f
fix: narrow visitorDataToUpdate type for externalIds
ricardogarim b0c123c
changeset all to minor
d-gubert d65e2b5
clarifying comment on why we're using dot notation
d-gubert b2633e3
docs: add external-id-test app to test packages README
ricardogarim 5e2acdd
fix: correct external-id-test app package
ricardogarim 25163ab
chore: mongodb wildcard indexes are sparse by default
ricardogarim 9168409
feat: migrate externalIds to array format with compound index
ricardogarim 292fe8d
test: update zip test app
ricardogarim cde168b
chore: add sparse prop to index creation
ricardogarim a955367
refactor: simplify externalIds handling in registerGuest
ricardogarim 28ba4ed
chore: revert out-of-scope eslint auto-fix
ricardogarim 34d647c
refactor: add entityId field to IVisitorExternalIdentifier
ricardogarim 29b7cf9
refactor: add metadata field to IVisitorExternalIdentifier
ricardogarim 072831b
refactor: expose only updateExternalIds and findByEntityId methods
ricardogarim bb8aaba
refactor: rename externalId source field to appId
ricardogarim 7dbe67b
fix: make appId required on IVisitorExternalIdentifier
ricardogarim 74734cc
fix: exclude externalIds from ChatTranscript PDF
ricardogarim 54f3d2a
test: remove obsolete resolveVisitor tests
ricardogarim 8d29889
fix: ensure externalIds queries are DocumentDB compatible
ricardogarim a9f9ddd
chore: revert unrelated eslint auto-fix in livechat bridge
ricardogarim a684a25
fix: add missing core-typings dependency
ricardogarim 71acfcc
fix: skip type check for unserializable externalIds.metadata
ricardogarim 1783c26
fix: resolveVisitor test app and MongoDB collection name
ricardogarim 3b82c91
refactor: rename and simplify contact identifier in ContactField
ricardogarim 78df16b
fix: transform externalIds.metadata to match Serialized type in PDF w…
ricardogarim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| '@rocket.chat/model-typings': minor | ||
| '@rocket.chat/core-typings': minor | ||
| '@rocket.chat/apps-engine': minor | ||
| '@rocket.chat/omni-core': minor | ||
| '@rocket.chat/models': minor | ||
| '@rocket.chat/meteor': minor | ||
| --- | ||
|
|
||
| Adds externalIds field to livechat visitors for external platform identification. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import type { IVisitorExternalIdentifier, ILivechatVisitor } from '@rocket.chat/core-typings'; | ||
| import { LivechatVisitors } from '@rocket.chat/models'; | ||
|
|
||
| type ResolveVisitorContactData = { phone: string } | { email: string }; | ||
|
|
||
| type ResolveVisitorParams = { | ||
| appId: string; | ||
| externalId: Omit<IVisitorExternalIdentifier, 'appId'>; | ||
| contactData?: ResolveVisitorContactData; | ||
| }; | ||
|
|
||
| export async function resolveVisitor({ appId, externalId, contactData }: ResolveVisitorParams): Promise<ILivechatVisitor | null> { | ||
| const visitorByExternalId = await LivechatVisitors.findOneByExternalId(externalId.entityId); | ||
| if (visitorByExternalId) { | ||
| return visitorByExternalId; | ||
| } | ||
|
|
||
| if (contactData && (('phone' in contactData && contactData.phone) || ('email' in contactData && contactData.email))) { | ||
| return LivechatVisitors.findOneVisitorByPhoneOrEmailAndAddExternalId(contactData, appId, externalId); | ||
| } | ||
|
|
||
| return null; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.