fix(ms-bing-capi): item price should be number not integer#3859
Open
scottlepich-lz wants to merge 1 commit into
Open
fix(ms-bing-capi): item price should be number not integer#3859scottlepich-lz wants to merge 1 commit into
scottlepich-lz wants to merge 1 commit into
Conversation
The `items` field defined per-item `price` with `type: 'integer'`, which is too strict. Microsoft's UET Conversions API accepts DECIMAL item prices in whole currency units — their official docs show the `price` parameter example as 25.1 and every JSON sample uses decimals such as "price": 25.1 and "price": 27.3 (https://learn.microsoft.com/en-us/advertising/guides/uet-conversion-api-integration). With `type: 'integer'`, Segment's mapping-kit rejected valid decimal prices (e.g. 9.99) with "400: Item Price must be an integer but it was a number", dropping the entire event. Changing the type to `number` allows decimal prices through. `quantity` remains an integer. generated-types.ts is unchanged since both integer and number map to the TypeScript type `number`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Updates the Microsoft Bing CAPI destination schema to allow decimal item prices and adds a regression test to ensure decimal prices pass mapping validation and are forwarded to Bing.
Changes:
- Relaxed
items[].pricevalidation fromintegertonumberin the action field schema. - Added a unit test confirming a decimal item price (
9.99) is accepted and appears in the outgoing request payload.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/destination-actions/src/destinations/ms-bing-capi/sendEvent/fields.ts | Loosens schema validation for item price to accept decimals. |
| packages/destination-actions/src/destinations/ms-bing-capi/sendEvent/tests/sendEvent.test.ts | Adds regression coverage for decimal item prices being forwarded successfully. |
| .post(`/v1/${settings.UetTag}/events`, (body: any) => { | ||
| const items = body.data[0].customData.items | ||
| expect(items).toHaveLength(1) | ||
| expect(items[0].price).toBe(9.99) |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Microsoft Bing CAPI destination's
itemsInputField defines the per-itempriceproperty withtype: 'integer'. This is too strict: Microsoft's own UET Conversions API accepts decimal item prices in whole currency units.Because of this, Segment's mapping-kit rejects perfectly valid decimal prices (e.g.
9.99) with:Since mapping validation fails, the entire event is dropped — not just the price field. Any storefront selling at non-round prices (which is essentially all of them) silently loses conversion events.
Evidence (Microsoft docs)
Microsoft's official UET Conversions API integration guide documents
priceas a decimal:priceexample value as25.1(a decimal)."price": 25.1and"price": 27.3.ecommTotalValueis typednumber($double).So
integeris incorrect; the correct type isnumber.Fix
Change the
items[].pricefield fromtype: 'integer'totype: 'number'.quantityis left asinteger(correct for quantity). Nothing else is changed.generated-types.tsis unchanged, because bothintegerandnumbermap to the TypeScript typenumber. Codegen (generate:types) was run for the destination and produced no diff.Testing
sendEvent/__tests__/sendEvent.test.tsproving a decimal item price (9.99) is now accepted and forwarded to the request payload without a validation error.type: 'integer'with the exact errorItem Price must be an integer but it was a number, and passes withtype: 'number'.jest src/destinations/ms-bing-capi).Follow-up observation (out of scope, not changed here)
While in this file I noticed a separate latent bug: the
itemsfield'sdefaultmapping writes to keyitem_price, but the defined property isprice. Since the field isadditionalProperties: false,item_priceis silently dropped, so the default mapping never sends a price at all. I've deliberately left this out of this PR to keep it focused on the type fix; flagging it as a follow-up.🤖 Generated with Claude Code