@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,106 @@
|
|
|
1
|
+
// src/shared.ts
|
|
2
|
+
/**
|
|
3
|
+
* The request header the browser's consent travels in: the names of the consented destinations,
|
|
4
|
+
* comma-separated. The bus writes it onto every same-origin fetch, the middleware reads it.
|
|
5
|
+
*/
|
|
6
|
+
const RELAY_CONSENT_HEADER = "x-relay-consent";
|
|
7
|
+
/** the attribute of an element whose click tracks the event serialized into it */
|
|
8
|
+
const RELAY_TRACK_ATTRIBUTE = "data-track";
|
|
9
|
+
const MAX_CONSENT_NAMES = 32;
|
|
10
|
+
const DESTINATION_NAME = /^[\w-]{1,64}$/;
|
|
11
|
+
/** the header value: the names of the consented destinations, empty when none */
|
|
12
|
+
function serializeConsent(consent) {
|
|
13
|
+
return Object.keys(consent).filter((name) => consent[name] === true && DESTINATION_NAME.test(name)).join(",");
|
|
14
|
+
}
|
|
15
|
+
/** the record from an untrusted header value: unknown names are dropped, a missing header is nothing consented */
|
|
16
|
+
function parseConsent(raw) {
|
|
17
|
+
if (!raw) return {};
|
|
18
|
+
const names = raw.split(",").map((name) => name.trim()).filter((name) => DESTINATION_NAME.test(name)).slice(0, MAX_CONSENT_NAMES);
|
|
19
|
+
return Object.fromEntries(names.map((name) => [name, true]));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* One of the site's events: a function that turns the site's own objects into the payloads of the
|
|
23
|
+
* destinations the event is meant for, under the key that identifies it in a `data-track`
|
|
24
|
+
* attribute and in logs. One export per event, so an island bundles only the events
|
|
25
|
+
* it tracks and an event only an action imports never reaches the browser; the key is the export's
|
|
26
|
+
* name.
|
|
27
|
+
*/
|
|
28
|
+
function defineEvent(key, create) {
|
|
29
|
+
const build = (...args) => {
|
|
30
|
+
const { id, ...event } = create(...args);
|
|
31
|
+
return id === void 0 ? {
|
|
32
|
+
key,
|
|
33
|
+
event
|
|
34
|
+
} : {
|
|
35
|
+
key,
|
|
36
|
+
id,
|
|
37
|
+
event
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
return Object.assign(build, { key });
|
|
41
|
+
}
|
|
42
|
+
function isDomainEvent(input) {
|
|
43
|
+
const candidate = input;
|
|
44
|
+
return typeof candidate.key === "string" && typeof candidate.event === "object" && candidate.event !== null;
|
|
45
|
+
}
|
|
46
|
+
/** the payloads and, for a defined one, its key and own id */
|
|
47
|
+
function toTracked(input) {
|
|
48
|
+
return isDomainEvent(input) ? {
|
|
49
|
+
event: input.event,
|
|
50
|
+
key: input.key,
|
|
51
|
+
id: input.id
|
|
52
|
+
} : {
|
|
53
|
+
event: input,
|
|
54
|
+
key: void 0,
|
|
55
|
+
id: void 0
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** a plain object with the right shape, from untrusted json (an attribute, the queue, storage) */
|
|
59
|
+
function isTrackInput(value) {
|
|
60
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
61
|
+
const candidate = value;
|
|
62
|
+
if (candidate.key === void 0 && candidate.event === void 0) return true;
|
|
63
|
+
return isDomainEvent(candidate);
|
|
64
|
+
}
|
|
65
|
+
/** the value of the `data-track` attribute of an element whose click tracks the event */
|
|
66
|
+
function trackAttribute(input) {
|
|
67
|
+
return JSON.stringify(input);
|
|
68
|
+
}
|
|
69
|
+
/** the payload of a destination in an event, `undefined` when the event is not meant for it */
|
|
70
|
+
function payloadOf(event, name) {
|
|
71
|
+
return event[name];
|
|
72
|
+
}
|
|
73
|
+
/** whether this runs in a browser: a runtime check, so the built package works outside vite too */
|
|
74
|
+
function isBrowser() {
|
|
75
|
+
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
76
|
+
}
|
|
77
|
+
/** a fresh event id: a uuid; `randomUUID` needs a secure context, random bytes do not */
|
|
78
|
+
function createEventId() {
|
|
79
|
+
if (typeof crypto.randomUUID === "function") return crypto.randomUUID();
|
|
80
|
+
const bytes = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));
|
|
81
|
+
bytes[6] = (bytes[6] ?? 0) & 15 | 64;
|
|
82
|
+
bytes[8] = (bytes[8] ?? 0) & 63 | 128;
|
|
83
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
84
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
85
|
+
}
|
|
86
|
+
const MAX_ID_LENGTH = 64;
|
|
87
|
+
const EVENT_ID = /^[\w.:-]+$/;
|
|
88
|
+
/** a usable event id from an untrusted value: non-empty, printable, bounded */
|
|
89
|
+
function isEventId(value) {
|
|
90
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_ID_LENGTH && EVENT_ID.test(value);
|
|
91
|
+
}
|
|
92
|
+
/** the id an event fires under: its own when it carries a usable one (an order number), else a fresh one */
|
|
93
|
+
function eventIdOf(own) {
|
|
94
|
+
return isEventId(own) ? own : createEventId();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Why an event does not fire under the id it came with, for the log of whoever tracked it: the
|
|
98
|
+
* other side reports the conversion under the own id, so a replaced one counts twice.
|
|
99
|
+
*/
|
|
100
|
+
function unusableEventId(own, id) {
|
|
101
|
+
if (own === void 0 || isEventId(own)) return void 0;
|
|
102
|
+
return `event id ${JSON.stringify(own)} is not usable (1 to ${MAX_ID_LENGTH} of A-Z, a-z, 0-9, _ . : -), the event fires under ${id} instead`;
|
|
103
|
+
}
|
|
104
|
+
export { isBrowser as a, payloadOf as c, trackAttribute as d, unusableEventId as f, eventIdOf as i, serializeConsent as l, RELAY_TRACK_ATTRIBUTE as n, isTrackInput as o, defineEvent as r, parseConsent as s, RELAY_CONSENT_HEADER as t, toTracked as u };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=shared-D281USsp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-D281USsp.js","names":[],"sources":["../src/shared.ts"],"sourcesContent":["// imported by the server, the client and the destination entries — no node or astro runtime imports here\n\n/**\n * The request header the browser's consent travels in: the names of the consented destinations,\n * comma-separated. The bus writes it onto every same-origin fetch, the middleware reads it.\n */\nexport const RELAY_CONSENT_HEADER = 'x-relay-consent';\n\n/** the attribute of an element whose click tracks the event serialized into it */\nexport const RELAY_TRACK_ATTRIBUTE = 'data-track';\n\n/** what the visitor allowed, by destination name */\nexport type ConsentRecord = Readonly<Record<string, boolean>>;\n\nconst MAX_CONSENT_NAMES = 32;\nconst DESTINATION_NAME = /^[\\w-]{1,64}$/;\n\n/** the header value: the names of the consented destinations, empty when none */\nexport function serializeConsent(consent: ConsentRecord): string {\n return Object.keys(consent)\n .filter((name) => consent[name] === true && DESTINATION_NAME.test(name))\n .join(',');\n}\n\n/** the record from an untrusted header value: unknown names are dropped, a missing header is nothing consented */\nexport function parseConsent(raw: string | null | undefined): ConsentRecord {\n if (!raw) return {};\n\n const names = raw\n .split(',')\n .map((name) => name.trim())\n .filter((name) => DESTINATION_NAME.test(name))\n .slice(0, MAX_CONSENT_NAMES);\n\n return Object.fromEntries(names.map((name) => [name, true]));\n}\n\n/**\n * The answer for one destination: `undefined` as long as the cmp has not read the stored choice yet\n * — not \"no\", but \"not known\", so events wait in memory instead of being dropped.\n */\nexport type ConsentAnswer = boolean | undefined;\n\n/**\n * Where the bus asks whether the visitor allowed a destination: a cmp adapter (`ccm19()`), or three\n * members of your own. It covers exactly the registered names — `names` and `of` make the type\n * invariant in them — so a destination without an answer is a type error.\n */\nexport type ConsentSource<N extends string = string> = {\n /** the registered destination names */\n names: readonly N[];\n /** whether the visitor allowed the destination */\n of: (name: N) => ConsentAnswer;\n /** destinations needing no consent: taken before the cmp has answered, not in the record */\n free?: readonly N[] | undefined;\n /** called once with the re-check: hook it to the cmp's change event, so a choice on this page delivers at once */\n watch?: ((notify: () => void) => void) | undefined;\n};\n\n/**\n * The destinations an event can carry a payload for, by name: the package's destination entries and a\n * site's own add theirs through module augmentation of `@astroscope/relay`, so every event\n * definition is checked against the payload the destination takes. `id`, `key` and `event` are\n * reserved names.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- filled by augmentation\nexport interface RelayDestinations {}\n\nexport type DestinationName = keyof RelayDestinations & string;\n\n/** the parameters of an event as a destination's builder takes them */\nexport type RelayParams = Record<string, unknown>;\n\n/** an event on the bus: the payload for each destination it is meant for, built by the destination's own builders */\nexport type RelayEvent = { [N in DestinationName]?: RelayDestinations[N] | undefined };\n\n/**\n * An event a site defined: the definition's key, optionally the id it fires under (an order\n * number, so every destination counts a conversion once, on both sides), and the payloads it built.\n */\nexport type DomainEvent<E extends RelayEvent = RelayEvent> = {\n key: string;\n id?: string | undefined;\n event: E;\n};\n\n/** what a definition returns: the payloads, and the id where the site's data has one */\nexport type DefinedPayloads = RelayEvent & { id?: string | undefined };\n\n/** what `track()`, `<Track>` and `data-track` take: a defined event or a plain one */\nexport type TrackInput = RelayEvent | DomainEvent;\n\n/** a defined event: builds the event from the site's own arguments and carries its key */\nexport type EventDefinition<\n Args extends unknown[] = unknown[],\n E extends RelayEvent = RelayEvent,\n K extends string = string,\n> = ((...args: Args) => DomainEvent<E>) & {\n readonly key: K;\n};\n\n/**\n * One of the site's events: a function that turns the site's own objects into the payloads of the\n * destinations the event is meant for, under the key that identifies it in a `data-track`\n * attribute and in logs. One export per event, so an island bundles only the events\n * it tracks and an event only an action imports never reaches the browser; the key is the export's\n * name.\n */\nexport function defineEvent<const K extends string, Args extends unknown[], E extends DefinedPayloads>(\n key: K,\n create: (...args: Args) => E,\n): EventDefinition<Args, Omit<E, 'id'>, K> {\n const build = (...args: Args): DomainEvent<Omit<E, 'id'>> => {\n const { id, ...event } = create(...args);\n\n return id === undefined ? { key, event } : { key, id, event };\n };\n\n return Object.assign(build, { key });\n}\n\nexport function isDomainEvent(input: TrackInput): input is DomainEvent {\n const candidate = input as Partial<DomainEvent>;\n\n return typeof candidate.key === 'string' && typeof candidate.event === 'object' && candidate.event !== null;\n}\n\n/** the payloads and, for a defined one, its key and own id */\nexport function toTracked(input: TrackInput): { event: RelayEvent; key: string | undefined; id: string | undefined } {\n return isDomainEvent(input)\n ? { event: input.event, key: input.key, id: input.id }\n : { event: input, key: undefined, id: undefined };\n}\n\n/** a plain object with the right shape, from untrusted json (an attribute, the queue, storage) */\nexport function isTrackInput(value: unknown): value is TrackInput {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false;\n\n const candidate = value as Partial<DomainEvent>;\n\n if (candidate.key === undefined && candidate.event === undefined) return true;\n\n return isDomainEvent(candidate as TrackInput);\n}\n\n/** the value of the `data-track` attribute of an element whose click tracks the event */\nexport function trackAttribute(input: TrackInput): string {\n return JSON.stringify(input);\n}\n\n/** the payload of a destination in an event, `undefined` when the event is not meant for it */\nexport function payloadOf(event: RelayEvent, name: string): unknown {\n return (event as Record<string, unknown>)[name];\n}\n\n/** what a destination knows about an event besides its payload */\nexport type EventMeta = {\n id: string;\n /** epoch milliseconds of the track call */\n at: number;\n /** the key of the definition the event came from, `undefined` for a plain event */\n key?: string | undefined;\n};\n\n/** `track()`, the same in the browser and on the server: puts the event on the bus, returns its id */\nexport type TrackFunction = (input: TrackInput) => string;\n\n/** whether this runs in a browser: a runtime check, so the built package works outside vite too */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n/** a fresh event id: a uuid; `randomUUID` needs a secure context, random bytes do not */\nexport function createEventId(): string {\n if (typeof crypto.randomUUID === 'function') return crypto.randomUUID();\n\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n\n bytes[6] = ((bytes[6] ?? 0) & 0x0F) | 0x40;\n bytes[8] = ((bytes[8] ?? 0) & 0x3F) | 0x80;\n\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\nconst MAX_ID_LENGTH = 64;\nconst EVENT_ID = /^[\\w.:-]+$/;\n\n/** a usable event id from an untrusted value: non-empty, printable, bounded */\nexport function isEventId(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0 && value.length <= MAX_ID_LENGTH && EVENT_ID.test(value);\n}\n\n/** the id an event fires under: its own when it carries a usable one (an order number), else a fresh one */\nexport function eventIdOf(own: string | undefined): string {\n return isEventId(own) ? own : createEventId();\n}\n\n/**\n * Why an event does not fire under the id it came with, for the log of whoever tracked it: the\n * other side reports the conversion under the own id, so a replaced one counts twice.\n */\nexport function unusableEventId(own: unknown, id: string): string | undefined {\n if (own === undefined || isEventId(own)) return undefined;\n\n return `event id ${JSON.stringify(own)} is not usable (1 to ${MAX_ID_LENGTH} of A-Z, a-z, 0-9, _ . : -), the event fires under ${id} instead`;\n}\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,136 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astroscope/relay",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Consent-aware event relay for Astro",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"browser": "./dist/index.browser.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./server": {
|
|
15
|
+
"types": "./dist/server/index.d.ts",
|
|
16
|
+
"import": "./dist/server/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./client": {
|
|
19
|
+
"types": "./dist/client/index.d.ts",
|
|
20
|
+
"import": "./dist/client/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./track": {
|
|
23
|
+
"types": "./dist/server/track.d.ts",
|
|
24
|
+
"browser": "./dist/client/track.js",
|
|
25
|
+
"default": "./dist/server/track.js"
|
|
26
|
+
},
|
|
27
|
+
"./registry": {
|
|
28
|
+
"types": "./dist/server/registry.d.ts",
|
|
29
|
+
"import": "./dist/server/registry.js"
|
|
30
|
+
},
|
|
31
|
+
"./middleware": {
|
|
32
|
+
"types": "./dist/server/middleware-entrypoint.d.ts",
|
|
33
|
+
"import": "./dist/server/middleware-entrypoint.js"
|
|
34
|
+
},
|
|
35
|
+
"./react": {
|
|
36
|
+
"types": "./dist/react/index.d.ts",
|
|
37
|
+
"import": "./dist/react/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./astro": {
|
|
40
|
+
"import": "./src/astro/index.ts"
|
|
41
|
+
},
|
|
42
|
+
"./ga4": {
|
|
43
|
+
"types": "./dist/ga4/index.d.ts",
|
|
44
|
+
"import": "./dist/ga4/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./gtm": {
|
|
47
|
+
"types": "./dist/gtm/index.d.ts",
|
|
48
|
+
"import": "./dist/gtm/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./matomo": {
|
|
51
|
+
"types": "./dist/matomo/index.d.ts",
|
|
52
|
+
"import": "./dist/matomo/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./ccm19": {
|
|
55
|
+
"types": "./dist/ccm19/index.d.ts",
|
|
56
|
+
"import": "./dist/ccm19/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./awin": {
|
|
59
|
+
"types": "./dist/awin/index.d.ts",
|
|
60
|
+
"import": "./dist/awin/index.js"
|
|
61
|
+
},
|
|
62
|
+
"./openai": {
|
|
63
|
+
"types": "./dist/openai/index.d.ts",
|
|
64
|
+
"import": "./dist/openai/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./openai/server": {
|
|
67
|
+
"types": "./dist/openai/server.d.ts",
|
|
68
|
+
"import": "./dist/openai/server.js"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"dist",
|
|
73
|
+
"src/astro"
|
|
74
|
+
],
|
|
75
|
+
"sideEffects": false,
|
|
76
|
+
"publishConfig": {
|
|
77
|
+
"access": "public"
|
|
78
|
+
},
|
|
79
|
+
"repository": {
|
|
80
|
+
"type": "git",
|
|
81
|
+
"url": "https://github.com/entwico/astroscope",
|
|
82
|
+
"directory": "packages/relay"
|
|
83
|
+
},
|
|
84
|
+
"keywords": [
|
|
85
|
+
"astro",
|
|
86
|
+
"astro-integration",
|
|
87
|
+
"analytics",
|
|
88
|
+
"consent",
|
|
89
|
+
"tracking",
|
|
90
|
+
"ga4",
|
|
91
|
+
"awin",
|
|
92
|
+
"ccm19",
|
|
93
|
+
"matomo",
|
|
94
|
+
"conversions",
|
|
95
|
+
"actions",
|
|
96
|
+
"gtm",
|
|
97
|
+
"middleware"
|
|
98
|
+
],
|
|
99
|
+
"author": "admin@entwico.com",
|
|
100
|
+
"license": "MIT",
|
|
101
|
+
"bugs": {
|
|
102
|
+
"url": "https://github.com/entwico/astroscope/issues"
|
|
103
|
+
},
|
|
104
|
+
"homepage": "https://github.com/entwico/astroscope/tree/main/packages/relay#readme",
|
|
105
|
+
"dependencies": {
|
|
106
|
+
"@entwico/dash": "^1.3.0"
|
|
107
|
+
},
|
|
108
|
+
"devDependencies": {
|
|
109
|
+
"@astroscope/node": "^4.2.0",
|
|
110
|
+
"@types/node": "^26.6.6",
|
|
111
|
+
"@types/react": "^19.3.0",
|
|
112
|
+
"astro": "^7.4.4",
|
|
113
|
+
"happy-dom": "^21.0.4",
|
|
114
|
+
"react": "^19.3.1",
|
|
115
|
+
"tsdown": "^0.23.4",
|
|
116
|
+
"typescript": "^6.0.3",
|
|
117
|
+
"vite": "^8.3.5",
|
|
118
|
+
"vitest": "^5.0.5"
|
|
119
|
+
},
|
|
120
|
+
"peerDependencies": {
|
|
121
|
+
"@astroscope/node": "^4.2.0",
|
|
122
|
+
"astro": "^7.0.0",
|
|
123
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
124
|
+
},
|
|
125
|
+
"peerDependenciesMeta": {
|
|
126
|
+
"react": {
|
|
127
|
+
"optional": true
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"scripts": {
|
|
131
|
+
"build": "tsdown",
|
|
132
|
+
"typecheck": "tsc --noEmit",
|
|
133
|
+
"lint": "eslint src --cache",
|
|
134
|
+
"lint:fix": "eslint src --fix"
|
|
135
|
+
}
|
|
6
136
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { type TrackInput, inlineTrack } from '@astroscope/relay';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tracks an event from server-rendered html: an inline push into the queue the bus drains when it
|
|
6
|
+
* installs, or straight onto the bus when it is already there. Use it for what the page shows
|
|
7
|
+
* (`view_item`, `view_item_list`), where no island is involved.
|
|
8
|
+
*/
|
|
9
|
+
type Props = {
|
|
10
|
+
event: TrackInput;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const { event } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<Fragment set:html={`<script>${inlineTrack(event)}</script>`} />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Track } from './Track.astro';
|