order3000 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs +67 -14
- package/dist/client.d.cts +425 -21
- package/dist/client.d.mts +425 -21
- package/dist/client.mjs +67 -14
- package/dist/schemas.cjs +566 -6
- package/dist/schemas.d.cts +299 -6
- package/dist/schemas.d.mts +299 -6
- package/dist/schemas.mjs +566 -6
- package/dist/tracking.cjs +37 -0
- package/dist/tracking.d.cts +34 -0
- package/dist/tracking.d.mts +34 -0
- package/dist/tracking.mjs +33 -0
- package/package.json +11 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const AD_CLICK_ID_KEYS = [
|
|
4
|
+
"gclid",
|
|
5
|
+
"gbraid",
|
|
6
|
+
"wbraid",
|
|
7
|
+
"fbclid"
|
|
8
|
+
];
|
|
9
|
+
const AD_CLICK_COOKIE_MAX_AGE = 90 * 24 * 60 * 60;
|
|
10
|
+
function writeCookie(name, value) {
|
|
11
|
+
document.cookie = `${name}=${encodeURIComponent(value)}; path=/; max-age=${AD_CLICK_COOKIE_MAX_AGE}; SameSite=Lax`;
|
|
12
|
+
}
|
|
13
|
+
function readCookie(name) {
|
|
14
|
+
const match = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`));
|
|
15
|
+
return match ? decodeURIComponent(match.slice(name.length + 1)) : void 0;
|
|
16
|
+
}
|
|
17
|
+
function persistAdClickIdsFromUrl() {
|
|
18
|
+
if (typeof window === "undefined") return;
|
|
19
|
+
const params = new URLSearchParams(window.location.search);
|
|
20
|
+
for (const key of AD_CLICK_ID_KEYS) {
|
|
21
|
+
const value = params.get(key);
|
|
22
|
+
if (value) writeCookie(key, value);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function getAdClickIds() {
|
|
26
|
+
if (typeof window === "undefined") return {};
|
|
27
|
+
const ids = {};
|
|
28
|
+
for (const key of AD_CLICK_ID_KEYS) {
|
|
29
|
+
const value = readCookie(key);
|
|
30
|
+
if (value) ids[key] = value;
|
|
31
|
+
}
|
|
32
|
+
return ids;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exports.AD_CLICK_ID_KEYS = AD_CLICK_ID_KEYS;
|
|
36
|
+
exports.getAdClickIds = getAdClickIds;
|
|
37
|
+
exports.persistAdClickIdsFromUrl = persistAdClickIdsFromUrl;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* order3000 ad-click attribution — first-party capture of the click identifiers
|
|
3
|
+
* that appear on an ad's landing URL (Google Ads auto-tagging `gclid`/`gbraid`/
|
|
4
|
+
* `wbraid`; Meta `fbclid`). A reservation made later in the session is then
|
|
5
|
+
* attributed to the originating ad click and reported to the ad platform
|
|
6
|
+
* server-side — Google Ads offline conversions and the Meta Conversions API.
|
|
7
|
+
*
|
|
8
|
+
* **Provided by order3000 so every consumer captures attribution identically,
|
|
9
|
+
* without re-implementing this logic.** Wire it in two lines on the restaurant
|
|
10
|
+
* frontend:
|
|
11
|
+
*
|
|
12
|
+
* - call `persistAdClickIdsFromUrl()` once on landing (every page), and
|
|
13
|
+
* - spread `getAdClickIds()` into the `reservations.make(...)` payload on
|
|
14
|
+
* submit.
|
|
15
|
+
*
|
|
16
|
+
* No Google/Meta script is ever loaded — these are plain query params we read
|
|
17
|
+
* ourselves and store in first-party cookies (browser-only; every function is a
|
|
18
|
+
* no-op when `window` is undefined, so it is safe to import in SSR code).
|
|
19
|
+
*/
|
|
20
|
+
/** The ad-click identifiers order3000 captures from a landing URL. */
|
|
21
|
+
declare const AD_CLICK_ID_KEYS: readonly ["gclid", "gbraid", "wbraid", "fbclid"];
|
|
22
|
+
type AdClickIdKey = (typeof AD_CLICK_ID_KEYS)[number];
|
|
23
|
+
type AdClickIds = Partial<Record<AdClickIdKey, string>>;
|
|
24
|
+
/**
|
|
25
|
+
* Read any ad-click ids from the current URL and persist them to first-party
|
|
26
|
+
* cookies. Call once on landing (every page). Only a present id is written, so a
|
|
27
|
+
* later non-ad navigation never clears an earlier attribution.
|
|
28
|
+
*/
|
|
29
|
+
declare function persistAdClickIdsFromUrl(): void;
|
|
30
|
+
/** The persisted ad-click ids, for attaching to a reservation on submit. */
|
|
31
|
+
declare function getAdClickIds(): AdClickIds;
|
|
32
|
+
|
|
33
|
+
export { AD_CLICK_ID_KEYS, getAdClickIds, persistAdClickIdsFromUrl };
|
|
34
|
+
export type { AdClickIdKey, AdClickIds };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* order3000 ad-click attribution — first-party capture of the click identifiers
|
|
3
|
+
* that appear on an ad's landing URL (Google Ads auto-tagging `gclid`/`gbraid`/
|
|
4
|
+
* `wbraid`; Meta `fbclid`). A reservation made later in the session is then
|
|
5
|
+
* attributed to the originating ad click and reported to the ad platform
|
|
6
|
+
* server-side — Google Ads offline conversions and the Meta Conversions API.
|
|
7
|
+
*
|
|
8
|
+
* **Provided by order3000 so every consumer captures attribution identically,
|
|
9
|
+
* without re-implementing this logic.** Wire it in two lines on the restaurant
|
|
10
|
+
* frontend:
|
|
11
|
+
*
|
|
12
|
+
* - call `persistAdClickIdsFromUrl()` once on landing (every page), and
|
|
13
|
+
* - spread `getAdClickIds()` into the `reservations.make(...)` payload on
|
|
14
|
+
* submit.
|
|
15
|
+
*
|
|
16
|
+
* No Google/Meta script is ever loaded — these are plain query params we read
|
|
17
|
+
* ourselves and store in first-party cookies (browser-only; every function is a
|
|
18
|
+
* no-op when `window` is undefined, so it is safe to import in SSR code).
|
|
19
|
+
*/
|
|
20
|
+
/** The ad-click identifiers order3000 captures from a landing URL. */
|
|
21
|
+
declare const AD_CLICK_ID_KEYS: readonly ["gclid", "gbraid", "wbraid", "fbclid"];
|
|
22
|
+
type AdClickIdKey = (typeof AD_CLICK_ID_KEYS)[number];
|
|
23
|
+
type AdClickIds = Partial<Record<AdClickIdKey, string>>;
|
|
24
|
+
/**
|
|
25
|
+
* Read any ad-click ids from the current URL and persist them to first-party
|
|
26
|
+
* cookies. Call once on landing (every page). Only a present id is written, so a
|
|
27
|
+
* later non-ad navigation never clears an earlier attribution.
|
|
28
|
+
*/
|
|
29
|
+
declare function persistAdClickIdsFromUrl(): void;
|
|
30
|
+
/** The persisted ad-click ids, for attaching to a reservation on submit. */
|
|
31
|
+
declare function getAdClickIds(): AdClickIds;
|
|
32
|
+
|
|
33
|
+
export { AD_CLICK_ID_KEYS, getAdClickIds, persistAdClickIdsFromUrl };
|
|
34
|
+
export type { AdClickIdKey, AdClickIds };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const AD_CLICK_ID_KEYS = [
|
|
2
|
+
"gclid",
|
|
3
|
+
"gbraid",
|
|
4
|
+
"wbraid",
|
|
5
|
+
"fbclid"
|
|
6
|
+
];
|
|
7
|
+
const AD_CLICK_COOKIE_MAX_AGE = 90 * 24 * 60 * 60;
|
|
8
|
+
function writeCookie(name, value) {
|
|
9
|
+
document.cookie = `${name}=${encodeURIComponent(value)}; path=/; max-age=${AD_CLICK_COOKIE_MAX_AGE}; SameSite=Lax`;
|
|
10
|
+
}
|
|
11
|
+
function readCookie(name) {
|
|
12
|
+
const match = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`));
|
|
13
|
+
return match ? decodeURIComponent(match.slice(name.length + 1)) : void 0;
|
|
14
|
+
}
|
|
15
|
+
function persistAdClickIdsFromUrl() {
|
|
16
|
+
if (typeof window === "undefined") return;
|
|
17
|
+
const params = new URLSearchParams(window.location.search);
|
|
18
|
+
for (const key of AD_CLICK_ID_KEYS) {
|
|
19
|
+
const value = params.get(key);
|
|
20
|
+
if (value) writeCookie(key, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function getAdClickIds() {
|
|
24
|
+
if (typeof window === "undefined") return {};
|
|
25
|
+
const ids = {};
|
|
26
|
+
for (const key of AD_CLICK_ID_KEYS) {
|
|
27
|
+
const value = readCookie(key);
|
|
28
|
+
if (value) ids[key] = value;
|
|
29
|
+
}
|
|
30
|
+
return ids;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { AD_CLICK_ID_KEYS, getAdClickIds, persistAdClickIdsFromUrl };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "order3000",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "order3000 node.js sdk",
|
|
5
5
|
"main": "./dist/client.cjs",
|
|
6
6
|
"module": "./dist/client.mjs",
|
|
@@ -25,6 +25,16 @@
|
|
|
25
25
|
"types": "./dist/schemas.d.mts",
|
|
26
26
|
"default": "./dist/schemas.mjs"
|
|
27
27
|
}
|
|
28
|
+
},
|
|
29
|
+
"./tracking": {
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/tracking.d.cts",
|
|
32
|
+
"default": "./dist/tracking.cjs"
|
|
33
|
+
},
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/tracking.d.mts",
|
|
36
|
+
"default": "./dist/tracking.mjs"
|
|
37
|
+
}
|
|
28
38
|
}
|
|
29
39
|
},
|
|
30
40
|
"dependencies": {
|