Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Oct 28, 2025

Resolves #18818

Summary by CodeRabbit

  • New Features

    • Added five new event sources for Microsoft Dynamics 365 Sales: Account Ownership Changed, Account Status Changed, Contact Added to Account, New Account Activity, and New Account Created.
    • Added account ID selection dropdown for Microsoft Dynamics 365 Sales integration.
  • Chores

    • Bumped component and source versions across the Microsoft Dynamics 365 Sales integration.

@vercel
Copy link

vercel bot commented Oct 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Oct 28, 2025 4:47pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Oct 28, 2025 4:47pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 28, 2025

Walkthrough

This PR adds five new account-level event source modules to the Microsoft Dynamics 365 Sales component (new account created, account ownership changed, account status changed, contact added to account, new account activity). It introduces an accountId property definition with async account fetching capability and a listAccounts method to the app configuration. Multiple action and source module versions are incremented.

Changes

Cohort / File(s) Summary
App Configuration Updates
components/microsoft_dynamics_365_sales/microsoft_dynamics_365_sales.app.mjs
Added accountId prop definition with async options fetching accounts; added listAccounts() method performing GET to /accounts endpoint.
New Account-Level Sources
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs, components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs, components/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs, components/microsoft_dynamics_365_sales/sources/new-account-activity/new-account-activity.mjs, components/microsoft_dynamics_365_sales/sources/new-account-created/new-account-created.mjs
Five new source modules introduced, each extending common base with lifecycle methods for detecting account ownership changes, status changes, contact additions, new activities, and new accounts. Includes state persistence, change detection, timestamp handling, and event metadata generation.
Action Version Bumps
components/microsoft_dynamics_365_sales/actions/create-custom-entity/create-custom-entity.mjs, components/microsoft_dynamics_365_sales/actions/find-contact/find-contact.mjs
Version bumped from 0.0.5 to 0.0.6 for both actions.
Existing Source Version Updates
components/microsoft_dynamics_365_sales/sources/new-opportunity-activity/..., new-opportunity-created/..., opportunity-close-date-updated/..., opportunity-close-probability-updated/..., opportunity-contact-changed/..., opportunity-estimated-value-updated/..., opportunity-marked-won-or-lost/..., opportunity-ownership-changed/..., opportunity-reopened/..., opportunity-stage-updated/...
Ten existing source module versions incremented (various bumps: 0.0.10.0.2, 0.0.20.0.3, and 0.0.{{ts}}0.0.2).
Package Version
components/microsoft_dynamics_365_sales/package.json
Version bumped from 0.3.0 to 0.4.0.

Sequence Diagram

sequenceDiagram
    participant User
    participant Source
    participant Common
    participant DB
    participant API

    User->>Source: Initialize source instance
    Source->>Common: Extend common base configuration
    Note over Source: Inherits getResourceFn, getArgs,<br/>getTsField, generateMeta patterns

    Source->>DB: _getStoredState() (e.g., ownershipIds, statuses)
    DB-->>Source: Previous state (or empty)

    Source->>API: getResourceFn() returns resource (e.g., listAccounts)
    Source->>API: getArgs() builds request params
    API-->>Source: Fetch results with ordering/filters
    
    Source->>Source: getRelevantResults(results)
    Note over Source: Compare current state vs. stored state<br/>Detect changes (new, modified, status changed)
    
    Source->>DB: _setStoredState(newState) - Update mappings
    DB-->>Source: State persisted
    
    Source->>Source: For each relevant result: generateMeta(item)
    Note over Source: Build event metadata:<br/>Unique ID, summary, timestamp
    
    Source-->>User: Emit detected events with metadata
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • New account-level sources: Five new source files follow a consistent pattern (getResourceFn, getArgs, getTsField, getRelevantResults, generateMeta), but each requires verification of correct property definitions, state persistence logic, and change detection criteria. Focus areas: account-ownership-changed and account-status-changed (use DB-backed state comparison); contact-added-to-account and new-account-activity (query construction and filtering); new-account-created (metadata generation).
  • App-level additions: Verify accountId async options correctly maps fetched accounts; confirm listAccounts() method signature and API path are correct.
  • Version bumps: Multiple version increments across actions and sources are repetitive and low-risk, but totals add file count.

Possibly related PRs

Suggested labels

User submitted

Suggested reviewers

  • GTFalcao

Poem

🐰 Five new accounts now dance in the flow,
With ownership changed and status aglow,
Contacts join in, activities too,
App fetches wisely—version bumps true!
Dynamic triggers—Pipedream's new show! ✨

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The pull request includes changes that extend beyond the five specific account-level triggers defined in issue #18818. The new-account-activity.mjs source is not among the five required triggers listed in the issue, representing an out-of-scope addition. Furthermore, the PR includes numerous version bump changes across existing sources and actions (opportunity-related sources, find-contact, create-custom-entity) that are unrelated to the account-level event triggers specified in the linked issue, suggesting routine versioning updates bundled with this feature work.
Description Check ⚠️ Warning The pull request description only contains "Resolves #18818" without completing the required template structure. The repository's description template specifies a "WHY" section that should be completed by the author, but no such information is provided in the description. While the issue link provides context about the work, the description itself fails to follow the template format and lacks substantive reasoning for the changes introduced in the pull request.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Microsoft Dynamics - new sources" directly reflects the primary changes in the changeset, which adds five new source modules for account-level event triggers. The title is concise, clear, and specific enough to understand the main focus at a glance. While the PR also includes supporting infrastructure changes (app-level additions) and version updates, the core objective centers on introducing the new sources, making the title appropriately aligned with the primary contribution.
Linked Issues Check ✅ Passed The pull request successfully implements all five account-level event triggers specified in issue #18818: new-account-created.mjs, account-ownership-changed.mjs, account-status-changed.mjs, contact-added-to-account.mjs, and the status-changed source handles account activation/deactivation requirements. Additionally, the PR includes supporting infrastructure changes to the main app file (accountId property definition and listAccounts method) that enable these new sources to function correctly. All coding requirements from the linked issue appear to be addressed by the changes in this pull request.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-18818

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@michelle0927 michelle0927 marked this pull request as ready for review October 28, 2025 16:48
Copy link
Contributor

@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: 7

🧹 Nitpick comments (1)
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (1)

1-55: Consider abstracting the change-detection pattern.

This file and account-status-changed.mjs share nearly identical logic—both track a field in the database, detect changes, and emit events. The only differences are the field name (_ownerid_value vs. statuscode) and the storage key.

You could create a shared base class or helper that accepts the field name as a parameter to reduce duplication.

This is a low-priority refactoring suggestion that could improve maintainability if you add more change-tracking sources in the future.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36a8917 and d7041d3.

📒 Files selected for processing (19)
  • components/microsoft_dynamics_365_sales/actions/create-custom-entity/create-custom-entity.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/actions/find-contact/find-contact.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/microsoft_dynamics_365_sales.app.mjs (2 hunks)
  • components/microsoft_dynamics_365_sales/package.json (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/new-account-activity/new-account-activity.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/new-account-created/new-account-created.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/new-opportunity-activity/new-opportunity-activity.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/new-opportunity-created/new-opportunity-created.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/opportunity-close-date-updated/opportunity-close-date-updated.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/opportunity-close-probability-updated/opportunity-close-probability-updated.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/opportunity-estimated-value-updated/opportunity-estimated-value-updated.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/opportunity-marked-won-or-lost/opportunity-marked-won-or-lost.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/opportunity-ownership-changed/opportunity-ownership-changed.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/opportunity-reopened/opportunity-reopened.mjs (1 hunks)
  • components/microsoft_dynamics_365_sales/sources/opportunity-stage-updated/opportunity-stage-updated.mjs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs (4)
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (2)
  • relevantResults (34-34)
  • ts (47-47)
components/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs (3)
  • relevantResults (37-37)
  • account (38-38)
  • ts (48-48)
components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs (2)
  • relevantResults (34-34)
  • ts (47-47)
components/microsoft_dynamics_365_sales/sources/new-account-activity/new-account-activity.mjs (1)
  • ts (37-37)
components/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs (4)
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (2)
  • relevantResults (34-34)
  • ts (47-47)
components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs (2)
  • relevantResults (34-34)
  • ts (47-47)
components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs (2)
  • relevantResults (34-34)
  • ts (47-47)
components/microsoft_dynamics_365_sales/sources/new-account-activity/new-account-activity.mjs (1)
  • ts (37-37)
components/microsoft_dynamics_365_sales/sources/new-account-created/new-account-created.mjs (1)
components/microsoft_dynamics_365_sales/sources/contact-added-to-account/contact-added-to-account.mjs (1)
  • account (38-38)
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (2)
components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs (2)
  • relevantResults (34-34)
  • ts (47-47)
components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs (2)
  • relevantResults (34-34)
  • ts (47-47)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (22)
components/microsoft_dynamics_365_sales/sources/opportunity-stage-updated/opportunity-stage-updated.mjs (1)

8-8: Version bump aligns with release cycle.

The version update from 0.0.2 to 0.0.3 is part of the broader component versioning for this PR. No functional changes detected.

components/microsoft_dynamics_365_sales/sources/new-opportunity-activity/new-opportunity-activity.mjs (1)

8-8: Verify if this version bump is intentional.

The only change in this file is a version increment from 0.0.1 to 0.0.2 with no accompanying functional modifications. Given that the PR's stated objectives focus on new account-level event sources (not opportunity-level sources), clarify whether this version bump is:

  • Intentional as part of a release strategy (e.g., bumping all related modules)
  • Or collateral/unintended churn that should be removed
components/microsoft_dynamics_365_sales/sources/opportunity-estimated-value-updated/opportunity-estimated-value-updated.mjs (1)

8-8: Clarify the rationale for versioning this module.

This file is being version-bumped from 0.0.2 to 0.0.3 with no logic or behavior changes. The PR objectives focus on implementing account-level event triggers, but this module handles opportunity estimated-value updates—a distinct concern. The AI summary notes that "multiple unrelated source and action modules updated their exported version metadata" across this PR.

Please clarify whether this version bump is intentional as part of a coordinated versioning strategy, a dependency-driven change, or if it should be reverted.

components/microsoft_dynamics_365_sales/sources/opportunity-close-probability-updated/opportunity-close-probability-updated.mjs (1)

8-8: LGTM! Version bump aligns with PR-wide updates.

The version increment from 0.0.2 to 0.0.3 is appropriate for maintaining consistency across the component's sources. No functional changes introduced.

components/microsoft_dynamics_365_sales/sources/opportunity-marked-won-or-lost/opportunity-marked-won-or-lost.mjs (1)

1-85: Version bump aligns with coordinated updates across modules.

This file's version increment to 0.0.2 appears appropriately scoped as part of a coordinated release. The source module logic itself is sound—state tracking, filtering, and deduplication are all correct. No behavioral changes detected.

components/microsoft_dynamics_365_sales/sources/opportunity-close-date-updated/opportunity-close-date-updated.mjs (1)

8-8: LGTM! Version bump is appropriate.

The patch version increment aligns with the broader component updates in this PR. No functional changes to this source module.

components/microsoft_dynamics_365_sales/sources/opportunity-contact-changed/opportunity-contact-changed.mjs (1)

8-8: LGTM!

The version bump from a templated version to "0.0.2" is appropriate and aligns with the broader PR's version synchronization across the Microsoft Dynamics 365 Sales component.

components/microsoft_dynamics_365_sales/sources/opportunity-ownership-changed/opportunity-ownership-changed.mjs (1)

8-8: Verify the necessity of this version bump and file inclusion in the PR.

The review comment raises valid concerns that cannot be automatically verified:

  1. Why this file needs a version bump: This is an opportunity-related source, not account-related. No functional changes are visible in the file. Clarify whether changes to the common module, package-level updates, or other factors justify the version bump.

  2. Whether this file should be in this PR: Confirm this file's inclusion aligns with the stated objective of adding five NEW account-level event triggers, or if it was added unintentionally.

Please review and confirm these changes are intentional and necessary.

components/microsoft_dynamics_365_sales/package.json (1)

3-3: LGTM!

The version bump to 0.4.0 appropriately reflects the addition of new account-level event sources.

components/microsoft_dynamics_365_sales/actions/create-custom-entity/create-custom-entity.mjs (1)

9-9: LGTM!

Version bump is appropriate for this maintenance release.

components/microsoft_dynamics_365_sales/sources/new-opportunity-created/new-opportunity-created.mjs (1)

8-8: LGTM!

Version bump is appropriate for this maintenance release.

components/microsoft_dynamics_365_sales/sources/opportunity-reopened/opportunity-reopened.mjs (1)

8-8: LGTM!

Version bump is appropriate for this maintenance release.

components/microsoft_dynamics_365_sales/actions/find-contact/find-contact.mjs (1)

7-7: LGTM!

Version bump is appropriate for this maintenance release.

components/microsoft_dynamics_365_sales/microsoft_dynamics_365_sales.app.mjs (2)

57-70: LGTM!

The new accountId prop definition follows the same pattern as existing props (contactId, opportunityId) and correctly implements async options fetching.


136-141: LGTM!

The listAccounts method follows the established pattern and correctly implements the accounts endpoint.

components/microsoft_dynamics_365_sales/sources/new-account-created/new-account-created.mjs (1)

13-25: LGTM!

The resource configuration correctly retrieves accounts ordered by creation date descending, which is appropriate for detecting new accounts.

components/microsoft_dynamics_365_sales/sources/account-status-changed/account-status-changed.mjs (3)

13-18: LGTM!

The state persistence helpers correctly store and retrieve status mappings using the Pipedream database.


19-31: LGTM!

The configuration appropriately uses modifiedon for tracking status changes, as status changes will update the modification timestamp.


32-45: LGTM!

The change detection logic correctly:

  • Identifies status changes by comparing stored vs. current values
  • Prevents false positives on the first run (Line 37)
  • Persists updated state for future comparisons
components/microsoft_dynamics_365_sales/sources/account-ownership-changed/account-ownership-changed.mjs (3)

13-18: LGTM!

The state persistence helpers correctly store and retrieve ownership ID mappings.


19-31: LGTM!

The configuration appropriately uses modifiedon for tracking ownership changes.


32-45: LGTM!

The change detection logic correctly identifies ownership changes and prevents false positives on the first run.

Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @michelle0927, LGTM! Ready for QA!

@vunguyenhung vunguyenhung merged commit 20efdf2 into master Oct 29, 2025
10 checks passed
@vunguyenhung vunguyenhung deleted the issue-18818 branch October 29, 2025 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft Dynamics – account triggers: new account, ownership changed, status changed, new contact added, inactive/reactivated

4 participants