Add eTrusted new review polling source#21225
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new polling Pipedream source ( ChangeseTrusted New Review Polling Source
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@components/etrusted/sources/new-review/new-review.mjs`:
- Around line 62-67: The current state persistence in _getLastSubmittedAt() and
_setLastSubmittedAt() methods stores only the timestamp, which causes reviews
with identical submittedAt values to potentially be skipped. Add a secondary
tie-breaker by also storing and retrieving the last processed review ID
alongside the timestamp. Create corresponding getter/setter methods like
_getLastProcessedId() and _setLastProcessedId(), then update the polling logic
that uses these state methods to filter reviews by using both the timestamp AND
the ID tie-breaker when querying for new reviews, ensuring no reviews with equal
timestamps are silently dropped. Apply this same pattern to the duplicate code
at lines 145-147 as well.
- Around line 126-133: The issue is that newestSubmittedAt is computed from
reviews[0] before the array is reversed, which assumes the API returns reviews
in reverse chronological order. If the API returns reviews in ascending or mixed
order, this will cause the cursor to point to an old timestamp, leading to
re-emission of reviews on the next poll. Instead of using reviews[0], calculate
the maximum submitted timestamp by iterating through all review objects in the
reviews array using _getSubmittedAt and comparing their values to determine the
true newest timestamp, then pass this maximum value to _setLastSubmittedAt to
ensure the cursor always moves forward.
- Around line 68-74: The _getParams() method calls .join() on values returned by
parseObject() for channelId, type, status, and rating, but parseObject() can
return scalar strings instead of arrays. Since strings do not have a .join()
method, this causes runtime errors. Wrap each parseObject() result with logic to
ensure it returns an array before calling .join(), such as checking if the
result is an array and converting scalar values to single-element arrays, or
using a utility function that normalizes the output to always return an array.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0285a156-2719-472f-9ab5-0006b8244cf8
📒 Files selected for processing (3)
components/etrusted/package.jsoncomponents/etrusted/sources/new-review/new-review.mjscomponents/etrusted/sources/new-review/test-event.mjs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@components/etrusted/sources/new-review/new-review.mjs`:
- Around line 71-85: In the _toCsv method, modify the condition that checks for
null or empty values to also handle empty arrays returned by parseObject. After
calling parseObject(value), add a check to return undefined if the parsed result
is an empty array, ensuring that unset filters do not produce empty strings that
get passed as blank query parameters (like channels=, type=, status=, rating=)
to the _getParams method and ultimately to the /reviews endpoint.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 849b3bf4-7d9f-4b1b-a66d-f78436cbc53d
📒 Files selected for processing (1)
components/etrusted/sources/new-review/new-review.mjs
| @@ -0,0 +1,16 @@ | |||
| export default { | |||
There was a problem hiding this comment.
The sample event doesn't match the real CustomerReview payload. I deployed this source against a live eTrusted account and captured a real emitted event. The current fixture uses field names that don't exist in the API response (status -> actually state, channel: {id, name} -> actually channelRef string, consumer: {email} -> actually customer: {}), and omits ~11 real fields. Since sampleEmit drives downstream autocomplete, builders referencing steps.trigger.event.channel.name or .status would be building against fields that never arrive.
Suggest replacing the fixture with this real event shape (captured live, PII neutralized):
export default {
_object: "CustomerReview",
accountRef: "acc-5b57249d-9b51-49ef-aa8c-02b8dbad6722",
channelRef: "chl-3de8e569-400f-4d31-9fdf-0d9b852748aa",
comment: "Test",
createdAt: "2026-06-25T12:47:20.793Z",
customer: {
email: "customer@example.com",
firstName: "John",
fullName: "John Doe",
lastName: "Doe",
},
event: {
id: "evt-de79c52f-f6eb-43e5-9b3b-54f548dfbb6c",
type: "test",
},
feedbackType: "REVIEW",
hasAttachments: false,
id: "rev-c6411ca3-5e24-4913-be18-6c1c45777516",
metadata: {
OriginalCarModel: "Golf GTI",
OriginalNameTP: "John Smith",
title: "Mr.",
nameAgent: "VW Demo Dealer",
},
questionnaire: {
id: "qre-19f0315e-df85-4a39-80f1-e8a139cee10c",
locale: "en_150",
templateRef: "tpl-qst-b59263c2-89ef-4b4c-bbc8-cf4b5ae9725f",
},
rating: 5,
state: "APPROVED",
submittedAt: "2026-06-25T12:47:20.000Z",
surveyData: [
{
questionRef: "coreStarRating",
type: "CORE_STAR_RATING",
userDefinedId: "coreStarRating",
properties: {},
value: {},
},
{
questionRef: "coreReviewGood",
type: "CORE_REVIEW",
userDefinedId: "coreReviewGood",
properties: {},
value: {},
},
{
questionRef: "opinionScale",
type: "DIMENSIONS",
userDefinedId: "opinionScale",
properties: {},
value: {},
},
],
title: "Test",
transaction: {
date: "2026-06-24T12:35:33.887Z",
reference: "Test250626",
},
type: "SERVICE_REVIEW",
updatedAt: "2026-06-25T12:47:20.859Z",
verificationType: "VERIFIED",
};
|
Hi @lixiyuan1030-stack, thank you for your contribution! The changes LGTM, except for the one comment I've added. |
Summary
Adds a new eTrusted polling source that emits an event when a new review is submitted.
Fixes: #21224
Changes
etrusted-new-reviewsource/reviewsendpointsubmittedAttimestamp and usessubmittedAfteron subsequent runs@pipedream/etrustedpackage versionTests
node --check components\etrusted\sources\new-review\new-review.mjsnode --check components\etrusted\sources\new-review\test-event.mjsgit diff --checkcmd /c npm test -- components/etrustedcould not run locally because dependencies are not installed in this environment (jestis unavailable).Summary by CodeRabbit