@astroscope/relay 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +236 -2
- package/dist/awin/index.d.ts +57 -0
- package/dist/awin/index.d.ts.map +1 -0
- package/dist/awin/index.js +54 -0
- package/dist/awin/index.js.map +1 -0
- package/dist/bus-Z7l8oJtS.d.ts +48 -0
- package/dist/bus-Z7l8oJtS.d.ts.map +1 -0
- package/dist/ccm19/index.d.ts +33 -0
- package/dist/ccm19/index.d.ts.map +1 -0
- package/dist/ccm19/index.js +29 -0
- package/dist/ccm19/index.js.map +1 -0
- package/dist/client/index.d.ts +16 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +24 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/track.d.ts +4 -0
- package/dist/client/track.d.ts.map +1 -0
- package/dist/client/track.js +7 -0
- package/dist/client/track.js.map +1 -0
- package/dist/collect-DRl177oR.d.ts +31 -0
- package/dist/collect-DRl177oR.d.ts.map +1 -0
- package/dist/collect-DWdHyn-u.js +45 -0
- package/dist/collect-DWdHyn-u.js.map +1 -0
- package/dist/commerce-DCGO8yag.d.ts +106 -0
- package/dist/commerce-DCGO8yag.d.ts.map +1 -0
- package/dist/commerce-DgNeBWhO.js +46 -0
- package/dist/commerce-DgNeBWhO.js.map +1 -0
- package/dist/context-D11BBDcb.js +27 -0
- package/dist/context-D11BBDcb.js.map +1 -0
- package/dist/conversion-user-CV8xIWDK.js +49 -0
- package/dist/conversion-user-CV8xIWDK.js.map +1 -0
- package/dist/conversion-user-DCfM5EuZ.d.ts +35 -0
- package/dist/conversion-user-DCfM5EuZ.d.ts.map +1 -0
- package/dist/ga4/index.d.ts +50 -0
- package/dist/ga4/index.d.ts.map +1 -0
- package/dist/ga4/index.js +45 -0
- package/dist/ga4/index.js.map +1 -0
- package/dist/gtm/index.d.ts +51 -0
- package/dist/gtm/index.d.ts.map +1 -0
- package/dist/gtm/index.js +49 -0
- package/dist/gtm/index.js.map +1 -0
- package/dist/index.browser.d.ts +8 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +11 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/instance-Bu0EMJ_-.js +268 -0
- package/dist/instance-Bu0EMJ_-.js.map +1 -0
- package/dist/matomo/index.d.ts +46 -0
- package/dist/matomo/index.d.ts.map +1 -0
- package/dist/matomo/index.js +61 -0
- package/dist/matomo/index.js.map +1 -0
- package/dist/openai/index.d.ts +97 -0
- package/dist/openai/index.d.ts.map +1 -0
- package/dist/openai/index.js +79 -0
- package/dist/openai/index.js.map +1 -0
- package/dist/openai/server.d.ts +17 -0
- package/dist/openai/server.d.ts.map +1 -0
- package/dist/openai/server.js +55 -0
- package/dist/openai/server.js.map +1 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +13 -0
- package/dist/react/index.js.map +1 -0
- package/dist/runtime-J8VplGyY.d.ts +48 -0
- package/dist/runtime-J8VplGyY.d.ts.map +1 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +10 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/middleware-entrypoint.d.ts +2 -0
- package/dist/server/middleware-entrypoint.d.ts.map +1 -0
- package/dist/server/middleware-entrypoint.js +25 -0
- package/dist/server/middleware-entrypoint.js.map +1 -0
- package/dist/server/registry.d.ts +9 -0
- package/dist/server/registry.d.ts.map +1 -0
- package/dist/server/registry.js +10 -0
- package/dist/server/registry.js.map +1 -0
- package/dist/server/track.d.ts +10 -0
- package/dist/server/track.d.ts.map +1 -0
- package/dist/server/track.js +90 -0
- package/dist/server/track.js.map +1 -0
- package/dist/shared-CSwqcxPI.d.ts +77 -0
- package/dist/shared-CSwqcxPI.d.ts.map +1 -0
- package/dist/shared-D281USsp.js +106 -0
- package/dist/shared-D281USsp.js.map +1 -0
- package/package.json +133 -3
- package/src/astro/Track.astro +16 -0
- package/src/astro/index.ts +1 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/inline.ts
|
|
2
|
+
/**
|
|
3
|
+
* The body of an inline script that tracks an event from hand-written html, before or after the
|
|
4
|
+
* bus is installed; `<Track>` is the same thing as an Astro component.
|
|
5
|
+
*/
|
|
6
|
+
function inlineTrack(input) {
|
|
7
|
+
return `(self.__relay__??={q:[]}).q.push(${JSON.stringify(input).replaceAll("<", String.raw`\u003c`)});`;
|
|
8
|
+
}
|
|
9
|
+
// src/collect.ts
|
|
10
|
+
const DEFAULT_WITHIN = 500;
|
|
11
|
+
/**
|
|
12
|
+
* Folds single sightings into batched events: a list of items is seen one item at a time as the
|
|
13
|
+
* rows enter the viewport, while `view_item_list` is one event with the items. The collector
|
|
14
|
+
* keeps a buffer per key and flushes it after the quiet time, in chunks of at most `max` items.
|
|
15
|
+
* Buffers are shared by every caller of the collector, so sightings with the same key from
|
|
16
|
+
* several components go out as one batch.
|
|
17
|
+
*/
|
|
18
|
+
function collect(options) {
|
|
19
|
+
const { flush, within = DEFAULT_WITHIN } = options;
|
|
20
|
+
const max = Math.max(1, options.max ?? Infinity);
|
|
21
|
+
const keyOf = options.key ?? ((context) => context);
|
|
22
|
+
const batches = /* @__PURE__ */ new Map();
|
|
23
|
+
const flushBatch = (key) => {
|
|
24
|
+
const batch = batches.get(key);
|
|
25
|
+
if (!batch) return;
|
|
26
|
+
batches.delete(key);
|
|
27
|
+
for (let start = 0; start < batch.items.length; start += max) flush(batch.context, batch.items.slice(start, start + max));
|
|
28
|
+
};
|
|
29
|
+
return (context, item) => {
|
|
30
|
+
const key = keyOf(context);
|
|
31
|
+
const existing = batches.get(key);
|
|
32
|
+
existing?.cancel();
|
|
33
|
+
const handle = setTimeout(() => flushBatch(key), within);
|
|
34
|
+
const batch = {
|
|
35
|
+
context: existing?.context ?? context,
|
|
36
|
+
items: existing?.items ?? [],
|
|
37
|
+
cancel: () => clearTimeout(handle)
|
|
38
|
+
};
|
|
39
|
+
batch.items.push(item);
|
|
40
|
+
batches.set(key, batch);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export { inlineTrack as n, collect as t };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=collect-DWdHyn-u.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect-DWdHyn-u.js","names":[],"sources":["../src/inline.ts","../src/collect.ts"],"sourcesContent":["import type { TrackInput } from './shared.js';\n\n/**\n * The body of an inline script that tracks an event from hand-written html, before or after the\n * bus is installed; `<Track>` is the same thing as an Astro component.\n */\nexport function inlineTrack(input: TrackInput): string {\n // `<` is escaped so the json can never close the script tag it is written into\n const json = JSON.stringify(input).replaceAll('<', String.raw`\\u003c`);\n\n return `(self.__relay__??={q:[]}).q.push(${json});`;\n}\n","/** a collector's options; the context identifies the batch and is handed back with it */\nexport type CollectOptions<Ctx, Item> = {\n /** takes one batch: the context of its first sighting and the items collected under that key */\n flush: (context: Ctx, items: Item[]) => void;\n /** the quiet time after the last sighting before the batch goes out, in ms; default 500 */\n within?: number | undefined;\n /** the items a batch carries at most, 1 or more; a fuller buffer goes out as several batches; default unlimited */\n max?: number | undefined;\n};\n\n/** a string context is its own key; any other context needs a key function */\ntype KeyOption<Ctx> = Ctx extends string\n ? { key?: ((context: Ctx) => string) | undefined }\n : { key: (context: Ctx) => string };\n\ntype Batch<Ctx, Item> = {\n context: Ctx;\n items: Item[];\n cancel: () => void;\n};\n\nconst DEFAULT_WITHIN = 500;\n\n/**\n * Folds single sightings into batched events: a list of items is seen one item at a time as the\n * rows enter the viewport, while `view_item_list` is one event with the items. The collector\n * keeps a buffer per key and flushes it after the quiet time, in chunks of at most `max` items.\n * Buffers are shared by every caller of the collector, so sightings with the same key from\n * several components go out as one batch.\n */\nexport function collect<Ctx, Item>(\n options: CollectOptions<Ctx, Item> & KeyOption<Ctx>,\n): (context: Ctx, item: Item) => void {\n const { flush, within = DEFAULT_WITHIN } = options;\n const max = Math.max(1, options.max ?? Infinity);\n const keyOf = options.key ?? ((context: Ctx) => context as string);\n const batches = new Map<string, Batch<Ctx, Item>>();\n\n const flushBatch = (key: string): void => {\n const batch = batches.get(key);\n\n if (!batch) {\n return;\n }\n\n batches.delete(key);\n\n for (let start = 0; start < batch.items.length; start += max) {\n flush(batch.context, batch.items.slice(start, start + max));\n }\n };\n\n return (context, item) => {\n const key = keyOf(context);\n const existing = batches.get(key);\n\n existing?.cancel();\n\n const handle = setTimeout(() => flushBatch(key), within);\n const batch: Batch<Ctx, Item> = {\n context: existing?.context ?? context,\n items: existing?.items ?? [],\n cancel: () => clearTimeout(handle),\n };\n\n batch.items.push(item);\n batches.set(key, batch);\n };\n}\n"],"mappings":";;;;;AAMA,SAAgB,YAAY,OAA2B;CAIrD,OAAO,oCAFM,KAAK,UAAU,KAAK,CAAC,CAAC,WAAW,KAAK,OAAO,GAAG,QAEf,EAAE;AAClD;;ACUA,MAAM,iBAAiB;;;;;;;;AASvB,SAAgB,QACd,SACoC;CACpC,MAAM,EAAE,OAAO,SAAS,mBAAmB;CAC3C,MAAM,MAAM,KAAK,IAAI,GAAG,QAAQ,OAAO,QAAQ;CAC/C,MAAM,QAAQ,QAAQ,SAAS,YAAiB;CAChD,MAAM,0BAAU,IAAI,IAA8B;CAElD,MAAM,cAAc,QAAsB;EACxC,MAAM,QAAQ,QAAQ,IAAI,GAAG;EAE7B,IAAI,CAAC,OACH;EAGF,QAAQ,OAAO,GAAG;EAElB,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,MAAM,QAAQ,SAAS,KACvD,MAAM,MAAM,SAAS,MAAM,MAAM,MAAM,OAAO,QAAQ,GAAG,CAAC;CAE9D;CAEA,QAAQ,SAAS,SAAS;EACxB,MAAM,MAAM,MAAM,OAAO;EACzB,MAAM,WAAW,QAAQ,IAAI,GAAG;EAEhC,UAAU,OAAO;EAEjB,MAAM,SAAS,iBAAiB,WAAW,GAAG,GAAG,MAAM;EACvD,MAAM,QAA0B;GAC9B,SAAS,UAAU,WAAW;GAC9B,OAAO,UAAU,SAAS,CAAC;GAC3B,cAAc,aAAa,MAAM;EACnC;EAEA,MAAM,MAAM,KAAK,IAAI;EACrB,QAAQ,IAAI,KAAK,KAAK;CACxB;AACF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { d as RelayParams } from "./shared-CSwqcxPI.js";
|
|
2
|
+
/** an item of the commerce events */
|
|
3
|
+
type CommerceItem = {
|
|
4
|
+
item_id: string;
|
|
5
|
+
item_name: string;
|
|
6
|
+
price: number;
|
|
7
|
+
quantity: number;
|
|
8
|
+
index?: number | undefined;
|
|
9
|
+
affiliation?: string | undefined;
|
|
10
|
+
coupon?: string | undefined;
|
|
11
|
+
discount?: number | undefined;
|
|
12
|
+
item_brand?: string | undefined;
|
|
13
|
+
item_category?: string | undefined;
|
|
14
|
+
item_category2?: string | undefined;
|
|
15
|
+
item_category3?: string | undefined;
|
|
16
|
+
item_category4?: string | undefined;
|
|
17
|
+
item_category5?: string | undefined;
|
|
18
|
+
item_list_id?: string | undefined;
|
|
19
|
+
item_list_name?: string | undefined;
|
|
20
|
+
item_variant?: string | undefined;
|
|
21
|
+
location_id?: string | undefined;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
type Items = {
|
|
25
|
+
items: readonly CommerceItem[];
|
|
26
|
+
};
|
|
27
|
+
type Money = {
|
|
28
|
+
currency?: string | undefined;
|
|
29
|
+
value?: number | undefined;
|
|
30
|
+
};
|
|
31
|
+
type Listed = {
|
|
32
|
+
item_list_id?: string | undefined;
|
|
33
|
+
item_list_name?: string | undefined;
|
|
34
|
+
};
|
|
35
|
+
/** every well-known params type takes custom parameters next to the known ones */
|
|
36
|
+
type Params<P> = P & RelayParams;
|
|
37
|
+
type ViewItemParams = Params<Items & Money>;
|
|
38
|
+
type ViewItemListParams = Params<Items & Listed>;
|
|
39
|
+
type SelectItemParams = Params<Items & Listed>;
|
|
40
|
+
type AddToCartParams = Params<Items & Money>;
|
|
41
|
+
type RemoveFromCartParams = Params<Items & Money>;
|
|
42
|
+
type ViewCartParams = Params<Items & Money>;
|
|
43
|
+
type BeginCheckoutParams = Params<Items & Money & {
|
|
44
|
+
coupon?: string | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
type AddShippingInfoParams = Params<Items & Money & {
|
|
47
|
+
coupon?: string | undefined;
|
|
48
|
+
shipping_tier?: string | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
type AddPaymentInfoParams = Params<Items & Money & {
|
|
51
|
+
coupon?: string | undefined;
|
|
52
|
+
payment_type?: string | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
type PurchaseParams = Params<Items & {
|
|
55
|
+
transaction_id: string;
|
|
56
|
+
value: number;
|
|
57
|
+
currency: string;
|
|
58
|
+
tax?: number | undefined;
|
|
59
|
+
shipping?: number | undefined;
|
|
60
|
+
coupon?: string | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
type RefundParams = Params<Money & {
|
|
63
|
+
transaction_id: string;
|
|
64
|
+
tax?: number | undefined;
|
|
65
|
+
shipping?: number | undefined;
|
|
66
|
+
items?: readonly CommerceItem[] | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
type SearchParams = Params<{
|
|
69
|
+
search_term: string;
|
|
70
|
+
}>;
|
|
71
|
+
type SignUpParams = Params<{
|
|
72
|
+
method?: string | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
type LoginParams = Params<{
|
|
75
|
+
method?: string | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
type GenerateLeadParams = Params<Money>;
|
|
78
|
+
type WellKnownName = 'view_item' | 'view_item_list' | 'select_item' | 'add_to_cart' | 'remove_from_cart' | 'view_cart' | 'begin_checkout' | 'add_shipping_info' | 'add_payment_info' | 'purchase' | 'refund' | 'search' | 'sign_up' | 'login' | 'generate_lead';
|
|
79
|
+
/** whether a well-known event is a commerce one, whose parameters a container reads under `ecommerce` */
|
|
80
|
+
declare function isCommerceEvent(name: string): boolean;
|
|
81
|
+
/** what a builder set is made of: the event's name and parameters in, the destination's payload out */
|
|
82
|
+
type WellKnownCreate<R> = (name: WellKnownName, params: RelayParams, extra: RelayParams | undefined) => R;
|
|
83
|
+
/**
|
|
84
|
+
* The well-known events as builders over `create`: one function per event, typed by its
|
|
85
|
+
* parameters, taking the destination's extra parameters second. The ga4 and tag-manager builders are
|
|
86
|
+
* made of it; a site's own destination that speaks ga4's names can be too.
|
|
87
|
+
*/
|
|
88
|
+
declare function wellKnownEvents<R>(create: WellKnownCreate<R>): {
|
|
89
|
+
viewItem: (params: ViewItemParams, extra?: RelayParams) => R;
|
|
90
|
+
viewItemList: (params: ViewItemListParams, extra?: RelayParams) => R;
|
|
91
|
+
selectItem: (params: SelectItemParams, extra?: RelayParams) => R;
|
|
92
|
+
addToCart: (params: AddToCartParams, extra?: RelayParams) => R;
|
|
93
|
+
removeFromCart: (params: RemoveFromCartParams, extra?: RelayParams) => R;
|
|
94
|
+
viewCart: (params: ViewCartParams, extra?: RelayParams) => R;
|
|
95
|
+
beginCheckout: (params: BeginCheckoutParams, extra?: RelayParams) => R;
|
|
96
|
+
addShippingInfo: (params: AddShippingInfoParams, extra?: RelayParams) => R;
|
|
97
|
+
addPaymentInfo: (params: AddPaymentInfoParams, extra?: RelayParams) => R;
|
|
98
|
+
purchase: (params: PurchaseParams, extra?: RelayParams) => R;
|
|
99
|
+
refund: (params: RefundParams, extra?: RelayParams) => R;
|
|
100
|
+
search: (params: SearchParams, extra?: RelayParams) => R;
|
|
101
|
+
signUp: (params: SignUpParams, extra?: RelayParams) => R;
|
|
102
|
+
login: (params: LoginParams, extra?: RelayParams) => R;
|
|
103
|
+
generateLead: (params: GenerateLeadParams, extra?: RelayParams) => R;
|
|
104
|
+
};
|
|
105
|
+
export { WellKnownCreate as _, CommerceItem as a, wellKnownEvents as b, PurchaseParams as c, SearchParams as d, SelectItemParams as f, ViewItemParams as g, ViewItemListParams as h, BeginCheckoutParams as i, RefundParams as l, ViewCartParams as m, AddShippingInfoParams as n, GenerateLeadParams as o, SignUpParams as p, AddToCartParams as r, LoginParams as s, AddPaymentInfoParams as t, RemoveFromCartParams as u, WellKnownName as v, isCommerceEvent as y };
|
|
106
|
+
//# sourceMappingURL=commerce-DCGO8yag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commerce-DCGO8yag.d.ts","names":[],"sources":["../src/commerce.ts"],"mappings":";;KAMY;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;GACC;;KAGE;EAAU,gBAAgB;;KAC1B;EAAU;EAA+B;;KACzC;EAAW;EAAmC;;;KAG9C,OAAO,KAAK,IAAI;KAET,iBAAiB,OAAO,QAAQ;KAChC,qBAAqB,OAAO,QAAQ;KACpC,mBAAmB,OAAO,QAAQ;KAClC,kBAAkB,OAAO,QAAQ;KACjC,uBAAuB,OAAO,QAAQ;KACtC,iBAAiB,OAAO,QAAQ;KAChC,sBAAsB,OAAO,QAAQ;EAAU;;KAC/C,wBAAwB,OAClC,QAAQ;EAAU;EAA6B;;KAErC,uBAAuB,OACjC,QAAQ;EAAU;EAA6B;;KAErC,iBAAiB,OAC3B;EACE;EACA;EACA;EACA;EACA;EACA;;KAGQ,eAAe,OACzB;EACE;EACA;EACA;EACA,iBAAiB;;KAGT,eAAe;EAAS;;KACxB,eAAe;EAAS;;KACxB,cAAc;EAAS;;KACvB,qBAAqB,OAAO;KAE5B;;iBAgCI,gBAAgB;;KAKpB,gBAAgB,MAAM,MAAM,eAAe,QAAQ,aAAa,OAAO,4BAA4B;;;;;;iBAO/F,gBAAgB,GAAG,QAAQ,gBAAgB;EAGjC,WAAA,QAAA,gBAAA,QAAA,gBAAc;EAAd,eAAA,QAAA,oBAAA,QAAA,gBAAc;EAAd,aAAA,QAAA,kBAAA,QAAA,gBAAc;EAAd,YAAA,QAAA,iBAAA,QAAA,gBAAc;EAAd,iBAAA,QAAA,sBAAA,QAAA,gBAAc;EAAd,WAAA,QAAA,gBAAA,QAAA,gBAAc;EAAd,gBAAA,QAAA,qBAAA,QAAA,gBAAc;EAAd,kBAAA,QAAA,uBAAA,QAAA,gBAAc;EAAd,iBAAA,QAAA,sBAAA,QAAA,gBAAc;EAAd,WAAA,QAAA,gBAAA,QAAA,gBAAc;EAAd,SAAA,QAAA,cAAA,QAAA,gBAAc;EAAd,SAAA,QAAA,cAAA,QAAA,gBAAc;EAAd,SAAA,QAAA,cAAA,QAAA,gBAAc;EAAd,QAAA,QAAA,aAAA,QAAA,gBAAc;EAAd,eAAA,QAAA,oBAAA,QAAA,gBAAc"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// src/commerce.ts
|
|
2
|
+
const COMMERCE_NAMES = /* @__PURE__ */ new Set([
|
|
3
|
+
"view_item",
|
|
4
|
+
"view_item_list",
|
|
5
|
+
"select_item",
|
|
6
|
+
"add_to_cart",
|
|
7
|
+
"remove_from_cart",
|
|
8
|
+
"view_cart",
|
|
9
|
+
"begin_checkout",
|
|
10
|
+
"add_shipping_info",
|
|
11
|
+
"add_payment_info",
|
|
12
|
+
"purchase",
|
|
13
|
+
"refund"
|
|
14
|
+
]);
|
|
15
|
+
/** whether a well-known event is a commerce one, whose parameters a container reads under `ecommerce` */
|
|
16
|
+
function isCommerceEvent(name) {
|
|
17
|
+
return COMMERCE_NAMES.has(name);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The well-known events as builders over `create`: one function per event, typed by its
|
|
21
|
+
* parameters, taking the destination's extra parameters second. The ga4 and tag-manager builders are
|
|
22
|
+
* made of it; a site's own destination that speaks ga4's names can be too.
|
|
23
|
+
*/
|
|
24
|
+
function wellKnownEvents(create) {
|
|
25
|
+
const builder = (name) => (params, extra) => create(name, params, extra);
|
|
26
|
+
return {
|
|
27
|
+
viewItem: builder("view_item"),
|
|
28
|
+
viewItemList: builder("view_item_list"),
|
|
29
|
+
selectItem: builder("select_item"),
|
|
30
|
+
addToCart: builder("add_to_cart"),
|
|
31
|
+
removeFromCart: builder("remove_from_cart"),
|
|
32
|
+
viewCart: builder("view_cart"),
|
|
33
|
+
beginCheckout: builder("begin_checkout"),
|
|
34
|
+
addShippingInfo: builder("add_shipping_info"),
|
|
35
|
+
addPaymentInfo: builder("add_payment_info"),
|
|
36
|
+
purchase: builder("purchase"),
|
|
37
|
+
refund: builder("refund"),
|
|
38
|
+
search: builder("search"),
|
|
39
|
+
signUp: builder("sign_up"),
|
|
40
|
+
login: builder("login"),
|
|
41
|
+
generateLead: builder("generate_lead")
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export { wellKnownEvents as n, isCommerceEvent as t };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=commerce-DgNeBWhO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commerce-DgNeBWhO.js","names":[],"sources":["../src/commerce.ts"],"sourcesContent":["// the well-known events — ga4's recommended events, the catalogue every tag vendor maps from — as\n// typed parameters, and a factory the ga4 and tag-manager builders are made of. No runtime imports here.\n\nimport type { RelayParams } from './shared.js';\n\n/** an item of the commerce events */\nexport type CommerceItem = {\n item_id: string;\n item_name: string;\n price: number;\n quantity: number;\n index?: number | undefined;\n affiliation?: string | undefined;\n coupon?: string | undefined;\n discount?: number | undefined;\n item_brand?: string | undefined;\n item_category?: string | undefined;\n item_category2?: string | undefined;\n item_category3?: string | undefined;\n item_category4?: string | undefined;\n item_category5?: string | undefined;\n item_list_id?: string | undefined;\n item_list_name?: string | undefined;\n item_variant?: string | undefined;\n location_id?: string | undefined;\n [key: string]: unknown;\n};\n\ntype Items = { items: readonly CommerceItem[] };\ntype Money = { currency?: string | undefined; value?: number | undefined };\ntype Listed = { item_list_id?: string | undefined; item_list_name?: string | undefined };\n\n/** every well-known params type takes custom parameters next to the known ones */\ntype Params<P> = P & RelayParams;\n\nexport type ViewItemParams = Params<Items & Money>;\nexport type ViewItemListParams = Params<Items & Listed>;\nexport type SelectItemParams = Params<Items & Listed>;\nexport type AddToCartParams = Params<Items & Money>;\nexport type RemoveFromCartParams = Params<Items & Money>;\nexport type ViewCartParams = Params<Items & Money>;\nexport type BeginCheckoutParams = Params<Items & Money & { coupon?: string | undefined }>;\nexport type AddShippingInfoParams = Params<\n Items & Money & { coupon?: string | undefined; shipping_tier?: string | undefined }\n>;\nexport type AddPaymentInfoParams = Params<\n Items & Money & { coupon?: string | undefined; payment_type?: string | undefined }\n>;\nexport type PurchaseParams = Params<\n Items & {\n transaction_id: string;\n value: number;\n currency: string;\n tax?: number | undefined;\n shipping?: number | undefined;\n coupon?: string | undefined;\n }\n>;\nexport type RefundParams = Params<\n Money & {\n transaction_id: string;\n tax?: number | undefined;\n shipping?: number | undefined;\n items?: readonly CommerceItem[] | undefined;\n }\n>;\nexport type SearchParams = Params<{ search_term: string }>;\nexport type SignUpParams = Params<{ method?: string | undefined }>;\nexport type LoginParams = Params<{ method?: string | undefined }>;\nexport type GenerateLeadParams = Params<Money>;\n\nexport type WellKnownName =\n | 'view_item'\n | 'view_item_list'\n | 'select_item'\n | 'add_to_cart'\n | 'remove_from_cart'\n | 'view_cart'\n | 'begin_checkout'\n | 'add_shipping_info'\n | 'add_payment_info'\n | 'purchase'\n | 'refund'\n | 'search'\n | 'sign_up'\n | 'login'\n | 'generate_lead';\n\nconst COMMERCE_NAMES: ReadonlySet<string> = new Set([\n 'view_item',\n 'view_item_list',\n 'select_item',\n 'add_to_cart',\n 'remove_from_cart',\n 'view_cart',\n 'begin_checkout',\n 'add_shipping_info',\n 'add_payment_info',\n 'purchase',\n 'refund',\n]);\n\n/** whether a well-known event is a commerce one, whose parameters a container reads under `ecommerce` */\nexport function isCommerceEvent(name: string): boolean {\n return COMMERCE_NAMES.has(name);\n}\n\n/** what a builder set is made of: the event's name and parameters in, the destination's payload out */\nexport type WellKnownCreate<R> = (name: WellKnownName, params: RelayParams, extra: RelayParams | undefined) => R;\n\n/**\n * The well-known events as builders over `create`: one function per event, typed by its\n * parameters, taking the destination's extra parameters second. The ga4 and tag-manager builders are\n * made of it; a site's own destination that speaks ga4's names can be too.\n */\nexport function wellKnownEvents<R>(create: WellKnownCreate<R>) {\n const builder =\n <P extends RelayParams>(name: WellKnownName) =>\n (params: P, extra?: RelayParams): R =>\n create(name, params, extra);\n\n return {\n viewItem: builder<ViewItemParams>('view_item'),\n viewItemList: builder<ViewItemListParams>('view_item_list'),\n selectItem: builder<SelectItemParams>('select_item'),\n addToCart: builder<AddToCartParams>('add_to_cart'),\n removeFromCart: builder<RemoveFromCartParams>('remove_from_cart'),\n viewCart: builder<ViewCartParams>('view_cart'),\n beginCheckout: builder<BeginCheckoutParams>('begin_checkout'),\n addShippingInfo: builder<AddShippingInfoParams>('add_shipping_info'),\n addPaymentInfo: builder<AddPaymentInfoParams>('add_payment_info'),\n purchase: builder<PurchaseParams>('purchase'),\n refund: builder<RefundParams>('refund'),\n search: builder<SearchParams>('search'),\n signUp: builder<SignUpParams>('sign_up'),\n login: builder<LoginParams>('login'),\n generateLead: builder<GenerateLeadParams>('generate_lead'),\n };\n}\n"],"mappings":";AAwFA,MAAM,iCAAsC,IAAI,IAAI;CAClD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,SAAgB,gBAAgB,MAAuB;CACrD,OAAO,eAAe,IAAI,IAAI;AAChC;;;;;;AAUA,SAAgB,gBAAmB,QAA4B;CAC7D,MAAM,WACoB,UACrB,QAAW,UACV,OAAO,MAAM,QAAQ,KAAK;CAEhC,OAAO;EACL,UAAU,QAAwB,WAAW;EAC7C,cAAc,QAA4B,gBAAgB;EAC1D,YAAY,QAA0B,aAAa;EACnD,WAAW,QAAyB,aAAa;EACjD,gBAAgB,QAA8B,kBAAkB;EAChE,UAAU,QAAwB,WAAW;EAC7C,eAAe,QAA6B,gBAAgB;EAC5D,iBAAiB,QAA+B,mBAAmB;EACnE,gBAAgB,QAA8B,kBAAkB;EAChE,UAAU,QAAwB,UAAU;EAC5C,QAAQ,QAAsB,QAAQ;EACtC,QAAQ,QAAsB,QAAQ;EACtC,QAAQ,QAAsB,SAAS;EACvC,OAAO,QAAqB,OAAO;EACnC,cAAc,QAA4B,eAAe;CAC3D;AACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
// src/server/context.ts
|
|
3
|
+
const CONTEXT_KEY = Symbol.for("@astroscope/relay.context");
|
|
4
|
+
function storage() {
|
|
5
|
+
const holder = globalThis;
|
|
6
|
+
holder[CONTEXT_KEY] ??= new AsyncLocalStorage();
|
|
7
|
+
return holder[CONTEXT_KEY];
|
|
8
|
+
}
|
|
9
|
+
/** runs the rest of the request inside the relay context; the middleware's business */
|
|
10
|
+
function runWithRelayContext(context, fn) {
|
|
11
|
+
return storage().run(context, fn);
|
|
12
|
+
}
|
|
13
|
+
/** the context of the current request, `undefined` outside one (a build, a cron, a startup hook) */
|
|
14
|
+
function getRelayContext() {
|
|
15
|
+
return storage().getStore();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The consent the current request carries, by destination name: what a server destination's default
|
|
19
|
+
* `consent` reads, and what a custom one reads to share another destination's flag. Empty outside a
|
|
20
|
+
* request and for a request the browser sent nothing with.
|
|
21
|
+
*/
|
|
22
|
+
function relayConsent() {
|
|
23
|
+
return getRelayContext()?.consent ?? {};
|
|
24
|
+
}
|
|
25
|
+
export { relayConsent as n, runWithRelayContext as r, getRelayContext as t };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=context-D11BBDcb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-D11BBDcb.js","names":[],"sources":["../src/server/context.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks';\nimport type { APIContext } from 'astro';\nimport type { ConsentRecord } from '../shared.js';\n\n/** what the middleware knows about the request `track()` is called in */\nexport type RelayRequestContext = {\n /** the consent the browser sent, by destination name */\n consent: ConsentRecord;\n context: APIContext;\n};\n\n// keyed on globalThis like the config: the middleware and a `track()` call may come from separate\n// module instances of this package, and the store must be the one the middleware wrote to\nconst CONTEXT_KEY = Symbol.for('@astroscope/relay.context');\n\ntype ContextHolder = { [CONTEXT_KEY]?: AsyncLocalStorage<RelayRequestContext> | undefined };\n\nfunction storage(): AsyncLocalStorage<RelayRequestContext> {\n const holder = globalThis as ContextHolder;\n\n holder[CONTEXT_KEY] ??= new AsyncLocalStorage<RelayRequestContext>();\n\n return holder[CONTEXT_KEY];\n}\n\n/** runs the rest of the request inside the relay context; the middleware's business */\nexport function runWithRelayContext<T>(context: RelayRequestContext, fn: () => T): T {\n return storage().run(context, fn);\n}\n\n/** the context of the current request, `undefined` outside one (a build, a cron, a startup hook) */\nexport function getRelayContext(): RelayRequestContext | undefined {\n return storage().getStore();\n}\n\n/**\n * The consent the current request carries, by destination name: what a server destination's default\n * `consent` reads, and what a custom one reads to share another destination's flag. Empty outside a\n * request and for a request the browser sent nothing with.\n */\nexport function relayConsent(): ConsentRecord {\n return getRelayContext()?.consent ?? {};\n}\n"],"mappings":";;AAaA,MAAM,cAAc,OAAO,IAAI,2BAA2B;AAI1D,SAAS,UAAkD;CACzD,MAAM,SAAS;CAEf,OAAO,iBAAiB,IAAI,kBAAuC;CAEnE,OAAO,OAAO;AAChB;;AAGA,SAAgB,oBAAuB,SAA8B,IAAgB;CACnF,OAAO,QAAQ,CAAC,CAAC,IAAI,SAAS,EAAE;AAClC;;AAGA,SAAgB,kBAAmD;CACjE,OAAO,QAAQ,CAAC,CAAC,SAAS;AAC5B;;;;;;AAOA,SAAgB,eAA8B;CAC5C,OAAO,gBAAgB,CAAC,EAAE,WAAW,CAAC;AACxC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/conversion-user.ts
|
|
2
|
+
/** normalizes and hashes the identifiers the way the pixels and the conversions apis expect them */
|
|
3
|
+
async function hashUser(user, options = {}) {
|
|
4
|
+
const [email, phone, firstName, lastName] = await Promise.all([
|
|
5
|
+
hashOptional(normalizeEmail(user.email)),
|
|
6
|
+
hashOptional(normalizePhone(user.phone, options.countryCallingCode)),
|
|
7
|
+
hashOptional(normalizeName(user.firstName)),
|
|
8
|
+
hashOptional(normalizeName(user.lastName))
|
|
9
|
+
]);
|
|
10
|
+
return withoutEmpty({
|
|
11
|
+
email,
|
|
12
|
+
phone,
|
|
13
|
+
firstName,
|
|
14
|
+
lastName
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function normalizeEmail(email) {
|
|
18
|
+
return email?.trim().toLowerCase() || void 0;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Digits only, with the country calling code: a national number (one leading zero) gets the
|
|
22
|
+
* site's code, `+` and `00` prefixes are dropped. Returns `undefined` for anything that is not
|
|
23
|
+
* 8 to 15 digits afterwards.
|
|
24
|
+
*/
|
|
25
|
+
function normalizePhone(phone, countryCallingCode) {
|
|
26
|
+
const compact = phone?.replaceAll(/[\s().-]/g, "");
|
|
27
|
+
if (!compact) return;
|
|
28
|
+
const international = compact.startsWith("+") || compact.startsWith("00");
|
|
29
|
+
const national = compact.replace(/^\+?0*/, "");
|
|
30
|
+
const digits = international || !compact.startsWith("0") ? national : `${countryCallingCode ?? ""}${national}`;
|
|
31
|
+
return /^\d{8,15}$/.test(digits) ? digits : void 0;
|
|
32
|
+
}
|
|
33
|
+
/** lowercase, without whitespace and punctuation */
|
|
34
|
+
function normalizeName(name) {
|
|
35
|
+
return name?.toLowerCase().replaceAll(/[\s!-/:-@[-`{-~]/g, "") || void 0;
|
|
36
|
+
}
|
|
37
|
+
async function sha256(value) {
|
|
38
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
|
|
39
|
+
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
40
|
+
}
|
|
41
|
+
async function hashOptional(value) {
|
|
42
|
+
return value ? sha256(value) : void 0;
|
|
43
|
+
}
|
|
44
|
+
function withoutEmpty(user) {
|
|
45
|
+
return Object.fromEntries(Object.entries(user).filter(([, value]) => value));
|
|
46
|
+
}
|
|
47
|
+
export { sha256 as a, normalizePhone as i, normalizeEmail as n, normalizeName as r, hashUser as t };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=conversion-user-CV8xIWDK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversion-user-CV8xIWDK.js","names":[],"sources":["../src/conversion-user.ts"],"sourcesContent":["/** what the visitor entered for a conversion; a destination that identifies hashes it as it requires */\nexport type ConversionUser = {\n email?: string | undefined;\n phone?: string | undefined;\n firstName?: string | undefined;\n lastName?: string | undefined;\n};\n\n/** the identifiers of a visitor as the ad platforms match them: normalized, then sha256 as lowercase hex */\nexport type HashedUser = {\n email?: string | undefined;\n phone?: string | undefined;\n firstName?: string | undefined;\n lastName?: string | undefined;\n};\n\nexport type HashOptions = {\n /**\n * The country calling code a national phone number gets (`49` for a German site): a number\n * with one leading zero is taken as national, `+` or `00` prefixes are international.\n */\n countryCallingCode?: string | undefined;\n};\n\n/** normalizes and hashes the identifiers the way the pixels and the conversions apis expect them */\nexport async function hashUser(user: ConversionUser, options: HashOptions = {}): Promise<HashedUser> {\n const [email, phone, firstName, lastName] = await Promise.all([\n hashOptional(normalizeEmail(user.email)),\n hashOptional(normalizePhone(user.phone, options.countryCallingCode)),\n hashOptional(normalizeName(user.firstName)),\n hashOptional(normalizeName(user.lastName)),\n ]);\n\n return withoutEmpty({ email, phone, firstName, lastName });\n}\n\nexport function normalizeEmail(email: string | undefined): string | undefined {\n return email?.trim().toLowerCase() || undefined;\n}\n\n/**\n * Digits only, with the country calling code: a national number (one leading zero) gets the\n * site's code, `+` and `00` prefixes are dropped. Returns `undefined` for anything that is not\n * 8 to 15 digits afterwards.\n */\nexport function normalizePhone(phone: string | undefined, countryCallingCode: string | undefined): string | undefined {\n const compact = phone?.replaceAll(/[\\s().-]/g, '');\n\n if (!compact) {\n return undefined;\n }\n\n const international = compact.startsWith('+') || compact.startsWith('00');\n const national = compact.replace(/^\\+?0*/, '');\n const digits = international || !compact.startsWith('0') ? national : `${countryCallingCode ?? ''}${national}`;\n\n return /^\\d{8,15}$/.test(digits) ? digits : undefined;\n}\n\n/** lowercase, without whitespace and punctuation */\nexport function normalizeName(name: string | undefined): string | undefined {\n return name?.toLowerCase().replaceAll(/[\\s!-/:-@[-`{-~]/g, '') || undefined;\n}\n\nexport async function sha256(value: string): Promise<string> {\n const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value));\n\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\nasync function hashOptional(value: string | undefined): Promise<string | undefined> {\n return value ? sha256(value) : undefined;\n}\n\nfunction withoutEmpty(user: HashedUser): HashedUser {\n return Object.fromEntries(Object.entries(user).filter(([, value]) => value)) as HashedUser;\n}\n"],"mappings":";;AAyBA,eAAsB,SAAS,MAAsB,UAAuB,CAAC,GAAwB;CACnG,MAAM,CAAC,OAAO,OAAO,WAAW,YAAY,MAAM,QAAQ,IAAI;EAC5D,aAAa,eAAe,KAAK,KAAK,CAAC;EACvC,aAAa,eAAe,KAAK,OAAO,QAAQ,kBAAkB,CAAC;EACnE,aAAa,cAAc,KAAK,SAAS,CAAC;EAC1C,aAAa,cAAc,KAAK,QAAQ,CAAC;CAC3C,CAAC;CAED,OAAO,aAAa;EAAE;EAAO;EAAO;EAAW;CAAS,CAAC;AAC3D;AAEA,SAAgB,eAAe,OAA+C;CAC5E,OAAO,OAAO,KAAK,CAAC,CAAC,YAAY,KAAK,KAAA;AACxC;;;;;;AAOA,SAAgB,eAAe,OAA2B,oBAA4D;CACpH,MAAM,UAAU,OAAO,WAAW,aAAa,EAAE;CAEjD,IAAI,CAAC,SACH;CAGF,MAAM,gBAAgB,QAAQ,WAAW,GAAG,KAAK,QAAQ,WAAW,IAAI;CACxE,MAAM,WAAW,QAAQ,QAAQ,UAAU,EAAE;CAC7C,MAAM,SAAS,iBAAiB,CAAC,QAAQ,WAAW,GAAG,IAAI,WAAW,GAAG,sBAAsB,KAAK;CAEpG,OAAO,aAAa,KAAK,MAAM,IAAI,SAAS,KAAA;AAC9C;;AAGA,SAAgB,cAAc,MAA8C;CAC1E,OAAO,MAAM,YAAY,CAAC,CAAC,WAAW,qBAAqB,EAAE,KAAK,KAAA;AACpE;AAEA,eAAsB,OAAO,OAAgC;CAC3D,MAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,CAAC;CAEpF,OAAO,MAAM,KAAK,IAAI,WAAW,MAAM,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;AACjG;AAEA,eAAe,aAAa,OAAwD;CAClF,OAAO,QAAQ,OAAO,KAAK,IAAI,KAAA;AACjC;AAEA,SAAS,aAAa,MAA8B;CAClD,OAAO,OAAO,YAAY,OAAO,QAAQ,IAAI,CAAC,CAAC,QAAQ,GAAG,WAAW,KAAK,CAAC;AAC7E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** what the visitor entered for a conversion; a destination that identifies hashes it as it requires */
|
|
2
|
+
type ConversionUser = {
|
|
3
|
+
email?: string | undefined;
|
|
4
|
+
phone?: string | undefined;
|
|
5
|
+
firstName?: string | undefined;
|
|
6
|
+
lastName?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
/** the identifiers of a visitor as the ad platforms match them: normalized, then sha256 as lowercase hex */
|
|
9
|
+
type HashedUser = {
|
|
10
|
+
email?: string | undefined;
|
|
11
|
+
phone?: string | undefined;
|
|
12
|
+
firstName?: string | undefined;
|
|
13
|
+
lastName?: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
type HashOptions = {
|
|
16
|
+
/**
|
|
17
|
+
* The country calling code a national phone number gets (`49` for a German site): a number
|
|
18
|
+
* with one leading zero is taken as national, `+` or `00` prefixes are international.
|
|
19
|
+
*/
|
|
20
|
+
countryCallingCode?: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
/** normalizes and hashes the identifiers the way the pixels and the conversions apis expect them */
|
|
23
|
+
declare function hashUser(user: ConversionUser, options?: HashOptions): Promise<HashedUser>;
|
|
24
|
+
declare function normalizeEmail(email: string | undefined): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Digits only, with the country calling code: a national number (one leading zero) gets the
|
|
27
|
+
* site's code, `+` and `00` prefixes are dropped. Returns `undefined` for anything that is not
|
|
28
|
+
* 8 to 15 digits afterwards.
|
|
29
|
+
*/
|
|
30
|
+
declare function normalizePhone(phone: string | undefined, countryCallingCode: string | undefined): string | undefined;
|
|
31
|
+
/** lowercase, without whitespace and punctuation */
|
|
32
|
+
declare function normalizeName(name: string | undefined): string | undefined;
|
|
33
|
+
declare function sha256(value: string): Promise<string>;
|
|
34
|
+
export { normalizeEmail as a, sha256 as c, hashUser as i, HashOptions as n, normalizeName as o, HashedUser as r, normalizePhone as s, ConversionUser as t };
|
|
35
|
+
//# sourceMappingURL=conversion-user-DCfM5EuZ.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversion-user-DCfM5EuZ.d.ts","names":[],"sources":["../src/conversion-user.ts"],"mappings":";KACY;EACV;EACA;EACA;EACA;;;KAIU;EACV;EACA;EACA;EACA;;KAGU;;;;;EAKV;;;iBAIoB,SAAS,MAAM,gBAAgB,UAAS,cAAmB,QAAQ;iBAWzE,eAAe;;;;;;iBASf,eAAe,2BAA2B;;iBAe1C,cAAc;iBAIR,OAAO,gBAAgB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { a as Destination } from "../bus-Z7l8oJtS.js";
|
|
2
|
+
import { d as RelayParams } from "../shared-CSwqcxPI.js";
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
dataLayer?: unknown[] | undefined;
|
|
6
|
+
gtag?: ((...args: unknown[]) => void) | undefined;
|
|
7
|
+
/** set by gtag.js once the tag has loaded */
|
|
8
|
+
google_tag_manager?: unknown;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** what the google tag takes: `gtag('event', name, params)` */
|
|
12
|
+
export type Ga4Event = {
|
|
13
|
+
name: string;
|
|
14
|
+
params: RelayParams;
|
|
15
|
+
};
|
|
16
|
+
declare module '@astroscope/relay' {
|
|
17
|
+
interface RelayDestinations {
|
|
18
|
+
ga4: Ga4Event;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The ga4 builders: the well-known events (ga4's recommended ones) typed by their parameters, and
|
|
23
|
+
* `event(name, params)` for a custom one. What an event definition puts under `ga4`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const ga4: {
|
|
26
|
+
viewItem: (params: import("@astroscope/relay").ViewItemParams, extra?: RelayParams) => Ga4Event;
|
|
27
|
+
viewItemList: (params: import("@astroscope/relay").ViewItemListParams, extra?: RelayParams) => Ga4Event;
|
|
28
|
+
selectItem: (params: import("@astroscope/relay").SelectItemParams, extra?: RelayParams) => Ga4Event;
|
|
29
|
+
addToCart: (params: import("@astroscope/relay").AddToCartParams, extra?: RelayParams) => Ga4Event;
|
|
30
|
+
removeFromCart: (params: import("@astroscope/relay").RemoveFromCartParams, extra?: RelayParams) => Ga4Event;
|
|
31
|
+
viewCart: (params: import("@astroscope/relay").ViewCartParams, extra?: RelayParams) => Ga4Event;
|
|
32
|
+
beginCheckout: (params: import("@astroscope/relay").BeginCheckoutParams, extra?: RelayParams) => Ga4Event;
|
|
33
|
+
addShippingInfo: (params: import("@astroscope/relay").AddShippingInfoParams, extra?: RelayParams) => Ga4Event;
|
|
34
|
+
addPaymentInfo: (params: import("@astroscope/relay").AddPaymentInfoParams, extra?: RelayParams) => Ga4Event;
|
|
35
|
+
purchase: (params: import("@astroscope/relay").PurchaseParams, extra?: RelayParams) => Ga4Event;
|
|
36
|
+
refund: (params: import("@astroscope/relay").RefundParams, extra?: RelayParams) => Ga4Event;
|
|
37
|
+
search: (params: import("@astroscope/relay").SearchParams, extra?: RelayParams) => Ga4Event;
|
|
38
|
+
signUp: (params: import("@astroscope/relay").SignUpParams, extra?: RelayParams) => Ga4Event;
|
|
39
|
+
login: (params: import("@astroscope/relay").LoginParams, extra?: RelayParams) => Ga4Event;
|
|
40
|
+
generateLead: (params: import("@astroscope/relay").GenerateLeadParams, extra?: RelayParams) => Ga4Event;
|
|
41
|
+
event: (name: string, params?: RelayParams) => Ga4Event;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* The google tag as a destination: hands the `ga4` payload of an event to `gtag('event', …)`. The
|
|
45
|
+
* `gtag` queue stub is installed right away, so the tag's own snippet only has to load; a consented
|
|
46
|
+
* event is delivered once it has and kept across a navigation until then. A site that runs the tag
|
|
47
|
+
* inside a tag-manager container takes `@astroscope/relay/gtm` instead.
|
|
48
|
+
*/
|
|
49
|
+
export declare function ga4Tag(): Destination<'ga4'>;
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/ga4/index.ts"],"mappings":";;QAIQ;YACI;IACR;IACA,YAAY;;IAEZ;;;;YAKQ;EACV;EACA,QAAQ;;;YAIE;IACR,KAAK;;;;;;;qBAQI;;;;;;;;;;;;;;;;EACG,QAAA,cAAM,SAAU,gBAAmB;;;;;;;;wBAUnC,UAAU"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { n as wellKnownEvents } from "../commerce-DgNeBWhO.js";
|
|
2
|
+
import { a as isBrowser } from "../shared-D281USsp.js";
|
|
3
|
+
// src/ga4/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* The ga4 builders: the well-known events (ga4's recommended ones) typed by their parameters, and
|
|
6
|
+
* `event(name, params)` for a custom one. What an event definition puts under `ga4`.
|
|
7
|
+
*/
|
|
8
|
+
const ga4 = {
|
|
9
|
+
event: (name, params = {}) => ({
|
|
10
|
+
name,
|
|
11
|
+
params
|
|
12
|
+
}),
|
|
13
|
+
...wellKnownEvents((name, params, extra) => ({
|
|
14
|
+
name,
|
|
15
|
+
params: {
|
|
16
|
+
...extra,
|
|
17
|
+
...params
|
|
18
|
+
}
|
|
19
|
+
}))
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The google tag as a destination: hands the `ga4` payload of an event to `gtag('event', …)`. The
|
|
23
|
+
* `gtag` queue stub is installed right away, so the tag's own snippet only has to load; a consented
|
|
24
|
+
* event is delivered once it has and kept across a navigation until then. A site that runs the tag
|
|
25
|
+
* inside a tag-manager container takes `@astroscope/relay/gtm` instead.
|
|
26
|
+
*/
|
|
27
|
+
function ga4Tag() {
|
|
28
|
+
if (isBrowser()) installQueue();
|
|
29
|
+
return {
|
|
30
|
+
name: "ga4",
|
|
31
|
+
ready: () => isBrowser() && globalThis.window.google_tag_manager !== void 0,
|
|
32
|
+
send: (event) => {
|
|
33
|
+
globalThis.window.gtag?.("event", event.name, event.params);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function installQueue() {
|
|
38
|
+
window.dataLayer ??= [];
|
|
39
|
+
window.gtag ??= function() {
|
|
40
|
+
globalThis.window.dataLayer?.push(arguments);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export { ga4, ga4Tag };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/ga4/index.ts"],"sourcesContent":["import type { Destination } from '../client/bus.js';\nimport { wellKnownEvents } from '../commerce.js';\nimport { type RelayParams, isBrowser } from '../shared.js';\n\ndeclare global {\n interface Window {\n dataLayer?: unknown[] | undefined;\n gtag?: ((...args: unknown[]) => void) | undefined;\n /** set by gtag.js once the tag has loaded */\n google_tag_manager?: unknown;\n }\n}\n\n/** what the google tag takes: `gtag('event', name, params)` */\nexport type Ga4Event = {\n name: string;\n params: RelayParams;\n};\n\ndeclare module '@astroscope/relay' {\n interface RelayDestinations {\n ga4: Ga4Event;\n }\n}\n\n/**\n * The ga4 builders: the well-known events (ga4's recommended ones) typed by their parameters, and\n * `event(name, params)` for a custom one. What an event definition puts under `ga4`.\n */\nexport const ga4 = {\n event: (name: string, params: RelayParams = {}): Ga4Event => ({ name, params }),\n ...wellKnownEvents((name, params, extra): Ga4Event => ({ name, params: { ...extra, ...params } })),\n};\n\n/**\n * The google tag as a destination: hands the `ga4` payload of an event to `gtag('event', …)`. The\n * `gtag` queue stub is installed right away, so the tag's own snippet only has to load; a consented\n * event is delivered once it has and kept across a navigation until then. A site that runs the tag\n * inside a tag-manager container takes `@astroscope/relay/gtm` instead.\n */\nexport function ga4Tag(): Destination<'ga4'> {\n if (isBrowser()) {\n installQueue();\n }\n\n return {\n name: 'ga4',\n ready: () => isBrowser() && globalThis.window.google_tag_manager !== undefined,\n send: (event) => {\n globalThis.window.gtag?.('event', event.name, event.params);\n },\n };\n}\n\n// the google snippet: the tag replays the `arguments` entries of the data layer once loaded\nfunction installQueue(): void {\n /* eslint-disable unicorn/no-global-object-property-assignment -- `window.dataLayer` and `window.gtag` are the tag's documented contract */\n window.dataLayer ??= [];\n window.gtag ??= function () {\n // eslint-disable-next-line prefer-rest-params -- gtag.js processes `arguments` objects only\n globalThis.window.dataLayer?.push(arguments);\n };\n /* eslint-enable unicorn/no-global-object-property-assignment */\n}\n"],"mappings":";;;;;;;AA6BA,MAAa,MAAM;CACjB,QAAQ,MAAc,SAAsB,CAAC,OAAiB;EAAE;EAAM;CAAO;CAC7E,GAAG,iBAAiB,MAAM,QAAQ,WAAqB;EAAE;EAAM,QAAQ;GAAE,GAAG;GAAO,GAAG;EAAO;CAAE,EAAE;AACnG;;;;;;;AAQA,SAAgB,SAA6B;CAC3C,IAAI,UAAU,GACZ,aAAa;CAGf,OAAO;EACL,MAAM;EACN,aAAa,UAAU,KAAK,WAAW,OAAO,uBAAuB,KAAA;EACrE,OAAO,UAAU;GACf,WAAW,OAAO,OAAO,SAAS,MAAM,MAAM,MAAM,MAAM;EAC5D;CACF;AACF;AAGA,SAAS,eAAqB;CAE5B,OAAO,cAAc,CAAC;CACtB,OAAO,SAAS,WAAY;EAE1B,WAAW,OAAO,WAAW,KAAK,SAAS;CAC7C;AAEF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { a as Destination } from "../bus-Z7l8oJtS.js";
|
|
2
|
+
import { d as RelayParams } from "../shared-CSwqcxPI.js";
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
dataLayer?: unknown[] | undefined;
|
|
6
|
+
/** set by gtm.js once the container has loaded */
|
|
7
|
+
google_tag_manager?: unknown;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** one data layer push: the container's event name and what its variables read */
|
|
11
|
+
export type GtmPush = RelayParams & {
|
|
12
|
+
event: string;
|
|
13
|
+
};
|
|
14
|
+
declare module '@astroscope/relay' {
|
|
15
|
+
interface RelayDestinations {
|
|
16
|
+
gtm: GtmPush;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The tag-manager builders: `event(name, params)` is the push as the container's variables read
|
|
21
|
+
* it; the well-known events put their parameters under `ecommerce` — the shape a container's ga4
|
|
22
|
+
* tags are written against — and take the parameters next to it second (`purchase(commerce, {
|
|
23
|
+
* user_email })`). What an event definition puts under `gtm`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const gtm: {
|
|
26
|
+
viewItem: (params: import("@astroscope/relay").ViewItemParams, extra?: RelayParams) => GtmPush;
|
|
27
|
+
viewItemList: (params: import("@astroscope/relay").ViewItemListParams, extra?: RelayParams) => GtmPush;
|
|
28
|
+
selectItem: (params: import("@astroscope/relay").SelectItemParams, extra?: RelayParams) => GtmPush;
|
|
29
|
+
addToCart: (params: import("@astroscope/relay").AddToCartParams, extra?: RelayParams) => GtmPush;
|
|
30
|
+
removeFromCart: (params: import("@astroscope/relay").RemoveFromCartParams, extra?: RelayParams) => GtmPush;
|
|
31
|
+
viewCart: (params: import("@astroscope/relay").ViewCartParams, extra?: RelayParams) => GtmPush;
|
|
32
|
+
beginCheckout: (params: import("@astroscope/relay").BeginCheckoutParams, extra?: RelayParams) => GtmPush;
|
|
33
|
+
addShippingInfo: (params: import("@astroscope/relay").AddShippingInfoParams, extra?: RelayParams) => GtmPush;
|
|
34
|
+
addPaymentInfo: (params: import("@astroscope/relay").AddPaymentInfoParams, extra?: RelayParams) => GtmPush;
|
|
35
|
+
purchase: (params: import("@astroscope/relay").PurchaseParams, extra?: RelayParams) => GtmPush;
|
|
36
|
+
refund: (params: import("@astroscope/relay").RefundParams, extra?: RelayParams) => GtmPush;
|
|
37
|
+
search: (params: import("@astroscope/relay").SearchParams, extra?: RelayParams) => GtmPush;
|
|
38
|
+
signUp: (params: import("@astroscope/relay").SignUpParams, extra?: RelayParams) => GtmPush;
|
|
39
|
+
login: (params: import("@astroscope/relay").LoginParams, extra?: RelayParams) => GtmPush;
|
|
40
|
+
generateLead: (params: import("@astroscope/relay").GenerateLeadParams, extra?: RelayParams) => GtmPush;
|
|
41
|
+
event: (name: string, params?: RelayParams) => GtmPush;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A tag-manager container as a destination: pushes the `gtm` payload of an event into the data layer
|
|
45
|
+
* with the event id (`event_id`, what the container's Meta or Ads tags use to deduplicate against
|
|
46
|
+
* their server-side counterparts). Which tags fire on a push is the container's business, so the
|
|
47
|
+
* consent asked for is the container's own (its embedding in the cmp). Ready once the container
|
|
48
|
+
* has loaded.
|
|
49
|
+
*/
|
|
50
|
+
export declare function gtmContainer(): Destination<'gtm'>;
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/gtm/index.ts"],"mappings":";;QAIQ;YACI;IACR;;IAEA;;;;YAKQ,UAAU;EACpB;;;YAIU;IACR,KAAK;;;;;;;;;qBAUI;;;;;;;;;;;;;;;;EACG,QAAA,cAAM,SAAU,gBAAmB;;;;;;;;;wBAcnC,gBAAgB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { n as wellKnownEvents, t as isCommerceEvent } from "../commerce-DgNeBWhO.js";
|
|
2
|
+
import { a as isBrowser } from "../shared-D281USsp.js";
|
|
3
|
+
// src/gtm/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* The tag-manager builders: `event(name, params)` is the push as the container's variables read
|
|
6
|
+
* it; the well-known events put their parameters under `ecommerce` — the shape a container's ga4
|
|
7
|
+
* tags are written against — and take the parameters next to it second (`purchase(commerce, {
|
|
8
|
+
* user_email })`). What an event definition puts under `gtm`.
|
|
9
|
+
*/
|
|
10
|
+
const gtm = {
|
|
11
|
+
event: (name, params = {}) => ({
|
|
12
|
+
event: name,
|
|
13
|
+
...params
|
|
14
|
+
}),
|
|
15
|
+
...wellKnownEvents((name, params, extra) => isCommerceEvent(name) ? {
|
|
16
|
+
event: name,
|
|
17
|
+
...extra,
|
|
18
|
+
ecommerce: params
|
|
19
|
+
} : {
|
|
20
|
+
event: name,
|
|
21
|
+
...extra,
|
|
22
|
+
...params
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A tag-manager container as a destination: pushes the `gtm` payload of an event into the data layer
|
|
27
|
+
* with the event id (`event_id`, what the container's Meta or Ads tags use to deduplicate against
|
|
28
|
+
* their server-side counterparts). Which tags fire on a push is the container's business, so the
|
|
29
|
+
* consent asked for is the container's own (its embedding in the cmp). Ready once the container
|
|
30
|
+
* has loaded.
|
|
31
|
+
*/
|
|
32
|
+
function gtmContainer() {
|
|
33
|
+
return {
|
|
34
|
+
name: "gtm",
|
|
35
|
+
ready: () => isBrowser() && globalThis.window.google_tag_manager !== void 0,
|
|
36
|
+
send: (push, meta) => {
|
|
37
|
+
const dataLayer = globalThis.window.dataLayer ??= [];
|
|
38
|
+
const entry = {
|
|
39
|
+
...push,
|
|
40
|
+
event_id: meta.id
|
|
41
|
+
};
|
|
42
|
+
if ("ecommerce" in push) dataLayer.push({ ecommerce: null }, entry);
|
|
43
|
+
else dataLayer.push(entry);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export { gtm, gtmContainer };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/gtm/index.ts"],"sourcesContent":["import type { Destination } from '../client/bus.js';\nimport { isCommerceEvent, wellKnownEvents } from '../commerce.js';\nimport { type RelayParams, isBrowser } from '../shared.js';\n\ndeclare global {\n interface Window {\n dataLayer?: unknown[] | undefined;\n /** set by gtm.js once the container has loaded */\n google_tag_manager?: unknown;\n }\n}\n\n/** one data layer push: the container's event name and what its variables read */\nexport type GtmPush = RelayParams & {\n event: string;\n};\n\ndeclare module '@astroscope/relay' {\n interface RelayDestinations {\n gtm: GtmPush;\n }\n}\n\n/**\n * The tag-manager builders: `event(name, params)` is the push as the container's variables read\n * it; the well-known events put their parameters under `ecommerce` — the shape a container's ga4\n * tags are written against — and take the parameters next to it second (`purchase(commerce, {\n * user_email })`). What an event definition puts under `gtm`.\n */\nexport const gtm = {\n event: (name: string, params: RelayParams = {}): GtmPush => ({ event: name, ...params }),\n ...wellKnownEvents(\n (name, params, extra): GtmPush =>\n isCommerceEvent(name) ? { event: name, ...extra, ecommerce: params } : { event: name, ...extra, ...params },\n ),\n};\n\n/**\n * A tag-manager container as a destination: pushes the `gtm` payload of an event into the data layer\n * with the event id (`event_id`, what the container's Meta or Ads tags use to deduplicate against\n * their server-side counterparts). Which tags fire on a push is the container's business, so the\n * consent asked for is the container's own (its embedding in the cmp). Ready once the container\n * has loaded.\n */\nexport function gtmContainer(): Destination<'gtm'> {\n return {\n name: 'gtm',\n ready: () => isBrowser() && globalThis.window.google_tag_manager !== undefined,\n send: (push, meta) => {\n const dataLayer = (globalThis.window.dataLayer ??= []);\n const entry = { ...push, event_id: meta.id };\n\n if ('ecommerce' in push) {\n // the container merges pushes, a cleared object keeps the previous event's items out\n dataLayer.push({ ecommerce: null }, entry);\n } else {\n dataLayer.push(entry);\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;AA6BA,MAAa,MAAM;CACjB,QAAQ,MAAc,SAAsB,CAAC,OAAgB;EAAE,OAAO;EAAM,GAAG;CAAO;CACtF,GAAG,iBACA,MAAM,QAAQ,UACb,gBAAgB,IAAI,IAAI;EAAE,OAAO;EAAM,GAAG;EAAO,WAAW;CAAO,IAAI;EAAE,OAAO;EAAM,GAAG;EAAO,GAAG;CAAO,CAC9G;AACF;;;;;;;;AASA,SAAgB,eAAmC;CACjD,OAAO;EACL,MAAM;EACN,aAAa,UAAU,KAAK,WAAW,OAAO,uBAAuB,KAAA;EACrE,OAAO,MAAM,SAAS;GACpB,MAAM,YAAa,WAAW,OAAO,cAAc,CAAC;GACpD,MAAM,QAAQ;IAAE,GAAG;IAAM,UAAU,KAAK;GAAG;GAE3C,IAAI,eAAe,MAEjB,UAAU,KAAK,EAAE,WAAW,KAAK,GAAG,KAAK;QAEzC,UAAU,KAAK,KAAK;EAExB;CACF;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { t as ConversionUser } from "./conversion-user-DCfM5EuZ.js";
|
|
2
|
+
import { n as collect, r as inlineTrack, t as CollectOptions } from "./collect-DRl177oR.js";
|
|
3
|
+
import { _ as WellKnownCreate, a as CommerceItem, b as wellKnownEvents, c as PurchaseParams, d as SearchParams, f as SelectItemParams, g as ViewItemParams, h as ViewItemListParams, i as BeginCheckoutParams, l as RefundParams, m as ViewCartParams, n as AddShippingInfoParams, o as GenerateLeadParams, p as SignUpParams, r as AddToCartParams, s as LoginParams, t as AddPaymentInfoParams, u as RemoveFromCartParams, v as WellKnownName, y as isCommerceEvent } from "./commerce-DCGO8yag.js";
|
|
4
|
+
import { a as DomainEvent, c as RELAY_TRACK_ATTRIBUTE, d as RelayParams, h as trackAttribute, i as DestinationName, l as RelayDestinations, m as defineEvent, n as ConsentRecord, o as EventDefinition, p as TrackInput, r as ConsentSource, s as EventMeta, t as ConsentAnswer, u as RelayEvent } from "./shared-CSwqcxPI.js";
|
|
5
|
+
/** the integration is server-only; the browser build of the root entry never loads it */
|
|
6
|
+
export default function relayIntegration(): never;
|
|
7
|
+
export { type AddPaymentInfoParams, type AddShippingInfoParams, type AddToCartParams, type BeginCheckoutParams, type CollectOptions, type CommerceItem, type ConsentAnswer, type ConsentRecord, type ConsentSource, type ConversionUser, type DestinationName, type DomainEvent, type EventDefinition, type EventMeta, type GenerateLeadParams, type LoginParams, type PurchaseParams, RELAY_TRACK_ATTRIBUTE, type RefundParams, type RelayDestinations, type RelayEvent, type RelayParams, type RemoveFromCartParams, type SearchParams, type SelectItemParams, type SignUpParams, type TrackInput, type ViewCartParams, type ViewItemListParams, type ViewItemParams, type WellKnownCreate, type WellKnownName, collect, defineEvent, inlineTrack, isCommerceEvent, trackAttribute, wellKnownEvents };
|
|
8
|
+
//# sourceMappingURL=index.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","names":[],"sources":["../src/index.browser.ts"],"mappings":";;;;;wBAyCwB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { n as inlineTrack, t as collect } from "./collect-DWdHyn-u.js";
|
|
2
|
+
import { n as wellKnownEvents, t as isCommerceEvent } from "./commerce-DgNeBWhO.js";
|
|
3
|
+
import { d as trackAttribute, n as RELAY_TRACK_ATTRIBUTE, r as defineEvent } from "./shared-D281USsp.js";
|
|
4
|
+
// src/index.browser.ts
|
|
5
|
+
/** the integration is server-only; the browser build of the root entry never loads it */
|
|
6
|
+
function relayIntegration() {
|
|
7
|
+
throw new Error("the @astroscope/relay integration is server-only");
|
|
8
|
+
}
|
|
9
|
+
export { RELAY_TRACK_ATTRIBUTE, collect, relayIntegration as default, defineEvent, inlineTrack, isCommerceEvent, trackAttribute, wellKnownEvents };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=index.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.js","names":[],"sources":["../src/index.browser.ts"],"sourcesContent":["export type { ConversionUser } from './conversion-user.js';\nexport { inlineTrack } from './inline.js';\nexport type { CollectOptions } from './collect.js';\nexport { collect } from './collect.js';\nexport type {\n AddPaymentInfoParams,\n AddShippingInfoParams,\n AddToCartParams,\n BeginCheckoutParams,\n CommerceItem,\n GenerateLeadParams,\n LoginParams,\n PurchaseParams,\n RefundParams,\n RemoveFromCartParams,\n SearchParams,\n SelectItemParams,\n SignUpParams,\n ViewCartParams,\n ViewItemListParams,\n ViewItemParams,\n WellKnownCreate,\n WellKnownName,\n} from './commerce.js';\nexport { isCommerceEvent, wellKnownEvents } from './commerce.js';\nexport type {\n ConsentAnswer,\n ConsentRecord,\n ConsentSource,\n DomainEvent,\n EventDefinition,\n EventMeta,\n DestinationName,\n RelayEvent,\n RelayParams,\n RelayDestinations,\n TrackInput,\n} from './shared.js';\nexport { RELAY_TRACK_ATTRIBUTE, defineEvent, trackAttribute } from './shared.js';\n\n/** the integration is server-only; the browser build of the root entry never loads it */\nexport default function relayIntegration(): never {\n throw new Error('the @astroscope/relay integration is server-only');\n}\n"],"mappings":";;;;;AAyCA,SAAwB,mBAA0B;CAChD,MAAM,IAAI,MAAM,kDAAkD;AACpE"}
|