@moonbase.sh/storefront 3.14.0 → 3.16.0

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/README.md CHANGED
@@ -706,6 +706,21 @@ const { payload } = await jwtVerify(token, jwks, {
706
706
 
707
707
  Don't read the widget's `localStorage` entry yourself: it holds the refresh token as well, which must never leave the browser.
708
708
 
709
+ ## Saving the customer's address
710
+
711
+ `Moonbase.updateAddress(address)` saves the signed-in customer's address and resolves to the customer as saved. Their next checkout starts from it; a checkout they have already entered billing details in keeps those. It rejects when nobody is signed in, and for an address the store can't use: it needs a known country, a street address, a city or a region, and in the US a postal code.
712
+
713
+ ```ts
714
+ const user = await Moonbase.updateAddress({
715
+ countryCode: 'AU',
716
+ streetAddress1: '1 George Street',
717
+ streetAddress2: null,
718
+ locality: 'Sydney',
719
+ region: 'NSW',
720
+ postCode: '2000',
721
+ })
722
+ ```
723
+
709
724
  ## Integrations
710
725
 
711
726
  The widget can forward its commerce and auth events to common marketing/analytics SDKs without any extra glue code. Enable a provider by passing its config in `integrations`:
@@ -762,6 +777,21 @@ onConsentGranted(() => Moonbase.configure({ integrations: { metaPixel: { pixelId
762
777
  Moonbase.configure({ integrations: { metaPixel: undefined } })
763
778
  ```
764
779
 
780
+ ### Attribution
781
+
782
+ The widget reads how a visitor arrived: the UTM tags and the referring site, and the ad click IDs Google Ads, Meta, Microsoft Advertising and TikTok add to their links (`gclid`, `gbraid`, `wbraid`, `fbclid`, `msclkid`, `ttclid`). It sends them with the cart, checkout and sign-up, so campaign revenue, UTM-targeted prices and traffic types work.
783
+
784
+ A click ID identifies the visitor's click, so the widget keeps one, and records the arrival on a cart as the page loads (so a visitor who comes back later to buy is still put down to it), only with the visitor's consent to marketing cookies. Without it, it keeps only which platform the click came from, and the arrival for the tab only.
785
+
786
+ Until your page says anything, the widget follows the store's setting in Moonbase, Account settings > Storefront > "Features" > "Ad and campaign tracking": "Ask where the law requires it" tracks visitors outside the EEA, the United Kingdom and Switzerland (by where Moonbase locates the visit) and waits for consent elsewhere, "Only with cookie consent" always waits, and "Always" never asks. Whatever your cookie banner reports wins over the setting:
787
+
788
+ ```ts
789
+ onConsentGranted(() => Moonbase.configure({ attribution: { consent: true } }))
790
+ onConsentWithdrawn(() => Moonbase.configure({ attribution: { consent: false } }))
791
+ ```
792
+
793
+ Whether a setting fits your business is for your own legal advice; a business based in the EU may owe consent to every visitor.
794
+
765
795
  ### Identity
766
796
 
767
797
  `signed-in` / `signed-up` forward an identify call when an email/id is available (Meta advanced match, GA4 `user_id`, Klaviyo identify, TikTok identify). On `signed-out`, Moonbase clears what each SDK supports (GA4 `user_id` is reset, GTM gets a `logout` push); Meta, TikTok, and Klaviyo expose no per-user logout, so their profiles persist for the session.
@@ -1,4 +1,5 @@
1
1
  import { ActivationRequestFulfillmentType } from '@moonbase.sh/vue';
2
+ import { Address } from '@moonbase.sh/vue';
2
3
  import { CartItem } from '@moonbase.sh/vue';
3
4
  import { CheckoutBackdropColor } from '@moonbase.sh/vue';
4
5
  import { CheckoutBackdropOpacity } from '@moonbase.sh/vue';
@@ -288,6 +289,7 @@ declare class MoonbaseImpl implements MoonbaseInstance {
288
289
  configure(options: DeepPartial<MoonbaseOptions>): void;
289
290
  on<TEvent extends MoonbaseEvent>(eventType: TEvent, callback: (event: MoonbaseEventArgs[TEvent]) => void): void;
290
291
  getAccessToken(): Promise<string | null>;
292
+ updateAddress(address: Address): Promise<User>;
291
293
  private handleLocationIntent;
292
294
  sign_in(parameters?: MoonbaseIntentArgs['sign_in']): void;
293
295
  sign_up(parameters?: MoonbaseIntentArgs['sign_up']): void;
@@ -330,6 +332,14 @@ export declare type MoonbaseInstance = MoonbaseInstanceIntents & {
330
332
  * account's public key, at `/api/key/jwks` on your Moonbase address.
331
333
  */
332
334
  getAccessToken: () => Promise<string | null>;
335
+ /**
336
+ * Saves the signed-in customer's address, which their next checkout starts from, and
337
+ * resolves to the customer as saved. A checkout they have already entered billing details
338
+ * in keeps those. Rejects when nobody is signed in, and for an address the store can't
339
+ * use: it needs a known country, a street address, a city or a region, and in the US a
340
+ * postal code.
341
+ */
342
+ updateAddress: (address: Address) => Promise<User>;
333
343
  };
334
344
 
335
345
  declare type MoonbaseInstanceIntents = {
@@ -655,6 +665,18 @@ export declare interface MoonbaseOptions {
655
665
  * `dataLayer`, `klaviyo`, `ttq`). Pass a provider's config to turn it on.
656
666
  */
657
667
  integrations: IntegrationsConfig;
668
+ attribution: {
669
+ /**
670
+ * Whether the visitor has agreed to marketing cookies, the category your cookie banner files
671
+ * ad tracking under. `true` keeps the ad click IDs (`gclid`, `fbclid` and the rest) and
672
+ * remembers the arrival beyond the visit; `false` records only the UTM tags, referring site
673
+ * and the ad platform a click came from, for the visit. Left out (the default), the widget
674
+ * follows the store's setting in Moonbase (Account settings > Storefront > "Features"):
675
+ * always, per country, or only with cookie consent. Set it with `Moonbase.configure()` when
676
+ * the banner reports the visitor's choice.
677
+ */
678
+ consent: boolean | undefined;
679
+ };
658
680
  }
659
681
 
660
682
  /** Which surface a promotion was rendered on. */