create-brainerce-store 1.86.0 → 1.86.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var require_package = __commonJS({
|
|
|
31
31
|
"package.json"(exports2, module2) {
|
|
32
32
|
module2.exports = {
|
|
33
33
|
name: "create-brainerce-store",
|
|
34
|
-
version: "1.86.
|
|
34
|
+
version: "1.86.1",
|
|
35
35
|
description: "Scaffold a production-ready e-commerce storefront connected to Brainerce",
|
|
36
36
|
homepage: "https://brainerce.com",
|
|
37
37
|
repository: {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Cart, Order, Product, ProductVariant, TrackingEventItem } from 'brainerce';
|
|
2
|
-
import { getCartTotals
|
|
2
|
+
import { getCartTotals } from 'brainerce';
|
|
3
3
|
|
|
4
4
|
import { getClient } from './brainerce';
|
|
5
5
|
|
|
@@ -33,6 +33,50 @@ function toNumber(value: string | number | null | undefined): number | undefined
|
|
|
33
33
|
return Number.isFinite(parsed) ? parsed : undefined;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Builds a GA4-spec-correct `{value, tax, shipping}` triple for the
|
|
38
|
+
* `purchase` event: `value` must be net item revenue only, with `tax`/
|
|
39
|
+
* `shipping` reported alongside it, never folded in.
|
|
40
|
+
*
|
|
41
|
+
* Inlined rather than imported from `buildGa4CommercePayload` in `brainerce`
|
|
42
|
+
* — that export only exists from SDK 3.1.0 (published 2026-09-18), and
|
|
43
|
+
* `packages/cli-shared/src/versions.ts`'s exact pin cannot move to a
|
|
44
|
+
* same-day release (its own ⛔⛔ RAISING THIS FLOOR rule: a pinned version
|
|
45
|
+
* must already be 7+ days old, so cooldown-enforcing installers like pnpm's
|
|
46
|
+
* `minimumReleaseAge` or ChatGPT Sites don't refuse the scaffold outright).
|
|
47
|
+
* Once 3.1.0 clears that week, swap this back to the SDK import and raise
|
|
48
|
+
* the pin in the same change — keep this in sync with
|
|
49
|
+
* `packages/sdk/src/types.ts`'s `buildGa4CommercePayload` until then.
|
|
50
|
+
*/
|
|
51
|
+
function buildGa4CommercePayload(
|
|
52
|
+
order: Pick<
|
|
53
|
+
Order,
|
|
54
|
+
| 'subtotal'
|
|
55
|
+
| 'totalAmount'
|
|
56
|
+
| 'discountAmount'
|
|
57
|
+
| 'shippingAmount'
|
|
58
|
+
| 'taxAmount'
|
|
59
|
+
| 'taxBreakdown'
|
|
60
|
+
| 'currency'
|
|
61
|
+
>
|
|
62
|
+
): { value: number; tax: number; shipping: number; currency?: string } {
|
|
63
|
+
const pricesIncludeTax = order.taxBreakdown?.pricesIncludeTax ?? false;
|
|
64
|
+
const subtotal = parseFloat(order.subtotal ?? order.totalAmount) || 0;
|
|
65
|
+
const discountAmount = parseFloat(order.discountAmount ?? '0') || 0;
|
|
66
|
+
const shippingAmount = parseFloat(order.shippingAmount ?? '0') || 0;
|
|
67
|
+
const taxAmount = parseFloat(order.taxAmount ?? '0') || 0;
|
|
68
|
+
const tax = pricesIncludeTax ? (order.taxBreakdown?.totalTax ?? 0) : taxAmount;
|
|
69
|
+
const netSubtotal = pricesIncludeTax ? subtotal - tax : subtotal;
|
|
70
|
+
const round2 = (n: number) => Math.round((n + Number.EPSILON) * 100) / 100;
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
value: round2(Math.max(0, netSubtotal - discountAmount)),
|
|
74
|
+
tax: round2(tax),
|
|
75
|
+
shipping: round2(shippingAmount),
|
|
76
|
+
currency: order.currency,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
36
80
|
/**
|
|
37
81
|
* Resolve the SKU for a product/variant pair, falling back to the variant then
|
|
38
82
|
* product id only when the catalog has no SKU at all — a feed-less product
|