@fayz-ai/storefront 0.77.0 → 0.77.5

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.
@@ -0,0 +1,22 @@
1
+ import type { ResolvedStorefrontConfig } from '../document/config';
2
+ import { useCartStore } from '../stores/cart.store';
3
+ type CartSnapshot = ReturnType<typeof useCartStore.getState>;
4
+ /** The ordering flow: the menu, a product, the cart, the checkout, the order. */
5
+ export declare function isOrderingPath(path: string, menuPath: string | undefined): boolean;
6
+ /** What a cart change was, line by line: added or removed, and how many. */
7
+ export declare function cartChanges(prev: Pick<CartSnapshot, 'lines'>, next: Pick<CartSnapshot, 'lines'>): {
8
+ kind: "added" | "removed";
9
+ line: CartSnapshot["lines"][number];
10
+ quantity: number;
11
+ }[];
12
+ /**
13
+ * Mounted once by the shell. Starts the analytics client when the store
14
+ * configured one, and reports what no single page owns: cart changes and a
15
+ * shopper leaving the ordering flow for the rest of the site.
16
+ */
17
+ export declare function StorefrontAnalytics({ config, path }: {
18
+ config: ResolvedStorefrontConfig;
19
+ path: string;
20
+ }): null;
21
+ export {};
22
+ //# sourceMappingURL=StorefrontAnalytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorefrontAnalytics.d.ts","sourceRoot":"","sources":["../../src/analytics/StorefrontAnalytics.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,EAAE,YAAY,EAA+B,MAAM,sBAAsB,CAAA;AAIhF,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAA;AAE5D,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAIlF;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC;UAIrE,OAAO,GAAG,SAAS;UAAQ,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;cAAY,MAAM;IAQpG;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,wBAAwB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,QAoDvG"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The storefront's own record of what a shopper does, kept apart from any
3
+ * analytics vendor: components report here, and whatever is listening (the
4
+ * PostHog client, a test, nothing) decides what to do with it.
5
+ *
6
+ * Events reported before anyone listens are held, so the first product view of
7
+ * a page load is not lost while the analytics client is still loading.
8
+ */
9
+ export type StorefrontEventName = 'product_viewed' | 'product_added_to_cart' | 'product_removed_from_cart' | 'cart_viewed' | 'coupon_applied' | 'checkout_started' | 'checkout_step_viewed' | 'checkout_payment_selected' | 'checkout_error' | 'checkout_completed' | 'delivery_exit';
10
+ export type StorefrontEventProperties = Record<string, string | number | boolean | null | undefined>;
11
+ export interface StorefrontEvent {
12
+ name: StorefrontEventName;
13
+ properties: StorefrontEventProperties;
14
+ at: number;
15
+ }
16
+ type Listener = (event: StorefrontEvent) => void;
17
+ type Identifier = (email: string) => void;
18
+ export declare function trackStorefront(name: StorefrontEventName, properties?: StorefrontEventProperties): void;
19
+ export declare function onStorefrontEvent(listener: Listener): () => void;
20
+ /**
21
+ * The buyer said who they are (the checkout's e-mail). Handed to the analytics
22
+ * client to tie this visit to the orders the server reports; never sent on as
23
+ * an event property.
24
+ */
25
+ export declare function identifyStorefrontBuyer(email: string): void;
26
+ export declare function setStorefrontIdentifier(fn: Identifier | null): void;
27
+ /** When this event was last reported on this page (0 = never). */
28
+ export declare function lastStorefrontEventAt(name: StorefrontEventName): number;
29
+ /** Test seam: forget listeners and held events. */
30
+ export declare function resetStorefrontEvents(): void;
31
+ export {};
32
+ //# sourceMappingURL=bus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bus.d.ts","sourceRoot":"","sources":["../../src/analytics/bus.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,mBAAmB,GAC3B,gBAAgB,GAChB,uBAAuB,GACvB,2BAA2B,GAC3B,aAAa,GACb,gBAAgB,GAChB,kBAAkB,GAClB,sBAAsB,GACtB,2BAA2B,GAC3B,gBAAgB,GAChB,oBAAoB,GACpB,eAAe,CAAA;AAEnB,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;AAEpG,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,mBAAmB,CAAA;IACzB,UAAU,EAAE,yBAAyB,CAAA;IACrC,EAAE,EAAE,MAAM,CAAA;CACX;AAED,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;AAChD,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;AASzC,wBAAgB,eAAe,CAAC,IAAI,EAAE,mBAAmB,EAAE,UAAU,GAAE,yBAA8B,GAAG,IAAI,CAY3G;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI,CAUhE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAK3D;AAED,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAMnE;AAED,kEAAkE;AAClE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM,CAEvE;AAED,mDAAmD;AACnD,wBAAgB,qBAAqB,IAAI,IAAI,CAM5C"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The store's own door to PostHog, for a Worker (or any fetch-style) host.
3
+ *
4
+ * Events sent to the store's domain under `/ingest` are not dropped by ad
5
+ * blockers the way requests to a known analytics host are, and the store needs
6
+ * no PostHog setting of its own: every store forwards to the same project.
7
+ *
8
+ * if (url.pathname.startsWith('/ingest')) return posthogProxy(request)
9
+ */
10
+ export interface PostHogProxyOptions {
11
+ /** The path the storefront's analytics client sends to. Default `/ingest`. */
12
+ prefix?: string;
13
+ /** PostHog's region. Default `us`. */
14
+ region?: 'us' | 'eu';
15
+ }
16
+ export declare function isPostHogProxyPath(pathname: string, prefix?: string): boolean;
17
+ export declare function posthogProxy(request: Request, options?: PostHogProxyOptions): Promise<Response>;
18
+ //# sourceMappingURL=edge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/analytics/edge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sCAAsC;IACtC,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CACrB;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAY,GAAG,OAAO,CAEhF;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAwBzG"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Who a buyer is, to analytics, without telling analytics who they are.
3
+ *
4
+ * `store:<store id>:<sha-256 of the lower-cased e-mail>`. The server computes
5
+ * the same string for the orders it reports (shop migration 0146), which is how
6
+ * a visit and its order meet in one person. The store id keeps one e-mail at two
7
+ * restaurants as two people: every store's buyers stay that store's.
8
+ */
9
+ export declare function storeBuyerId(storeId: string, email: string): Promise<string | null>;
10
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/analytics/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQzF"}
@@ -0,0 +1,5 @@
1
+ export { trackStorefront, onStorefrontEvent, identifyStorefrontBuyer, type StorefrontEvent, type StorefrontEventName, type StorefrontEventProperties, } from './bus';
2
+ export { storeBuyerId } from './identity';
3
+ export { startStorefrontPostHog, type StorefrontAnalyticsConfig, type StorefrontPostHogConfig } from './posthog';
4
+ export { StorefrontAnalytics, isOrderingPath, cartChanges } from './StorefrontAnalytics';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analytics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,GAC/B,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,sBAAsB,EAAE,KAAK,yBAAyB,EAAE,KAAK,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAChH,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,31 @@
1
+ export interface StorefrontPostHogConfig {
2
+ /** The project token (`phc_…`). Public by design: it can only send events. */
3
+ key: string;
4
+ /** The store this site sells for (its tenant id). Every event is grouped under it. */
5
+ storeId: string;
6
+ /** Where the client sends. Default `/ingest`, the store's own proxy (see `posthogProxy`). */
7
+ apiHost?: string;
8
+ /** The PostHog app, for links the toolbar opens. Default `https://us.posthog.com`. */
9
+ uiHost?: string;
10
+ /** Session replay. Default on; inputs are always masked. */
11
+ replay?: boolean;
12
+ }
13
+ export interface StorefrontAnalyticsConfig {
14
+ posthog?: StorefrontPostHogConfig;
15
+ }
16
+ interface StartContext {
17
+ storeName: string;
18
+ commerceMode: string;
19
+ }
20
+ /**
21
+ * Loads PostHog once per page, in the browser only, off the first paint.
22
+ *
23
+ * The store is attached to every event in `before_send` rather than with
24
+ * `posthog.group()`: `group()` turns on person processing for every anonymous
25
+ * visitor, and across hundreds of stores that is the difference between paying
26
+ * for buyers and paying for every passer-by. Only a buyer who reaches the
27
+ * checkout becomes a person (`identify` with the store-scoped buyer id).
28
+ */
29
+ export declare function startStorefrontPostHog(config: StorefrontPostHogConfig, context: StartContext): Promise<void> | null;
30
+ export {};
31
+ //# sourceMappingURL=posthog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posthog.d.ts","sourceRoot":"","sources":["../../src/analytics/posthog.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,uBAAuB;IACtC,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAA;IACX,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAA;IACf,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4DAA4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,uBAAuB,CAAA;CAClC;AAED,UAAU,YAAY;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;CACrB;AAID;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,uBAAuB,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAkCnH"}
@@ -1 +1 @@
1
- {"version":3,"file":"createStorefrontApp.d.ts","sourceRoot":"","sources":["../../src/app/createStorefrontApp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM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CAAA;IACnC,KAAK,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAA;IAClC,QAAQ,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAA;CACxC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,KAAK,CAAC,aAAa,CAgBtF"}
@@ -35,8 +35,8 @@ export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorEle
35
35
  * explicit targets are still handed to the browser.
36
36
  */
37
37
  export declare function Link({ to, children, onClick, target, ...rest }: LinkProps): React.DetailedReactHTMLElement<{
38
- style?: React.CSSProperties | undefined;
39
38
  prefix?: string | undefined | undefined;
39
+ style?: React.CSSProperties | undefined;
40
40
  slot?: string | undefined | undefined;
41
41
  title?: string | undefined | undefined;
42
42
  download?: any;