Skip to content

refactor: shopify source to v2 spec and pixel fixes - #4178

Merged
krishna2020 merged 5 commits into
developfrom
chore.shopify-v2-migration2
Mar 21, 2025
Merged

krishna2020 merged 5 commits into
developfrom
chore.shopify-v2-migration2

Conversation

@koladilip

@koladilip koladilip commented Mar 18, 2025 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

  • Move shopify source to v2
  • Fix pixels
  • Fix sonar issues
  • Move tracker to v2

What is the related Linear task?

Resolves INT-3129, INT-3333, INT-3396

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

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

N/A

Any new dependencies introduced with this change?

N/A

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

N/A

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.

Summary by CodeRabbit

  • New Features

    • Streamlined Shopify event processing now focuses on the latest (v2) flow, resulting in improved event routing and data tracking.
    • Enhanced mapping for customer and shipping details delivers more accurate analytics.
    • New JSON files introduced for address and identification mappings to facilitate data transformation.
  • Refactor

    • Optimized internal event processing and configuration for better performance and reliability.
    • Improved modularity and clarity in event handling logic with new helper functions.
  • Tests

    • Comprehensive test scenarios added for pixel checkout events, enhancing validation of event tracking functionality.
    • Updated test structures to reflect new request body formats and versioning for various Shopify events.

@koladilip
koladilip requested review from a team and sivashanmukh as code owners March 18, 2025 16:06
@koladilip
koladilip requested review from a team, vinayteki95 and yashasvibajpai March 18, 2025 16:06
@koladilip koladilip mentioned this pull request Mar 18, 2025
10 tasks
@krishna2020 krishna2020 added the DO NOT MERGE Don't merge this PR without having discussion label Mar 18, 2025
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Mar 18, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 84.84848% with 20 lines in your changes missing coverage. Please review.

Project coverage is 91.02%. Comparing base (eeb7a50) to head (1bc6754).
Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
...pify/webhookTransformations/serverSideTransform.js 50.00% 11 Missing and 4 partials ⚠️
.../shopify/webpixelTransformations/pixelTransform.js 66.66% 2 Missing ⚠️
src/sources/shopify/tracker/transform.js 97.87% 1 Missing ⚠️
src/sources/shopify/transform.js 93.33% 1 Missing ⚠️
.../shopify/webhookTransformations/serverSideUtlis.js 85.71% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4178      +/-   ##
===========================================
- Coverage    91.39%   91.02%   -0.38%     
===========================================
  Files          636      635       -1     
  Lines        33144    33141       -3     
  Branches      7833     7831       -2     
===========================================
- Hits         30293    30167     -126     
- Misses        2645     2723      +78     
- Partials       206      251      +45     

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

@krishna2020

Copy link
Copy Markdown
Collaborator

@CodeRabbit review

1 similar comment
@krishna2020

Copy link
Copy Markdown
Collaborator

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Mar 20, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Mar 20, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes refactor and update the Shopify integration code and tests. Source version filtering is now fixed to version “v2”. Several event processing functions were split into smaller helpers, renamed, or removed, streamlining control flow—particularly distinguishing between pixel and tracker events. Import paths were revised across multiple modules. New JSON mapping files were added for address and identify data, while numerous test files were restructured to validate new payload formats and event scenarios. Deprecated v1 files were removed, and Redis connection tests were enhanced.

Changes

File(s) Change Summary
src/controllers/util/index.ts
src/services/__tests__/misc.test.ts
Updated version filtering to process only "v2" sources and revised module paths in tests.
src/sources/shopify/tracker/transform.js
src/sources/shopify/transform.js
src/sources/shopify/transformPixel.js
src/sources/shopify/webhookTransformations/serverSideTransform.js
src/sources/shopify/webpixelTransformations/pixelTransform.js
src/sources/shopify/webpixelTransformations/pixelUtils.js
Refactored event processing logic by modularizing functions (e.g., createMessageForEvent, handleCartsUpdate, enrichNonIdentifyMessage), renaming functions (e.g., processV1Events to processPixelEvents), and removing obsolete converters.
src/sources/shopify/tracker/util.js
src/sources/shopify/utils.js
src/sources/shopify/utils.test.js
src/sources/shopify/webhookTransformations/serverSideUtlis.js
src/sources/shopify/webpixelTransformations/pixelTransform.redisCartToken.test.js
Updated import paths and simplified conditionals; renamed functions (e.g., isShopifyV1Event to isShopifyPixelEvent) for improved clarity.
src/sources/shopify/config.js
src/sources/shopify/webhookEventsMapping/addressMapping.json
src/sources/shopify/webhookEventsMapping/identifyMapping.json
Added new JSON mapping files and a new constant (addressMappingJSON) for enhanced data transformation.
src/sources/shopify/tracker/shopify_redis.util.test.js
src/util/redis/redisConnector.test.js
Enhanced Redis connection testing with new test suites for connection readiness and tracker event processing; removed a dynamic source tests suite.
test/integrations/... Restructured and added new test scenarios (for pixel events, checkout events, order events, user identify events) across multiple new files, updated request bodies to JSON strings, and switched scenario versions from "v1" to "v2".
src/v1/sources/shopify/transform.js
src/v1/sources/shopify/webhookEventsMapping/identifyMapping.json
test/integrations/sources/shopify/webhookTestScenarios/IdentifyTests.ts
Removed deprecated v1 transformation and mapping files.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Transformer
    participant PixelHandler
    participant TrackerHandler

    Client->>Transformer: Send v2 event payload
    Transformer->>Transformer: Extract event via getEventFromV2Request
    alt Shopify Pixel Event
        Transformer->>PixelHandler: Call processPixelEvents(event)
    else Other Event
        Transformer->>TrackerHandler: Call processTrackerEvents(event)
    end
Loading

Poem

I’m a rabbit hopping through fresh code,
Where functions split like carrots on the road.
V2 now reigns, clear and bright,
Refactored paths lead me to delight.
With tests renewed and mappings in view,
I celebrate each change—cute and true! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this 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.

@koladilip
koladilip force-pushed the chore.shopify-v2-migration2 branch from 4f33757 to 5b8cc3e Compare March 20, 2025 06:20
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@coderabbitai

coderabbitai Bot commented Mar 20, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

1 similar comment
@coderabbitai

coderabbitai Bot commented Mar 20, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (14)
src/sources/shopify/transformPixel.js (1)

28-31: Error message still references V1

While the function name has been updated to be version-agnostic, the error message still refers to "Shopiyf V1". This should be updated to maintain consistency with the renamed function.

  throw new PlatformError(
-    'Invalid Event for Shopiyf V1 (not matching client or server side event requirements)',
+    'Invalid Event for Shopify Pixel (not matching client or server side event requirements)',
    500,
  );
test/integrations/sources/shopify/pixelMappingTests/CheckoutStepsTests.ts (1)

1-1689: New test file adds comprehensive pixel checkout step test coverage

This new file adds detailed test scenarios for Shopify checkout steps from web pixels, covering all key checkout steps (address, contact, shipping, and payment info submission). The test data structure is comprehensive and realistic.

A few observations:

  1. All scenarios are marked with skip: true, indicating they are not currently active in the test suite
  2. Version is set to 'v2', consistent with the overall PR direction
  3. The test cases use appropriate anonymousId and checkout_id values for tracking

This file enhances test coverage for the pixel integration, though you might want to consider enabling at least some of these tests by removing the skip flag.

Consider enabling at least one test scenario from each checkout step by selectively removing the skip: true flag. This would provide immediate test coverage while allowing you to enable more tests incrementally.

src/sources/shopify/webhookTransformations/serverSideUtils.test.js (4)

11-11: Use direct import naming to reflect file usage
"stats" might be too generic. Consider using a more descriptive import alias, if needed, to clearly convey its purpose.


13-15: Consider grouping related imports
Imports from the same domain can be grouped for improved readability, though this is mostly stylistic. Ensure it aligns with established conventions.


17-18: Revisit mocking of internal modules
Mocking internal modules can obscure genuine test coverage. Whenever feasible, keep the real modules or switch to partial mocking to preserve actual behaviors.


165-165: Enforce consistent object shape in assertions
For more flexible tests, consider using .toMatchObject() if you anticipate other fields or partial matches.

test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts (1)

394-531: Revised structure with JSON.stringify looks good; confirm correct field mapping.

The shift to a JSON-stringified payload for checkout_completed aligns with the newly adopted pattern. Ensure all required fields (e.g., finalLinePrice, discountAllocations) are correctly asserted in tests.

🧰 Tools
🪛 Gitleaks (8.21.2)

411-411: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


430-430: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

src/sources/shopify/webpixelTransformations/pixelUtils.js (1)

107-107: Line items destructuring in productViewedEventBuilder.

No direct issue, but consider validating empty or null line items for edge cases.

src/sources/shopify/tracker/transform.js (1)

68-68: Potential timestamp logic.

The comment implies possible created_at usage for checkout_create. Might be worth clarifying or removing the commented note.

src/sources/shopify/webhookTransformations/serverSideTransform.js (5)

11-15: Check for potential typographical error.

The identifier INTEGERATION might be slightly misspelled if it’s intended to mean "INTEGRATION." Consider renaming to avoid confusion:

-  INTEGERATION,
+  INTEGRATION,

48-48: Minor note on naming.

Destructuring { id } from customerDetails is clear, but you could consider a more descriptive name like customerId to enhance readability.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 48-48: src/sources/shopify/webhookTransformations/serverSideTransform.js#L48
Added line #L48 was not covered by tests


50-58: Add specific test coverage for dynamic traits mapping.

Your trait mapping loop correctly sets context traits from identifyMappingJSON. However, lines 51, 53, 55-56 are flagged for lacking test coverage.

Consider adding unit tests to verify each mapping scenario and ensure sourceValue is correctly set on the trait path.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 51-51: src/sources/shopify/webhookTransformations/serverSideTransform.js#L51
Added line #L51 was not covered by tests


[warning] 53-53: src/sources/shopify/webhookTransformations/serverSideTransform.js#L53
Added line #L53 was not covered by tests


[warning] 55-56: src/sources/shopify/webhookTransformations/serverSideTransform.js#L55-L56
Added lines #L55 - L56 were not covered by tests


71-78: Avoid duplication with shipping address mapping.

Similar logic is repeated for both customerDetails and shipping_address mappings. You could factor out a helper to DRY up the code. Also, lines 75-76 are missing coverage.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 75-76: src/sources/shopify/webhookTransformations/serverSideTransform.js#L75-L76
Added lines #L75 - L76 were not covered by tests


147-149: Handle potential Redis errors.

Attaching anonymousId and updating it in Redis is key, but any Redis failure could break stitching logic. Consider try/catch or error handling to avoid silent failures or unhandled rejections.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 551b0e2 and 5b8cc3e6b6f69b4db57c043b3523e2ce709af9d4.

📒 Files selected for processing (36)
  • src/controllers/util/index.ts (1 hunks)
  • src/services/__tests__/misc.test.ts (1 hunks)
  • src/sources/shopify/config.js (2 hunks)
  • src/sources/shopify/tracker/shopify_redis.util.test.js (2 hunks)
  • src/sources/shopify/tracker/transform.js (3 hunks)
  • src/sources/shopify/tracker/util.js (3 hunks)
  • src/sources/shopify/transform.js (1 hunks)
  • src/sources/shopify/transformPixel.js (2 hunks)
  • src/sources/shopify/utils.js (3 hunks)
  • src/sources/shopify/utils.test.js (1 hunks)
  • src/sources/shopify/webhookEventsMapping/addressMapping.json (1 hunks)
  • src/sources/shopify/webhookEventsMapping/identifyMapping.json (1 hunks)
  • src/sources/shopify/webhookTransformations/serverSideTransform.js (6 hunks)
  • src/sources/shopify/webhookTransformations/serverSideUtils.test.js (3 hunks)
  • src/sources/shopify/webhookTransformations/serverSideUtlis.js (3 hunks)
  • src/sources/shopify/webpixelTransformations/pixelTransform.js (3 hunks)
  • src/sources/shopify/webpixelTransformations/pixelTransform.redisCartToken.test.js (1 hunks)
  • src/sources/shopify/webpixelTransformations/pixelUtils.js (8 hunks)
  • src/sources/shopify/webpixelTransformations/pixelUtils.test.js (5 hunks)
  • src/util/redis/redisConnector.test.js (0 hunks)
  • src/v1/sources/shopify/transform.js (0 hunks)
  • src/v1/sources/shopify/webhookEventsMapping/identifyMapping.json (0 hunks)
  • test/integrations/component.test.ts (1 hunks)
  • test/integrations/sources/shopify/data.ts (11 hunks)
  • test/integrations/sources/shopify/pixelMappingTests/CheckoutEventsTests.ts (1 hunks)
  • test/integrations/sources/shopify/pixelMappingTests/CheckoutStepsTests.ts (1 hunks)
  • test/integrations/sources/shopify/pixelMappingTests/ProductEventsTests.ts (1 hunks)
  • test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts (2 hunks)
  • test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts (5 hunks)
  • test/integrations/sources/shopify/pixelTestScenarios/ProductEventsTests.ts (8 hunks)
  • test/integrations/sources/shopify/webhookMappingTests/CheckoutEventsTests.ts (1 hunks)
  • test/integrations/sources/shopify/webhookMappingTests/OrderEventsTests.ts (1 hunks)
  • test/integrations/sources/shopify/webhookMappingTests/userIdentifyTests.ts (1 hunks)
  • test/integrations/sources/shopify/webhookTestScenarios/CheckoutEventsTests.ts (6 hunks)
  • test/integrations/sources/shopify/webhookTestScenarios/GenericTrackTests.ts (3 hunks)
  • test/integrations/sources/shopify/webhookTestScenarios/IdentifyTests.ts (0 hunks)
💤 Files with no reviewable changes (4)
  • src/util/redis/redisConnector.test.js
  • src/v1/sources/shopify/transform.js
  • test/integrations/sources/shopify/webhookTestScenarios/IdentifyTests.ts
  • src/v1/sources/shopify/webhookEventsMapping/identifyMapping.json
🧰 Additional context used
🧬 Code Definitions (15)
src/sources/shopify/config.js (3)
src/sources/shopify/tracker/config.js (2) (2)
  • fs (2-2)
  • path (1-1)
src/sources/shopify/tracker/shopify_redis.util.test.js (2) (2)
  • fs (3-3)
  • path (4-4)
src/util/redis/redisConnector.test.js (2) (2)
  • fs (1-1)
  • path (2-2)
src/sources/shopify/utils.test.js (4)
src/sources/shopify/webhookTransformations/serverSideTransform.js (11) (11)
  • require (3-3)
  • require (5-5)
  • require (6-6)
  • require (8-8)
  • require (9-9)
  • require (10-15)
  • require (16-16)
  • require (17-23)
  • require (24-24)
  • require (25-25)
  • stats (4-4)
src/sources/shopify/webhookTransformations/serverSideUtlis.js (6) (6)
  • require (3-3)
  • require (4-4)
  • require (5-5)
  • require (6-6)
  • require (7-7)
  • stats (8-8)
src/sources/shopify/webhookTransformations/serverSideUtils.test.js (2) (2)
  • require (1-1)
  • stats (11-11)
src/sources/shopify/utils.js (1) (1)
  • stats (2-2)
src/sources/shopify/webpixelTransformations/pixelTransform.js (3)
src/sources/shopify/webpixelTransformations/pixelTransform.redisCartToken.test.js (2) (2)
  • stats (3-3)
  • logger (4-4)
src/sources/shopify/tracker/util.js (3) (3)
  • stats (6-6)
  • logger (19-19)
  • inputEvent (257-257)
src/sources/shopify/webpixelTransformations/pixelUtils.js (1) (1)
  • inputEvent (65-65)
src/sources/shopify/webpixelTransformations/pixelTransform.redisCartToken.test.js (4)
src/sources/shopify/webhookTransformations/serverSideUtlis.js (6) (6)
  • require (3-3)
  • require (4-4)
  • require (5-5)
  • require (6-6)
  • require (7-7)
  • stats (8-8)
src/sources/shopify/webpixelTransformations/pixelTransform.js (2) (2)
  • stats (5-5)
  • logger (6-6)
src/sources/shopify/tracker/transform.js (2) (2)
  • stats (5-5)
  • logger (16-16)
src/sources/shopify/tracker/util.js (2) (2)
  • stats (6-6)
  • logger (19-19)
src/sources/shopify/utils.js (3)
src/sources/shopify/webhookTransformations/serverSideTransform.js (13) (13)
  • require (3-3)
  • require (5-5)
  • require (6-6)
  • require (8-8)
  • require (9-9)
  • require (10-15)
  • require (16-16)
  • require (17-23)
  • require (24-24)
  • require (25-25)
  • stats (4-4)
  • event (123-123)
  • event (124-124)
src/sources/shopify/utils.test.js (1) (1)
  • stats (7-7)
src/sources/shopify/transformPixel.js (1) (1)
  • event (8-8)
src/sources/shopify/tracker/util.js (2)
src/sources/shopify/webhookTransformations/serverSideTransform.js (10) (10)
  • require (3-3)
  • require (5-5)
  • require (6-6)
  • require (8-8)
  • require (9-9)
  • require (10-15)
  • require (16-16)
  • require (17-23)
  • require (24-24)
  • require (25-25)
src/sources/shopify/webhookTransformations/serverSideUtlis.js (5) (5)
  • require (3-3)
  • require (4-4)
  • require (5-5)
  • require (6-6)
  • require (7-7)
src/sources/shopify/webhookTransformations/serverSideUtlis.js (3)
src/sources/shopify/webhookTransformations/serverSideTransform.js (13) (13)
  • require (3-3)
  • require (5-5)
  • require (6-6)
  • require (8-8)
  • require (9-9)
  • require (10-15)
  • require (16-16)
  • require (17-23)
  • require (24-24)
  • require (25-25)
  • get (2-2)
  • event (123-123)
  • event (124-124)
src/sources/shopify/webhookTransformations/serverSideUtils.test.js (4) (4)
  • require (1-1)
  • require (2-9)
  • require (13-13)
  • require (15-15)
src/sources/shopify/tracker/util.js (2) (2)
  • email (108-108)
  • extractEmailFromPayload (106-118)
test/integrations/sources/shopify/pixelTestScenarios/ProductEventsTests.ts (1)
test/integrations/sources/shopify/constants.ts (2) (2)
  • dummyContextwithCampaign (141-193)
  • dummyContext (87-139)
src/sources/shopify/tracker/transform.js (2)
src/sources/shopify/tracker/config.js (5) (5)
  • IDENTIFY_TOPICS (5-8)
  • ECOM_TOPICS (11-16)
  • useRedisDatabase (162-162)
  • INTEGERATION (81-81)
  • SUPPORTED_TRACK_EVENTS (116-159)
src/sources/shopify/tracker/util.js (6) (6)
  • redisData (29-29)
  • getDataFromRedis (21-50)
  • checkAndUpdateCartItems (242-267)
  • email (108-108)
  • inputEvent (257-257)
  • stats (6-6)
test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts (1)
test/integrations/sources/shopify/constants.ts (2) (2)
  • dummyBillingAddresses (71-85)
  • dummyContext (87-139)
src/sources/shopify/webpixelTransformations/pixelUtils.js (1)
src/sources/shopify/config.js (2) (2)
  • contextualFieldMappingJSON (54-56)
  • PIXEL_EVENT_MAPPING (22-36)
src/sources/shopify/webhookTransformations/serverSideUtils.test.js (2)
src/sources/shopify/webhookTransformations/serverSideTransform.js (17) (17)
  • require (3-3)
  • require (5-5)
  • require (6-6)
  • require (8-8)
  • require (9-9)
  • require (10-15)
  • require (16-16)
  • require (17-23)
  • require (24-24)
  • require (25-25)
  • Message (7-7)
  • message (36-36)
  • message (84-84)
  • message (100-100)
  • message (122-122)
  • event (123-123)
  • event (124-124)
src/sources/shopify/webhookTransformations/serverSideUtlis.js (6) (6)
  • require (3-3)
  • require (4-4)
  • require (5-5)
  • require (6-6)
  • require (7-7)
  • addCartTokenHashToTraits (74-84)
test/integrations/sources/shopify/data.ts (4)
test/integrations/sources/shopify/webhookMappingTests/userIdentifyTests.ts (1) (1)
  • userTestScenarios (5-373)
test/integrations/sources/shopify/pixelMappingTests/CheckoutStepsTests.ts (1) (1)
  • newpixelCheckoutStepsScenarios (3-1688)
test/integrations/sources/shopify/pixelMappingTests/ProductEventsTests.ts (1) (1)
  • newpixelEventsTestScenarios (4-1223)
test/integrations/sources/shopify/webhookMappingTests/OrderEventsTests.ts (1) (1)
  • newWebhookOrderEventsTestScenarios (4-1665)
src/sources/shopify/webhookTransformations/serverSideTransform.js (3)
src/sources/shopify/webhookTransformations/serverSideUtlis.js (6) (6)
  • require (3-3)
  • require (4-4)
  • require (5-5)
  • require (6-6)
  • require (7-7)
  • setAnonymousId (92-129)
src/sources/shopify/webhookTransformations/serverSideUtils.test.js (4) (4)
  • require (1-1)
  • require (2-9)
  • require (13-13)
  • require (15-15)
src/sources/shopify/tracker/config.js (1) (1)
  • identifyMappingJSON (69-71)
test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts (1)
test/integrations/sources/shopify/constants.ts (1) (1)
  • dummyContext (87-139)
🪛 GitHub Check: codecov/patch
src/sources/shopify/webpixelTransformations/pixelTransform.js

[warning] 90-90: src/sources/shopify/webpixelTransformations/pixelTransform.js#L90
Added line #L90 was not covered by tests


[warning] 169-169: src/sources/shopify/webpixelTransformations/pixelTransform.js#L169
Added line #L169 was not covered by tests

src/sources/shopify/transform.js

[warning] 51-51: src/sources/shopify/transform.js#L51
Added line #L51 was not covered by tests

src/sources/shopify/webhookTransformations/serverSideUtlis.js

[warning] 141-141: src/sources/shopify/webhookTransformations/serverSideUtlis.js#L141
Added line #L141 was not covered by tests

src/sources/shopify/tracker/transform.js

[warning] 145-145: src/sources/shopify/tracker/transform.js#L145
Added line #L145 was not covered by tests

src/sources/shopify/webhookTransformations/serverSideTransform.js

[warning] 48-48: src/sources/shopify/webhookTransformations/serverSideTransform.js#L48
Added line #L48 was not covered by tests


[warning] 51-51: src/sources/shopify/webhookTransformations/serverSideTransform.js#L51
Added line #L51 was not covered by tests


[warning] 53-53: src/sources/shopify/webhookTransformations/serverSideTransform.js#L53
Added line #L53 was not covered by tests


[warning] 55-56: src/sources/shopify/webhookTransformations/serverSideTransform.js#L55-L56
Added lines #L55 - L56 were not covered by tests


[warning] 63-63: src/sources/shopify/webhookTransformations/serverSideTransform.js#L63
Added line #L63 was not covered by tests


[warning] 66-66: src/sources/shopify/webhookTransformations/serverSideTransform.js#L66
Added line #L66 was not covered by tests


[warning] 75-76: src/sources/shopify/webhookTransformations/serverSideTransform.js#L75-L76
Added lines #L75 - L76 were not covered by tests


[warning] 100-101: src/sources/shopify/webhookTransformations/serverSideTransform.js#L100-L101
Added lines #L100 - L101 were not covered by tests

🪛 Gitleaks (8.21.2)
test/integrations/sources/shopify/webhookTestScenarios/GenericTrackTests.ts

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


265-265: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


266-266: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

test/integrations/sources/shopify/webhookTestScenarios/CheckoutEventsTests.ts

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


265-265: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


266-266: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


331-331: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


704-704: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


706-706: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


766-766: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


785-785: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1485-1485: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1487-1487: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1501-1501: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1505-1505: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


2091-2091: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


2092-2092: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

test/integrations/sources/shopify/webhookMappingTests/CheckoutEventsTests.ts

22-22: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


24-24: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


84-84: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


103-103: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


342-342: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


343-343: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


349-349: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


351-351: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


411-411: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


430-430: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


633-633: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

test/integrations/sources/shopify/webhookMappingTests/OrderEventsTests.ts

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


131-131: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


134-134: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


135-135: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


265-265: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


266-266: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


331-331: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


406-406: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


417-417: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


418-418: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


483-483: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


580-580: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


704-704: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


706-706: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


766-766: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


785-785: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1006-1006: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1007-1007: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1013-1013: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1015-1015: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1075-1075: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1094-1094: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1283-1283: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1485-1485: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1487-1487: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1501-1501: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1505-1505: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1635-1635: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1636-1636: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1642-1642: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1644-1644: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1658-1658: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1662-1662: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts

22-22: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


24-24: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


84-84: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


103-103: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


411-411: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


430-430: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 Biome (1.9.4)
src/sources/shopify/tracker/transform.js

[error] 229-229: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

test/integrations/sources/shopify/data.ts

[error] 683-683: This number literal will lose precision at runtime.

The value at runtime will be 820982911946154500

(lint/correctness/noPrecisionLoss)


[error] 870-870: This number literal will lose precision at runtime.

The value at runtime will be 115310627314723950

(lint/correctness/noPrecisionLoss)


[error] 893-893: This number literal will lose precision at runtime.

The value at runtime will be 715243470612851200

(lint/correctness/noPrecisionLoss)


[error] 894-894: This number literal will lose precision at runtime.

The value at runtime will be 115310627314723950

(lint/correctness/noPrecisionLoss)


[error] 916-916: This number literal will lose precision at runtime.

The value at runtime will be 866550311766439000

(lint/correctness/noPrecisionLoss)


[error] 970-970: This number literal will lose precision at runtime.

The value at runtime will be 141249953214522980

(lint/correctness/noPrecisionLoss)


[error] 1040-1040: This number literal will lose precision at runtime.

The value at runtime will be 271878346596884000

(lint/correctness/noPrecisionLoss)

🔇 Additional comments (114)
src/sources/shopify/utils.test.js (2)

6-7: Import paths have been updated correctly to match new directory structure.

The import paths for both RedisDB and stats modules have been updated from a higher level path (../../../util/...) to a closer directory level (../../util/...). This change is consistent with similar updates in other files like src/sources/shopify/utils.js.


9-9: Mock path updated to match the new import path.

The jest.mock path has been correctly updated to reflect the new import path for the stats module, maintaining consistency between imports and mocks.

src/sources/shopify/webhookEventsMapping/addressMapping.json (1)

1-26: Well-structured address field mapping.

This new JSON file correctly maps address fields from Shopify's format to the standardized traits structure. The mapping follows a consistent pattern and includes all essential address components.

src/sources/shopify/config.js (2)

86-88: New address mapping JSON loader follows established pattern.

The addition of the addressMappingJSON constant follows the same pattern as other JSON mappings in this file, maintaining code consistency.


126-126: Address mapping correctly exported.

The addressMappingJSON constant is now properly exported from the module, making it available for use in other parts of the application.

src/sources/shopify/webpixelTransformations/pixelTransform.redisCartToken.test.js (2)

2-4: Import paths correctly updated to match directory structure changes.

The import paths for RedisDB, stats, and logger modules have been updated to use the correct relative paths. This change is consistent with similar updates in other files across the codebase.


6-10: Mock paths synchronized with updated import paths.

All mock paths have been updated to match the new import paths, ensuring tests will run correctly with the restructured project.

Also applies to: 12-14, 16-19

src/services/__tests__/misc.test.ts (1)

19-20: Updated test to align with Shopify v2 migration

The test has been updated to reflect the architectural change of moving Shopify sources to v2 exclusively. The hardcoded version and direct path to the transform module are consistent with other changes in the codebase.

src/controllers/util/index.ts (1)

44-44:

Details

❓ Verification inconclusive

Simplified version support to v2 only

The change restricts Shopify source mapping to only v2, which aligns with the PR objective of moving the Shopify source to version 2. This is a significant architectural change, though according to the PR description, it doesn't affect existing behaviors.


🏁 Script executed:

#!/bin/bash
# Verifying that no code paths are still referring to v0 or v1 for Shopify sources
# which could break after this change

echo "Checking for v0/v1 Shopify source references:"
rg -i --no-heading "(?:v0|v1).*sources.*shopify" --exclude="*test*"

Length of output: 582


Action Required: Re-verify Shopify Version References

The change in src/controllers/util/index.ts (line 44)—updating the versions array to ['v2']—appears to successfully restrict Shopify source mapping to version 2 in line with the PR objective. However, the verification script encountered an error due to the incorrect use of the --exclude flag with rg.

To re-verify there are no lingering references to deprecated Shopify source versions (v0 or v1), please re-run the following adjusted command that correctly excludes test files using the -g flag:

#!/bin/bash
# Verifying that no code paths are still referring to v0 or v1 for Shopify sources

echo "Checking for v0/v1 Shopify source references:"
rg -i --no-heading "(?:v0|v1).*sources.*shopify" -g '!*test*'

Once you've manually verified that there are no unintended references left, we can confidently conclude that the changes align with the PR’s intentions.

src/sources/shopify/transformPixel.js (1)

6-6: Function renamed for clarity

The function has been renamed from processV1Events to processPixelEvents to better describe its functionality rather than tying it to a specific version. This improves code readability and maintainability.

Also applies to: 35-35

src/sources/shopify/webhookEventsMapping/identifyMapping.json (1)

1-36: Well-structured mapping file

This new JSON mapping file is well-organized and follows a consistent pattern. It separates configuration from implementation, which improves maintainability. The field mappings logically connect Shopify user data to standardized trait fields.

src/sources/shopify/webpixelTransformations/pixelTransform.js (2)

5-8: Import paths updated to reflect new directory structure.

The import paths have been updated from three directories up to two directories up, aligning with the move to Shopify source v2 as mentioned in the PR objectives.


90-90:

Details

✅ Verification successful

Added timestamp to event destructuring.

The timestamp property has been added to the destructured properties from inputEvent. This is a necessary change to support setting the timestamp on the message later in the function.


🏁 Script executed:

#!/bin/bash
# Check if the timestamp property is being sent in test files

# First, look for timestamp field in test fixtures
rg -A 5 -B 5 "timestamp.*" test/integrations/sources/shopify

Length of output: 74532


Timestamp property correctly added and verified
The addition of timestamp to the destructured properties in src/sources/shopify/webpixelTransformations/pixelTransform.js has been confirmed as necessary. The test fixtures within the Shopify integrations consistently include a timestamp field, validating that this change aligns with our expectations for setting the message’s timestamp. No further modifications are needed.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 90-90: src/sources/shopify/webpixelTransformations/pixelTransform.js#L90
Added line #L90 was not covered by tests

test/integrations/sources/shopify/pixelMappingTests/CheckoutEventsTests.ts (4)

1-8: New test file for Shopify pixel checkout events.

This file introduces comprehensive test scenarios for pixel checkout events, which is essential for ensuring proper functionality of the checkout process in the v2 implementation.


133-326: Comprehensive expected output validation.

The test properly validates the transformation result structure, including order properties, product details, and contextual information. This ensures that the Shopify source correctly processes checkout events according to RudderStack's event schema.


333-785: Complete test scenario for checkout_completed event.

The checkout_completed test scenario is well-defined with appropriate input and expected output. It properly tests multiple products in a single order, which is a common real-world scenario.


9-118:

Details

✅ Verification successful

Well-structured test scenario for checkout_started event.

The test scenario includes all necessary components: request body with product details, billing address, pricing information, and appropriate context data.

The test is currently marked with skip: true. Is this intentional, or should these tests be enabled?


🏁 Script executed:

#!/bin/bash
# Check if other test files in the same directory are also skipped
rg "skip: true" test/integrations/sources/shopify/pixelMappingTests/

Length of output: 1332


Approval: Tests are intentionally skipped

The checkout_started event test is well-structured and includes all the necessary request data and context. A search across the repository confirms that other tests (such as those in ProductEventsTests.ts and CheckoutStepsTests.ts) are also marked with skip: true, indicating that this is an intentional setup for now. Please ensure that this skip behavior aligns with your overall testing strategy, and add any necessary documentation if enabling these tests in the future is planned.

src/sources/shopify/utils.js (3)

1-2: Updated import paths for Redis and stats modules.

Import paths have been updated to reflect the new directory structure, consistent with the overall refactoring effort.


67-67: Updated export for renamed function.

The export statement has been updated to match the renamed function, ensuring proper access from other modules.


53-62:

Details

❓ Verification inconclusive

Renamed function from isShopifyV1Event to isShopifyPixelEvent.

The function has been renamed to more accurately reflect its purpose - detecting Shopify Pixel events rather than specifically v1 events. This improves code readability and maintainability.

Let's ensure this renamed function is properly referenced throughout the codebase:


🏁 Script executed:

#!/bin/bash
# Check for any remaining references to the old function name
rg "isShopifyV1Event" --type js

Length of output: 31


Action: Please manually verify all references to the renamed function

The renaming of the function from isShopifyV1Event to isShopifyPixelEvent in src/sources/shopify/utils.js (lines 53–62) appears to improve clarity by better indicating its purpose (detecting Shopify Pixel events). The provided reference search using

rg "isShopifyV1Event" --type js

did not show any occurrences in JavaScript files. However, since this check produced no output and may not cover all file types, please ensure that there are no lingering references (in TypeScript files or other relevant parts of the codebase) before merging.

  • Verify that no references to isShopifyV1Event exist in non-JS files (e.g., TypeScript files).
  • Confirm that all call sites have been updated to use isShopifyPixelEvent.
src/sources/shopify/webhookTransformations/serverSideUtlis.js (2)

4-8: Updated import paths for utility functions.

Import paths have been updated to reflect the new directory structure, with some imports moved to more specific locations (e.g., extractEmailFromPayload is now imported from tracker/util).


78-81: Modified to use context.traits instead of direct traits.

The code has been restructured to place traits under the context namespace, which aligns with standardized event schema practices.

src/sources/shopify/tracker/util.js (3)

7-7: Import path correction aligns with new directory structure

The import path has been updated from a relative path to a more specific path that references the v0 directory. This change is consistent with the architectural changes in the PR that standardize the Shopify source to v2 spec.


73-73: Improved code readability with optional chaining

The condition has been simplified using optional chaining, which makes the code more concise and readable while maintaining the same functionality.


214-214: Simplified boolean logic improves clarity

The function now directly returns the comparison result instead of using negation, making the code more readable and easier to understand.

test/integrations/sources/shopify/webhookTestScenarios/CheckoutEventsTests.ts (3)

12-12: Version standardization to 'v2' aligns with PR objectives

All test scenarios have been updated from 'v1' to 'v2', consistent with the PR objective of moving the Shopify source to v2 spec. This change ensures the test suite validates against the correct version.

Also applies to: 257-257, 693-693, 1474-1474, 2083-2083


17-97: Improved test data formatting with JSON.stringify

The request body structure has been updated to use JSON.stringify() for the body content, which better simulates how the data would be sent in actual API requests. This change makes the tests more realistic and likely to catch serialization issues.

The test data has also been expanded to include additional fields that would be present in real Shopify data, making the tests more comprehensive.

Also applies to: 262-385, 698-972, 1479-1601, 2088-2169

🧰 Tools
🪛 Gitleaks (8.21.2)

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


19-102:

Details

✅ Verification successful

Static analysis detected potential API key exposure

The static analysis tool flagged several token, checkout_token, and cart_token values as potential API keys. While these appear to be test data and not actual credentials, it's worth verifying that no real API keys are included in the test files.


🏁 Script executed:

#!/bin/bash
# Check for patterns that look like real API keys in test data
echo "Checking for potential real API keys in test data..."
grep -r "writeKey.*:" --include="*.ts" test/integrations/sources/shopify/

Length of output: 6704


API Key Verification Complete – Dummy Test Data Verified

Static analysis flagged potential API key exposure due to the presence of keys like 'sample-write-key', 'dummy-write-key', and placeholder values (e.g., '2mw9SN679HngnXXXHT4oSVVBVmb'). A repository-wide grep confirmed that these keys are only present in test files and are intentionally set as dummy values for testing purposes. Please ensure that these remain strictly test data and that no production credentials are ever introduced.

🧰 Tools
🪛 Gitleaks (8.21.2)

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

src/sources/shopify/webhookTransformations/serverSideUtils.test.js (4)

77-78: Consistent key naming
price is numeric while product_id is a string. Ensure the entire pipeline handles these types as intended.


158-159: Good positive test coverage
Verifies that cart_token_hash is correctly added when a cart token is present.


173-177: Solid negative test coverage
Ensures cart_token_hash is not incorrectly added. This test strengthens confidence in the logic.


74-74:

Details

❓ Verification inconclusive

Check numeric vs. string typed fields
Confirm that numeric usage for price is consistently handled and expected elsewhere in the codebase.

Do you want me to search the repository references to ensure price is consistently handled as a number?


🏁 Script executed:

#!/bin/bash
rg -A 3 'price:' 

Length of output: 102515


Action Required: Verify Consistency of Price Field Data Types

After reviewing the repository search results, it’s clear that the price field is handled differently across the codebase. In several files (for example, in parts of the GenericTrack and CheckoutEvents test scenarios) the price is provided as a numeric value (e.g., 600 or 12.34), while in other areas (such as some webhook mapping tests) it appears as a string (e.g., '729.95'). This variation suggests that different integrations or formatting stages expect different representations.

In the file under review (src/sources/shopify/webhookTransformations/serverSideUtils.test.js) the test uses a numeric value:

{ brand: 'Hydrogen Vendor', price: 600, product_id: '7234590408818', quantity: 1 },

This usage is consistent with several other tests that expect a numeric input for price. However, given the observed coexistence of formatted (string) pricing elsewhere, please confirm that this difference is intentional and that any downstream processing correctly handles both cases. If a standard representation is desired across the codebase, consider adding explicit type conversion or clear documentation to define the expected schema.

src/sources/shopify/transform.js (2)

1-4: Clearer import naming
Renaming process to processTrackerEvents clarifies responsibilities and avoids confusion with other processes.


6-35: Helpful versioning documentation
Maintaining these references for V0, V1, and V2 event structures fosters better maintainability and onboarding.

test/integrations/sources/shopify/pixelMappingTests/ProductEventsTests.ts (1)

1-1224: Extensive test scenarios
These newly introduced scenarios thoroughly cover many Shopify pixel events. However, most are marked with skip: true. Verify whether the skips are intentional or if you plan to enable them soon.

test/integrations/sources/shopify/webhookMappingTests/OrderEventsTests.ts (8)

1-3: Good use of modular imports for test utilities and constants.

The file properly imports mock functions and constants from parent directories, promoting code reuse and maintainability.


4-11: Well-structured test scenarios with appropriate metadata.

The test scenarios are well-structured with clear identifiers, descriptive names, and proper version specification. The skip: true flag indicates these tests are being prepared but not yet activated, which is appropriate during the refactoring process.


12-304: Comprehensive input data modeling for the "Order Updated" test scenario.

The test payload contains a detailed and realistic representation of a Shopify order webhook, including all relevant order details, customer information, line items, and addresses. This thoroughness ensures proper validation of the payload parsing and transformation logic.

🧰 Tools
🪛 Gitleaks (8.21.2)

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


131-131: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


134-134: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


135-135: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


265-265: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


266-266: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


305-644: Well-defined expected output structure for accurate assertions.

The expected output structure properly defines both the track and identify events that should be generated from the order webhook. The track event includes order details and products, while the identify event captures customer information. This dual-event approach ensures proper data flow for both event tracking and user identification.

🧰 Tools
🪛 Gitleaks (8.21.2)

331-331: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


406-406: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


417-417: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


418-418: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


483-483: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


580-580: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


645-1063: Good coverage of the "Order Created" event with condensed test data.

This test scenario focuses on the "Order Created" event with a more compact request payload compared to "Order Updated", which is appropriate since you're testing a different event type with similar structure. The expected output correctly includes a "value" property that wasn't present in the "Order Updated" event.

🧰 Tools
🪛 Gitleaks (8.21.2)

704-704: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


706-706: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


766-766: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


785-785: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1006-1006: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1007-1007: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1013-1013: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1015-1015: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1064-1200: Effective minimum viable test case for "Order Cancelled" event.

The "Order Cancelled" test uses a minimal request payload with only essential fields, which is a good practice when testing specific event types. This approach helps verify that the handler works with the minimum required data rather than relying on optional fields.

🧰 Tools
🪛 Gitleaks (8.21.2)

1075-1075: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1094-1094: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1201-1664: Thorough test coverage for "Order Paid" event.

The test for the "Order Paid" event provides comprehensive validation with detailed input and expected output. I notice that the expected output structure differs slightly from other events in terms of the traits included, which appropriately reflects the differences in how various order events should be processed.

🧰 Tools
🪛 Gitleaks (8.21.2)

1283-1283: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1485-1485: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1487-1487: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1501-1501: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1505-1505: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1635-1635: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1636-1636: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1642-1642: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1644-1644: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1658-1658: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1662-1662: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1665-1666: Effective use of mock functions across all test scenarios.

The use of .map() to apply mock functions to all test scenarios ensures consistent test behavior and reduces code duplication. This is a clean pattern for injecting mocks into test data.

test/integrations/sources/shopify/webhookMappingTests/CheckoutEventsTests.ts (7)

1-3: Good organization with consistent import patterns.

The file follows the same import pattern as other test files, maintaining consistency across the test suite.


4-11: Clear test structure with descriptive scenario identifiers.

The test scenarios use consistent and meaningful identifiers (cs001, cs002, cs003) with detailed descriptions that explain the purpose of each test case.


12-248: Comprehensive "Checkout Started" webhook test scenario.

The first test scenario provides a detailed checkout started webhook payload and expected response structure, validating that cart information is properly processed and anonymousId is correctly assigned.

🧰 Tools
🪛 Gitleaks (8.21.2)

22-22: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


24-24: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


84-84: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


103-103: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


249-386: Consistent test structure for "Order Cancelled" event.

The "Order Cancelled" test scenario follows the same pattern as other tests but with event-specific data, maintaining a consistent testing approach across different event types.

🧰 Tools
🪛 Gitleaks (8.21.2)

342-342: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


343-343: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


349-349: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


351-351: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


387-392: Excellent edge case testing for race condition scenarios.

The test explicitly addresses a race condition scenario where Redis might not have an anonymousId, forcing the system to create one from the cart_token hash. This demonstrates thorough consideration of real-world edge cases.


393-631: Proper handling of edge case in race condition test.

The test scenario properly defines different expected behavior for the race condition case, where the anonymousId is set to the cart_token hash instead of a UUID from Redis. This validates the system's resilience to timing issues.

🧰 Tools
🪛 Gitleaks (8.21.2)

411-411: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


430-430: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


632-634: Consistent mock function application.

Like other test files, this uses the same pattern to apply mock functions to all test scenarios, maintaining consistency across the test suite.

🧰 Tools
🪛 Gitleaks (8.21.2)

633-633: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

src/sources/shopify/tracker/shopify_redis.util.test.js (7)

1-8: Good module organization with focused imports.

The additional import of processTrackerEvents from './transform' supports the new test cases while maintaining the existing imports.


9-23: Effective mocking of dependencies for isolated testing.

The module mocks key utility functions and configuration settings to create a controlled test environment. Mocking generateUUID and setting useRedisDatabase to true ensures predictable test behavior.


25-28: Useful timeout helper for asynchronous testing.

The timeoutPromise function provides a clean way to handle timing in asynchronous tests, particularly useful when testing Redis connection states.


319-330: Good coverage of Redis connection recovery scenarios.

The checkRedisConnectionReadyState tests properly verify both error recovery and already-connected scenarios, ensuring the connection handling is robust.


331-341: Comprehensive connection state validation.

The checkAndConnectConnection tests verify both reconnection after client end and already-connected states, providing full coverage of the connection handling logic.


342-345: Structured approach to source testing.

The test harness properly loads test cases from a JSON file, promoting maintainability by separating test data from test logic.


346-356: Thorough error handling validation.

The source tests include proper error handling, checking both successful outputs and expected error messages, ensuring that the error paths are properly tested.

test/integrations/sources/shopify/webhookMappingTests/userIdentifyTests.ts (6)

1-4: Clear file purpose with appropriate imports.

The file header comment clearly describes the purpose of the test scenarios, and imports follow the established pattern of the other test files.


5-13: Well-structured test scenario with clear description.

The test scenario is well-defined with a descriptive identifier and clear purpose statement. The use of the skip flag is consistent with other test files in the refactoring process.


14-151: Comprehensive input data for realistic checkout update testing.

The test input contains detailed customer information, shipping details, and line items that represent a realistic checkout update event from Shopify.


152-332: Properly structured track event in expected output.

The expected track event output for the checkout update includes all required fields with appropriate types and values, ensuring proper validation of the transformation logic.


333-365: Comprehensive identify event structure in expected output.

The identify event properly includes customer traits including address information, contact details, and cart token hash, ensuring proper user identification data is captured.


366-374: Consistent mock function application.

The file follows the same pattern as other test files for applying mock functions to test scenarios, maintaining consistency across the test suite.

test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts (2)

9-9: Upgraded version to 'v2'.

Switching the version from 'v1' to 'v2' is consistent with the PR goal of migrating Shopify events to the new spec.


387-389: Version bump for checkout_completed scenario matches checkout_started.

No issues noted; maintaining consistency across all checkout events.

test/integrations/sources/shopify/webhookTestScenarios/GenericTrackTests.ts (6)

12-12: Upgraded version to 'v2'.

Aligns with the broader migration effort.


17-26: JSON stringification for cart event payload.

Using JSON.stringify ensures a consistent payload structure. Double-check that the note_attributes and timestamps remain valid in text form.

🧰 Tools
🪛 Gitleaks (8.21.2)

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


96-96: Maintaining version consistency (v2).

No issues here; keeps all events in sync with the new spec.


101-103: Minimal JSON body for unsupported event is correct.

Despite being unsupported, this scenario confirms graceful handling. Looks good.


137-137: Adopting 'v2' for generic track events.

Appropriately consistent with the rest of the changes.


142-324: Expanded generic event payload with JSON.stringify.

The large object is well-structured and matches the pattern used across the codebase. As before, verify sensitive fields are properly masked if needed.

Would you like to confirm in your environment that these references are purely test data?

🧰 Tools
🪛 Gitleaks (8.21.2)

265-265: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


266-266: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

src/sources/shopify/webpixelTransformations/pixelUtils.js (9)

2-3: Use of removeNullValues and Message.

Good approach to sanitize null fields and avoid extraneous data in the final message.


51-51: Null-removal on mapped object.

Returning removeNullValues(trackProperties) ensures cleanliness of the final payload.


65-68: PageViewedEventBuilder: mapping context keys.

Mapping with mapObjectKeys(context, contextualFieldMappingJSON) is consistent. Double-check the presence of page property in the mapping JSON.


88-88: Mapping context for cartViewed event.

Ensures that context fields are standardized. No issues spotted.


115-115: Mapping context for productViewedEventBuilder.

Aligns with earlier usage. Maintains uniform data shape.


153-155: Removing null from checkout properties and mapping context.

Solid approach to keep only meaningful data in the final event.


163-167: Checkout step event references checkout_id.

Looks consistent with the rest of the file. The newly introduced param clarifies usage in subsequent logic.


178-179: Campaign parameter extraction for recognized UTM.

Proper usage of isDefinedAndNotNull(value). No concerns.


212-215: Stripping utm_ prefixes.

Code is straightforward; ensures keys are stored neatly without the prefix.

src/sources/shopify/tracker/transform.js (13)

18-19: Removed undefined values & ensuring data is not null.

The helper usage from v0/util is consistent with rest of the code.


128-141: New createMessageForEvent function.

Effectively centralizes message creation logic. This refactor improves readability.


144-165: Handling carts_update with Redis.

Separating logic into handleCartsUpdate is clear. Good approach for maintainability.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 145-145: src/sources/shopify/tracker/transform.js#L145
Added line #L145 was not covered by tests


167-190: enrichNonIdentifyMessage extracted from enrichMessage.

Enhances modularity. Looks good.


193-194: Converting userId to string.

Ensures consistent type for downstream usage.


205-206: Modular check for non-IDENTIFY event.

Offloads specialized logic to enrichNonIdentifyMessage, eliminating duplication. Nicely done.


208-208: Setting Shopify integration flag.

Aligns well with standard integration marking.


212-212: Appending library context.

Indicates the source is Shopify Cloud (version 1.0.0). This is consistent with usage in other modules.


215-215: context.topic alignment.

Attaches the Shopify topic for clarity—helpful for debugging.


217-217: Explicitly tracking cart_token.

Ensures cart flows are traceable. Looks correct.


233-241: Graceful handling of unsupported events.

Early return with NO_OPERATION_SUCCESS is a neat pattern for ignoring them.


247-251: Skipping invalid cart events.

Good approach to avoid noisy tracking. The NO_OPERATION_SUCCESS approach remains consistent.


255-256: Unified message creation for all other events.

Clean fallback to createMessageForEvent.

src/sources/shopify/webhookTransformations/serverSideTransform.js (8)

4-9: Imports look good.

These new or updated imports appear correct and align with the code usage below.


18-23: Utility imports are consistent.

These references to utility functions are appropriate for server-side transformations.


25-25: Redis connector usage is properly imported.

The import from redisConnector is valid and used below.


45-46: Re-initializing traits.

Calling message.context = message.context || {} is safe; however, resetting message.context.traits = {} overrides any pre-existing traits. Ensure no prior traits are needed from earlier processing steps.


61-64: Confirm userId assignment.

Assigning message.userId = id; is straightforward. Verify if this is always the correct interpretation of the Shopify customer.id field.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 63-63: src/sources/shopify/webhookTransformations/serverSideTransform.js#L63
Added line #L63 was not covered by tests


66-66: Good cleanup step.

Removing undefined and null values from message.context.traits helps ensure consistent final payload. Consider adding test coverage.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 66-66: src/sources/shopify/webhookTransformations/serverSideTransform.js#L66
Added line #L66 was not covered by tests


100-101: Destructuring from message.

This destructuring is straightforward but flagged for test coverage. Confirm you have tests verifying usage of userId, anonymousId, and context.traits.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 100-101: src/sources/shopify/webhookTransformations/serverSideTransform.js#L100-L101
Added lines #L100 - L101 were not covered by tests


110-111: Preserving traits in Identify event.

Cloning traits avoids undesired modifications, which is good. Ensure test cases cover conditionals when traits is empty or undefined.

test/integrations/sources/shopify/data.ts (3)

6-11: New scenario imports.

These imports for userTestScenarios, newpixelCheckoutEventsTestScenarios, etc., expand coverage for pixel and webhook tests in v2.


14-31: Migrated scenario to v2.

Renaming to serverSideEventsScenariosForLegacyApp with version: 'v2' preserves legacy test coverage while shifting to the new spec. Looks consistent.


1498-1510: Inclusion of new test scenarios.

Appending the new scenario arrays ensures coverage of webhook, pixel, and user identify flows under v2. Great to see these anchored in the shared data export.

test/integrations/sources/shopify/pixelTestScenarios/ProductEventsTests.ts (2)

16-16: Updated version from 'v1' to 'v2' for all test scenarios

The version has been consistently updated from 'v1' to 'v2' throughout all test scenarios, which aligns with the PR objective of moving the Shopify source to v2 spec.

Also applies to: 98-98, 226-226, 407-407, 663-663, 812-812, 961-961, 1048-1048


21-32: Restructured request body format for all event types

The request body structure has been updated across all event types to use JSON.stringify() to encapsulate the event data. This change improves compatibility with the v2 spec by ensuring proper serialization of complex objects before transmission.

Also applies to: 103-136, 231-285, 412-492, 668-709, 817-858, 966-981, 1053-1068

test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts (3)

8-8: Updated version from 'v1' to 'v2' for all checkout test scenarios

The version has been consistently updated from 'v1' to 'v2' across all checkout test scenarios, maintaining consistency with the product events tests and aligning with the Shopify source v2 spec refactoring.

Also applies to: 581-581, 1106-1106, 1679-1679


13-190: Restructured checkout request body format

The request body structure has been updated to use JSON.stringify() to encapsulate the event data, consistent with the changes in ProductEventsTests.ts. This ensures proper serialization of complex objects and alignment with the v2 spec format.

Also applies to: 586-747, 1111-1288, 1684-1861


1102-1674: Added new test scenarios for checkout steps

New test scenarios have been added for:

  1. checkout_shipping_info_submitted
  2. payment_info_submitted

These additions ensure more comprehensive test coverage for the checkout flow, which is critical for e-commerce functionality.

Also applies to: 1675-2247

src/sources/shopify/webpixelTransformations/pixelUtils.test.js (5)

13-15: Updated import paths for Message module

The import path for the Message module has been updated to use relative paths rather than absolute paths, which improves maintainability and is more consistent with modern JavaScript module practices.


25-77: Enhanced context object with detailed browser information

The input event context has been significantly expanded to include comprehensive browser information including document location, navigator details, and window properties. This provides a more realistic test environment and validates that the code can handle the full range of context data provided by Shopify's pixel API.


83-102: Updated expectation assertions for page view event properties

The expected message properties and context have been updated to include more detailed information such as path, search, title, url, and screen dimensions. This ensures that the page view event correctly extracts and formats information from the enhanced browser context.


703-706: Updated campaign parameter naming

Campaign parameter mapping has been changed from utm_source to source, which aligns with more modern attribution tracking systems. This change is consistently applied across multiple test cases.

Also applies to: 733-735


669-670:

Details

❓ Verification inconclusive

Simplified checkout step event builder expectations

The expectations for the checkoutStepEventBuilder test have been simplified to only check for the checkout_id property. Verify that this simplification doesn't omit critical assertions that should be tested.

This simplification could potentially miss regressions in the checkout step events. Check the implementation to confirm if other properties have been intentionally removed from the output:


🏁 Script executed:

#!/bin/bash
# Find and display the checkoutStepEventBuilder implementation
echo "Looking for checkoutStepEventBuilder implementation..."
rg -A 20 "function checkoutStepEventBuilder" --type js

Length of output: 175


Action Required: Confirm if Simplified Assertion Covers All Critical Checkout Step Properties

The current test now only asserts the presence of the checkout_id property. However, our search for the checkoutStepEventBuilder implementation didn’t return any results, so we couldn't verify if other properties were expected or intentionally removed. Please manually verify that this simplification:

  • Does not omit other critical properties that should be present in the checkout step events.
  • Aligns with the intended behavior and updated implementation of checkoutStepEventBuilder.

If after manual review you confirm that testing only checkout_id is sufficient, please document that decision. Otherwise, update the test to cover any additional properties as needed.

Comment thread test/integrations/component.test.ts Resolved
Comment thread src/sources/shopify/transform.js Resolved
@koladilip

Copy link
Copy Markdown
Contributor Author

LGTM

vinayteki95 and others added 5 commits March 21, 2025 18:15
chore: move shopify tests to v2 format
* chore(test): add tests for shopify v2 bugbash fixes

* chore(test): update descriptive labels

* chore(test): beautify structure and order of tests

* chore(test): address comment, fix directories

* chore: update pixel events context

* chore: rename mapping-specific test directories

* chore: move new shopify mapping specific tests to v2 format

* chore: add missing case
@krishna2020
krishna2020 force-pushed the chore.shopify-v2-migration2 branch from 5b8cc3e to 1bc6754 Compare March 21, 2025 12:45
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@sonarqubecloud

Copy link
Copy Markdown

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

♻️ Duplicate comments (1)
test/integrations/sources/shopify/data.ts (1)

683-683: ⚠️ Potential issue

Large numeric literals cause potential precision loss.

JavaScript integers exceed safe range around 2^53, so these ID values will lose precision at runtime. To fix:

Use strings or BigInt for exactness. For instance:

- id: 820982911946154508,
+ id: "820982911946154508",

Apply similar changes for all flagged lines (683, 870, 893, 894, 916, 970, 1040).

Also applies to: 870-870, 893-893, 894-894, 916-916, 970-970, 1040-1040

🧰 Tools
🪛 Biome (1.9.4)

[error] 683-683: This number literal will lose precision at runtime.

The value at runtime will be 820982911946154500

(lint/correctness/noPrecisionLoss)

🧹 Nitpick comments (8)
src/sources/shopify/transform.js (2)

6-35: Good documentation of payload structures across versions.

The documentation of payload structures for different versions (V0, V1, V2) provides valuable context for understanding the transformation logic. This helps developers understand the evolution of the data structure.

Consider formalizing this documentation with JSDoc format to make it more parseable by documentation tools:

-/*
-V0
-{
-  query_parameters: { }
-  key: value
-}
-
-V1
-{
-  event: {
-    query_parameters: { }
-    key: value
-  },
-  source: {}
-}
-
-V2
-{
-  request: {
-    body: {
-      
-    },
-    query_parameters: { },
-    headers: {},
-    method: 'POST',
-    url: 'https://api.shopify.com/v1/shopify/events'
-  },
-  source: {}
-}
-*/
+/**
+ * Payload structure examples across different versions:
+ * 
+ * @example V0
+ * {
+ *   query_parameters: { }
+ *   key: value
+ * }
+ * 
+ * @example V1
+ * {
+ *   event: {
+ *     query_parameters: { }
+ *     key: value
+ *   },
+ *   source: {}
+ * }
+ * 
+ * @example V2
+ * {
+ *   request: {
+ *     body: { },
+ *     query_parameters: { },
+ *     headers: {},
+ *     method: 'POST',
+ *     url: 'https://api.shopify.com/v1/shopify/events'
+ *   },
+ *   source: {}
+ * }
+ */

37-45: Effective extraction of event data from V2 request.

Based on the retrieved learnings, I acknowledge that getBodyFromV2SpecPayload already handles the case where request is undefined by throwing an appropriate error, making additional null checks unnecessary.

Consider adding a brief comment to document that error handling for null/undefined requests is handled by getBodyFromV2SpecPayload:

 function getEventFromV2Request(sourceEvent) {
+  // getBodyFromV2SpecPayload will throw an error if request is undefined
   const event = getBodyFromV2SpecPayload(sourceEvent);
   const queryParams = sourceEvent.request.query_parameters;
src/sources/shopify/tracker/transform.js (1)

230-230: Consider alternative to delete operator.

Using delete event.query_parameters may impact performance. Consider assigning undefined or using destructuring to create a new object without that property.

- const event = lodash.cloneDeep(inputEvent);
- const shopifyTopic = getShopifyTopic(event);
- delete event.query_parameters;
+ const { query_parameters, ...eventData } = lodash.cloneDeep(inputEvent);
+ const event = eventData;
+ const shopifyTopic = getShopifyTopic(event);
test/integrations/component.test.ts (1)

187-188: Removed type annotation aligns with PR objectives but decreases explicit type safety.

The code changes remove the explicit TestCaseData type annotation from the tcData parameter and hardcode the version to 'v2' instead of using DEFAULT_VERSION. While TypeScript can infer the type, explicit annotations are generally preferred for better code maintainability.

The hardcoded 'v2' version aligns with the PR objective of "refactoring the Shopify source to v2 spec" as indicated in the PR summary.

Consider maintaining the type annotation for better developer experience:

-const sourceTestHandler = async (tcData) => {
+const sourceTestHandler = async (tcData: TestCaseData) => {
  const route = `/${join(tcData.version || 'v2', 'sources', tcData.name, tcData.input.pathSuffix || '')}`;
  await testRoute(route, tcData);
};
test/integrations/sources/shopify/pixelMappingTests/CheckoutStepsTests.ts (1)

8-8: Consider enabling these tests.
All scenarios are marked with skip: true, resulting in no test coverage. If these tests are ready and stable, you might remove or set skip: false.

Also applies to: 437-437, 834-834, 1263-1263

test/integrations/sources/shopify/webhookMappingTests/OrderEventsTests.ts (1)

10-10: Consider enabling these tests.
All scenarios are marked with skip: true, leading to no test coverage. If these tests are now stable, you might remove or set skip: false.

Also applies to: 690-690, 1070-1070, 1206-1206

test/integrations/sources/shopify/webhookMappingTests/CheckoutEventsTests.ts (1)

10-10: Consider enabling these tests.
All scenarios are marked with skip: true, which removes them from active test coverage. If these tests are ready, you might remove or set skip: false.

Also applies to: 255-255, 393-393

test/integrations/sources/shopify/webhookMappingTests/userIdentifyTests.ts (1)

19-26: Test data should clearly indicate these are non-sensitive test values.

The tokens, IDs, and personally identifiable information (PII) in the test data (email, cart token, etc.) should be clearly marked as test/dummy values. Consider adding a comment or using more obvious placeholder values.

-                id: 35374569160817,
-                token: 'e89d4437003b6b8480f8bc7f8036a659',
-                cart_token: 'Z2NwLXVzLWVhc3QxOjAxSjdXRjdOQjY0NlFFNFdQVEg0MTRFM1E2',
-                email: '[email protected]',
+                id: 35374569160817, // Test ID
+                token: 'TEST_TOKEN_e89d4437003b6b8480f8bc7f8036a659',
+                cart_token: 'TEST_CART_TOKEN_Z2NwLXVzLWVhc3QxOjAxSjdXRjdOQjY0NlFFNFdQVEg0MTRFM1E2',
+                email: '[email protected]', // Test email
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b8cc3e6b6f69b4db57c043b3523e2ce709af9d4 and 1bc6754.

📒 Files selected for processing (36)
  • src/controllers/util/index.ts (1 hunks)
  • src/services/__tests__/misc.test.ts (1 hunks)
  • src/sources/shopify/config.js (2 hunks)
  • src/sources/shopify/tracker/shopify_redis.util.test.js (2 hunks)
  • src/sources/shopify/tracker/transform.js (3 hunks)
  • src/sources/shopify/tracker/util.js (3 hunks)
  • src/sources/shopify/transform.js (1 hunks)
  • src/sources/shopify/transformPixel.js (2 hunks)
  • src/sources/shopify/utils.js (3 hunks)
  • src/sources/shopify/utils.test.js (1 hunks)
  • src/sources/shopify/webhookEventsMapping/addressMapping.json (1 hunks)
  • src/sources/shopify/webhookEventsMapping/identifyMapping.json (1 hunks)
  • src/sources/shopify/webhookTransformations/serverSideTransform.js (6 hunks)
  • src/sources/shopify/webhookTransformations/serverSideUtils.test.js (3 hunks)
  • src/sources/shopify/webhookTransformations/serverSideUtlis.js (3 hunks)
  • src/sources/shopify/webpixelTransformations/pixelTransform.js (3 hunks)
  • src/sources/shopify/webpixelTransformations/pixelTransform.redisCartToken.test.js (1 hunks)
  • src/sources/shopify/webpixelTransformations/pixelUtils.js (8 hunks)
  • src/sources/shopify/webpixelTransformations/pixelUtils.test.js (5 hunks)
  • src/util/redis/redisConnector.test.js (0 hunks)
  • src/v1/sources/shopify/transform.js (0 hunks)
  • src/v1/sources/shopify/webhookEventsMapping/identifyMapping.json (0 hunks)
  • test/integrations/component.test.ts (1 hunks)
  • test/integrations/sources/shopify/data.ts (11 hunks)
  • test/integrations/sources/shopify/pixelMappingTests/CheckoutEventsTests.ts (1 hunks)
  • test/integrations/sources/shopify/pixelMappingTests/CheckoutStepsTests.ts (1 hunks)
  • test/integrations/sources/shopify/pixelMappingTests/ProductEventsTests.ts (1 hunks)
  • test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts (2 hunks)
  • test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts (5 hunks)
  • test/integrations/sources/shopify/pixelTestScenarios/ProductEventsTests.ts (8 hunks)
  • test/integrations/sources/shopify/webhookMappingTests/CheckoutEventsTests.ts (1 hunks)
  • test/integrations/sources/shopify/webhookMappingTests/OrderEventsTests.ts (1 hunks)
  • test/integrations/sources/shopify/webhookMappingTests/userIdentifyTests.ts (1 hunks)
  • test/integrations/sources/shopify/webhookTestScenarios/CheckoutEventsTests.ts (6 hunks)
  • test/integrations/sources/shopify/webhookTestScenarios/GenericTrackTests.ts (3 hunks)
  • test/integrations/sources/shopify/webhookTestScenarios/IdentifyTests.ts (0 hunks)
💤 Files with no reviewable changes (4)
  • src/v1/sources/shopify/webhookEventsMapping/identifyMapping.json
  • src/v1/sources/shopify/transform.js
  • test/integrations/sources/shopify/webhookTestScenarios/IdentifyTests.ts
  • src/util/redis/redisConnector.test.js
🚧 Files skipped from review as they are similar to previous changes (15)
  • src/controllers/util/index.ts
  • src/sources/shopify/webhookEventsMapping/addressMapping.json
  • src/sources/shopify/webpixelTransformations/pixelTransform.redisCartToken.test.js
  • src/sources/shopify/config.js
  • src/services/tests/misc.test.ts
  • src/sources/shopify/webhookEventsMapping/identifyMapping.json
  • src/sources/shopify/transformPixel.js
  • src/sources/shopify/utils.test.js
  • src/sources/shopify/tracker/util.js
  • src/sources/shopify/utils.js
  • src/sources/shopify/webpixelTransformations/pixelTransform.js
  • test/integrations/sources/shopify/pixelMappingTests/ProductEventsTests.ts
  • src/sources/shopify/webhookTransformations/serverSideUtlis.js
  • src/sources/shopify/webhookTransformations/serverSideUtils.test.js
  • test/integrations/sources/shopify/pixelTestScenarios/ProductEventsTests.ts
🧰 Additional context used
🧠 Learnings (1)
src/sources/shopify/transform.js (3)
Learnt from: krishna2020
PR: rudderlabs/rudder-transformer#4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function in Shopify source transformation throws an error if request is not defined, making additional null checks in getEventFromV2Request function unnecessary.
Learnt from: krishna2020
PR: rudderlabs/rudder-transformer#4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function throws an error if request is not defined, making additional null checks in the getEventFromV2Request function unnecessary.
Learnt from: krishna2020
PR: rudderlabs/rudder-transformer#4178
File: src/sources/shopify/transform.js:37-45
Timestamp: 2025-03-21T12:32:28.443Z
Learning: The getBodyFromV2SpecPayload function in the Shopify source throws an error if request is not defined, making additional null checks in getEventFromV2Request function unnecessary.
🧬 Code Definitions (9)
src/sources/shopify/transform.js (3)
src/sources/shopify/tracker/transform.js (2) (2)
  • event (227-227)
  • process (325-335)
src/sources/shopify/transformPixel.js (2) (2)
  • event (8-8)
  • processPixelEvents (6-32)
src/sources/shopify/utils.js (3) (3)
  • event (37-37)
  • event (55-55)
  • isShopifyPixelEvent (53-62)
src/sources/shopify/webpixelTransformations/pixelUtils.test.js (4)
src/sources/shopify/webhookTransformations/serverSideUtils.test.js (2) (2)
  • Message (14-14)
  • require (1-1)
src/sources/shopify/webpixelTransformations/pixelUtils.js (4) (4)
  • Message (3-3)
  • message (55-55)
  • pageViewedEventBuilder (64-69)
  • inputEvent (65-65)
src/sources/shopify/tracker/transform.js (5) (5)
  • Message (19-19)
  • message (41-41)
  • message (52-52)
  • message (87-87)
  • message (255-255)
src/sources/shopify/tracker/util.js (3) (3)
  • message (121-121)
  • message (185-185)
  • inputEvent (257-257)
src/sources/shopify/webpixelTransformations/pixelUtils.js (2)
src/sources/shopify/webpixelTransformations/pixelUtils.test.js (1) (1)
  • Message (13-13)
src/sources/shopify/config.js (2) (2)
  • contextualFieldMappingJSON (54-56)
  • PIXEL_EVENT_MAPPING (22-36)
src/sources/shopify/webhookTransformations/serverSideTransform.js (2)
src/sources/shopify/config.js (2) (2)
  • identifyMappingJSON (82-84)
  • addressMappingJSON (86-88)
src/sources/shopify/tracker/config.js (1) (1)
  • identifyMappingJSON (69-71)
test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts (1)
test/integrations/sources/shopify/constants.ts (1) (1)
  • dummyContext (87-139)
src/sources/shopify/tracker/transform.js (2)
src/sources/shopify/tracker/config.js (5) (5)
  • IDENTIFY_TOPICS (5-8)
  • ECOM_TOPICS (11-16)
  • useRedisDatabase (162-162)
  • INTEGERATION (81-81)
  • SUPPORTED_TRACK_EVENTS (116-159)
src/sources/shopify/tracker/util.js (6) (6)
  • redisData (29-29)
  • getDataFromRedis (21-50)
  • checkAndUpdateCartItems (242-267)
  • email (108-108)
  • inputEvent (257-257)
  • stats (6-6)
src/sources/shopify/tracker/shopify_redis.util.test.js (1)
src/sources/shopify/tracker/transform.js (1) (1)
  • process (325-335)
test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts (1)
test/integrations/sources/shopify/constants.ts (2) (2)
  • dummyBillingAddresses (71-85)
  • dummyContext (87-139)
test/integrations/sources/shopify/data.ts (6)
test/integrations/sources/shopify/webhookMappingTests/userIdentifyTests.ts (1) (1)
  • userTestScenarios (5-373)
test/integrations/sources/shopify/pixelMappingTests/CheckoutEventsTests.ts (1) (1)
  • newpixelCheckoutEventsTestScenarios (4-786)
test/integrations/sources/shopify/pixelMappingTests/CheckoutStepsTests.ts (1) (1)
  • newpixelCheckoutStepsScenarios (3-1688)
test/integrations/sources/shopify/pixelMappingTests/ProductEventsTests.ts (1) (1)
  • newpixelEventsTestScenarios (4-1223)
test/integrations/sources/shopify/webhookMappingTests/CheckoutEventsTests.ts (1) (1)
  • newWebhookcheckoutEventsTestScenarios (4-633)
test/integrations/sources/shopify/webhookMappingTests/OrderEventsTests.ts (1) (1)
  • newWebhookOrderEventsTestScenarios (4-1665)
🪛 Gitleaks (8.21.2)
test/integrations/sources/shopify/webhookTestScenarios/CheckoutEventsTests.ts

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


265-265: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


266-266: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


331-331: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


704-704: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


706-706: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


766-766: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


785-785: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1485-1485: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1487-1487: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1501-1501: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1505-1505: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


2091-2091: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


2092-2092: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

test/integrations/sources/shopify/webhookMappingTests/CheckoutEventsTests.ts

21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


22-22: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


87-87: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


165-165: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


176-176: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


177-177: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


242-242: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


301-301: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


355-355: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts

19-19: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


147-147: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


150-150: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


151-151: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

test/integrations/sources/shopify/webhookTestScenarios/GenericTrackTests.ts

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


265-265: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


266-266: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 Biome (1.9.4)
src/sources/shopify/tracker/transform.js

[error] 229-229: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

test/integrations/sources/shopify/data.ts

[error] 683-683: This number literal will lose precision at runtime.

The value at runtime will be 820982911946154500

(lint/correctness/noPrecisionLoss)


[error] 870-870: This number literal will lose precision at runtime.

The value at runtime will be 115310627314723950

(lint/correctness/noPrecisionLoss)


[error] 893-893: This number literal will lose precision at runtime.

The value at runtime will be 715243470612851200

(lint/correctness/noPrecisionLoss)


[error] 894-894: This number literal will lose precision at runtime.

The value at runtime will be 115310627314723950

(lint/correctness/noPrecisionLoss)


[error] 916-916: This number literal will lose precision at runtime.

The value at runtime will be 866550311766439000

(lint/correctness/noPrecisionLoss)


[error] 970-970: This number literal will lose precision at runtime.

The value at runtime will be 141249953214522980

(lint/correctness/noPrecisionLoss)


[error] 1040-1040: This number literal will lose precision at runtime.

The value at runtime will be 271878346596884000

(lint/correctness/noPrecisionLoss)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • 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: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
  • GitHub Check: Code Coverage
  • GitHub Check: test_and_publish
🔇 Additional comments (62)
src/sources/shopify/transform.js (1)

1-4: Improved imports for the v2 spec refactoring.

The imports have been updated to align with the v2 specification refactoring. Notably:

  • Renamed imports to match their updated function names (e.g., processPixelEvents instead of processV1Events)
  • Added getBodyFromV2SpecPayload import for handling v2 spec payloads
  • Used more descriptive import naming with processTrackerEvents to distinguish between different event processing pathways
src/sources/shopify/webpixelTransformations/pixelUtils.js (8)

2-2: Great addition of removeNullValues utility.

Adding this import from the integrations library enables better data sanitization throughout the file, ensuring cleaner payloads are sent to destinations.


3-4: Clean up of imports.

Good organization of imports, using proper paths for Message and EventType constants.


51-51: Improved data sanitization in mapObjectKeys.

Adding removeNullValues to cleanse the returned object ensures that no null values are passed downstream, which improves data quality and reduces payload size.


65-68: Enhanced structure of pageViewedEventBuilder.

Destructuring context directly and using a clearer approach to extract page properties improves readability and maintainability.


88-88: Consistent use of contextual payload mapping.

Standardizing on mapObjectKeys across all event builders improves consistency and maintainability of the codebase.

Also applies to: 107-107, 115-115, 123-123, 164-164, 180-180


153-154: Explicit sanitization of checkout properties.

Good practice to explicitly sanitize properties before passing them to the message creator, ensuring data cleanliness. The separate variable makes the code more readable.

Also applies to: 158-158


166-166: Simplified checkout_id access.

Directly accessing the token property from checkout rather than spreading the entire checkout object reduces unnecessary data copying and is more explicit about what's being used.


212-214: Improved handling of UTM parameters.

Removing the 'utm_' prefix and using the remainder as the key name follows industry standards for campaign parameter naming in analytics.

src/sources/shopify/webpixelTransformations/pixelUtils.test.js (5)

13-13: Simplified import paths.

Using a more direct import path for Message and updating its mock accordingly improves maintainability and is consistent with other files in the project.

Also applies to: 15-15


25-77: Enhanced test fixture with comprehensive context data.

The expanded context object with detailed browser, document, and window information provides more realistic test data, ensuring that the code handles real-world scenarios correctly.


83-102: Updated assertions to match new behavior.

The expanded assertions correctly verify that the page properties and context are properly extracted and mapped according to the changes in the implementation.


669-669: Simplified checkout step test assertions.

Focusing the test on just the checkout_id property aligns with the implementation changes and makes the test more focused on what's important.


703-703: Updated campaign parameter names in tests.

Correctly updated tests to expect 'source' instead of 'utm_source', reflecting the changes in the implementation that removes the 'utm_' prefix.

Also applies to: 733-733

src/sources/shopify/tracker/shopify_redis.util.test.js (5)

2-5: Enhanced test imports for better functionality.

Adding imports for processTrackerEvents, fs, path, and RedisDB enables more comprehensive testing of Redis connection handling and event processing.


9-23: Improved mocking for deterministic tests.

Mocking UUID generation and Redis database configuration ensures that tests are deterministic and don't rely on environmental factors, making them more reliable.


25-29: Added utility function for async testing.

The timeoutPromise function helps avoid test hangs and ensures that async tests complete within a reasonable time, improving test reliability.


319-341: New test suites for Redis connection handling.

These test suites verify the behavior of Redis connection state checking, ensuring that the system handles connection errors and reconnections properly, which is crucial for production reliability.


342-356: Data-driven testing for tracker events.

Using external JSON data for testing different scenarios makes the tests more maintainable and allows for easy addition of new test cases without modifying the test code.

src/sources/shopify/tracker/transform.js (6)

18-19: Updated utility imports.

Using more specific imports for utility functions and updating the import path for Message improves code organization and dependency management.


67-67: Improved code documentation.

Adding a comment about checking created_at for checkout_create events helps future developers understand potential implementation details.


128-141: Great extraction of message creation logic.

Extracting the createMessageForEvent function consolidates message creation logic into a single place, making the code more maintainable and easier to understand.


143-165: Improved handling of cart update events.

Creating a dedicated function for cart update events clarifies the special logic needed for these events and improves error handling by explicitly checking for invalid events.


167-189: Good separation of concerns for message enrichment.

Extracting the enrichNonIdentifyMessage function improves code organization by separating the enrichment logic for non-identify messages, making it easier to understand and maintain.


226-257: Cleaner event processing logic.

The refactored processEvent function now has a clearer flow:

  1. Early return for unsupported events
  2. Special handling for cart updates
  3. Standard processing for other events

This improves readability and maintainability while making the error handling more robust.

🧰 Tools
🪛 Biome (1.9.4)

[error] 229-229: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

src/sources/shopify/webhookTransformations/serverSideTransform.js (6)

4-8: Import paths refactored for v2 structure

The import paths have been updated to align with the new directory structure in v2. The changes maintain proper module resolution while updating the relative paths.

Also applies to: 11-15, 25-25


44-67: Customer traits mapping implementation improved

The refactoring now properly initializes context.traits and uses identifyMappingJSON to dynamically map customer details instead of hardcoding the mappings. This approach is more maintainable and consistent with modern best practices.


72-78: Address mapping implementation using JSON configuration

Using addressMappingJSON for shipping address mapping is a good improvement that:

  1. Makes the code more maintainable
  2. Centralizes mapping logic in configuration files
  3. Follows the same pattern as other mappings in the codebase

This is a solid improvement over the previous implementation.


100-102: Improved trait handling in createIdentifyEvent

The function now correctly extracts traits from the context object and uses lodash.cloneDeep to prevent mutation of the original traits. This is a better practice as it avoids side effects that could lead to unexpected behavior.

Also applies to: 111-111


147-150: Explicit async handling in processEvent

The code now properly awaits the asynchronous operations for setting the anonymousId and updating the Redis mapping, which ensures operations complete in the correct sequence and prevents potential race conditions.


1-194: Removal of identifyPayloadBuilder simplifies the codebase

According to the AI summary, the identifyPayloadBuilder function has been removed, and its functionality has been integrated into ecomPayloadBuilder and createIdentifyEvent. This simplification improves code maintainability by eliminating duplicated logic.

🧰 Tools
🪛 Biome (1.9.4)

[error] 126-126: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

test/integrations/sources/shopify/pixelMappingTests/CheckoutEventsTests.ts (3)

1-4: LGTM! Comprehensive test for pixel checkout events.

This new file adds test scenarios for pixel checkout events in Shopify, specifically covering 'checkout_started' and 'checkout_completed' events.


9-10: Note test scenarios are currently skipped.

Both test scenarios are marked with skip: true, meaning they won't be executed during test runs. This is likely intentional during development, but should be revisited before merging.

Is this intentional? Make sure to enable these tests before finalizing the PR if they're ready for use.


115-118: Well-structured test data with consistent naming convention.

The event information follows a clear, consistent structure and properly aligns with the Shopify data model. The dummyContext import provides reusable test fixtures, promoting DRY principles.

test/integrations/sources/shopify/webhookTestScenarios/CheckoutEventsTests.ts (4)

12-12: Version update to v2 aligned with PR objectives.

The version field has been updated from 'v1' to 'v2', which aligns with the PR objective of "refactoring the Shopify source to v2 spec" as mentioned in the PR summary.


17-95: Improved request structure using JSON.stringify for better type safety.

The request body is now properly wrapped with JSON.stringify, making the structure more explicit and ensuring the data is properly serialized. This change is consistent with the standardization efforts mentioned in the PR objectives.

🧰 Tools
🪛 Gitleaks (8.21.2)

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


257-257: Consistent version update across all test scenarios.

All test scenarios have been updated to use version 'v2', ensuring consistency across the entire test suite. This systematic approach aligns with the PR's objective to refactor the Shopify source to v2 specification.

Also applies to: 693-693, 1474-1474, 1945-1945, 2083-2083


20-21: Test API keys are properly mocked.

The static analysis tool flagged potential API key exposures, but these are mock API keys used specifically for testing purposes and pose no security risk.

Also applies to: 265-266, 331-331, 704-706, 785-785, 1485-1487, 1501-1505, 2091-2092

🧰 Tools
🪛 Gitleaks (8.21.2)

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

test/integrations/sources/shopify/pixelMappingTests/CheckoutStepsTests.ts (1)

193-195: Verify the usage of 'dummy-write-key'.
If this is an actual key, please remove or mask it. If purely a placeholder for testing, you can ignore this warning.

Also applies to: 605-608, 1019-1022, 1448-1450

test/integrations/sources/shopify/pixelTestScenarios/CheckoutStepsTests.ts (4)

8-8: Version upgrade to v2 aligns with refactoring goals.

The change from 'v1' to 'v2' is consistent with the PR objective of moving the Shopify source to version 2 specification.


13-191: Improved request body structure with JSON.stringify for better standardization.

The restructured request body now properly uses JSON.stringify to encapsulate the event data, which provides better serialization and standardization. The payload structure with id, name, data, type, clientId, timestamp, context and pixelEventLabel follows a more consistent format.

🧰 Tools
🪛 Gitleaks (8.21.2)

19-19: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


147-147: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


150-150: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


151-151: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


1102-1288: New checkout step events added for more comprehensive tracking.

The addition of checkout_shipping_info_submitted event enhances the checkout flow tracking capabilities, providing better visibility into the customer journey through the checkout process.


1676-1861: New payment_info_submitted event adds important conversion step tracking.

The addition of the payment_info_submitted event provides critical tracking for the payment step of the checkout process, completing the checkout funnel tracking capabilities.

test/integrations/sources/shopify/webhookMappingTests/userIdentifyTests.ts (4)

1-4: New test file adds valuable coverage for user identification functionality.

This new file properly tests the multiplexing of checkout update events into both track and identify calls, ensuring customer data is correctly enriched. The file structure aligns with the rest of the test suite.


12-12: Skipped test may need to be enabled before merging.

This test is currently marked with skip: true, meaning it won't run as part of the test suite. Consider enabling it before merging if the functionality is ready for testing, or add a comment explaining why it's skipped.

Is this test intentionally skipped due to ongoing development, or should it be enabled before merging?


13-13: Version v2 specification is consistent with other test files.

The use of version 'v2' here is consistent with the other changes in this PR, supporting the migration to the new version specification.


373-373: Good usage of mock functions for test scenarios.

Using the map function to apply mockFns to all test scenarios is a clean approach, making the tests more maintainable and consistent.

test/integrations/sources/shopify/pixelTestScenarios/CheckoutEventsTests.ts (4)

9-9: Version upgrade to v2 maintains consistency across test files.

The update from 'v1' to 'v2' is consistent with the PR objective and aligns with changes in other test files.

Also applies to: 389-389


14-118: Restructured request body with JSON.stringify for checkout_started event.

The checkout_started event's request body now properly uses JSON.stringify and follows the v2 specification format with a more detailed data structure. The addition of fields like discountsAmount with currencyCode and finalLinePrice instead of price improves data completeness.


394-531: Restructured request body with JSON.stringify for checkout_completed event.

The checkout_completed event follows the same pattern as the checkout_started event, ensuring consistency across different event types while adhering to the v2 specification.


16-24: Ensure tokens in test data are clearly marked as non-sensitive test values.

Similar to the other files, the tokens and IDs in the test data should be clearly indicated as test/dummy values to avoid confusion with real sensitive data.

Also applies to: 404-404

test/integrations/sources/shopify/webhookTestScenarios/GenericTrackTests.ts (6)

12-12: Version upgrade to v2 maintains consistency across test suites.

The update from 'v1' to 'v2' across all test scenarios is consistent with the PR's refactoring goals and aligns with changes in other test files.

Also applies to: 96-96, 137-137


17-26: Restructured request body for Cart Update event follows v2 specification.

The Cart Update event now properly uses JSON.stringify for the request body, following the v2 specification pattern.

🧰 Tools
🪛 Gitleaks (8.21.2)

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


101-102: Simplified request body for unsupported event maintains consistency.

The unsupported event test case maintains the same JSON.stringify pattern as the other scenarios, ensuring a consistent approach across different test cases.


142-323: Comprehensive test data for generic event follows v2 specification.

The generic event test case maintains the JSON.stringify pattern and includes a comprehensive set of test data that covers various aspects of order and customer information, providing good test coverage.

🧰 Tools
🪛 Gitleaks (8.21.2)

265-265: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


266-266: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


594-594: Good usage of mock functions for test scenarios.

Using the map function to apply mockFns to all test scenarios is a clean approach, making the tests more maintainable and consistent.


19-21: Ensure test tokens and IDs are clearly marked as non-sensitive.

Similar to the other files, tokens and IDs in the test data should be clearly indicated as test/dummy values to avoid any security concerns.

Also applies to: 102-102, 185-185

🧰 Tools
🪛 Gitleaks (8.21.2)

20-20: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

test/integrations/sources/shopify/data.ts (5)

6-11: New import structure supports pixel and webhook refactoring.

The added imports align with the refactoring goal of separating pixel and webhook event scenarios, creating clearer test organization and improving maintainability.


14-14: Good variable renaming for clarity.

Renaming serverSideEventsScenarios to serverSideEventsScenariosForLegacyApp clearly indicates these scenarios are for legacy compatibility, improving code readability.


19-19: Appropriate version update to v2.

Consistently updating the version field from 'v1' to 'v2' across all test scenarios aligns with the PR objective to move the Shopify source to version 2.

Also applies to: 54-54, 88-88, 129-129, 175-175, 207-207, 391-391, 453-453, 671-671


24-36: Request body structure improvement with JSON.stringify().

The request structure has been standardized to use JSON.stringify() for the body content, which ensures consistent serialization and better reflects real API interactions.

Also applies to: 93-95, 135-137, 180-182, 212-288, 396-427, 458-547


1497-1510: Test scenario updates properly migrate to v2 implementation.

The data export now correctly includes the new v2 test scenarios while commenting out the older ones. This approach allows for a smooth transition to the new version while maintaining the ability to revert if needed.

The inclusion of specialized test scenarios for different event types (pixel checkout events, webhook events, etc.) provides better test coverage and aligns with the modular approach to handling different event sources.

Comment thread src/sources/shopify/transform.js Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DO NOT MERGE Don't merge this PR without having discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants