@profullstack/waitlist 0.11.0 → 0.13.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/README.md CHANGED
@@ -120,7 +120,7 @@ The page reports one exposure a day; a signup is the conversion. Both go through
120
120
  waitlist API, which holds the CrawlProof token. Stop the experiment with a winner in
121
121
  CrawlProof and every page switches to it. Turn it off per site with `"ab": false`.
122
122
 
123
- ## Plugins (0.4; buyaday 0.6; book + promo 0.7; affiliate 0.9)
123
+ ## Plugins (0.4; buyaday 0.6; book + promo 0.7; affiliate 0.9; paid referral terms 0.13)
124
124
 
125
125
  Every page showcases all plugins by default. Pick per site in `sites.json`:
126
126
  `"plugins": ["form", "board"]` keeps only those, `"plugins": { "faq": false }` drops some.
@@ -141,25 +141,68 @@ Every page showcases all plugins by default. Pick per site in `sites.json`:
141
141
  | `promo` | "More from the network": sister properties from the live `@profullstack/cross-promo` catalog, tagged `utm_medium=waitlist`. `"promoAudience": "developers"` (or a list) overrides the audience picked from the hierarchy |
142
142
  | `community` | A header bar with Search and a branded **Community** button to the name's own tsbb board (`https://bbs.<name>.pit.world`, sign in with pit.world / CoinPay OAuth 2.1, or `tsbb login <board> --with coinpay`). Linked only once the board answers over HTTPS, so new names gain it as their certificate lands. Writes `brand.json` (look, colours, light/dark, closest tsbb skin) that pit.world's board seed uses to match the site |
143
143
  | (search, resources) | Every search item and resource carries pit.world's result tools from `https://pit.world/widgets.js`: vote, Summarize, Listen and Share. They work without an account; on a pit.world host, "Sign in with CoinPay" (OAuth 2.1 + PKCE through pit.world) raises the limits. From a terminal the same account is `pit login` |
144
- | `affiliate` | Referrals (0.9). Every signup gets a personal link `https://<site>/?ref=<code>`, shown right after joining by `<pf-referral-share>` ("You are #X of Y, N people referred.", copy button, plain X/Bluesky/LinkedIn/email links) and in the confirmation email with a signed status page. A visitor who arrives with `?ref=` keeps a 30-day first-party, first-touch cookie `wl_ref`; their signup credits the referrer once they confirm. Each confirmed referral moves the referrer up `bumpPlaces`. A "Move up the list" section bakes `<pf-referral-leaderboard>` (handles or masked emails only). With `buyaday` on, a door sold to a referred visitor credits the referrer too (holi.days `ref=<code>.<site>`). See below |
144
+ | `affiliate` | Referrals (0.9). Every signup gets a personal link `https://<site>/?ref=<code>`, shown right after joining by `<pf-referral-share>` ("You are #X of Y, N people referred.", copy button, plain X/Bluesky/LinkedIn/email links) and in the confirmation email with a signed status page. A visitor who arrives with `?ref=` keeps a 30-day first-party, first-touch cookie `wl_ref`; their signup credits the referrer once they confirm. Each confirmed referral moves the referrer up `bumpPlaces`. A "Move up the list" section bakes `<pf-referral-leaderboard>` (handles or masked emails only). With `buyaday` on, a door sold to a referred visitor credits the referrer too (holi.days `ref=<code>.<site>`), and since 0.13 the page states the paid terms: the referrer earns `commissionPct` of what that visitor pays and the visitor gets `discountPct` off. See below |
145
145
 
146
146
  ### Referrals (`affiliate`)
147
147
 
148
148
  ```json
149
- { "name": "comp.lang", "affiliate": { "enabled": true, "bumpPlaces": 3, "leaderboard": true, "leaderboardLimit": 10 } }
149
+ { "name": "comp.lang", "affiliate": { "enabled": true, "bumpPlaces": 3, "leaderboard": true, "leaderboardLimit": 10, "commissionPct": 20, "discountPct": 10 } }
150
150
  ```
151
151
 
152
152
  All keys are optional (shown with their defaults); `"affiliate": { "enabled": false }` or
153
153
  `"plugins": { "affiliate": false }` turns it off. The rules live on the API (moshcoding.com):
154
154
  no self-referral (same normalized email: case, `+tags`, Gmail dots), one credit per referred
155
155
  person per list, only confirmed signups count, at most 3 credited signups per hashed IP per
156
- list per day (IPs are HMAC'd, never stored). Nothing here pays or promises money.
156
+ list per day (IPs are HMAC'd, never stored).
157
+
158
+ #### Paid referrals (0.13)
159
+
160
+ The only thing a waitlist site sells is a door on a [holi.days](https://holi.days.pit.world)
161
+ calendar, through the `buyaday` block. When a visitor who arrived through someone's referral
162
+ link pays for a door, holi.days takes `discountPct` off the price and records `commissionPct`
163
+ of the amount paid as owed to the referrer.
164
+
165
+ | Key | Default | Meaning |
166
+ | --- | --- | --- |
167
+ | `commissionPct` | `20` | Percent of what a referred buyer pays that the referrer earns. Whole number, 0..50. |
168
+ | `discountPct` | `10` | Percent off a paid door for the referred buyer. Whole number, 0..50. |
169
+
170
+ With either above 0 (and both `affiliate` and `buyaday` on) the site says so in three places:
171
+
172
+ - "Move up the list" gains one paragraph: "When someone you refer buys a calendar door through
173
+ your link, you earn 20% of what they pay and they get 10% off. We pay commissions in USDC
174
+ through CoinPay and email you at the address you joined with when you have earnings. Doors
175
+ booked free with the holi.days badge do not count." The place-bump sentence stays.
176
+ - `<pf-referral-share commission-pct="20" discount-pct="10">`, shown after a signup: "Earn 20%
177
+ of what people you refer pay. They get 10% off."
178
+ - `<pf-buy-a-day discount-pct="10" commission-pct="20">`: "10% off a paid door with a referral
179
+ link. Referrers earn 20% of what the buyer pays."
180
+
181
+ `0` leaves that half out. `"commissionPct": 0, "discountPct": 0` turns the money wording off for
182
+ a site, and it reads as it did before 0.13. A site without `buyaday` says nothing about money
183
+ either: there is nothing on it to buy.
184
+
185
+ What to know before turning it on:
186
+
187
+ - **These two keys are wording.** The waitlist moves no money. holi.days applies the discount
188
+ and keeps the commission ledger from its own `REFERRAL_DISCOUNT_PCT` and
189
+ `REFERRAL_COMMISSION_PCT` (defaults 10 and 20; live values at
190
+ `https://holi.days.pit.world/api/v1/referral-terms`). Keep the site's numbers equal to those.
191
+ - **Paid doors need holi.days payments to be open.** holi.days sells a door through CoinPay
192
+ only when its `COINPAY_API_KEY` is set (`paidBookingOpen` in the terms JSON). While it is
193
+ closed, nobody can pay for a door, so nobody earns a commission or gets a discount; doors are
194
+ then only bookable free with the holi.days badge, which never counts.
195
+ - **Payouts are made by hand.** Commissions are owed once the buyer's payment confirms, and
196
+ paid in USDC through CoinPay by whoever runs holi.days (its admin API lists what is owed per
197
+ code). The email to the referrer is sent by that person: nothing in this package sends it.
198
+ - A commission is void if the door is refunded, released or hidden before the payout, and a
199
+ door bought through your own link earns nothing.
157
200
 
158
201
  Snippet for any page on the same API:
159
202
 
160
203
  ```html
161
204
  <waitlist-form dn="comp.lang" bump="3"></waitlist-form>
162
- <pf-referral-share bump="3"></pf-referral-share>
205
+ <pf-referral-share bump="3" commission-pct="20" discount-pct="10"></pf-referral-share>
163
206
  <pf-referral-leaderboard dn="comp.lang"></pf-referral-leaderboard>
164
207
  <script type="module" src="https://cdn.jsdelivr.net/npm/@profullstack/waitlist/src/index.js"></script>
165
208
  <script type="module" src="https://cdn.jsdelivr.net/npm/@profullstack/marketing-widgets/src/widgets.js"></script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/waitlist",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "Email waitlist for any launch page: a <waitlist-form> web component, a live signup chart, and a static-site builder on @profullstack/css + @profullstack/charts.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -51,7 +51,7 @@
51
51
  "@profullstack/footer": "^0.7.3",
52
52
  "@resvg/resvg-js": "^2.6.2",
53
53
  "@profullstack/comments": "^0.2.0",
54
- "@profullstack/marketing-widgets": "^0.2.0",
54
+ "@profullstack/marketing-widgets": "^0.3.0",
55
55
  "@profullstack/cross-promo": "^0.2.1"
56
56
  },
57
57
  "devDependencies": {
package/src/build.js CHANGED
@@ -40,7 +40,10 @@ export const DEFAULT_AB = { experiment: 'waitlist-look-v1', arms: ['themed', 'cl
40
40
  */
41
41
  export function abHeadScript(ab, themed) {
42
42
  const cfg = JSON.stringify({ e: ab.experiment, a: ab.arms, t: themed }).replace(/</g, '\\u003c');
43
- return `<script>(function(c){try{var L=localStorage,u=L.getItem("wl-unit");if(!u){u=Array.from(crypto.getRandomValues(new Uint8Array(12)),function(b){return(b%36).toString(36)}).join("");L.setItem("wl-unit",u)}
43
+ // The unit lives in localStorage and in a wl-unit cookie on this host, which bbs.<host> and
44
+ // social.<host> read too (tsbb 0.18+ board.lookAb): one visitor, one arm, across all three.
45
+ return `<script>(function(c){try{var L=localStorage,m=document.cookie.match(/(?:^|; )wl-unit=([a-z0-9]{6,32})/),u=(m&&m[1])||L.getItem("wl-unit");if(!u){u=Array.from(crypto.getRandomValues(new Uint8Array(12)),function(b){return(b%36).toString(36)}).join("")}L.setItem("wl-unit",u);
46
+ document.cookie="wl-unit="+u+"; Domain="+location.hostname.replace(/^www\\./,"")+"; Path=/; Max-Age=31536000; SameSite=Lax"+(location.protocol==="https:"?"; Secure":"");
44
47
  function h(s){var a=3735928559,b=1103547991;for(var i=0;i<s.length;i++){var k=s.charCodeAt(i);a=Math.imul(a^k,2654435761);b=Math.imul(b^k,1597334677)}a=Math.imul(a^a>>>16,2246822507);a^=Math.imul(b^b>>>13,3266489909);b=Math.imul(b^b>>>16,2246822507);b^=Math.imul(a^a>>>13,3266489909);return 4294967296*(2097151&b)+(a>>>0)}
45
48
  var w=L.getItem("wl-winner:"+c.e),arm=w&&c.a.indexOf(w)>=0?w:c.a[Math.floor(h(c.e+"\\0"+u)/Math.pow(2,53)*c.a.length)],d=document.documentElement;
46
49
  d.dataset.look=arm==="themed"?c.t:arm;d.dataset.abArm=arm;window.__wlab={experiment:c.e,unit:u,arm:arm,themed:c.t,winner:!!w}}catch(x){}})(${cfg});</script>`;
package/src/community.js CHANGED
@@ -58,6 +58,8 @@ export async function brandJson(s) {
58
58
  skin: SKIN[s.look] ?? 'modern',
59
59
  icon: `${s.url}assets/icon-192.png`,
60
60
  community: boardUrl(s),
61
+ // The look A/B test the site runs, for the board and social feed to share (same wl-unit cookie).
62
+ ab: s.ab ? { experiment: s.ab.experiment, arms: s.ab.arms } : null,
61
63
  };
62
64
  }
63
65
 
package/src/plugins.js CHANGED
@@ -13,7 +13,8 @@
13
13
  * promo "More from the network": sister properties from @profullstack/cross-promo.
14
14
  * `"promoAudience": "developers"` (or a list) picks who the reader is.
15
15
  * affiliate referral links, place bumps and a leaderboard (`"affiliate": {...}`, see
16
- * affiliateConfig); door sales credit the referrer when buyaday is on.
16
+ * affiliateConfig); door sales credit the referrer when buyaday is on, and
17
+ * the page then states the paid terms (commissionPct / discountPct).
17
18
  */
18
19
  import { mkdir, readFile, writeFile, copyFile } from 'node:fs/promises';
19
20
  import { createRequire } from 'node:module';
@@ -37,9 +38,17 @@ export function pluginSet(setting) {
37
38
  /**
38
39
  * The `affiliate` plugin's settings from sites.json:
39
40
  *
40
- * "affiliate": { "enabled": true, "bumpPlaces": 3, "leaderboard": true, "leaderboardLimit": 10 }
41
+ * "affiliate": { "enabled": true, "bumpPlaces": 3, "leaderboard": true, "leaderboardLimit": 10,
42
+ * "commissionPct": 20, "discountPct": 10 }
41
43
  *
42
44
  * bumpPlaces is how many places one confirmed referral moves someone up (0..50).
45
+ *
46
+ * commissionPct / discountPct are the paid referral terms the page states: what
47
+ * a referrer earns of a calendar door a referred visitor pays for, and what that
48
+ * visitor gets off (whole numbers, 0..50). They are wording only: holi.days
49
+ * applies the discount and keeps the ledger from its own REFERRAL_COMMISSION_PCT
50
+ * and REFERRAL_DISCOUNT_PCT, so keep the two in step. 0 leaves that part out;
51
+ * both 0 and the site says nothing about money.
43
52
  */
44
53
  export function affiliateConfig(raw) {
45
54
  const a = raw && typeof raw === 'object' ? raw : {};
@@ -49,9 +58,31 @@ export function affiliateConfig(raw) {
49
58
  bumpPlaces: int(a.bumpPlaces, 3, 0, 50),
50
59
  leaderboard: a.leaderboard !== false,
51
60
  leaderboardLimit: int(a.leaderboardLimit, 10, 1, 100),
61
+ commissionPct: int(a.commissionPct, 20, 0, 50),
62
+ discountPct: int(a.discountPct, 10, 0, 50),
52
63
  };
53
64
  }
54
65
 
66
+ /**
67
+ * The paid referral terms a site states, or zeros when it should say nothing
68
+ * about money: affiliate off, or no `buyaday` (the buy-a-day block is the only
69
+ * thing a referred visitor can pay for, so without it there is nothing to earn).
70
+ */
71
+ export function referralTerms(s) {
72
+ const on = s.plugins || pluginSet();
73
+ const a = s.affiliate;
74
+ if (!a || !on.has('affiliate') || !on.has('buyaday')) return { commissionPct: 0, discountPct: 0 };
75
+ return { commissionPct: a.commissionPct || 0, discountPct: a.discountPct || 0 };
76
+ }
77
+
78
+ /** The one paragraph about money in "Move up the list" ('' when the site states no terms). */
79
+ export function referralTermsParagraph({ commissionPct, discountPct }) {
80
+ if (!commissionPct && !discountPct) return '';
81
+ const what = [commissionPct ? `you earn ${commissionPct}% of what they pay` : '', discountPct ? `they get ${discountPct}% off` : ''].filter(Boolean).join(' and ');
82
+ const pay = commissionPct ? ' We pay commissions in USDC through CoinPay and email you at the address you joined with when you have earnings.' : '';
83
+ return `When someone you refer buys a calendar door through your link, ${what}.${pay} Doors booked free with the holi.days badge do not count.`;
84
+ }
85
+
55
86
  /**
56
87
  * Copy the @profullstack/marketing-widgets browser files FLAT into assets/ (as
57
88
  * mw-widgets.js + mw-core.js: versionAssets reads assets/ and would EISDIR on a
@@ -75,8 +106,10 @@ export async function affiliateHtml(s, { fetchImpl } = {}) {
75
106
  ? `Everyone who joins gets a personal link. Each friend who joins through yours and confirms their email moves you up ${a.bumpPlaces} ${a.bumpPlaces === 1 ? 'place' : 'places'}.`
76
107
  : 'Everyone who joins gets a personal link. Friends who join through yours and confirm their email put you on the board.';
77
108
  const board = a.leaderboard ? await mw.referralLeaderboardHtml({ dn: s.dn, api: s.api, limit: a.leaderboardLimit, fetchImpl }) : '';
109
+ const money = referralTermsParagraph(referralTerms(s));
78
110
  return `<section class="stack waitlist-affiliate" aria-labelledby="referrals"><h2 id="referrals">Move up the list</h2>
79
111
  <p>${esc(how)}</p>
112
+ ${money ? `<p class="waitlist-referral-terms">${esc(money)}</p>` : ''}
80
113
  ${board}
81
114
  </section>`;
82
115
  }
@@ -157,7 +190,9 @@ export function baseSlot(s) {
157
190
  <div class="field-group"><input id="wl-email" name="email" type="email" autocomplete="email" required><button type="submit">${esc(s.button)}</button></div></form>
158
191
  </waitlist-form>`);
159
192
  // Shown after a signup: place on the list, personal link, copy + share links.
160
- if (aff) slot.hero.push(`<pf-referral-share bump="${aff.bumpPlaces}"></pf-referral-share>`);
193
+ // commission-pct / discount-pct make it state the paid terms; absent, it says nothing about money.
194
+ const terms = referralTerms(s);
195
+ if (aff) slot.hero.push(`<pf-referral-share bump="${aff.bumpPlaces}"${terms.commissionPct ? ` commission-pct="${terms.commissionPct}"` : ''}${terms.discountPct ? ` discount-pct="${terms.discountPct}"` : ''}></pf-referral-share>`);
161
196
  }
162
197
  if (on.has('stats')) {
163
198
  slot.cards.push(`<section class="card stack" aria-labelledby="count"><h2 id="count">Who's waiting</h2>
@@ -200,9 +235,10 @@ export async function runPlugins(s, out, { fetchImpl, cacheDir, maxAgeMs, search
200
235
  // Offers are baked in (no script needed, crawlers read them); the copied script
201
236
  // refreshes them live so taken doors drop off. An empty feed renders nothing.
202
237
  // With affiliate on, a door sold to a referred visitor credits the referrer too
203
- // (holi.days ref = <code>.<site>, from ?ref or the wl_ref cookie).
238
+ // (holi.days ref = <code>.<site>, from ?ref or the wl_ref cookie), and the offer
239
+ // states the referral discount (needs marketing-widgets 0.3).
204
240
  const mw = await import('@profullstack/marketing-widgets');
205
- const html = await mw.buyADayHtml({ ref: s.host, keywords: s.buyadayKeywords || keywordsFor(s), limit: s.buyadayLimit || 3, fetchImpl, referrerCookie: on.has('affiliate') });
241
+ const html = await mw.buyADayHtml({ ref: s.host, keywords: s.buyadayKeywords || keywordsFor(s), limit: s.buyadayLimit || 3, fetchImpl, referrerCookie: on.has('affiliate'), ...referralTerms(s) });
206
242
  if (html.includes('pf-mw-offer')) {
207
243
  await copyMarketingWidgets(mw, out, slot);
208
244
  slot.sections.push(`<section class="stack" aria-label="Buy a day">${html}</section>`);