Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Parsing at the gate: Shopify and Webflow

Shopify and Webflow apps send the same kinds of data (customers, products, content, events) in different shapes. When both share one Cloudflare Worker as the gating endpoint, the Worker does the same five things to every request before anything reaches Xano, BigQuery or Basin:

 Shopify                              Webflow
 webhooks · app proxy · Web Pixel     webhooks · Data API · site custom code · Designer Extension
         │                                     │
         └───────────────┬─────────────────────┘
                         ▼
 Cloudflare Worker (one gating endpoint)
   1. verify   the signature (HMAC), the timestamp, the shop or site
   2. parse    into a typed Rust struct (compiled to WebAssembly)
   3. normalise ISO 3166 codes, UTC timestamps, money as micros, IDs as GIDs
   4. decide   consent and purpose from the ledger, through the release gate
   5. record   an idempotency key and a receipt, then forward
                         │
                         ▼
 Xano (system of record) · Basin Pipelines (events) · BigQuery (Google joins)

The rule from Function gating across clouds applies: steps 2 to 4 are one Rust crate, not a parser per app. The ECC side of the book already works this way; Shopify and Webflow are two more inputs to it.

Where each app’s data comes in

App surfaceWhat arrivesHow it’s verifiedParsing notes
Shopify webhooksJSON for orders, customers, products, refunds; the GDPR topics (customers/data_request, customers/redact, shop/redact)X-Shopify-Hmac-Sha256 over the raw bodyPayloads are REST-shaped: a numeric id plus admin_graphql_api_id (the GID). Keep the GID. Delivery is at least once and can arrive out of order: deduplicate on the webhook ID
Shopify app proxyStorefront requests forwarded from /apps/… to the WorkerA signature query parameter (HMAC over the other parameters)Shopify strips cookies on the proxy; the shopper arrives as logged_in_customer_id and shop, not as a session cookie
Shopify Web PixelStandard customer events: page_viewed, product_viewed, product_added_to_cart, checkout_started, checkout_completedRuns in Shopify’s sandbox; posts to the WorkerShopify applies its Customer Privacy API before the pixel runs; the gate records the consent the pixel ran under, it doesn’t override it
Shopify FunctionsDiscount, delivery and checkout logic, in WebAssemblyRuns inside ShopifyNo network calls. A Function can’t ask the gate; the gate’s decision has to be written beforehand (to a metafield the Function’s input query reads)
Shopify Admin GraphQLProducts, variants, markets, translations, on requestApp access tokencamelCase fields, GIDs, MoneyV2 (amount as a decimal string, currencyCode)
Webflow webhooksForm submissions, CMS item changes, site publishx-webflow-signature (HMAC) with x-webflow-timestamp; reject stale timestampsRetries on failure: deduplicate on the item ID and timestamp
Webflow Data APICMS items, locales, assetsSite or app tokenfieldData is keyed by each field’s slug; option fields return option IDs, reference fields return item IDs, rich text is HTML, images are {fileId, url, alt}; isDraft, isArchived, lastPublished decide what’s live; each locale is its own item version (cmsLocaleId)
Webflow site custom codeOne tag in the head that loads the islands and the consent checkServed by the WorkerWebflow has no consent API of its own: the edge banner and the Worker’s session decision are the consent layer
Webflow Designer ExtensionThe designer’s app inside the DesignerWebflow’s extension authReads classes, data-* attributes and components: the same contract Beautiful Soup reads from an export (see What is ABAP?)

One record from three shapes

The same product, as each source sends it, and as the gate writes it:

FieldECCShopifyWebflow CMSAfter the gate
IDMATNR 000000000000012345gid://shopify/Product/9001 (webhook: id: 9001)Item ID 64f…, slug heated-mat-queenProduct key from the Xano crosswalk, with all three kept
TitleMAKT-MAKTX per language keytitle, translations per localefieldData.name per cmsLocaleIdText per BCP 47 locale
PriceKONP-KBETR 129.00, KONWA USDMoneyV2 {"amount": "129.0", "currencyCode": "USD"}A number field, currency implied by the site{amountMicros: 129000000, currency: "USD"}
UpdatedDATS + server local timeISO 8601 UTClastUpdated ISO 8601UTC with a sequence number
Live?LVORM deletion flagstatus ACTIVE / DRAFT / ARCHIVEDisDraft, isArchivedOne status enum

Gaps the shared endpoint has to cover

GapWhyWhat the gate does
Shopify Functions can’t call outNo network access inside a FunctionWrites the decision ahead of time where the Function reads it; a stale decision expires
Out-of-order webhooksBoth platforms retry; an update can arrive after a newer oneCompare the source’s timestamp with the stored one; the newer wins, the older is receipted and dropped
Two sources of consentShopify’s Customer Privacy API on the storefront, the edge banner on WebflowOne ledger subject per person; both decisions recorded with their source and banner version
No cookie on the app proxyShopify strips itSession tied by the signed logged_in_customer_id or a signed token, never a cookie
Webflow fields keyed by slugA designer renaming a field’s slug breaks a parser that hard-codes itMap slugs in one place (the crosswalk), fail the build or the request loudly on an unknown slug
Drafts and localesWebflow and Shopify both hold unpublished and per-locale versionsOnly published, current-locale versions forward; drafts never leave
Personal data in eventsForm submissions and checkout events can carry names and e-mailsPseudonymise before Basin; personal data goes to Xano only, under the gate

The rule: one endpoint, one parser, one ledger. Shopify and Webflow keep their own surfaces; the Worker verifies, parses into the same typed record, and asks the same gate, so a product, a person or a consent decision means the same thing whichever app sent it.

One Rust crate, layered into WebAssembly: ownership, Javy and conditional loading

The gate’s rules live in one Rust crate (src/release_gate.rs: decide(destination, subject, rows) -> Decision). The same crate can be compiled into each layer that has to apply them, including a Shopify Function, which can’t call the gate itself. What makes that safe is Rust’s ownership model; what makes it cheap is loading each piece only where and when it’s needed.

Ownership, in one paragraph

In Rust every value has exactly one owner. Other code can borrow it, either read-only (many at once) or to change it (one at a time), and the compiler checks both rules before the program runs. When the owner goes out of scope the value is freed. There is no garbage collector, so a WebAssembly module built from Rust carries no runtime to manage memory: it is small, starts fast and behaves the same on every run. Two classes of bug that matter when parsing untrusted input, reading freed memory and two writers changing the same data, can’t compile.

The model maps onto the gate. One owner per decision: the Worker owns it, writes it once, and every other layer only borrows a read-only copy. The same rule in the type system is the same rule in the architecture.

The layers

LayerBuild targetWho loads it, and whenNetworkWhat it does with the decision
Cloudflare Worker (the gate’s endpoint)WebAssembly for Workers, through workers-rs / wasm-bindgenBundled at deploy; your code decides per request which routes instantiate itYesOwns it: reads the ledger, calls decide, writes the result
Shopify Function (discount, delivery, checkout validation)WebAssembly (WASI), built by the Shopify CLIShopify runs it, only when that function is active for the shop and the cart or checkout reaches itNoneBorrows it: reads the decision the Worker wrote to a metafield, through the Function’s input query
Browser islandWebAssembly, wasm-bindgenThe Worker adds its tag to the page only after the session’s consent decisionThrough the WorkerUses it for display only (a price preview, a converter); never decides
Native and PythonNative binary; Python extension (PyO3)Batch jobs, the design pipelineYesReads it, never writes consent

Rust or Javy for a Shopify Function

Shopify Functions can be written in Rust or in JavaScript. JavaScript Functions are compiled with Javy, a Bytecode Alliance project started at Shopify, which builds a WebAssembly module that runs your JavaScript inside an embedded JavaScript engine (QuickJS).

RustJavaScript through Javy
What’s in the moduleYour compiled logic onlyYour script plus a JavaScript engine to run it (Javy can link the engine separately to keep the module small)
MemoryOwnership, decided at compile time; no garbage collectorThe engine’s garbage collector, inside the module
Size and speedSmaller and faster for the same logicLarger, and more instructions per run
Shopify’s limitsFurther from Functions’ size, memory and instruction limitsCloser to them as the logic grows
Reuse in other layersThe same crate as the Worker and the batch toolsThe same JavaScript can run in a Worker directly, but not in the Rust core
Best forRules shared with the gate; anything heavy (many cart lines, pricing, parsing)Small, Function-only logic a JavaScript team owns

Shopify publishes the current Function limits and recommends Rust where performance matters; check them before choosing. For this layer the deciding point is reuse: a Rust Function reads the decision with the same type the Worker wrote it with, so the two can’t drift.

The decision as a shared type

The Worker serialises a decision with an expiry; the Function deserialises it with the same struct and refuses one that’s stale. A sketch, built on the crate’s existing Decision:

#![allow(unused)]
fn main() {
use serde::{Deserialize, Serialize};

/// Written once by the Worker (the owner) to an app metafield; read-only everywhere else.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PublishedDecision {
    pub destination: String,   // e.g. "member_price", "audience"
    pub allowed: bool,         // release_gate::Decision.allowed
    pub reason: String,        // release_gate::Decision.reason
    pub rule_version: u32,     // which version of the rules decided it
    pub expires_at: i64,       // Unix seconds; after this the decision is not trusted
}

impl PublishedDecision {
    /// Borrows `self` read-only: checking a decision never changes it.
    pub fn is_current(&self, now: i64) -> bool {
        now < self.expires_at
    }
}
}

In the Function, a missing, unreadable or expired decision falls back to the safe default for its purpose: deny for anything that grants a member price, a discount tied to consent or an audience; ignore (proceed normally) for anything that is part of fulfilling the order. The time the Function compares against has to come from its input, since a Function has no network and no clock of its own to trust.

Conditional loading, server side

Loading each piece only where it is needed keeps every layer small and keeps decisions where they belong:

  • In the Worker, the module is bundled at deploy, but it doesn’t have to run on every request. Instantiate the Rust core only on routes that parse or decide (webhooks, the app proxy, exports), keep it for the isolate’s lifetime, and let static pages skip it.
  • For the browser, the Worker decides on the server which island tags to add (HTMLRewriter), after the consent check. A visitor who hasn’t consented never downloads a module they aren’t allowed to run. That’s the same consent-first rule as What is ABAP? → islands, applied to WebAssembly.
  • For Shopify Functions, Shopify does the loading: a Function runs only when it is active for the shop and the cart or checkout reaches it. What you control is its input: the input query asks only for the fields and the metafield the decision needs, so the Function reads less and runs fewer instructions.

The rule: one crate, one owner per decision. The Worker owns and writes; Shopify Functions, browser islands and batch tools borrow and read; each layer loads the module only when its route, its consent state or Shopify’s activation needs it.