Skip to content

feat(ga4): add endpointPath field to response and update tests - #4628

Merged
koladilip merged 1 commit into
developfrom
fix/ga4-test-updates
Sep 15, 2025
Merged

koladilip merged 1 commit into
developfrom
fix/ga4-test-updates

Conversation

@koladilip

@koladilip koladilip commented Sep 11, 2025 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

This PR adds the endpointPath field to the GA4 destination response and updates all related test data to include this new field.

What is the related Linear task?

Resolves https://linear.app/rudderstack/issue/INT-4102/add-endpoint-path-details-in-rudder-transformer-for-top-15

Please explain the objectives of your changes below

The changes ensure consistency between the actual GA4 destination response and the test expectations by:

  1. Adding endpointPath field to GA4 utils response: Both debug and production modes now include the endpointPath field in the response
  2. Updating testUtils: The transformResultBuilder function now includes endpointPath in the expected output structure
  3. Updating test data: All GA4 test data files have been updated to include the endpointPath field in their expected outputs

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

No breaking changes. This is purely additive - adding a new field to the response structure that was missing from the test expectations.

Any new dependencies introduced with this change?

N/A

Any new generic utility introduced or modified. Please explain the changes.

Modified testUtils.ts to include endpointPath in the transformResultBuilder function.

Any technical or performance related pointers to consider with the change?

N/A

@coderabbitai review


Developer checklist

  • My code follows the style guidelines of this project
  • No breaking changes are being introduced.
  • All related docs linked with the PR?
  • All changes manually tested?
  • Any documentation changes needed with this change?
  • Is the PR limited to 10 file changes?
  • Is the PR limited to one linear task?
  • Are relevant unit and component test-cases added in new readability format?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?
  • Verified that there are no credentials or confidential data exposed with the changes.

@koladilip
koladilip requested review from a team and sivashanmukh as code owners September 11, 2025 12:40
@koladilip
koladilip requested review from a team, krishna2020 and manish339k September 11, 2025 12:40
@coderabbitai

coderabbitai Bot commented Sep 11, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Ensures GA4 event delivery uses the correct endpoint path based on Debug Mode, routing debug traffic to the debug collection endpoint and all other traffic to the standard collection endpoint. This improves reliability and clarity during testing without affecting production behavior. No configuration changes required; fully backward-compatible for existing setups.

Walkthrough

Adds assignment of response.endpointPath in buildDeliverablePayload (src/v0/destinations/ga4/utils.js): sets '/debug/mp/collect' when Config.debugMode is true, otherwise '/mp/collect'. Existing endpoint selection (DEBUG_ENDPOINT vs ENDPOINT) remains unchanged. No exported/public signatures changed.

Changes

Cohort / File(s) Summary
GA4 deliverable payload endpoint path
src/v0/destinations/ga4/utils.js
Populate response.endpointPath based on Config.debugMode: set to '/debug/mp/collect' for debug mode, else '/mp/collect'. Leaves existing endpoint (DEBUG_ENDPOINT/ENDPOINT) logic intact.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Caller as deliverable builder
    participant GA4 as buildDeliverablePayload
    participant Config as Config.debugMode

    Caller->>GA4: request buildDeliverablePayload(payload)
    GA4->>Config: read debugMode
    alt debugMode == true
        GA4-->>Caller: set response.endpoint = DEBUG_ENDPOINT
        GA4-->>Caller: set response.endpointPath = "/debug/mp/collect"
    else debugMode == false
        GA4-->>Caller: set response.endpoint = ENDPOINT
        GA4-->>Caller: set response.endpointPath = "/mp/collect"
    end
    Note over Caller,GA4 #D6EAF8: downstream code continues using response.endpoint and new response.endpointPath
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes
Note: Recommend adding or updating unit tests to assert response.endpointPath matches Config.debugMode and aligns with the selected endpoint.

Possibly related PRs

Suggested reviewers

  • sivashanmukh
  • krishna2020
  • manish339k

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly and accurately summarizes the primary change — adding an endpointPath field to the GA4 response and updating tests — and follows conventional commit formatting (feat(ga4):). It is concise, relevant, and free of noise.
Description Check ✅ Passed The PR description closely follows the repository template: it provides a clear change summary, links the related Linear task (INT-4102), explains objectives and test updates, and includes the developer checklist entries. The information is specific enough for reviewers to understand intent and scope.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 31a9ee3 and b589a8b.

⛔ Files ignored due to path filters (7)
  • test/integrations/destinations/ga4/processor/ecomTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/ga4/processor/groupTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/ga4/processor/pageTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/ga4/processor/trackTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/ga4_v2/network.ts is excluded by !**/test/**
  • test/integrations/destinations/ga4_v2/processor/customMappings.ts is excluded by !**/test/**
  • test/integrations/testUtils.ts is excluded by !**/test/**
📒 Files selected for processing (1)
  • src/v0/destinations/ga4/utils.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/v0/destinations/ga4/utils.js
⏰ 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). (8)
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Code Coverage
  • GitHub Check: UT Tests
  • GitHub Check: test_and_publish
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ga4-test-updates

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/v0/destinations/ga4/utils.js (1)

528-534: Reduce duplication: compute endpoint and path once

Minor DRY-up to keep the two branches in sync and make future edits safer.

Apply this diff locally:

-  if (Config.debugMode) {
-    response.endpoint = DEBUG_ENDPOINT;
-    response.endpointPath = '/debug/mp/collect';
-  } else {
-    response.endpoint = ENDPOINT;
-    response.endpointPath = '/mp/collect';
-  }
+  const isDebug = !!Config.debugMode;
+  response.endpoint = isDebug ? DEBUG_ENDPOINT : ENDPOINT;
+  response.endpointPath = isDebug ? '/debug/mp/collect' : '/mp/collect';

Optional: export DEBUG_ENDPOINT_PATH and ENDPOINT_PATH from ./config and use them here to keep paths centralized.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b30364 and 31a9ee3.

⛔ Files ignored due to path filters (5)
  • test/integrations/destinations/ga4/processor/ecomTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/ga4/processor/groupTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/ga4/processor/pageTestData.ts is excluded by !**/test/**
  • test/integrations/destinations/ga4/processor/trackTestData.ts is excluded by !**/test/**
  • test/integrations/testUtils.ts is excluded by !**/test/**
📒 Files selected for processing (1)
  • src/v0/destinations/ga4/utils.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js

⚙️ CodeRabbit configuration file

Focus on ESLint errors (max 3) and warnings (max 5).

Files:

  • src/v0/destinations/ga4/utils.js
🧬 Code graph analysis (1)
src/v0/destinations/ga4/utils.js (2)
src/v0/destinations/clevertap/transform.js (1)
  • response (59-59)
src/v0/destinations/ga4/transform.js (1)
  • response (212-212)
⏰ 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). (9)
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Code Coverage
  • GitHub Check: UT Tests
  • GitHub Check: test_and_publish
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
src/v0/destinations/ga4/utils.js (1)

528-535: LGTM: endpointPath correctly mirrors debug/prod endpoint selection

Additive and backward-compatible. No ESLint concerns in this hunk.

@codecov

codecov Bot commented Sep 11, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.78%. Comparing base (63bd4e3) to head (b589a8b).
⚠️ Report is 25 commits behind head on develop.

Files with missing lines Patch % Lines
src/v0/destinations/ga4/utils.js 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4628      +/-   ##
===========================================
- Coverage    91.78%   91.78%   -0.01%     
===========================================
  Files          642      642              
  Lines        33941    33943       +2     
  Branches      8035     8044       +9     
===========================================
+ Hits         31152    31153       +1     
+ Misses        2559     2538      -21     
- Partials       230      252      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Add endpointPath field to GA4 utils response for both debug and production modes
- Update testUtils to include endpointPath in transformResultBuilder
- Update all GA4 test data files to include endpointPath in expected outputs
- Ensures consistency between actual response and test expectations
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

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.

5 participants