-
Notifications
You must be signed in to change notification settings - Fork 511
fix: include items array in purchase dataLayer #8339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -237,10 +237,14 @@ describe('useSubscription', () => { | |||||||||||||||||||||||||||||||||||||
| event: 'purchase', | ||||||||||||||||||||||||||||||||||||||
| transaction_id: 'sub_123', | ||||||||||||||||||||||||||||||||||||||
| currency: 'USD', | ||||||||||||||||||||||||||||||||||||||
| item_id: 'monthly_creator', | ||||||||||||||||||||||||||||||||||||||
| item_variant: 'monthly', | ||||||||||||||||||||||||||||||||||||||
| item_category: 'subscription', | ||||||||||||||||||||||||||||||||||||||
| quantity: 1 | ||||||||||||||||||||||||||||||||||||||
| items: [ | ||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||
| item_id: 'monthly_creator', | ||||||||||||||||||||||||||||||||||||||
| item_variant: 'monthly', | ||||||||||||||||||||||||||||||||||||||
| item_category: 'subscription', | ||||||||||||||||||||||||||||||||||||||
| quantity: 1 | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+240
to
+247
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Locate and read the test file to see the actual content at lines 240-247
fd -e test.ts -p "useSubscription" | head -5Repository: Comfy-Org/ComfyUI_frontend Length of output: 374 🏁 Script executed: # Search for the useSubscription.test.ts file
find . -name "useSubscription.test.ts" -type fRepository: Comfy-Org/ComfyUI_frontend Length of output: 139 🏁 Script executed: # Try a broader search for subscription test files
fd "useSubscription" -t fRepository: Comfy-Org/ComfyUI_frontend Length of output: 728 🏁 Script executed: # Read the test file, focusing on lines 240-247 and surrounding context
sed -n '230,260p' src/platform/cloud/subscription/composables/useSubscription.test.tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 976 🏁 Script executed: # Get total line count to understand the file size
wc -l src/platform/cloud/subscription/composables/useSubscription.test.tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 141 🏁 Script executed: # Search for the test containing the items payload to understand context
rg "item_id.*monthly_creator" src/platform/cloud/subscription/composables/useSubscription.test.ts -A 10 -B 10Repository: Comfy-Org/ComfyUI_frontend Length of output: 636 🏁 Script executed: # Read the useSubscription.ts implementation to see what's being pushed to dataLayer
rg "item_id.*monthly_creator" src/platform/cloud/subscription/composables/useSubscription.ts -A 10 -B 10Repository: Comfy-Org/ComfyUI_frontend Length of output: 52 🏁 Script executed: # Broader search for dataLayer push in the implementation
rg "dataLayer" src/platform/cloud/subscription/composables/useSubscription.ts -A 5 -B 5Repository: Comfy-Org/ComfyUI_frontend Length of output: 52 🏁 Script executed: # Search for item_name or price being set in subscription composables
rg "item_name|item_price|price.*subscription" src/platform/cloud/subscription/ -t tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 163 🏁 Script executed: # Read the implementation file to see the full dataLayer payload being constructed
cat -n src/platform/cloud/subscription/composables/useSubscription.ts | sed -n '1,100p'Repository: Comfy-Org/ComfyUI_frontend Length of output: 4233 🏁 Script executed: # Search for where the dataLayer event is constructed - look for item_name context
rg "item_name" src/platform/cloud/subscription/composables/useSubscription.ts -B 5 -A 5Repository: Comfy-Org/ComfyUI_frontend Length of output: 345 🏁 Script executed: # Search for price in the subscription context
rg "price" src/platform/cloud/subscription/composables/ -t ts -B 2 -A 2Repository: Comfy-Org/ComfyUI_frontend Length of output: 519 🌐 Web query:
💡 Result: For GA4 ecommerce (including the
In other words: each item must include at least one of Related implementation notes from Google’s docs:
Sources: Google Analytics developer documentation. [1] [2] [3] [4] 🏁 Script executed: # Let me get more context around the dataLayer push to understand the full picture
rg "pushDataLayerEvent\|dataLayer.push" src/platform/cloud/subscription/composables/useSubscription.ts -B 10 -A 10Repository: Comfy-Org/ComfyUI_frontend Length of output: 52 🏁 Script executed: # Search for the dataLayer event construction with different pattern
rg "event.*purchase" src/platform/cloud/subscription/composables/useSubscription.ts -B 15 -A 5Repository: Comfy-Org/ComfyUI_frontend Length of output: 801 🏁 Script executed: # Look at the entire section where the items array is built
sed -n '100,250p' src/platform/cloud/subscription/composables/useSubscription.tsRepository: Comfy-Org/ComfyUI_frontend Length of output: 4294 Assert The test omits assertions for fields that are being sent in the actual payload. Add assertions to verify Suggested test update items: [
{
item_id: 'monthly_creator',
+ item_name: expect.any(String),
item_variant: 'monthly',
item_category: 'subscription',
+ price: expect.any(Number),
quantity: 1
}
]📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||
| expect(localStorage.getItem('pending_subscription_purchase')).toBeNull() | ||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test assertion is incomplete. The implementation includes
item_nameandpricefields in the items array (lines 132 and 135 in useSubscription.ts), but the test doesn't verify these fields are present. For a monthly creator subscription, these should be:item_name: The translated plan name (e.g., "Creator")price: 35 (the monthly price for creator tier)Additionally, the test should verify the top-level
valuefield is set to 35.