@veroxm/sdk 1.3.0 → 1.5.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/CHANGELOG.md +19 -0
- package/README.md +7 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.js +2 -0
- package/dist/embed.d.ts +80 -0
- package/dist/embed.js +321 -0
- package/dist/forms.d.ts +27 -0
- package/dist/forms.js +35 -0
- package/dist/generated/api.d.ts +584 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/tracker.d.ts +9 -0
- package/dist/tracker.js +22 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
- Forms (public API 2.7). `embedForm({ baseUrl, form, mode })` shows a VeroXM form in a page: `inline` (in an element,
|
|
6
|
+
optionally growing with its content), `popup` (a dialog), `fullpage` or `toast` (a card that slides in from a
|
|
7
|
+
corner). Popups and toasts open from `trigger` buttons, `open()`, or by themselves (`openOn`: on load, after a delay,
|
|
8
|
+
on scroll); a closed toast stays closed for `rememberDismissDays`. `hidden` passes hidden fields; `onSubmit`,
|
|
9
|
+
`onStarted`, `onReady` and `onClose` report what happened; `getToken` hands a form that needs signing in the
|
|
10
|
+
person's access token. `embedFormsFromPage` reads `data-veroxm-form` elements (the script tag at
|
|
11
|
+
`<VeroXM address>/f/embed.js` is the same code).
|
|
12
|
+
- `app.forms` for your servers, with a key that has the "Read forms and responses" permission: `list()`, `get(id)`,
|
|
13
|
+
`responses(id, { status, since, cursor, limit })`, `allResponses(id, options)` (every page) and `response(id, rid)`.
|
|
14
|
+
`Schemas` has the form shapes and `ApiPaths` their routes.
|
|
15
|
+
|
|
16
|
+
## 1.4.0
|
|
17
|
+
|
|
18
|
+
- Campaign targeting (public API 2.6): in a browser, `getExperience` and `getFlag` send the page the visit started on
|
|
19
|
+
and its referrer, so experiences can target `campaign.*` (utm tags, ad click ids, the referring site) on the landing
|
|
20
|
+
page itself. `tracker.setLandingPage(url, referrer?)` sets it for an app opened by a link, or a server.
|
|
21
|
+
|
|
3
22
|
## 1.3.0
|
|
4
23
|
|
|
5
24
|
- Two-step sign-in (public API 2.5). A sign-in throws `VeroXMTwoStepRequiredError` (a `VeroXMApiError`, code
|
package/README.md
CHANGED
|
@@ -291,7 +291,13 @@ const stop = tracker.subscribe(() => rerenderExperiences());
|
|
|
291
291
|
- **Consent:** before analytics consent it resolves to `'none'` with
|
|
292
292
|
`waitingForConsent: true` and makes no request (a sticky assignment needs
|
|
293
293
|
a stored visitor id, and the server records an exposure). Segment
|
|
294
|
-
targeting additionally needs personalization consent
|
|
294
|
+
targeting additionally needs personalization consent, except rules on
|
|
295
|
+
the visit's own campaign (`campaign.*`).
|
|
296
|
+
- **Campaigns:** in a browser the tracker sends the page the visit started
|
|
297
|
+
on and its referrer, so a variant can target `campaign.source`,
|
|
298
|
+
`campaign.channel`, a link tag like `campaign.param.tf_campaign`, and so
|
|
299
|
+
on, on the landing page itself. In an app opened by a link, call
|
|
300
|
+
`tracker.setLandingPage(url)` first (and `page({ url })` to record it).
|
|
295
301
|
- **Journey messages:** a journey's in-app step can leave a message for
|
|
296
302
|
this person on a placement. Then `d.reason === 'journey'` and the
|
|
297
303
|
message fields are in `d.config` (e.g. `title`, `text`, `ctaLabel`,
|
package/dist/client.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { MediaResource } from './media.js';
|
|
|
5
5
|
import { FunctionsResource } from './functions.js';
|
|
6
6
|
import { TasksResource } from './tasks.js';
|
|
7
7
|
import { ProcessesResource } from './processes.js';
|
|
8
|
+
import { FormsResource } from './forms.js';
|
|
8
9
|
import { type TokenStorage } from './token-storage.js';
|
|
9
10
|
export interface VeroXMAppOptions {
|
|
10
11
|
/** Your VeroXM deployment's origin, e.g. "https://cms.example.com" -- no trailing /public/... needed, VeroXMApp builds that itself. */
|
|
@@ -29,6 +30,8 @@ export declare class VeroXMApp {
|
|
|
29
30
|
readonly tasks: TasksResource;
|
|
30
31
|
/** Start processes and read their runs (server keys). */
|
|
31
32
|
readonly processes: ProcessesResource;
|
|
33
|
+
/** The project's forms and responses (server keys with forms:read). */
|
|
34
|
+
readonly forms: FormsResource;
|
|
32
35
|
private readonly apiBase;
|
|
33
36
|
private constructor();
|
|
34
37
|
static initializeApp(options: VeroXMAppOptions): VeroXMApp;
|
package/dist/client.js
CHANGED
|
@@ -6,6 +6,7 @@ import { MediaResource } from './media.js';
|
|
|
6
6
|
import { FunctionsResource } from './functions.js';
|
|
7
7
|
import { TasksResource } from './tasks.js';
|
|
8
8
|
import { ProcessesResource } from './processes.js';
|
|
9
|
+
import { FormsResource } from './forms.js';
|
|
9
10
|
import { MemoryTokenStorage, BrowserLocalStorageTokenStorage } from './token-storage.js';
|
|
10
11
|
function defaultTokenStorage(projectId) {
|
|
11
12
|
if (typeof window !== 'undefined' && typeof window.localStorage !== 'undefined') {
|
|
@@ -25,6 +26,7 @@ export class VeroXMApp {
|
|
|
25
26
|
this.functions = new FunctionsResource(this);
|
|
26
27
|
this.tasks = new TasksResource(this);
|
|
27
28
|
this.processes = new ProcessesResource(this);
|
|
29
|
+
this.forms = new FormsResource(this);
|
|
28
30
|
}
|
|
29
31
|
static initializeApp(options) {
|
|
30
32
|
const base = options.baseUrl.replace(/\/$/, '');
|
package/dist/embed.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type FormEmbedMode = 'inline' | 'popup' | 'fullpage' | 'toast';
|
|
2
|
+
export interface FormEmbedOpenTrigger {
|
|
3
|
+
/** When a popup or toast opens by itself: on page load, after `delaySeconds`, or once the visitor has scrolled `scrollPercent` of the page. Default: manual (call `open()`, or use `trigger`). */
|
|
4
|
+
on?: 'load' | 'delay' | 'scroll' | 'manual';
|
|
5
|
+
delaySeconds?: number;
|
|
6
|
+
scrollPercent?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface FormEmbedOptions {
|
|
9
|
+
/** Your VeroXM address, e.g. "https://cms.example.com". */
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
/** The form id (f_...), from the form's Share tab. */
|
|
12
|
+
form: string;
|
|
13
|
+
/** Default "inline". */
|
|
14
|
+
mode?: FormEmbedMode;
|
|
15
|
+
/** inline and fullpage: the element (or a CSS selector) the form goes in. fullpage without one covers the window. */
|
|
16
|
+
container?: HTMLElement | string;
|
|
17
|
+
/** Hidden fields the form declares, e.g. `{ source: "pricing-page" }`. */
|
|
18
|
+
hidden?: Record<string, string>;
|
|
19
|
+
/** inline: the height in pixels (default 520). */
|
|
20
|
+
height?: number;
|
|
21
|
+
/** inline: grow and shrink with the form's content (good for the all-on-a-page layout). */
|
|
22
|
+
autoHeight?: boolean;
|
|
23
|
+
/** popup: "small" (480 wide), "medium" (720, default) or "large" (960). */
|
|
24
|
+
size?: 'small' | 'medium' | 'large';
|
|
25
|
+
/** toast: which corner (default "bottom-right"). */
|
|
26
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
27
|
+
/** popup and toast: open by themselves on load, after a delay or on scroll. */
|
|
28
|
+
openOn?: FormEmbedOpenTrigger;
|
|
29
|
+
/** popup and toast: elements (or a selector) that open the form when clicked. */
|
|
30
|
+
trigger?: HTMLElement | string;
|
|
31
|
+
/** toast: once closed, don't show it again by itself for this many days (default 7; 0 to show every time). */
|
|
32
|
+
rememberDismissDays?: number;
|
|
33
|
+
/** popup, toast and fullpage: close this many seconds after the form is sent (default: stay open on the ending). */
|
|
34
|
+
autoCloseSeconds?: number;
|
|
35
|
+
/** The iframe's accessible name (default "Form"). */
|
|
36
|
+
title?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Forms that need signing in: the signed-in person's access token for this project (from @veroxm/sdk's
|
|
39
|
+
* `app.auth.getAccessToken()`). Called when the form asks; return null if nobody is signed in.
|
|
40
|
+
*/
|
|
41
|
+
getToken?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
42
|
+
onReady?: () => void;
|
|
43
|
+
/** The first answer. */
|
|
44
|
+
onStarted?: () => void;
|
|
45
|
+
/** The form was sent. */
|
|
46
|
+
onSubmit?: (result: {
|
|
47
|
+
responseId: string;
|
|
48
|
+
endingId: string | null;
|
|
49
|
+
}) => void;
|
|
50
|
+
onClose?: () => void;
|
|
51
|
+
}
|
|
52
|
+
export interface FormEmbed {
|
|
53
|
+
readonly iframe: HTMLIFrameElement;
|
|
54
|
+
/** popup and toast: show it. */
|
|
55
|
+
open(): void;
|
|
56
|
+
/** popup, toast and fullpage: hide it. */
|
|
57
|
+
close(): void;
|
|
58
|
+
/** Remove everything this embed added to the page. */
|
|
59
|
+
destroy(): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Shows a VeroXM form in the page. Returns a handle to open, close or remove it.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* embedForm({ baseUrl: 'https://cms.example.com', form: 'f_Ab3dEf7hJk9mNpQr2sTu', container: '#survey' });
|
|
66
|
+
* embedForm({ baseUrl, form, mode: 'toast', openOn: { on: 'scroll', scrollPercent: 50 } });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function embedForm(options: FormEmbedOptions): FormEmbed;
|
|
70
|
+
/**
|
|
71
|
+
* The script-tag embed: reads data attributes and embeds every form it finds. Used by /f/embed.js; call it yourself
|
|
72
|
+
* after adding such elements later.
|
|
73
|
+
*
|
|
74
|
+
* ```html
|
|
75
|
+
* <div data-veroxm-form="f_..." data-mode="inline" data-height="600"></div>
|
|
76
|
+
* <button data-veroxm-form="f_..." data-mode="popup">Give feedback</button>
|
|
77
|
+
* <script src="https://cms.example.com/f/embed.js" data-veroxm-form="f_..." data-mode="toast" data-open-on="delay" async></script>
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function embedFormsFromPage(baseUrl: string, root?: ParentNode): FormEmbed[];
|
package/dist/embed.js
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
// Embedding VeroXM forms in a website or app (docs.veroxm.com/forms#embedding).
|
|
2
|
+
//
|
|
3
|
+
// The form runs in an iframe of its hosted page (<VeroXM address>/f/<form id>), so it keeps its own look, checks and
|
|
4
|
+
// files, and nothing about the visitor or the project's keys touches the host page. The two sides talk with
|
|
5
|
+
// postMessage, each checking where a message came from:
|
|
6
|
+
//
|
|
7
|
+
// form -> page { source: "veroxm-form", id, type: "ready" | "height" | "started" | "submitted" | "redirect" | "close" | "need-token", ... }
|
|
8
|
+
// page -> form { source: "veroxm-embed", id, type: "token", token }
|
|
9
|
+
//
|
|
10
|
+
// Four ways to show it: inline (in the page), popup (a dialog), fullpage (covering the window) and toast (a card that
|
|
11
|
+
// slides in from a corner). This file has no imports on purpose: it is also served, as is, as the script-tag embed
|
|
12
|
+
// (/f/embed.js, generated by scripts/gen-embed.mjs).
|
|
13
|
+
const STYLE_ID = 'veroxm-form-embed-style';
|
|
14
|
+
const CSS = `
|
|
15
|
+
.vxe-frame{border:0;display:block;width:100%;background:transparent;color-scheme:normal}
|
|
16
|
+
.vxe-backdrop{position:fixed;inset:0;z-index:2147483000;background:rgba(15,17,23,.55);display:flex;align-items:center;justify-content:center;padding:16px;opacity:0;transition:opacity .2s ease}
|
|
17
|
+
.vxe-backdrop.vxe-in{opacity:1}
|
|
18
|
+
.vxe-backdrop[hidden],.vxe-toast[hidden],.vxe-full[hidden]{display:none}
|
|
19
|
+
.vxe-dialog{position:relative;width:100%;height:min(720px,calc(100vh - 32px));border-radius:14px;overflow:hidden;box-shadow:0 20px 60px rgba(0,0,0,.35);background:#fff}
|
|
20
|
+
.vxe-dialog .vxe-frame,.vxe-toast .vxe-frame,.vxe-full .vxe-frame{height:100%}
|
|
21
|
+
.vxe-close{position:absolute;top:8px;right:8px;z-index:1;width:34px;height:34px;border-radius:999px;border:0;background:rgba(15,17,23,.6);color:#fff;font:600 18px/1 system-ui,sans-serif;cursor:pointer}
|
|
22
|
+
.vxe-close:focus-visible{outline:2px solid #fff;outline-offset:2px}
|
|
23
|
+
.vxe-full{position:fixed;inset:0;z-index:2147483000;background:#fff}
|
|
24
|
+
.vxe-toast{position:fixed;bottom:16px;z-index:2147483000;width:min(380px,calc(100vw - 32px));height:min(560px,calc(100vh - 32px));border-radius:14px;overflow:hidden;box-shadow:0 12px 40px rgba(0,0,0,.3);background:#fff;transform:translateY(calc(100% + 24px));opacity:0;transition:transform .3s ease,opacity .3s ease}
|
|
25
|
+
.vxe-toast.vxe-right{right:16px}.vxe-toast.vxe-left{left:16px}
|
|
26
|
+
.vxe-toast.vxe-in{transform:none;opacity:1}
|
|
27
|
+
@media (prefers-reduced-motion:reduce){.vxe-backdrop,.vxe-toast{transition:none}}
|
|
28
|
+
`;
|
|
29
|
+
const SIZES = { small: 480, medium: 720, large: 960 };
|
|
30
|
+
function el(tag, className) {
|
|
31
|
+
const e = document.createElement(tag);
|
|
32
|
+
e.className = className;
|
|
33
|
+
return e;
|
|
34
|
+
}
|
|
35
|
+
function resolve(target) {
|
|
36
|
+
if (!target)
|
|
37
|
+
return null;
|
|
38
|
+
return typeof target === 'string' ? document.querySelector(target) : target;
|
|
39
|
+
}
|
|
40
|
+
function storageGet(key) {
|
|
41
|
+
try {
|
|
42
|
+
return window.localStorage.getItem(key);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function storageSet(key, value) {
|
|
49
|
+
try {
|
|
50
|
+
if (value === null)
|
|
51
|
+
window.localStorage.removeItem(key);
|
|
52
|
+
else
|
|
53
|
+
window.localStorage.setItem(key, value);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Storage blocked: the toast just shows again next time.
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Shows a VeroXM form in the page. Returns a handle to open, close or remove it.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* embedForm({ baseUrl: 'https://cms.example.com', form: 'f_Ab3dEf7hJk9mNpQr2sTu', container: '#survey' });
|
|
64
|
+
* embedForm({ baseUrl, form, mode: 'toast', openOn: { on: 'scroll', scrollPercent: 50 } });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export function embedForm(options) {
|
|
68
|
+
if (typeof window === 'undefined' || typeof document === 'undefined')
|
|
69
|
+
throw new Error('embedForm runs in a browser');
|
|
70
|
+
if (!/^f_[A-Za-z0-9]{20}$/.test(options.form))
|
|
71
|
+
throw new Error(`"${options.form}" isn't a form id (f_ and 20 letters or digits)`);
|
|
72
|
+
const base = new URL(options.baseUrl);
|
|
73
|
+
const formOrigin = base.origin;
|
|
74
|
+
const mode = options.mode ?? 'inline';
|
|
75
|
+
const id = Math.random().toString(36).slice(2, 10);
|
|
76
|
+
if (!document.getElementById(STYLE_ID)) {
|
|
77
|
+
const style = document.createElement('style');
|
|
78
|
+
style.id = STYLE_ID;
|
|
79
|
+
style.textContent = CSS;
|
|
80
|
+
document.head.appendChild(style);
|
|
81
|
+
}
|
|
82
|
+
const url = new URL(`/f/${options.form}`, formOrigin);
|
|
83
|
+
for (const [k, v] of Object.entries(options.hidden ?? {}))
|
|
84
|
+
url.searchParams.set(k, String(v));
|
|
85
|
+
url.searchParams.set('vx_embed', mode);
|
|
86
|
+
url.searchParams.set('vx_id', id);
|
|
87
|
+
url.searchParams.set('vx_origin', window.location.origin);
|
|
88
|
+
// For the response's campaign attribution: the page the form is on, and how the visitor got there.
|
|
89
|
+
url.searchParams.set('vx_page', window.location.href.slice(0, 1500));
|
|
90
|
+
if (document.referrer)
|
|
91
|
+
url.searchParams.set('vx_ref', document.referrer.slice(0, 500));
|
|
92
|
+
const iframe = el('iframe', 'vxe-frame');
|
|
93
|
+
iframe.title = options.title ?? 'Form';
|
|
94
|
+
iframe.allow = 'clipboard-write';
|
|
95
|
+
iframe.src = url.toString();
|
|
96
|
+
iframe.setAttribute('loading', mode === 'inline' ? 'lazy' : 'eager');
|
|
97
|
+
let shell = null; // what this embed added around the iframe
|
|
98
|
+
let opener = null;
|
|
99
|
+
let isOpen = mode === 'inline';
|
|
100
|
+
let closeTimer = null;
|
|
101
|
+
const cleanups = [];
|
|
102
|
+
const dismissKey = `vxf-dismissed:${options.form}`;
|
|
103
|
+
const closeButton = () => {
|
|
104
|
+
const b = el('button', 'vxe-close');
|
|
105
|
+
b.type = 'button';
|
|
106
|
+
b.setAttribute('aria-label', 'Close');
|
|
107
|
+
b.textContent = '×';
|
|
108
|
+
b.addEventListener('click', () => handle.close());
|
|
109
|
+
return b;
|
|
110
|
+
};
|
|
111
|
+
if (mode === 'inline') {
|
|
112
|
+
const host = resolve(options.container);
|
|
113
|
+
if (!host)
|
|
114
|
+
throw new Error('embedForm: inline needs a container');
|
|
115
|
+
iframe.style.height = `${options.height ?? 520}px`;
|
|
116
|
+
host.appendChild(iframe);
|
|
117
|
+
}
|
|
118
|
+
else if (mode === 'fullpage') {
|
|
119
|
+
const host = resolve(options.container);
|
|
120
|
+
if (host) {
|
|
121
|
+
iframe.style.height = '100%';
|
|
122
|
+
host.appendChild(iframe);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
shell = el('div', 'vxe-full');
|
|
126
|
+
shell.appendChild(iframe);
|
|
127
|
+
document.body.appendChild(shell);
|
|
128
|
+
}
|
|
129
|
+
isOpen = true;
|
|
130
|
+
}
|
|
131
|
+
else if (mode === 'popup') {
|
|
132
|
+
shell = el('div', 'vxe-backdrop');
|
|
133
|
+
shell.hidden = true;
|
|
134
|
+
const dialog = el('div', 'vxe-dialog');
|
|
135
|
+
dialog.setAttribute('role', 'dialog');
|
|
136
|
+
dialog.setAttribute('aria-modal', 'true');
|
|
137
|
+
dialog.setAttribute('aria-label', options.title ?? 'Form');
|
|
138
|
+
dialog.style.maxWidth = `${SIZES[options.size ?? 'medium']}px`;
|
|
139
|
+
dialog.append(closeButton(), iframe);
|
|
140
|
+
shell.appendChild(dialog);
|
|
141
|
+
shell.addEventListener('click', (e) => {
|
|
142
|
+
if (e.target === shell)
|
|
143
|
+
handle.close();
|
|
144
|
+
});
|
|
145
|
+
document.body.appendChild(shell);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
shell = el('div', `vxe-toast ${options.position === 'bottom-left' ? 'vxe-left' : 'vxe-right'}`);
|
|
149
|
+
shell.setAttribute('role', 'dialog');
|
|
150
|
+
shell.setAttribute('aria-label', options.title ?? 'Form');
|
|
151
|
+
shell.hidden = true;
|
|
152
|
+
shell.append(closeButton(), iframe);
|
|
153
|
+
document.body.appendChild(shell);
|
|
154
|
+
}
|
|
155
|
+
const onKey = (e) => {
|
|
156
|
+
if (e.key === 'Escape' && isOpen && (mode === 'popup' || mode === 'toast'))
|
|
157
|
+
handle.close();
|
|
158
|
+
};
|
|
159
|
+
document.addEventListener('keydown', onKey);
|
|
160
|
+
cleanups.push(() => document.removeEventListener('keydown', onKey));
|
|
161
|
+
const send = (message) => iframe.contentWindow?.postMessage({ source: 'veroxm-embed', id, ...message }, formOrigin);
|
|
162
|
+
const onMessage = async (event) => {
|
|
163
|
+
// Only this embed's own iframe, from the VeroXM address.
|
|
164
|
+
if (event.origin !== formOrigin || event.source !== iframe.contentWindow)
|
|
165
|
+
return;
|
|
166
|
+
const m = event.data;
|
|
167
|
+
if (!m || m.source !== 'veroxm-form' || m.id !== id)
|
|
168
|
+
return;
|
|
169
|
+
if (m.type === 'ready')
|
|
170
|
+
options.onReady?.();
|
|
171
|
+
else if (m.type === 'height' && mode === 'inline' && options.autoHeight && typeof m.height === 'number') {
|
|
172
|
+
iframe.style.height = `${Math.max(120, Math.min(20000, Math.ceil(m.height)))}px`;
|
|
173
|
+
}
|
|
174
|
+
else if (m.type === 'started')
|
|
175
|
+
options.onStarted?.();
|
|
176
|
+
else if (m.type === 'submitted' && m.responseId) {
|
|
177
|
+
options.onSubmit?.({ responseId: m.responseId, endingId: m.endingId ?? null });
|
|
178
|
+
if (mode === 'toast')
|
|
179
|
+
storageSet(dismissKey, String(Date.now() + 3650 * 86400000));
|
|
180
|
+
if (options.autoCloseSeconds !== undefined && mode !== 'inline') {
|
|
181
|
+
closeTimer = window.setTimeout(() => handle.close(), Math.max(0, options.autoCloseSeconds) * 1000);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else if (m.type === 'redirect' && typeof m.url === 'string' && m.url.startsWith('https://')) {
|
|
185
|
+
window.location.assign(m.url);
|
|
186
|
+
}
|
|
187
|
+
else if (m.type === 'close')
|
|
188
|
+
handle.close();
|
|
189
|
+
else if (m.type === 'need-token') {
|
|
190
|
+
const token = options.getToken ? await options.getToken() : null;
|
|
191
|
+
send({ type: 'token', token: token ?? null });
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
window.addEventListener('message', onMessage);
|
|
195
|
+
cleanups.push(() => window.removeEventListener('message', onMessage));
|
|
196
|
+
const handle = {
|
|
197
|
+
iframe,
|
|
198
|
+
open() {
|
|
199
|
+
if (!shell || mode === 'fullpage' || isOpen)
|
|
200
|
+
return;
|
|
201
|
+
opener = document.activeElement;
|
|
202
|
+
shell.hidden = false;
|
|
203
|
+
isOpen = true;
|
|
204
|
+
// Next frame, so the transition runs from the hidden state.
|
|
205
|
+
window.requestAnimationFrame(() => {
|
|
206
|
+
shell?.classList.add('vxe-in');
|
|
207
|
+
iframe.focus();
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
close() {
|
|
211
|
+
if (closeTimer)
|
|
212
|
+
window.clearTimeout(closeTimer);
|
|
213
|
+
closeTimer = null;
|
|
214
|
+
if (!shell || !isOpen)
|
|
215
|
+
return;
|
|
216
|
+
isOpen = false;
|
|
217
|
+
shell.classList.remove('vxe-in');
|
|
218
|
+
if (mode === 'fullpage')
|
|
219
|
+
shell.hidden = true;
|
|
220
|
+
else
|
|
221
|
+
window.setTimeout(() => shell && !isOpen && (shell.hidden = true), 300);
|
|
222
|
+
if (mode === 'toast' && (options.rememberDismissDays ?? 7) > 0 && !storageGet(dismissKey)) {
|
|
223
|
+
storageSet(dismissKey, String(Date.now() + (options.rememberDismissDays ?? 7) * 86400000));
|
|
224
|
+
}
|
|
225
|
+
if (opener instanceof HTMLElement)
|
|
226
|
+
opener.focus();
|
|
227
|
+
options.onClose?.();
|
|
228
|
+
},
|
|
229
|
+
destroy() {
|
|
230
|
+
if (closeTimer)
|
|
231
|
+
window.clearTimeout(closeTimer);
|
|
232
|
+
for (const c of cleanups)
|
|
233
|
+
c();
|
|
234
|
+
iframe.remove();
|
|
235
|
+
shell?.remove();
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
// Click-to-open buttons.
|
|
239
|
+
if ((mode === 'popup' || mode === 'toast') && options.trigger) {
|
|
240
|
+
const targets = typeof options.trigger === 'string' ? Array.from(document.querySelectorAll(options.trigger)) : [options.trigger];
|
|
241
|
+
const click = (e) => {
|
|
242
|
+
e.preventDefault();
|
|
243
|
+
handle.open();
|
|
244
|
+
};
|
|
245
|
+
for (const t of targets) {
|
|
246
|
+
t.addEventListener('click', click);
|
|
247
|
+
cleanups.push(() => t.removeEventListener('click', click));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Opening by itself. A toast someone closed (or answered) waits until rememberDismissDays have passed.
|
|
251
|
+
const auto = options.openOn?.on ?? 'manual';
|
|
252
|
+
const dismissedUntil = Number(storageGet(dismissKey) ?? 0);
|
|
253
|
+
if ((mode === 'popup' || mode === 'toast') && auto !== 'manual' && !(mode === 'toast' && dismissedUntil > Date.now())) {
|
|
254
|
+
if (auto === 'load')
|
|
255
|
+
handle.open();
|
|
256
|
+
else if (auto === 'delay') {
|
|
257
|
+
const t = window.setTimeout(() => handle.open(), Math.max(0, options.openOn?.delaySeconds ?? 5) * 1000);
|
|
258
|
+
cleanups.push(() => window.clearTimeout(t));
|
|
259
|
+
}
|
|
260
|
+
else if (auto === 'scroll') {
|
|
261
|
+
const pct = Math.min(100, Math.max(0, options.openOn?.scrollPercent ?? 50));
|
|
262
|
+
const onScroll = () => {
|
|
263
|
+
const doc = document.documentElement;
|
|
264
|
+
const scrollable = doc.scrollHeight - window.innerHeight;
|
|
265
|
+
const done = scrollable <= 0 ? 100 : (window.scrollY / scrollable) * 100;
|
|
266
|
+
if (done >= pct) {
|
|
267
|
+
window.removeEventListener('scroll', onScroll);
|
|
268
|
+
handle.open();
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
window.addEventListener('scroll', onScroll, { passive: true });
|
|
272
|
+
cleanups.push(() => window.removeEventListener('scroll', onScroll));
|
|
273
|
+
onScroll();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return handle;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* The script-tag embed: reads data attributes and embeds every form it finds. Used by /f/embed.js; call it yourself
|
|
280
|
+
* after adding such elements later.
|
|
281
|
+
*
|
|
282
|
+
* ```html
|
|
283
|
+
* <div data-veroxm-form="f_..." data-mode="inline" data-height="600"></div>
|
|
284
|
+
* <button data-veroxm-form="f_..." data-mode="popup">Give feedback</button>
|
|
285
|
+
* <script src="https://cms.example.com/f/embed.js" data-veroxm-form="f_..." data-mode="toast" data-open-on="delay" async></script>
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
export function embedFormsFromPage(baseUrl, root = document) {
|
|
289
|
+
const out = [];
|
|
290
|
+
for (const node of Array.from(root.querySelectorAll('[data-veroxm-form]'))) {
|
|
291
|
+
if (node.dataset.veroxmEmbedded)
|
|
292
|
+
continue;
|
|
293
|
+
node.dataset.veroxmEmbedded = '1';
|
|
294
|
+
const d = node.dataset;
|
|
295
|
+
const mode = ['inline', 'popup', 'fullpage', 'toast'].find((m) => m === d.mode) ?? (node.tagName === 'SCRIPT' ? 'toast' : node.tagName === 'BUTTON' || node.tagName === 'A' ? 'popup' : 'inline');
|
|
296
|
+
const hidden = {};
|
|
297
|
+
for (const [k, v] of Object.entries(d)) {
|
|
298
|
+
// data-hidden-source="newsletter" -> hidden.source
|
|
299
|
+
if (k.startsWith('hidden') && k.length > 6 && v !== undefined)
|
|
300
|
+
hidden[k.slice(6, 7).toLowerCase() + k.slice(7).replace(/[A-Z]/g, (c) => `_${c.toLowerCase()}`)] = v;
|
|
301
|
+
}
|
|
302
|
+
const num = (v) => (v !== undefined && v !== '' && Number.isFinite(Number(v)) ? Number(v) : undefined);
|
|
303
|
+
out.push(embedForm({
|
|
304
|
+
baseUrl,
|
|
305
|
+
form: d.veroxmForm ?? '',
|
|
306
|
+
mode,
|
|
307
|
+
container: mode === 'inline' || (mode === 'fullpage' && node.tagName !== 'SCRIPT') ? node : undefined,
|
|
308
|
+
hidden,
|
|
309
|
+
height: num(d.height),
|
|
310
|
+
autoHeight: d.autoHeight === 'true',
|
|
311
|
+
size: d.size === 'small' || d.size === 'large' ? d.size : undefined,
|
|
312
|
+
position: d.position === 'bottom-left' ? 'bottom-left' : undefined,
|
|
313
|
+
openOn: { on: ['load', 'delay', 'scroll', 'manual'].find((o) => o === d.openOn) ?? 'manual', delaySeconds: num(d.delay), scrollPercent: num(d.scroll) },
|
|
314
|
+
trigger: (mode === 'popup' || mode === 'toast') && node.tagName !== 'SCRIPT' ? node : undefined,
|
|
315
|
+
rememberDismissDays: num(d.rememberDays),
|
|
316
|
+
autoCloseSeconds: num(d.autoClose),
|
|
317
|
+
title: d.title,
|
|
318
|
+
}));
|
|
319
|
+
}
|
|
320
|
+
return out;
|
|
321
|
+
}
|
package/dist/forms.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { VeroXMApp } from './client.js';
|
|
2
|
+
import type { operations } from './generated/api.js';
|
|
3
|
+
import type { Schemas } from './schemas.js';
|
|
4
|
+
/** A form, as listed. */
|
|
5
|
+
export type FormSummary = Schemas['FormSummary'];
|
|
6
|
+
/** A form with its live questions (answers are keyed by their `ref`). */
|
|
7
|
+
export type FormDetail = Schemas['FormDetail'];
|
|
8
|
+
/** A response with its answers by question ref: `answers.email.value`, `answers.cover.text`. */
|
|
9
|
+
export type FormResponse = Schemas['FormResponse'];
|
|
10
|
+
export type FormResponsePage = Schemas['FormResponsePage'];
|
|
11
|
+
export type FormResponseListOptions = NonNullable<operations['listFormResponses']['parameters']['query']>;
|
|
12
|
+
/**
|
|
13
|
+
* The project's forms and their responses, for your own servers: a key with the "Read forms and responses"
|
|
14
|
+
* permission (`forms:read`), signed in with `auth.signInWithApiKey`. Responses are personal data -- never use such a
|
|
15
|
+
* key in a browser. To show a form in a page, use `embedForm`.
|
|
16
|
+
*/
|
|
17
|
+
export declare class FormsResource {
|
|
18
|
+
private readonly app;
|
|
19
|
+
constructor(app: VeroXMApp);
|
|
20
|
+
list(): Promise<FormSummary[]>;
|
|
21
|
+
get(formId: number): Promise<FormDetail>;
|
|
22
|
+
/** One page of responses, oldest first. Completed ones unless `status` says otherwise; `since` for changes after a time. */
|
|
23
|
+
responses(formId: number, options?: FormResponseListOptions): Promise<FormResponsePage>;
|
|
24
|
+
/** Every matching response, page by page: `for await (const r of app.forms.allResponses(id, { since }))`. */
|
|
25
|
+
allResponses(formId: number, options?: Omit<FormResponseListOptions, 'cursor'>): AsyncGenerator<FormResponse>;
|
|
26
|
+
response(formId: number, responseId: string): Promise<FormResponse>;
|
|
27
|
+
}
|
package/dist/forms.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The project's forms and their responses, for your own servers: a key with the "Read forms and responses"
|
|
3
|
+
* permission (`forms:read`), signed in with `auth.signInWithApiKey`. Responses are personal data -- never use such a
|
|
4
|
+
* key in a browser. To show a form in a page, use `embedForm`.
|
|
5
|
+
*/
|
|
6
|
+
export class FormsResource {
|
|
7
|
+
constructor(app) {
|
|
8
|
+
this.app = app;
|
|
9
|
+
}
|
|
10
|
+
async list() {
|
|
11
|
+
return (await this.app.request({ path: '/forms' })).items;
|
|
12
|
+
}
|
|
13
|
+
async get(formId) {
|
|
14
|
+
return (await this.app.request({ path: `/forms/${formId}` }));
|
|
15
|
+
}
|
|
16
|
+
/** One page of responses, oldest first. Completed ones unless `status` says otherwise; `since` for changes after a time. */
|
|
17
|
+
async responses(formId, options = {}) {
|
|
18
|
+
return (await this.app.request({
|
|
19
|
+
path: `/forms/${formId}/responses`,
|
|
20
|
+
query: { status: options.status, since: options.since, cursor: options.cursor, limit: options.limit },
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
/** Every matching response, page by page: `for await (const r of app.forms.allResponses(id, { since }))`. */
|
|
24
|
+
async *allResponses(formId, options = {}) {
|
|
25
|
+
let cursor;
|
|
26
|
+
do {
|
|
27
|
+
const page = await this.responses(formId, { ...options, cursor });
|
|
28
|
+
yield* page.items;
|
|
29
|
+
cursor = page.next ?? undefined;
|
|
30
|
+
} while (cursor);
|
|
31
|
+
}
|
|
32
|
+
async response(formId, responseId) {
|
|
33
|
+
return (await this.app.request({ path: `/forms/${formId}/responses/${encodeURIComponent(responseId)}` }));
|
|
34
|
+
}
|
|
35
|
+
}
|
package/dist/generated/api.d.ts
CHANGED
|
@@ -936,6 +936,160 @@ export interface paths {
|
|
|
936
936
|
patch?: never;
|
|
937
937
|
trace?: never;
|
|
938
938
|
};
|
|
939
|
+
"/forms/{publicId}": {
|
|
940
|
+
parameters: {
|
|
941
|
+
query?: never;
|
|
942
|
+
header?: never;
|
|
943
|
+
path?: never;
|
|
944
|
+
cookie?: never;
|
|
945
|
+
};
|
|
946
|
+
/**
|
|
947
|
+
* The live form, or why it is closed
|
|
948
|
+
* @description No key. A form that needs signing in sends its questions only with an end user's access token of its project.
|
|
949
|
+
*/
|
|
950
|
+
get: operations["getPublicForm"];
|
|
951
|
+
put?: never;
|
|
952
|
+
post?: never;
|
|
953
|
+
delete?: never;
|
|
954
|
+
options?: never;
|
|
955
|
+
head?: never;
|
|
956
|
+
patch?: never;
|
|
957
|
+
trace?: never;
|
|
958
|
+
};
|
|
959
|
+
"/forms/{publicId}/responses": {
|
|
960
|
+
parameters: {
|
|
961
|
+
query?: never;
|
|
962
|
+
header?: never;
|
|
963
|
+
path?: never;
|
|
964
|
+
cookie?: never;
|
|
965
|
+
};
|
|
966
|
+
get?: never;
|
|
967
|
+
put?: never;
|
|
968
|
+
/**
|
|
969
|
+
* Send a response, partial or complete
|
|
970
|
+
* @description No key (an end user's access token for forms that need signing in). 422 with `fieldErrors` by question id when answers need attention; 403 when the form is closed; 409 `form_changed` for a version that does not exist, `already_answered` for a second response from one account.
|
|
971
|
+
*/
|
|
972
|
+
post: operations["submitFormResponse"];
|
|
973
|
+
delete?: never;
|
|
974
|
+
options?: never;
|
|
975
|
+
head?: never;
|
|
976
|
+
patch?: never;
|
|
977
|
+
trace?: never;
|
|
978
|
+
};
|
|
979
|
+
"/forms/{publicId}/uploads": {
|
|
980
|
+
parameters: {
|
|
981
|
+
query?: never;
|
|
982
|
+
header?: never;
|
|
983
|
+
path?: never;
|
|
984
|
+
cookie?: never;
|
|
985
|
+
};
|
|
986
|
+
get?: never;
|
|
987
|
+
put?: never;
|
|
988
|
+
/**
|
|
989
|
+
* Upload a file for a file question
|
|
990
|
+
* @description Returns the reference to put in the answer: `{ files: [reference] }`.
|
|
991
|
+
*/
|
|
992
|
+
post: operations["uploadFormFile"];
|
|
993
|
+
delete?: never;
|
|
994
|
+
options?: never;
|
|
995
|
+
head?: never;
|
|
996
|
+
patch?: never;
|
|
997
|
+
trace?: never;
|
|
998
|
+
};
|
|
999
|
+
"/forms/{publicId}/events": {
|
|
1000
|
+
parameters: {
|
|
1001
|
+
query?: never;
|
|
1002
|
+
header?: never;
|
|
1003
|
+
path?: never;
|
|
1004
|
+
cookie?: never;
|
|
1005
|
+
};
|
|
1006
|
+
get?: never;
|
|
1007
|
+
put?: never;
|
|
1008
|
+
/**
|
|
1009
|
+
* Count a view or a start for the form's Results
|
|
1010
|
+
* @description Each counts once per key per day.
|
|
1011
|
+
*/
|
|
1012
|
+
post: operations["sendFormEvent"];
|
|
1013
|
+
delete?: never;
|
|
1014
|
+
options?: never;
|
|
1015
|
+
head?: never;
|
|
1016
|
+
patch?: never;
|
|
1017
|
+
trace?: never;
|
|
1018
|
+
};
|
|
1019
|
+
"/projects/{uuid}/forms": {
|
|
1020
|
+
parameters: {
|
|
1021
|
+
query?: never;
|
|
1022
|
+
header?: never;
|
|
1023
|
+
path?: never;
|
|
1024
|
+
cookie?: never;
|
|
1025
|
+
};
|
|
1026
|
+
/**
|
|
1027
|
+
* The project's forms (not archived)
|
|
1028
|
+
* @description A project API key with the "Read forms and responses" permission (forms:read).
|
|
1029
|
+
*/
|
|
1030
|
+
get: operations["listForms"];
|
|
1031
|
+
put?: never;
|
|
1032
|
+
post?: never;
|
|
1033
|
+
delete?: never;
|
|
1034
|
+
options?: never;
|
|
1035
|
+
head?: never;
|
|
1036
|
+
patch?: never;
|
|
1037
|
+
trace?: never;
|
|
1038
|
+
};
|
|
1039
|
+
"/projects/{uuid}/forms/{formId}": {
|
|
1040
|
+
parameters: {
|
|
1041
|
+
query?: never;
|
|
1042
|
+
header?: never;
|
|
1043
|
+
path?: never;
|
|
1044
|
+
cookie?: never;
|
|
1045
|
+
};
|
|
1046
|
+
/** A form, with its live questions */
|
|
1047
|
+
get: operations["getForm"];
|
|
1048
|
+
put?: never;
|
|
1049
|
+
post?: never;
|
|
1050
|
+
delete?: never;
|
|
1051
|
+
options?: never;
|
|
1052
|
+
head?: never;
|
|
1053
|
+
patch?: never;
|
|
1054
|
+
trace?: never;
|
|
1055
|
+
};
|
|
1056
|
+
"/projects/{uuid}/forms/{formId}/responses": {
|
|
1057
|
+
parameters: {
|
|
1058
|
+
query?: never;
|
|
1059
|
+
header?: never;
|
|
1060
|
+
path?: never;
|
|
1061
|
+
cookie?: never;
|
|
1062
|
+
};
|
|
1063
|
+
/**
|
|
1064
|
+
* A form's responses, oldest first, a page at a time
|
|
1065
|
+
* @description Poll with `since` (changed at or after) and follow `next` to the end.
|
|
1066
|
+
*/
|
|
1067
|
+
get: operations["listFormResponses"];
|
|
1068
|
+
put?: never;
|
|
1069
|
+
post?: never;
|
|
1070
|
+
delete?: never;
|
|
1071
|
+
options?: never;
|
|
1072
|
+
head?: never;
|
|
1073
|
+
patch?: never;
|
|
1074
|
+
trace?: never;
|
|
1075
|
+
};
|
|
1076
|
+
"/projects/{uuid}/forms/{formId}/responses/{responseId}": {
|
|
1077
|
+
parameters: {
|
|
1078
|
+
query?: never;
|
|
1079
|
+
header?: never;
|
|
1080
|
+
path?: never;
|
|
1081
|
+
cookie?: never;
|
|
1082
|
+
};
|
|
1083
|
+
/** One response */
|
|
1084
|
+
get: operations["getFormResponse"];
|
|
1085
|
+
put?: never;
|
|
1086
|
+
post?: never;
|
|
1087
|
+
delete?: never;
|
|
1088
|
+
options?: never;
|
|
1089
|
+
head?: never;
|
|
1090
|
+
patch?: never;
|
|
1091
|
+
trace?: never;
|
|
1092
|
+
};
|
|
939
1093
|
}
|
|
940
1094
|
export type webhooks = Record<string, never>;
|
|
941
1095
|
export interface components {
|
|
@@ -1578,6 +1732,181 @@ export interface components {
|
|
|
1578
1732
|
error?: string;
|
|
1579
1733
|
}[];
|
|
1580
1734
|
};
|
|
1735
|
+
PublicForm: {
|
|
1736
|
+
/** @description The form id (f_...). */
|
|
1737
|
+
publicId: string;
|
|
1738
|
+
/** @description Whether it takes responses now. */
|
|
1739
|
+
open: boolean;
|
|
1740
|
+
/**
|
|
1741
|
+
* @description With open: false.
|
|
1742
|
+
* @enum {string}
|
|
1743
|
+
*/
|
|
1744
|
+
closedReason?: "not_open_yet" | "closed" | "limit_reached";
|
|
1745
|
+
closedMessage: string;
|
|
1746
|
+
/**
|
|
1747
|
+
* @description `signed_in`: answering needs an end user's access token of the project as the bearer token.
|
|
1748
|
+
* @enum {string}
|
|
1749
|
+
*/
|
|
1750
|
+
access: "public" | "signed_in";
|
|
1751
|
+
/** @description The sites that may embed the form; empty for any site. */
|
|
1752
|
+
embedOrigins: string[];
|
|
1753
|
+
/**
|
|
1754
|
+
* @description A form that needs signing in, asked without a valid token: no questions are sent.
|
|
1755
|
+
* @constant
|
|
1756
|
+
*/
|
|
1757
|
+
signInRequired?: true;
|
|
1758
|
+
/** @description Signed-in forms with one response per account: whether this account has answered. */
|
|
1759
|
+
alreadyAnswered?: boolean;
|
|
1760
|
+
/** @description The live version: send it with the response. */
|
|
1761
|
+
version?: number;
|
|
1762
|
+
/** @description The form definition (questions, logic, endings, theme): see docs.veroxm.com/forms#definition. */
|
|
1763
|
+
definition?: {
|
|
1764
|
+
[key: string]: unknown;
|
|
1765
|
+
};
|
|
1766
|
+
settings?: {
|
|
1767
|
+
onePerBrowser?: boolean;
|
|
1768
|
+
savePartial?: boolean;
|
|
1769
|
+
rememberProgress?: boolean;
|
|
1770
|
+
redirectUrl?: string | null;
|
|
1771
|
+
};
|
|
1772
|
+
};
|
|
1773
|
+
FormResponseSubmit: {
|
|
1774
|
+
/** @description Made once per response (16-64 letters, digits, _ or -); sending it again updates or repeats, never duplicates. */
|
|
1775
|
+
key: string;
|
|
1776
|
+
/** @description The version the person was shown. */
|
|
1777
|
+
version: number;
|
|
1778
|
+
/** @description By question ref. Text, email, phone, website and date are strings; numbers and scales numbers; choices `{ choices: [ids], other? }`; yes/no and consent true/false; contact info an object; files `{ files: [upload] }`. */
|
|
1779
|
+
answers: {
|
|
1780
|
+
[key: string]: unknown;
|
|
1781
|
+
};
|
|
1782
|
+
/** @description The form's hidden fields. */
|
|
1783
|
+
hidden?: {
|
|
1784
|
+
[key: string]: unknown;
|
|
1785
|
+
};
|
|
1786
|
+
/** @description Save what is answered so far (when the form keeps unfinished responses). */
|
|
1787
|
+
partial?: boolean;
|
|
1788
|
+
/** @description When the person started (ISO 8601). */
|
|
1789
|
+
startedAt?: string;
|
|
1790
|
+
/** @description Where the form was opened, for campaign attribution. */
|
|
1791
|
+
page?: {
|
|
1792
|
+
url?: string;
|
|
1793
|
+
referrer?: string | null;
|
|
1794
|
+
};
|
|
1795
|
+
};
|
|
1796
|
+
FormResponseResult: {
|
|
1797
|
+
/** @description The response id (r_...). */
|
|
1798
|
+
response: string;
|
|
1799
|
+
/** @enum {string} */
|
|
1800
|
+
status: "partial" | "completed";
|
|
1801
|
+
/** @description The ending the form's logic chose. */
|
|
1802
|
+
endingId: string | null;
|
|
1803
|
+
redirectUrl: string | null;
|
|
1804
|
+
};
|
|
1805
|
+
FormUpload: {
|
|
1806
|
+
file: string;
|
|
1807
|
+
/** @description The file question. */
|
|
1808
|
+
elementId: string;
|
|
1809
|
+
/** @description The version shown. */
|
|
1810
|
+
version: string;
|
|
1811
|
+
};
|
|
1812
|
+
FormFileRef: {
|
|
1813
|
+
id: string;
|
|
1814
|
+
name: string;
|
|
1815
|
+
size: number;
|
|
1816
|
+
type: string;
|
|
1817
|
+
};
|
|
1818
|
+
FormEvent: {
|
|
1819
|
+
/** @enum {string} */
|
|
1820
|
+
type: "view" | "start";
|
|
1821
|
+
/** @description The visit's response key. */
|
|
1822
|
+
key: string;
|
|
1823
|
+
};
|
|
1824
|
+
FormSummary: {
|
|
1825
|
+
id: number;
|
|
1826
|
+
publicId: string;
|
|
1827
|
+
name: string;
|
|
1828
|
+
/** @enum {string} */
|
|
1829
|
+
status: "draft" | "published";
|
|
1830
|
+
liveVersion: number | null;
|
|
1831
|
+
questionCount: number;
|
|
1832
|
+
/** @description Completed responses. */
|
|
1833
|
+
responseCount: number;
|
|
1834
|
+
/** Format: date-time */
|
|
1835
|
+
updatedAt: string;
|
|
1836
|
+
/** @description The hosted page, when published. */
|
|
1837
|
+
url: string | null;
|
|
1838
|
+
};
|
|
1839
|
+
FormList: {
|
|
1840
|
+
items: components["schemas"]["FormSummary"][];
|
|
1841
|
+
};
|
|
1842
|
+
FormDetail: components["schemas"]["FormSummary"] & {
|
|
1843
|
+
/** @description The live version's questions; answers are keyed by `ref`. */
|
|
1844
|
+
questions: {
|
|
1845
|
+
id: string;
|
|
1846
|
+
ref: string;
|
|
1847
|
+
type: string;
|
|
1848
|
+
title: string;
|
|
1849
|
+
required: boolean;
|
|
1850
|
+
choices?: {
|
|
1851
|
+
id: string;
|
|
1852
|
+
label: string;
|
|
1853
|
+
}[];
|
|
1854
|
+
}[];
|
|
1855
|
+
hiddenFields: string[];
|
|
1856
|
+
variables: string[];
|
|
1857
|
+
endings: {
|
|
1858
|
+
id: string;
|
|
1859
|
+
ref: string;
|
|
1860
|
+
title: string;
|
|
1861
|
+
}[];
|
|
1862
|
+
};
|
|
1863
|
+
FormAnswer: {
|
|
1864
|
+
question: string;
|
|
1865
|
+
type: string;
|
|
1866
|
+
/** @description As stored (see FormResponseSubmit.answers). */
|
|
1867
|
+
value: unknown;
|
|
1868
|
+
/** @description Written out as the dashboard shows it. */
|
|
1869
|
+
text: string;
|
|
1870
|
+
};
|
|
1871
|
+
FormResponse: {
|
|
1872
|
+
id: string;
|
|
1873
|
+
/** @enum {string} */
|
|
1874
|
+
status: "partial" | "completed";
|
|
1875
|
+
version: number | null;
|
|
1876
|
+
/** Format: date-time */
|
|
1877
|
+
startedAt: string;
|
|
1878
|
+
/** Format: date-time */
|
|
1879
|
+
completedAt: string | null;
|
|
1880
|
+
/** Format: date-time */
|
|
1881
|
+
updatedAt?: string;
|
|
1882
|
+
durationSeconds: number | null;
|
|
1883
|
+
ending: {
|
|
1884
|
+
id: string;
|
|
1885
|
+
ref: string;
|
|
1886
|
+
title: string;
|
|
1887
|
+
} | null;
|
|
1888
|
+
device: string | null;
|
|
1889
|
+
/** @description Signed-in forms: the project account that answered. */
|
|
1890
|
+
endUserId: number | null;
|
|
1891
|
+
variables: {
|
|
1892
|
+
[key: string]: number;
|
|
1893
|
+
};
|
|
1894
|
+
hidden: {
|
|
1895
|
+
[key: string]: string;
|
|
1896
|
+
};
|
|
1897
|
+
campaign: {
|
|
1898
|
+
[key: string]: unknown;
|
|
1899
|
+
} | null;
|
|
1900
|
+
/** @description By question ref. */
|
|
1901
|
+
answers: {
|
|
1902
|
+
[key: string]: components["schemas"]["FormAnswer"];
|
|
1903
|
+
};
|
|
1904
|
+
};
|
|
1905
|
+
FormResponsePage: {
|
|
1906
|
+
items: components["schemas"]["FormResponse"][];
|
|
1907
|
+
/** @description Pass as `cursor` for the next page; null at the end. */
|
|
1908
|
+
next: string | null;
|
|
1909
|
+
};
|
|
1581
1910
|
};
|
|
1582
1911
|
responses: {
|
|
1583
1912
|
/** @description The request is not valid */
|
|
@@ -1634,6 +1963,15 @@ export interface components {
|
|
|
1634
1963
|
"application/json": components["schemas"]["Error"];
|
|
1635
1964
|
};
|
|
1636
1965
|
};
|
|
1966
|
+
/** @description Some answers need attention: `fieldErrors` says which, by question id */
|
|
1967
|
+
E422: {
|
|
1968
|
+
headers: {
|
|
1969
|
+
[name: string]: unknown;
|
|
1970
|
+
};
|
|
1971
|
+
content: {
|
|
1972
|
+
"application/json": components["schemas"]["Error"];
|
|
1973
|
+
};
|
|
1974
|
+
};
|
|
1637
1975
|
/** @description Too many requests; see Retry-After */
|
|
1638
1976
|
E429: {
|
|
1639
1977
|
headers: {
|
|
@@ -3576,6 +3914,10 @@ export interface operations {
|
|
|
3576
3914
|
userId?: string;
|
|
3577
3915
|
/** @description Server keys: the person agreed to personalised content. */
|
|
3578
3916
|
consent?: "personalization";
|
|
3917
|
+
/** @description The page the visit started on: campaign.* rules read its campaign (utm tags, ad click ids). The SDK sends it. */
|
|
3918
|
+
url?: string;
|
|
3919
|
+
/** @description The page that linked to it. */
|
|
3920
|
+
referrer?: string;
|
|
3579
3921
|
};
|
|
3580
3922
|
header?: never;
|
|
3581
3923
|
path: {
|
|
@@ -3634,4 +3976,246 @@ export interface operations {
|
|
|
3634
3976
|
429: components["responses"]["E429"];
|
|
3635
3977
|
};
|
|
3636
3978
|
};
|
|
3979
|
+
getPublicForm: {
|
|
3980
|
+
parameters: {
|
|
3981
|
+
query?: never;
|
|
3982
|
+
header?: never;
|
|
3983
|
+
path: {
|
|
3984
|
+
/** @description The form id (f_...). */
|
|
3985
|
+
publicId: string;
|
|
3986
|
+
};
|
|
3987
|
+
cookie?: never;
|
|
3988
|
+
};
|
|
3989
|
+
requestBody?: never;
|
|
3990
|
+
responses: {
|
|
3991
|
+
/** @description OK */
|
|
3992
|
+
200: {
|
|
3993
|
+
headers: {
|
|
3994
|
+
[name: string]: unknown;
|
|
3995
|
+
};
|
|
3996
|
+
content: {
|
|
3997
|
+
"application/json": components["schemas"]["PublicForm"];
|
|
3998
|
+
};
|
|
3999
|
+
};
|
|
4000
|
+
404: components["responses"]["E404"];
|
|
4001
|
+
429: components["responses"]["E429"];
|
|
4002
|
+
};
|
|
4003
|
+
};
|
|
4004
|
+
submitFormResponse: {
|
|
4005
|
+
parameters: {
|
|
4006
|
+
query?: never;
|
|
4007
|
+
header?: never;
|
|
4008
|
+
path: {
|
|
4009
|
+
/** @description The form id (f_...). */
|
|
4010
|
+
publicId: string;
|
|
4011
|
+
};
|
|
4012
|
+
cookie?: never;
|
|
4013
|
+
};
|
|
4014
|
+
requestBody: {
|
|
4015
|
+
content: {
|
|
4016
|
+
"application/json": components["schemas"]["FormResponseSubmit"];
|
|
4017
|
+
};
|
|
4018
|
+
};
|
|
4019
|
+
responses: {
|
|
4020
|
+
/** @description OK */
|
|
4021
|
+
200: {
|
|
4022
|
+
headers: {
|
|
4023
|
+
[name: string]: unknown;
|
|
4024
|
+
};
|
|
4025
|
+
content: {
|
|
4026
|
+
"application/json": components["schemas"]["FormResponseResult"];
|
|
4027
|
+
};
|
|
4028
|
+
};
|
|
4029
|
+
400: components["responses"]["E400"];
|
|
4030
|
+
401: components["responses"]["E401"];
|
|
4031
|
+
403: components["responses"]["E403"];
|
|
4032
|
+
404: components["responses"]["E404"];
|
|
4033
|
+
409: components["responses"]["E409"];
|
|
4034
|
+
422: components["responses"]["E422"];
|
|
4035
|
+
429: components["responses"]["E429"];
|
|
4036
|
+
};
|
|
4037
|
+
};
|
|
4038
|
+
uploadFormFile: {
|
|
4039
|
+
parameters: {
|
|
4040
|
+
query?: never;
|
|
4041
|
+
header?: never;
|
|
4042
|
+
path: {
|
|
4043
|
+
/** @description The form id (f_...). */
|
|
4044
|
+
publicId: string;
|
|
4045
|
+
};
|
|
4046
|
+
cookie?: never;
|
|
4047
|
+
};
|
|
4048
|
+
requestBody: {
|
|
4049
|
+
content: {
|
|
4050
|
+
"multipart/form-data": components["schemas"]["FormUpload"];
|
|
4051
|
+
};
|
|
4052
|
+
};
|
|
4053
|
+
responses: {
|
|
4054
|
+
/** @description Uploaded */
|
|
4055
|
+
201: {
|
|
4056
|
+
headers: {
|
|
4057
|
+
[name: string]: unknown;
|
|
4058
|
+
};
|
|
4059
|
+
content: {
|
|
4060
|
+
"application/json": components["schemas"]["FormFileRef"];
|
|
4061
|
+
};
|
|
4062
|
+
};
|
|
4063
|
+
400: components["responses"]["E400"];
|
|
4064
|
+
401: components["responses"]["E401"];
|
|
4065
|
+
403: components["responses"]["E403"];
|
|
4066
|
+
404: components["responses"]["E404"];
|
|
4067
|
+
409: components["responses"]["E409"];
|
|
4068
|
+
413: components["responses"]["E413"];
|
|
4069
|
+
429: components["responses"]["E429"];
|
|
4070
|
+
};
|
|
4071
|
+
};
|
|
4072
|
+
sendFormEvent: {
|
|
4073
|
+
parameters: {
|
|
4074
|
+
query?: never;
|
|
4075
|
+
header?: never;
|
|
4076
|
+
path: {
|
|
4077
|
+
/** @description The form id (f_...). */
|
|
4078
|
+
publicId: string;
|
|
4079
|
+
};
|
|
4080
|
+
cookie?: never;
|
|
4081
|
+
};
|
|
4082
|
+
requestBody: {
|
|
4083
|
+
content: {
|
|
4084
|
+
"application/json": components["schemas"]["FormEvent"];
|
|
4085
|
+
};
|
|
4086
|
+
};
|
|
4087
|
+
responses: {
|
|
4088
|
+
/** @description Counted (or already counted) */
|
|
4089
|
+
204: {
|
|
4090
|
+
headers: {
|
|
4091
|
+
[name: string]: unknown;
|
|
4092
|
+
};
|
|
4093
|
+
content?: never;
|
|
4094
|
+
};
|
|
4095
|
+
400: components["responses"]["E400"];
|
|
4096
|
+
404: components["responses"]["E404"];
|
|
4097
|
+
429: components["responses"]["E429"];
|
|
4098
|
+
};
|
|
4099
|
+
};
|
|
4100
|
+
listForms: {
|
|
4101
|
+
parameters: {
|
|
4102
|
+
query?: never;
|
|
4103
|
+
header?: never;
|
|
4104
|
+
path: {
|
|
4105
|
+
/** @description The project's UUID. */
|
|
4106
|
+
uuid: string;
|
|
4107
|
+
};
|
|
4108
|
+
cookie?: never;
|
|
4109
|
+
};
|
|
4110
|
+
requestBody?: never;
|
|
4111
|
+
responses: {
|
|
4112
|
+
/** @description OK */
|
|
4113
|
+
200: {
|
|
4114
|
+
headers: {
|
|
4115
|
+
[name: string]: unknown;
|
|
4116
|
+
};
|
|
4117
|
+
content: {
|
|
4118
|
+
"application/json": components["schemas"]["FormList"];
|
|
4119
|
+
};
|
|
4120
|
+
};
|
|
4121
|
+
401: components["responses"]["E401"];
|
|
4122
|
+
403: components["responses"]["E403"];
|
|
4123
|
+
404: components["responses"]["E404"];
|
|
4124
|
+
429: components["responses"]["E429"];
|
|
4125
|
+
};
|
|
4126
|
+
};
|
|
4127
|
+
getForm: {
|
|
4128
|
+
parameters: {
|
|
4129
|
+
query?: never;
|
|
4130
|
+
header?: never;
|
|
4131
|
+
path: {
|
|
4132
|
+
/** @description The project's UUID. */
|
|
4133
|
+
uuid: string;
|
|
4134
|
+
formId: number;
|
|
4135
|
+
};
|
|
4136
|
+
cookie?: never;
|
|
4137
|
+
};
|
|
4138
|
+
requestBody?: never;
|
|
4139
|
+
responses: {
|
|
4140
|
+
/** @description OK */
|
|
4141
|
+
200: {
|
|
4142
|
+
headers: {
|
|
4143
|
+
[name: string]: unknown;
|
|
4144
|
+
};
|
|
4145
|
+
content: {
|
|
4146
|
+
"application/json": components["schemas"]["FormDetail"];
|
|
4147
|
+
};
|
|
4148
|
+
};
|
|
4149
|
+
400: components["responses"]["E400"];
|
|
4150
|
+
401: components["responses"]["E401"];
|
|
4151
|
+
403: components["responses"]["E403"];
|
|
4152
|
+
404: components["responses"]["E404"];
|
|
4153
|
+
429: components["responses"]["E429"];
|
|
4154
|
+
};
|
|
4155
|
+
};
|
|
4156
|
+
listFormResponses: {
|
|
4157
|
+
parameters: {
|
|
4158
|
+
query?: {
|
|
4159
|
+
status?: "completed" | "partial" | "all";
|
|
4160
|
+
/** @description Responses changed at or after this time. */
|
|
4161
|
+
since?: string;
|
|
4162
|
+
/** @description The previous page's `next`. */
|
|
4163
|
+
cursor?: string;
|
|
4164
|
+
limit?: number;
|
|
4165
|
+
};
|
|
4166
|
+
header?: never;
|
|
4167
|
+
path: {
|
|
4168
|
+
/** @description The project's UUID. */
|
|
4169
|
+
uuid: string;
|
|
4170
|
+
formId: number;
|
|
4171
|
+
};
|
|
4172
|
+
cookie?: never;
|
|
4173
|
+
};
|
|
4174
|
+
requestBody?: never;
|
|
4175
|
+
responses: {
|
|
4176
|
+
/** @description OK */
|
|
4177
|
+
200: {
|
|
4178
|
+
headers: {
|
|
4179
|
+
[name: string]: unknown;
|
|
4180
|
+
};
|
|
4181
|
+
content: {
|
|
4182
|
+
"application/json": components["schemas"]["FormResponsePage"];
|
|
4183
|
+
};
|
|
4184
|
+
};
|
|
4185
|
+
400: components["responses"]["E400"];
|
|
4186
|
+
401: components["responses"]["E401"];
|
|
4187
|
+
403: components["responses"]["E403"];
|
|
4188
|
+
404: components["responses"]["E404"];
|
|
4189
|
+
429: components["responses"]["E429"];
|
|
4190
|
+
};
|
|
4191
|
+
};
|
|
4192
|
+
getFormResponse: {
|
|
4193
|
+
parameters: {
|
|
4194
|
+
query?: never;
|
|
4195
|
+
header?: never;
|
|
4196
|
+
path: {
|
|
4197
|
+
/** @description The project's UUID. */
|
|
4198
|
+
uuid: string;
|
|
4199
|
+
formId: number;
|
|
4200
|
+
responseId: string;
|
|
4201
|
+
};
|
|
4202
|
+
cookie?: never;
|
|
4203
|
+
};
|
|
4204
|
+
requestBody?: never;
|
|
4205
|
+
responses: {
|
|
4206
|
+
/** @description OK */
|
|
4207
|
+
200: {
|
|
4208
|
+
headers: {
|
|
4209
|
+
[name: string]: unknown;
|
|
4210
|
+
};
|
|
4211
|
+
content: {
|
|
4212
|
+
"application/json": components["schemas"]["FormResponse"];
|
|
4213
|
+
};
|
|
4214
|
+
};
|
|
4215
|
+
401: components["responses"]["E401"];
|
|
4216
|
+
403: components["responses"]["E403"];
|
|
4217
|
+
404: components["responses"]["E404"];
|
|
4218
|
+
429: components["responses"]["E429"];
|
|
4219
|
+
};
|
|
4220
|
+
};
|
|
3637
4221
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export { TasksResource } from './tasks.js';
|
|
|
14
14
|
export type { Task, TaskDetail, TaskListOptions } from './tasks.js';
|
|
15
15
|
export { ProcessesResource } from './processes.js';
|
|
16
16
|
export type { ProcessRun, ProcessRunDetail, ProcessRunListOptions } from './processes.js';
|
|
17
|
+
export { FormsResource } from './forms.js';
|
|
18
|
+
export type { FormDetail, FormResponse, FormResponseListOptions, FormResponsePage, FormSummary } from './forms.js';
|
|
19
|
+
export { embedForm, embedFormsFromPage } from './embed.js';
|
|
20
|
+
export type { FormEmbed, FormEmbedMode, FormEmbedOpenTrigger, FormEmbedOptions } from './embed.js';
|
|
17
21
|
export type { Schemas } from './schemas.js';
|
|
18
22
|
export type { paths as ApiPaths, components as ApiComponents, operations as ApiOperations } from './generated/api.js';
|
|
19
23
|
export { VeroXMApiError, VeroXMNotAuthenticatedError, VeroXMTwoStepRequiredError } from './errors.js';
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@ export { MediaResource } from './media.js';
|
|
|
7
7
|
export { FunctionsResource } from './functions.js';
|
|
8
8
|
export { TasksResource } from './tasks.js';
|
|
9
9
|
export { ProcessesResource } from './processes.js';
|
|
10
|
+
export { FormsResource } from './forms.js';
|
|
11
|
+
// Showing forms in a page: inline, popup, full page or toast.
|
|
12
|
+
export { embedForm, embedFormsFromPage } from './embed.js';
|
|
10
13
|
export { VeroXMApiError, VeroXMNotAuthenticatedError, VeroXMTwoStepRequiredError } from './errors.js';
|
|
11
14
|
export { MemoryTokenStorage, BrowserLocalStorageTokenStorage } from './token-storage.js';
|
|
12
15
|
// Experience OS visitor tracking (page views, actions, consent, identify).
|
package/dist/tracker.d.ts
CHANGED
|
@@ -84,6 +84,8 @@ export declare class VeroxmTracker {
|
|
|
84
84
|
private backoffMs;
|
|
85
85
|
private retryAt;
|
|
86
86
|
private decisions;
|
|
87
|
+
/** The page this visit started on, and what linked to it: /decide reads its campaign (campaign.* rules). */
|
|
88
|
+
private landing;
|
|
87
89
|
private readonly listeners;
|
|
88
90
|
constructor(options: TrackerOptions);
|
|
89
91
|
/** The anonymous id for this browser/app install. */
|
|
@@ -107,6 +109,13 @@ export declare class VeroxmTracker {
|
|
|
107
109
|
identifyAccount(accessToken: string, traits?: Record<string, unknown>): Promise<void>;
|
|
108
110
|
/** Call on sign-out: starts a new anonymous visitor on this device. Consent answers are kept. */
|
|
109
111
|
reset(): void;
|
|
112
|
+
/**
|
|
113
|
+
* The address the visit started from, for campaign targeting (campaign.* rules) when it isn't the browser's own
|
|
114
|
+
* page: an app opened by a link (a deep link or universal link with utm tags), or a server rendering for a visitor.
|
|
115
|
+
* Call it before getExperience; decisions already made are asked again. Record the visit itself with
|
|
116
|
+
* `page({ url })`, so the visitor's profile keeps the campaign too.
|
|
117
|
+
*/
|
|
118
|
+
setLandingPage(url: string, referrer?: string): void;
|
|
110
119
|
/**
|
|
111
120
|
* Which variant of a placement this visitor sees, e.g.
|
|
112
121
|
* `const d = await tracker.getExperience('home.hero')` -- then render
|
package/dist/tracker.js
CHANGED
|
@@ -112,6 +112,8 @@ export class VeroxmTracker {
|
|
|
112
112
|
this.backoffMs = 0;
|
|
113
113
|
this.retryAt = 0;
|
|
114
114
|
this.decisions = new Map();
|
|
115
|
+
/** The page this visit started on, and what linked to it: /decide reads its campaign (campaign.* rules). */
|
|
116
|
+
this.landing = null;
|
|
115
117
|
this.listeners = new Set();
|
|
116
118
|
this.apiBase = `${options.baseUrl.replace(/\/$/, '')}/public/v2/projects/${options.projectId}`;
|
|
117
119
|
this.key = options.eventsKey;
|
|
@@ -125,6 +127,11 @@ export class VeroxmTracker {
|
|
|
125
127
|
};
|
|
126
128
|
this.consentState = this.readConsent();
|
|
127
129
|
this.visitorId = this.store().get(this.keys.visitor) ?? uuid();
|
|
130
|
+
// Campaign attribution: in a browser, the page the visitor arrived on (with its utm tags and ad click ids) and the
|
|
131
|
+
// page that linked to it. Kept in memory for this page load only; a single-page app keeps it as people move around.
|
|
132
|
+
if (typeof window !== 'undefined' && window.location) {
|
|
133
|
+
this.landing = { url: window.location.href, referrer: typeof document !== 'undefined' ? document.referrer : '' };
|
|
134
|
+
}
|
|
128
135
|
if (this.canPersist()) {
|
|
129
136
|
this.store().set(this.keys.visitor, this.visitorId);
|
|
130
137
|
setVisitorCookie(this.visitorId);
|
|
@@ -241,6 +248,16 @@ export class VeroxmTracker {
|
|
|
241
248
|
}
|
|
242
249
|
this.changed();
|
|
243
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* The address the visit started from, for campaign targeting (campaign.* rules) when it isn't the browser's own
|
|
253
|
+
* page: an app opened by a link (a deep link or universal link with utm tags), or a server rendering for a visitor.
|
|
254
|
+
* Call it before getExperience; decisions already made are asked again. Record the visit itself with
|
|
255
|
+
* `page({ url })`, so the visitor's profile keeps the campaign too.
|
|
256
|
+
*/
|
|
257
|
+
setLandingPage(url, referrer) {
|
|
258
|
+
this.landing = { url, referrer: referrer ?? '' };
|
|
259
|
+
this.decisions.clear();
|
|
260
|
+
}
|
|
244
261
|
/**
|
|
245
262
|
* Which variant of a placement this visitor sees, e.g.
|
|
246
263
|
* `const d = await tracker.getExperience('home.hero')` -- then render
|
|
@@ -266,7 +283,11 @@ export class VeroxmTracker {
|
|
|
266
283
|
const timeoutMs = options.timeoutMs ?? 1500;
|
|
267
284
|
const controller = typeof AbortController !== 'undefined' ? new AbortController() : null;
|
|
268
285
|
const timer = setTimeout(() => controller?.abort(), timeoutMs);
|
|
269
|
-
|
|
286
|
+
let qs = `placement=${encodeURIComponent(placement)}&visitorId=${encodeURIComponent(this.visitorId)}`;
|
|
287
|
+
if (this.landing?.url)
|
|
288
|
+
qs += `&url=${encodeURIComponent(this.landing.url.slice(0, 2000))}`;
|
|
289
|
+
if (this.landing?.referrer)
|
|
290
|
+
qs += `&referrer=${encodeURIComponent(this.landing.referrer.slice(0, 2000))}`;
|
|
270
291
|
const request = fetch(`${this.apiBase}/decide?${qs}`, {
|
|
271
292
|
headers: { Authorization: `Bearer ${this.key}` },
|
|
272
293
|
...(controller ? { signal: controller.signal } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veroxm/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "VeroXM client for JavaScript and TypeScript: content, media, experiences, events and the visitor tracker.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veroxm",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"build": "tsc -p tsconfig.json",
|
|
45
45
|
"test": "vitest run",
|
|
46
46
|
"gen:types": "node scripts/gen-types.mjs",
|
|
47
|
+
"gen:embed": "node scripts/gen-embed.mjs",
|
|
47
48
|
"api:report": "node ../../scripts/api-report.mjs . --write"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|