splithub 0.3.0 → 0.4.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/dist/alerts-Q46GJETJ.js +28 -0
- package/dist/analytics-BVBZVSCN.js +22 -0
- package/dist/{chunk-4YXB73AZ.js → chunk-4OQEIP33.js} +28 -3
- package/dist/chunk-4OQEIP33.js.map +1 -0
- package/dist/{chunk-4PUFNQ5F.js → chunk-6GP534WA.js} +6 -6
- package/dist/{chunk-QKOATM5G.js → chunk-6MWK7QV4.js} +12 -11
- package/dist/chunk-6MWK7QV4.js.map +1 -0
- package/dist/{chunk-TIL2VQX4.js → chunk-6T652N3X.js} +2 -2
- package/dist/chunk-7DFMYJTC.js +347 -0
- package/dist/chunk-7DFMYJTC.js.map +1 -0
- package/dist/chunk-CAFWOX3S.js +49 -0
- package/dist/chunk-CAFWOX3S.js.map +1 -0
- package/dist/chunk-FDSNZRQQ.js +125 -0
- package/dist/chunk-FDSNZRQQ.js.map +1 -0
- package/dist/{chunk-EQCMCULO.js → chunk-GIYKIJKW.js} +25 -8
- package/dist/chunk-GIYKIJKW.js.map +1 -0
- package/dist/{chunk-A3FYDTIP.js → chunk-HFIBLDUA.js} +2 -2
- package/dist/{chunk-J5ZUSS43.js → chunk-ILEPMQNT.js} +55 -2
- package/dist/chunk-ILEPMQNT.js.map +1 -0
- package/dist/chunk-J3DANPLP.js +250 -0
- package/dist/chunk-J3DANPLP.js.map +1 -0
- package/dist/{chunk-NHRWXNB5.js → chunk-KV7D6SB7.js} +8 -8
- package/dist/{chunk-NHRWXNB5.js.map → chunk-KV7D6SB7.js.map} +1 -1
- package/dist/chunk-MSYL3XZF.js +243 -0
- package/dist/chunk-MSYL3XZF.js.map +1 -0
- package/dist/{chunk-4LE4SCWY.js → chunk-MUDDASN6.js} +2 -2
- package/dist/{chunk-U3QRNSLM.js → chunk-NFZZSF4M.js} +3 -3
- package/dist/{chunk-WTUZFXXJ.js → chunk-NYWJZKOO.js} +8 -8
- package/dist/{chunk-WTUZFXXJ.js.map → chunk-NYWJZKOO.js.map} +1 -1
- package/dist/chunk-OXVLWFSD.js +822 -0
- package/dist/chunk-OXVLWFSD.js.map +1 -0
- package/dist/{chunk-VSMWYVJ2.js → chunk-QCFQFDEB.js} +35 -13
- package/dist/chunk-QCFQFDEB.js.map +1 -0
- package/dist/{chunk-PMER7I7F.js → chunk-RMWW4YMN.js} +4 -4
- package/dist/{chunk-PMER7I7F.js.map → chunk-RMWW4YMN.js.map} +1 -1
- package/dist/chunk-SHKXD2C6.js +199 -0
- package/dist/chunk-SHKXD2C6.js.map +1 -0
- package/dist/chunk-SUUNAQAC.js +270 -0
- package/dist/chunk-SUUNAQAC.js.map +1 -0
- package/dist/{chunk-JBPVGBLN.js → chunk-U7Z5VYNX.js} +24 -19
- package/dist/chunk-U7Z5VYNX.js.map +1 -0
- package/dist/{chunk-BNZFC2DQ.js → chunk-VVJ4WRAB.js} +31 -18
- package/dist/chunk-VVJ4WRAB.js.map +1 -0
- package/dist/{chunk-C3ZJEZDE.js → chunk-VY342F4X.js} +44 -17
- package/dist/chunk-VY342F4X.js.map +1 -0
- package/dist/chunk-WMZLKY6J.js +237 -0
- package/dist/chunk-WMZLKY6J.js.map +1 -0
- package/dist/{chunk-PP3RLIJP.js → chunk-ZISCJRR5.js} +4 -3
- package/dist/chunk-ZISCJRR5.js.map +1 -0
- package/dist/{ci-KFSOM2AF.js → ci-4SY2X2CU.js} +4 -4
- package/dist/connect-BVXKCJNO.js +225 -0
- package/dist/connect-BVXKCJNO.js.map +1 -0
- package/dist/create-IBVKGS3D.js +18 -0
- package/dist/dev-YNKPWJHX.js +11 -0
- package/dist/doctor-BKS7TUAT.js +14 -0
- package/dist/domains-CR34APOD.js +10 -0
- package/dist/experiment-reports-LL2TFQQN.js +49 -0
- package/dist/{holdout-OYKY6UIE.js → holdout-JJEP6673.js} +7 -6
- package/dist/holdout-JJEP6673.js.map +1 -0
- package/dist/index.js +128 -37
- package/dist/index.js.map +1 -1
- package/dist/init-HRCQ5WAA.js +15 -0
- package/dist/lifecycle-3GUIJ74P.js +12 -0
- package/dist/links-BQZLMGZJ.js +18 -0
- package/dist/{login-AETAL2DO.js → login-OT77MNKL.js} +4 -4
- package/dist/login-OT77MNKL.js.map +1 -0
- package/dist/menu-7EZD5NDF.js +726 -0
- package/dist/menu-7EZD5NDF.js.map +1 -0
- package/dist/notes-BASGWNNX.js +18 -0
- package/dist/notes-BASGWNNX.js.map +1 -0
- package/dist/{plan-Q2EZSSAO.js → plan-44334RQS.js} +7 -7
- package/dist/plan-44334RQS.js.map +1 -0
- package/dist/push-L2IRGUDM.js +16 -0
- package/dist/push-L2IRGUDM.js.map +1 -0
- package/dist/{refs-VPQ7WIRJ.js → refs-5DTSKMXU.js} +5 -5
- package/dist/{remove-IPLTQIFK.js → remove-PVVTBBWX.js} +10 -9
- package/dist/remove-PVVTBBWX.js.map +1 -0
- package/dist/{report-TOWSAQYM.js → report-JVMKVZTS.js} +6 -6
- package/dist/results-KC24ZZTX.js +20 -0
- package/dist/results-KC24ZZTX.js.map +1 -0
- package/dist/{review-HMBIZ6V2.js → review-GIYBPVP3.js} +3 -3
- package/dist/{ship-LKSCUDAE.js → ship-UP6DLCJN.js} +10 -9
- package/dist/ship-UP6DLCJN.js.map +1 -0
- package/dist/skills-J6X6DULX.js +18 -0
- package/dist/skills-J6X6DULX.js.map +1 -0
- package/dist/status-SK5PPBPL.js +17 -0
- package/dist/status-SK5PPBPL.js.map +1 -0
- package/dist/{update-R4L7ZP5G.js → update-XF7HWJ3A.js} +3 -3
- package/package.json +3 -3
- package/dist/chunk-4YXB73AZ.js.map +0 -1
- package/dist/chunk-BNZFC2DQ.js.map +0 -1
- package/dist/chunk-C3ZJEZDE.js.map +0 -1
- package/dist/chunk-EQCMCULO.js.map +0 -1
- package/dist/chunk-HK267YK2.js +0 -571
- package/dist/chunk-HK267YK2.js.map +0 -1
- package/dist/chunk-J5ZUSS43.js.map +0 -1
- package/dist/chunk-JBPVGBLN.js.map +0 -1
- package/dist/chunk-PP3RLIJP.js.map +0 -1
- package/dist/chunk-QKOATM5G.js.map +0 -1
- package/dist/chunk-VSMWYVJ2.js.map +0 -1
- package/dist/create-POZWP6JT.js +0 -18
- package/dist/dev-3SPMTW3T.js +0 -11
- package/dist/doctor-OHZEXUGO.js +0 -14
- package/dist/holdout-OYKY6UIE.js.map +0 -1
- package/dist/init-4PNOZUIZ.js +0 -15
- package/dist/lifecycle-3QVRQRHM.js +0 -12
- package/dist/menu-PBZVBCGA.js +0 -163
- package/dist/menu-PBZVBCGA.js.map +0 -1
- package/dist/plan-Q2EZSSAO.js.map +0 -1
- package/dist/push-7EELDSKG.js +0 -16
- package/dist/remove-IPLTQIFK.js.map +0 -1
- package/dist/results-SMBCREVI.js +0 -17
- package/dist/ship-LKSCUDAE.js.map +0 -1
- package/dist/skills-5ZAMIVP3.js +0 -18
- package/dist/status-7LDIKVX7.js +0 -12
- /package/dist/{ci-KFSOM2AF.js.map → alerts-Q46GJETJ.js.map} +0 -0
- /package/dist/{create-POZWP6JT.js.map → analytics-BVBZVSCN.js.map} +0 -0
- /package/dist/{chunk-4PUFNQ5F.js.map → chunk-6GP534WA.js.map} +0 -0
- /package/dist/{chunk-TIL2VQX4.js.map → chunk-6T652N3X.js.map} +0 -0
- /package/dist/{chunk-A3FYDTIP.js.map → chunk-HFIBLDUA.js.map} +0 -0
- /package/dist/{chunk-4LE4SCWY.js.map → chunk-MUDDASN6.js.map} +0 -0
- /package/dist/{chunk-U3QRNSLM.js.map → chunk-NFZZSF4M.js.map} +0 -0
- /package/dist/{dev-3SPMTW3T.js.map → ci-4SY2X2CU.js.map} +0 -0
- /package/dist/{doctor-OHZEXUGO.js.map → create-IBVKGS3D.js.map} +0 -0
- /package/dist/{init-4PNOZUIZ.js.map → dev-YNKPWJHX.js.map} +0 -0
- /package/dist/{lifecycle-3QVRQRHM.js.map → doctor-BKS7TUAT.js.map} +0 -0
- /package/dist/{login-AETAL2DO.js.map → domains-CR34APOD.js.map} +0 -0
- /package/dist/{push-7EELDSKG.js.map → experiment-reports-LL2TFQQN.js.map} +0 -0
- /package/dist/{results-SMBCREVI.js.map → init-HRCQ5WAA.js.map} +0 -0
- /package/dist/{skills-5ZAMIVP3.js.map → lifecycle-3GUIJ74P.js.map} +0 -0
- /package/dist/{status-7LDIKVX7.js.map → links-BQZLMGZJ.js.map} +0 -0
- /package/dist/{refs-VPQ7WIRJ.js.map → refs-5DTSKMXU.js.map} +0 -0
- /package/dist/{report-TOWSAQYM.js.map → report-JVMKVZTS.js.map} +0 -0
- /package/dist/{review-HMBIZ6V2.js.map → review-GIYBPVP3.js.map} +0 -0
- /package/dist/{update-R4L7ZP5G.js.map → update-XF7HWJ3A.js.map} +0 -0
|
@@ -6,22 +6,22 @@ import {
|
|
|
6
6
|
loadConfig,
|
|
7
7
|
readSource,
|
|
8
8
|
writeConfigChecked
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ILEPMQNT.js";
|
|
10
10
|
import {
|
|
11
11
|
componentVariantTemplate
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-OXVLWFSD.js";
|
|
13
13
|
import {
|
|
14
14
|
requireConfig
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MUDDASN6.js";
|
|
16
16
|
import {
|
|
17
17
|
c,
|
|
18
18
|
fail,
|
|
19
19
|
printJson
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ZISCJRR5.js";
|
|
21
21
|
|
|
22
22
|
// src/commands/create.ts
|
|
23
23
|
import * as p from "@clack/prompts";
|
|
24
|
-
import { mvtVariants } from "@splithub/core";
|
|
24
|
+
import { EVENT_NAME_PATTERN, goalKeyFor, mvtVariants } from "@splithub/core";
|
|
25
25
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
26
26
|
import { join, relative } from "path";
|
|
27
27
|
var KEY = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
@@ -159,7 +159,7 @@ async function create(flags) {
|
|
|
159
159
|
if (kind === "redirect") {
|
|
160
160
|
if (!match) {
|
|
161
161
|
if (!interactive) fail("USAGE", "A redirect experiment needs the path it runs on.", "Pass --match /path.");
|
|
162
|
-
match = await ask(p.text({ message: "Path to run the redirect
|
|
162
|
+
match = await ask(p.text({ message: "Path to run the redirect experiment on", initialValue: "/" }));
|
|
163
163
|
}
|
|
164
164
|
for (const k of variantKeys) {
|
|
165
165
|
if (tos[k] === void 0) {
|
|
@@ -175,15 +175,20 @@ async function create(flags) {
|
|
|
175
175
|
else if (goals.length > 0) {
|
|
176
176
|
goal = await ask(
|
|
177
177
|
p.select({
|
|
178
|
-
message: "Goal
|
|
179
|
-
options: [...goals.map((g) => ({ value: g, label: g })), { value: "", label: "none yet (add later)" }]
|
|
178
|
+
message: "Goal to optimise",
|
|
179
|
+
options: [...goals.map((g) => ({ value: g, label: g })), { value: "?", label: "another event" }, { value: "", label: "none yet (add later)" }]
|
|
180
180
|
})
|
|
181
181
|
);
|
|
182
|
+
if (goal === "?") goal = await ask(p.text({ message: "Event name", placeholder: "signup", validate: (v) => v && !EVENT_NAME_PATTERN.test(v) ? "Letters, digits, spaces and _ . : / -, up to 64 characters." : void 0 }));
|
|
183
|
+
if (!goal) goal = void 0;
|
|
184
|
+
} else {
|
|
185
|
+
goal = await ask(p.text({ message: "Goal: the event this experiment should raise (blank for later)", placeholder: "signup", validate: (v) => v && !EVENT_NAME_PATTERN.test(v) ? "Letters, digits, spaces and _ . : / -, up to 64 characters." : void 0 }));
|
|
182
186
|
if (!goal) goal = void 0;
|
|
183
187
|
}
|
|
184
188
|
}
|
|
185
|
-
if (goal
|
|
186
|
-
const
|
|
189
|
+
if (goal) checkEventName(goal, "--goal");
|
|
190
|
+
const isNewGoal = goal ? !goals.includes(goalKeyFor(config.goals, goal) ?? "") : false;
|
|
191
|
+
const extras = parseExtras(flags, config.goals, goal);
|
|
187
192
|
const status = str(flags.status) ?? "running";
|
|
188
193
|
if (!["draft", "running", "paused"].includes(status)) fail("INVALID_FLAG", `A new experiment can't be "${status}".`, "Use --status running or --status draft.");
|
|
189
194
|
const description = str(flags.description);
|
|
@@ -228,14 +233,16 @@ async function create(flags) {
|
|
|
228
233
|
const snippet = kind === "mvt" ? `const { ${Object.keys(factors).join(", ")} } = useValue<{ ${Object.keys(factors).map((f) => `${f}: string`).join("; ")} }>('${id}');` : kind === "value" ? `const value = useValue<string>('${id}');` : kind === "component" ? `<Experiment id="${id}">
|
|
229
234
|
${variantKeys.map((k) => ` <Variant name="${k}"><${componentNames[k]} /></Variant>`).join("\n")}
|
|
230
235
|
</Experiment>` : `// handled by @splithub/next middleware on ${match}; no code needed`;
|
|
231
|
-
const
|
|
236
|
+
const goalKey = goal ? goalKeyFor(config.goals, goal) : null;
|
|
237
|
+
const result = { experiment: id, kind, status, variants: experiment.variants, goal: goalKey, traffic: limits.traffic ?? 1, maxVisitors: limits.maxExposures ?? null, minDays: limits.minDays ?? null, goodSample: limits.goodSample ?? null, schedule: limits.schedule ?? null, configFile: relative(project.root, project.configFile), files, snippet };
|
|
232
238
|
if (json) {
|
|
233
239
|
const cloudMode = /mode\s*:\s*['"]cloud['"]/.test(readSource(project.configFile));
|
|
234
240
|
const handoff = status === "draft" ? `${id} is a draft: visitors do not see it and nothing is recorded until it is started. Tell the user and ask whether to start it now (npx splithub start ${id}).` : `${id} is running in the config: it goes live for visitors when this code is deployed${cloudMode ? " and pushed; local development never sends events to the cloud" : ""}. Tell the user, and that npx splithub pause ${id} or Pause in the dashboard holds it.`;
|
|
235
241
|
const nextStep = cloudMode ? `npx splithub push # the cloud does not know about ${id} until you push` : status === "draft" ? `npx splithub start ${id}` : "deploy the app";
|
|
236
|
-
printJson({ ...result, nextStep, handoff });
|
|
242
|
+
printJson({ ...result, ...isNewGoal && goal ? { goalNote: newGoalNote(goal) } : {}, nextStep, handoff });
|
|
237
243
|
return;
|
|
238
244
|
}
|
|
245
|
+
if (isNewGoal && goal) p.log.info(newGoalNote(goal));
|
|
239
246
|
p.note(snippet, kind === "redirect" ? "Nothing to wire" : "Wire it in your code");
|
|
240
247
|
if (files.length) p.note(files.join("\n"), "Scaffolded");
|
|
241
248
|
const cloud = /mode\s*:\s*['"]cloud['"]/.test(readSource(project.configFile));
|
|
@@ -250,7 +257,7 @@ function parseWeights(raw, count) {
|
|
|
250
257
|
const weights = raw.split(",").map((w) => Number(w.trim()));
|
|
251
258
|
if (weights.length !== count) fail("INVALID_FLAG", `--weights has ${weights.length} numbers for ${count} variants.`, "Give one weight per variant, in the same order: --weights 50,50.");
|
|
252
259
|
if (weights.some((w) => !Number.isFinite(w) || w < 0)) fail("INVALID_FLAG", `--weights "${raw}" has a value that isn't a number of 0 or more.`);
|
|
253
|
-
if (weights.every((w) => w === 0)) fail("INVALID_FLAG", "All weights are 0, so nobody would see the
|
|
260
|
+
if (weights.every((w) => w === 0)) fail("INVALID_FLAG", "All weights are 0, so nobody would see the experiment.");
|
|
254
261
|
return weights;
|
|
255
262
|
}
|
|
256
263
|
function parseLimits(flags) {
|
|
@@ -258,7 +265,7 @@ function parseLimits(flags) {
|
|
|
258
265
|
const traffic = str(flags.traffic);
|
|
259
266
|
if (traffic !== void 0) {
|
|
260
267
|
const t = Number(traffic.replace(/%$/, ""));
|
|
261
|
-
if (!Number.isFinite(t) || t <= 0 || t > 100) fail("INVALID_FLAG", `--traffic "${traffic}" must be a percent between 0 and 100.`, "For example --traffic 50 puts half of the visitors in the
|
|
268
|
+
if (!Number.isFinite(t) || t <= 0 || t > 100) fail("INVALID_FLAG", `--traffic "${traffic}" must be a percent between 0 and 100.`, "For example --traffic 50 puts half of the visitors in the experiment.");
|
|
262
269
|
if (t !== 100) out.traffic = Math.round(t * 100) / 1e4;
|
|
263
270
|
}
|
|
264
271
|
const max = str(flags["max-visitors"]);
|
|
@@ -292,6 +299,12 @@ function parseLimits(flags) {
|
|
|
292
299
|
if (startAt || endAt) out.schedule = { startAt, endAt };
|
|
293
300
|
return out;
|
|
294
301
|
}
|
|
302
|
+
function checkEventName(name, flag) {
|
|
303
|
+
if (!EVENT_NAME_PATTERN.test(name) || !goalKeyFor([], name)) fail("INVALID_FLAG", `${flag} "${name}" is not an event name.`, "Use letters, digits, spaces and _ . : / -, up to 64 characters (signup, Video Played).");
|
|
304
|
+
}
|
|
305
|
+
function newGoalNote(name) {
|
|
306
|
+
return `"${name}" becomes a goal: every track('${name}') now counts for this experiment.`;
|
|
307
|
+
}
|
|
295
308
|
function parseExtras(flags, goals, primary) {
|
|
296
309
|
const out = {};
|
|
297
310
|
const split = (v) => list(v).flatMap((x) => x.split(",")).map((x) => x.trim()).filter(Boolean);
|
|
@@ -304,8 +317,8 @@ function parseExtras(flags, goals, primary) {
|
|
|
304
317
|
const named = [...secondary, ...guardrails.map((g) => typeof g === "string" ? g : g.goal)];
|
|
305
318
|
if (named.length) {
|
|
306
319
|
if (!primary) fail("USAGE", "Secondary metrics and guardrails need a primary goal.", "Pass --goal too.");
|
|
307
|
-
for (const g of named)
|
|
308
|
-
const all = [primary, ...named];
|
|
320
|
+
for (const g of named) checkEventName(g, "--secondary / --guardrail");
|
|
321
|
+
const all = [primary, ...named].map((g) => goalKeyFor(goals, g));
|
|
309
322
|
if (new Set(all).size !== all.length) fail("INVALID_FLAG", "A goal is listed twice across --goal, --secondary and --guardrail.");
|
|
310
323
|
out.metrics = { ...secondary.length ? { secondary } : {}, ...guardrails.length ? { guardrails } : {} };
|
|
311
324
|
}
|
|
@@ -314,7 +327,7 @@ function parseExtras(flags, goals, primary) {
|
|
|
314
327
|
const m = /^([a-z0-9][a-z0-9_-]{0,63}):(\d{1,3})-(\d{1,3})$/.exec(layer);
|
|
315
328
|
const start = Number(m?.[2]);
|
|
316
329
|
const end = Number(m?.[3]);
|
|
317
|
-
if (!m || !(start < end) || end > 100) fail("INVALID_FLAG", `--layer "${layer}" must look like key:start-end with 0 <= start < end <= 100.`, "For example --layer checkout:0-50; another
|
|
330
|
+
if (!m || !(start < end) || end > 100) fail("INVALID_FLAG", `--layer "${layer}" must look like key:start-end with 0 <= start < end <= 100.`, "For example --layer checkout:0-50; another experiment in checkout:50-100 never shares a visitor.");
|
|
318
331
|
out.layer = { key: m[1], range: [start, end] };
|
|
319
332
|
}
|
|
320
333
|
return out;
|
|
@@ -326,4 +339,4 @@ export {
|
|
|
326
339
|
parseLimits,
|
|
327
340
|
parseExtras
|
|
328
341
|
};
|
|
329
|
-
//# sourceMappingURL=chunk-
|
|
342
|
+
//# sourceMappingURL=chunk-VVJ4WRAB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/create.ts"],"sourcesContent":["import * as p from '@clack/prompts';\nimport { EVENT_NAME_PATTERN, goalKeyFor, mvtVariants, type ExperimentKind, type ExperimentStatus } from '@splithub/core';\nimport { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { join, relative } from 'node:path';\nimport { ensureLayer, hasExperiment, insertExperiment, loadConfig, readSource, writeConfigChecked, type NewExperiment } from '../config-file';\nimport { fail, printJson } from '../errors';\nimport { requireConfig } from '../project';\nimport { componentVariantTemplate } from '../templates';\nimport { c } from '../ui';\nimport type { Flags } from './init';\n\nconst KEY = /^[a-z0-9][a-z0-9_-]{0,63}$/;\n\nfunction str(v: unknown): string | undefined {\n return typeof v === 'string' && v.length > 0 ? v : undefined;\n}\nfunction list(v: unknown): string[] {\n if (Array.isArray(v)) return v.map(String);\n if (typeof v === 'string') return [v];\n return [];\n}\nfunction parsePairs(items: string[]): Record<string, string> {\n const out: Record<string, string> = {};\n for (const item of items) {\n const i = item.indexOf('=');\n if (i > 0) out[item.slice(0, i).trim()] = item.slice(i + 1);\n }\n return out;\n}\nfunction pascal(s: string): string {\n return s.replace(/(^|[-_])([a-z0-9])/g, (_, __, ch: string) => ch.toUpperCase());\n}\n\nasync function ask<T>(promise: Promise<T | symbol>): Promise<T> {\n const v = await promise;\n if (p.isCancel(v)) {\n p.cancel('Cancelled.');\n process.exit(0);\n }\n return v as T;\n}\n\nexport async function create(flags: Flags): Promise<void> {\n const json = Boolean(flags.json);\n const yes = Boolean(flags.yes);\n const project = requireConfig();\n const config = await loadConfig(project.configFile);\n const source = readSource(project.configFile);\n const interactive = !yes && !json;\n\n if (interactive) p.intro(c.bold('splithub create'));\n\n let kind = str(flags.kind) as ExperimentKind | undefined;\n if (!kind) {\n if (!interactive) fail('USAGE', 'Which kind? Pass --kind value|component|redirect|mvt.');\n kind = await ask(\n p.select<ExperimentKind>({\n message: 'What changes between variants?',\n options: [\n { value: 'value', label: 'Text, image URL, number', hint: 'no new components' },\n { value: 'component', label: 'Layout / structure', hint: 'one component per variant' },\n { value: 'redirect', label: 'A whole page', hint: 'needs @splithub/next middleware' },\n { value: 'mvt', label: 'Several things at once', hint: 'multivariate: every combination, each factor read on its own' },\n ],\n })\n );\n }\n\n let id = str(flags.id);\n if (!id) {\n if (!interactive) fail('USAGE', 'Which id? Pass --id <key>, e.g. --id hero-title.');\n id = await ask(\n p.text({\n message: 'Experiment id',\n placeholder: 'hero-title',\n validate: (v) => (!KEY.test(v) ? 'lowercase a-z 0-9 - _ only' : hasExperiment(source, v) ? 'already exists' : undefined),\n })\n );\n }\n if (!['value', 'component', 'redirect', 'mvt'].includes(kind)) fail('INVALID_FLAG', `Unknown kind \"${kind}\".`, 'Use --kind value, component, redirect or mvt.');\n if (!KEY.test(id)) fail('INVALID_FLAG', `\"${id}\" isn't a valid id.`, 'Use lowercase a-z, 0-9, - and _, at most 64 characters.');\n if (hasExperiment(source, id) || config.experiments.some((e) => e.key === id)) fail('EXPERIMENT_EXISTS', `There's already an experiment \"${id}\".`, 'Pick another id: an old id keeps its history.');\n const limits = parseLimits(flags);\n\n // Multivariate: --factor headline=old:Old,new:New (repeatable); the variants are the combinations.\n const factors: Record<string, Record<string, string>> = {};\n if (kind === 'mvt') {\n for (const raw of list(flags.factor)) {\n const eq = raw.indexOf('=');\n if (eq <= 0) fail('INVALID_FLAG', `--factor expects name=level:value,level:value, got \"${raw}\".`);\n const name = raw.slice(0, eq).trim();\n const levels: Record<string, string> = {};\n for (const part of raw.slice(eq + 1).split(',')) {\n const colon = part.indexOf(':');\n const level = (colon >= 0 ? part.slice(0, colon) : part).trim();\n if (!level) continue;\n levels[level] = colon >= 0 ? part.slice(colon + 1).trim() : level;\n }\n factors[name] = levels;\n }\n while (interactive && Object.keys(factors).length === 0) {\n const name = await ask(p.text({ message: 'Factor name (what changes), e.g. headline', validate: (v) => (!KEY.test(v) ? 'lowercase a-z 0-9 - _ only' : undefined) }));\n const levelsRaw = await ask(p.text({ message: `Levels of \"${name}\" as key:value, comma separated (first = control)`, placeholder: 'old:Old headline, new:New headline' }));\n const levels: Record<string, string> = {};\n for (const part of levelsRaw.split(',')) {\n const colon = part.indexOf(':');\n const level = (colon >= 0 ? part.slice(0, colon) : part).trim();\n if (level) levels[level] = colon >= 0 ? part.slice(colon + 1).trim() : level;\n }\n factors[name] = levels;\n while (await ask(p.confirm({ message: 'Add another factor?', initialValue: false }))) {\n const more = await ask(p.text({ message: 'Factor name', validate: (v) => (!KEY.test(v) ? 'lowercase a-z 0-9 - _ only' : undefined) }));\n const moreRaw = await ask(p.text({ message: `Levels of \"${more}\" as key:value, comma separated`, placeholder: 'blue:#2563eb, green:#16a34a' }));\n const moreLevels: Record<string, string> = {};\n for (const part of moreRaw.split(',')) {\n const colon = part.indexOf(':');\n const level = (colon >= 0 ? part.slice(0, colon) : part).trim();\n if (level) moreLevels[level] = colon >= 0 ? part.slice(colon + 1).trim() : level;\n }\n factors[more] = moreLevels;\n }\n }\n if (Object.keys(factors).length === 0) fail('USAGE', 'An mvt experiment needs factors.', 'Pass --factor name=level:value,level:value once per factor.');\n if (flags.variants || flags.weights) fail('INVALID_FLAG', 'An mvt experiment takes --factor, not --variants or --weights.', 'Its variants are every combination of the factor levels, split equally.');\n }\n let mvt: ReturnType<typeof mvtVariants> | null = null;\n try {\n mvt = kind === 'mvt' ? mvtVariants(id, factors) : null;\n } catch (error) {\n fail('INVALID_FLAG', error instanceof Error ? error.message : String(error), 'At most 4 factors × 4 levels, 16 combinations.');\n }\n\n let variantKeys = mvt ? mvt.variants.map((v) => v.key) : str(flags.variants)?.split(',').map((s) => s.trim()).filter(Boolean);\n if (!variantKeys || variantKeys.length < 2) {\n if (!interactive) variantKeys = ['control', 'b'];\n else {\n const v = await ask(p.text({ message: 'Variant keys, comma separated (first = control)', initialValue: 'control, b' }));\n variantKeys = v.split(',').map((s) => s.trim()).filter(Boolean);\n }\n }\n for (const k of variantKeys) if (!KEY.test(k)) fail('INVALID_FLAG', `\"${k}\" isn't a valid variant key.`, 'Use lowercase a-z, 0-9, - and _.');\n if (variantKeys.length < 2) fail('INVALID_FLAG', 'An experiment needs at least 2 variants.', 'Pass --variants control,b.');\n if (new Set(variantKeys).size !== variantKeys.length) fail('INVALID_FLAG', 'Two variants have the same key.');\n\n const weights = mvt ? variantKeys.map(() => 1) : parseWeights(str(flags.weights), variantKeys.length);\n\n const values = parsePairs(list(flags.value));\n const tos = parsePairs(list(flags.to));\n if (kind === 'value' && interactive) {\n for (const k of variantKeys) {\n if (values[k] === undefined) values[k] = await ask(p.text({ message: `Value for \"${k}\"`, placeholder: k === variantKeys[0] ? 'current text' : 'new text' }));\n }\n }\n let match = str(flags.match);\n if (kind === 'redirect') {\n if (!match) {\n if (!interactive) fail('USAGE', 'A redirect experiment needs the path it runs on.', 'Pass --match /path.');\n match = await ask(p.text({ message: 'Path to run the redirect experiment on', initialValue: '/' }));\n }\n for (const k of variantKeys) {\n if (tos[k] === undefined) {\n if (!interactive) tos[k] = k === variantKeys[0] ? match : `${match.replace(/\\/$/, '')}/${k}`;\n else tos[k] = await ask(p.text({ message: `URL for \"${k}\"`, initialValue: k === variantKeys[0] ? match : '' }));\n }\n }\n }\n\n // The goal is any event name: one not declared in goals becomes an event goal when the config loads.\n let goal = str(flags.goal);\n const goals = config.goals.map((g) => g.key);\n if (!goal) {\n if (!interactive) goal = goals[0];\n else if (goals.length > 0) {\n goal = await ask(\n p.select<string>({\n message: 'Goal to optimise',\n options: [...goals.map((g) => ({ value: g, label: g })), { value: '?', label: 'another event' }, { value: '', label: 'none yet (add later)' }],\n })\n );\n if (goal === '?') goal = await ask(p.text({ message: 'Event name', placeholder: 'signup', validate: (v) => (v && !EVENT_NAME_PATTERN.test(v) ? 'Letters, digits, spaces and _ . : / -, up to 64 characters.' : undefined) }));\n if (!goal) goal = undefined;\n } else {\n goal = await ask(p.text({ message: 'Goal: the event this experiment should raise (blank for later)', placeholder: 'signup', validate: (v) => (v && !EVENT_NAME_PATTERN.test(v) ? 'Letters, digits, spaces and _ . : / -, up to 64 characters.' : undefined) }));\n if (!goal) goal = undefined;\n }\n }\n if (goal) checkEventName(goal, '--goal');\n const isNewGoal = goal ? !goals.includes(goalKeyFor(config.goals, goal) ?? '') : false;\n const extras = parseExtras(flags, config.goals, goal);\n\n // Running by default: the experiment goes live with the deploy that ships its code, first page views included.\n const status = (str(flags.status) as ExperimentStatus | undefined) ?? 'running';\n if (!['draft', 'running', 'paused'].includes(status)) fail('INVALID_FLAG', `A new experiment can't be \"${status}\".`, 'Use --status running or --status draft.');\n const description = str(flags.description);\n const name = str(flags.name)?.trim() || undefined;\n if (name && name.length > 80) fail('INVALID_FLAG', 'The name is longer than 80 characters.', 'Use a shorter --name; the key stays the id.');\n\n const experiment: NewExperiment = {\n key: id,\n kind,\n status,\n goal,\n match,\n name,\n description,\n variants: mvt ? mvt.variants.map((v) => ({ key: v.key, weight: v.weight })) : variantKeys.map((k, i) => ({ key: k, weight: weights[i]!, value: values[k], to: tos[k] })),\n ...(mvt ? { factors } : {}),\n ...limits,\n ...extras,\n };\n\n await writeConfigChecked(project.configFile, source, insertExperiment(extras.layer ? ensureLayer(source, extras.layer.key) : source, experiment), (loaded) => {\n const e = loaded.experiments.find((x) => x.key === id);\n if (!e) return `\"${id}\" is not in the file after the write`;\n if (e.status !== status) return `\"${id}\" loads as ${e.status}, not ${status}`;\n if (limits.minDays !== undefined && e.minDays !== limits.minDays) return `\"${id}\" loads with minDays ${e.minDays ?? 'unset'}, not ${limits.minDays}`;\n if (limits.goodSample !== undefined && e.goodSample !== limits.goodSample) return `\"${id}\" loads with goodSample ${e.goodSample ?? 'unset'}, not ${limits.goodSample}`;\n return null;\n });\n\n const files: string[] = [];\n const componentNames: Record<string, string> = {};\n if (kind === 'component') {\n const dir = join(project.root, project.hasSrc ? 'src/splithub' : 'splithub', id);\n mkdirSync(dir, { recursive: true });\n for (const k of variantKeys) {\n const name = `${pascal(id)}${pascal(k)}`;\n componentNames[k] = name;\n const file = join(dir, `${pascal(k)}.tsx`);\n if (!existsSync(file)) {\n writeFileSync(file, componentVariantTemplate(name, id, k), 'utf8');\n files.push(relative(project.root, file));\n }\n }\n }\n\n const snippet =\n kind === 'mvt'\n ? `const { ${Object.keys(factors).join(', ')} } = useValue<{ ${Object.keys(factors).map((f) => `${f}: string`).join('; ')} }>('${id}');`\n : kind === 'value'\n ? `const value = useValue<string>('${id}');`\n : kind === 'component'\n ? `<Experiment id=\"${id}\">\\n${variantKeys.map((k) => ` <Variant name=\"${k}\"><${componentNames[k]} /></Variant>`).join('\\n')}\\n</Experiment>`\n : `// handled by @splithub/next middleware on ${match}; no code needed`;\n\n const goalKey = goal ? goalKeyFor(config.goals, goal) : null;\n const result = { experiment: id, kind, status, variants: experiment.variants, goal: goalKey, traffic: limits.traffic ?? 1, maxVisitors: limits.maxExposures ?? null, minDays: limits.minDays ?? null, goodSample: limits.goodSample ?? null, schedule: limits.schedule ?? null, configFile: relative(project.root, project.configFile), files, snippet };\n if (json) {\n const cloudMode = /mode\\s*:\\s*['\"]cloud['\"]/.test(readSource(project.configFile));\n // Agents read this JSON: the hand-off line makes sure the human learns the experiment is not live yet.\n const handoff =\n status === 'draft'\n ? `${id} is a draft: visitors do not see it and nothing is recorded until it is started. Tell the user and ask whether to start it now (npx splithub start ${id}).`\n : `${id} is running in the config: it goes live for visitors when this code is deployed${cloudMode ? ' and pushed; local development never sends events to the cloud' : ''}. Tell the user, and that npx splithub pause ${id} or Pause in the dashboard holds it.`;\n const nextStep = cloudMode ? `npx splithub push # the cloud does not know about ${id} until you push` : status === 'draft' ? `npx splithub start ${id}` : 'deploy the app';\n printJson({ ...result, ...(isNewGoal && goal ? { goalNote: newGoalNote(goal) } : {}), nextStep, handoff });\n return;\n }\n if (isNewGoal && goal) p.log.info(newGoalNote(goal));\n p.note(snippet, kind === 'redirect' ? 'Nothing to wire' : 'Wire it in your code');\n if (files.length) p.note(files.join('\\n'), 'Scaffolded');\n const cloud = /mode\\s*:\\s*['\"]cloud['\"]/.test(readSource(project.configFile));\n if (cloud) p.log.warn(`Cloud mode: the cloud does not know about it until you run ${c.cyan('npx splithub push')}.`);\n if (status === 'draft') p.log.warn(`${c.bold(id)} is a draft: visitors do not see it and nothing is recorded until you start it.`);\n if (status === 'running') p.log.info(`${c.bold(id)} goes live when you deploy this code. Check it first with ${c.cyan(`?sh_force=${id}:<variant>`)}; ${c.cyan(`npx splithub pause ${id}`)} holds it.`);\n if (status === 'draft') p.log.info(`See it before you start it: ${c.cyan('runDraftsInDev: true')} in the config serves drafts in development, ${c.cyan(`?sh_force=${id}:<variant>`)} shows one variant anywhere.`);\n p.outro(`Added ${c.bold(id)} (${status}) to ${relative(project.root, project.configFile)}. ${status === 'running' ? '' : `Start it with ${c.cyan(`npx splithub start ${id}`)}. `}${cloud ? `Then ${c.cyan('npx splithub push')}.` : ''}`);\n}\n\n/** --weights 50,50: one non-negative number per variant, not all zero. Equal weights when absent. */\nexport function parseWeights(raw: string | undefined, count: number): number[] {\n if (!raw) return Array.from({ length: count }, () => 1);\n const weights = raw.split(',').map((w) => Number(w.trim()));\n if (weights.length !== count) fail('INVALID_FLAG', `--weights has ${weights.length} numbers for ${count} variants.`, 'Give one weight per variant, in the same order: --weights 50,50.');\n if (weights.some((w) => !Number.isFinite(w) || w < 0)) fail('INVALID_FLAG', `--weights \"${raw}\" has a value that isn't a number of 0 or more.`);\n if (weights.every((w) => w === 0)) fail('INVALID_FLAG', 'All weights are 0, so nobody would see the experiment.');\n return weights;\n}\n\nexport interface Limits {\n traffic?: number;\n maxExposures?: number;\n minDays?: number;\n goodSample?: number;\n schedule?: { startAt: string | null; endAt: string | null };\n}\n\n/** --traffic (percent, 0 < t <= 100), --max-visitors (whole number > 0), --min-days (whole number 0..30), --good-sample (whole number 100..10,000,000), --start / --end (dates, start before end). */\nexport function parseLimits(flags: Flags): Limits {\n const out: Limits = {};\n const traffic = str(flags.traffic);\n if (traffic !== undefined) {\n const t = Number(traffic.replace(/%$/, ''));\n if (!Number.isFinite(t) || t <= 0 || t > 100) fail('INVALID_FLAG', `--traffic \"${traffic}\" must be a percent between 0 and 100.`, 'For example --traffic 50 puts half of the visitors in the experiment.');\n if (t !== 100) out.traffic = Math.round(t * 100) / 10000;\n }\n const max = str(flags['max-visitors']);\n if (max !== undefined) {\n const m = Number(max);\n if (!Number.isInteger(m) || m <= 0) fail('INVALID_FLAG', `--max-visitors \"${max}\" must be a whole number above 0.`);\n out.maxExposures = m;\n }\n const minDays = str(flags['min-days']);\n if (minDays !== undefined) {\n const d = Number(minDays);\n if (!Number.isInteger(d) || d < 0 || d > 30) fail('INVALID_FLAG', `--min-days \"${minDays}\" must be a whole number from 0 to 30.`, 'It is the fewest days before a verdict; 0 means none, the default.');\n out.minDays = d;\n }\n const good = str(flags['good-sample']);\n if (good !== undefined) {\n const g = Number(good);\n if (!Number.isInteger(g) || g < 100 || g > 10_000_000) fail('INVALID_FLAG', `--good-sample \"${good}\" must be a whole number from 100 to 10,000,000.`, 'It is the total visitors at which the sample counts as good; the default is 5000.');\n out.goodSample = g;\n }\n const date = (name: 'start' | 'end'): string | null => {\n const v = str(flags[name]);\n if (v === undefined) return null;\n const ms = Date.parse(v);\n if (Number.isNaN(ms)) fail('INVALID_FLAG', `--${name} \"${v}\" isn't a date.`, 'Use an ISO date like 2026-11-01 or 2026-11-01T09:00:00Z.');\n return new Date(ms).toISOString();\n };\n const startAt = date('start');\n const endAt = date('end');\n if (startAt && endAt && Date.parse(endAt) <= Date.parse(startAt)) fail('INVALID_FLAG', '--end must be after --start.');\n if (startAt || endAt) out.schedule = { startAt, endAt };\n return out;\n}\n\nfunction checkEventName(name: string, flag: string): void {\n if (!EVENT_NAME_PATTERN.test(name) || !goalKeyFor([], name)) fail('INVALID_FLAG', `${flag} \"${name}\" is not an event name.`, 'Use letters, digits, spaces and _ . : / -, up to 64 characters (signup, Video Played).');\n}\n\n/** What the user reads when the goal is an event no goal declared yet. */\nfunction newGoalNote(name: string): string {\n return `\"${name}\" becomes a goal: every track('${name}') now counts for this experiment.`;\n}\n\n/**\n * --secondary a,b (goals to watch) · --guardrail refunds:higher,errors (goals that must not get worse;\n * :higher when a rise is bad, default :lower) · --layer key:0-50 (mutual exclusion, buckets [start, end)).\n */\nexport function parseExtras(flags: Flags, goals: Array<{ key: string; event?: string }>, primary: string | undefined): Pick<NewExperiment, 'metrics' | 'layer'> {\n const out: Pick<NewExperiment, 'metrics' | 'layer'> = {};\n const split = (v: unknown) => list(v).flatMap((x) => x.split(',')).map((x) => x.trim()).filter(Boolean);\n const secondary = split(flags.secondary);\n const guardrails = split(flags.guardrail).map((g) => {\n const [goal = '', worse] = g.split(':');\n if (worse !== undefined && worse !== 'lower' && worse !== 'higher') fail('INVALID_FLAG', `--guardrail \"${g}\": after the colon comes lower or higher.`, 'refunds:higher means more refunds is worse; signups (or signups:lower) means fewer is worse.');\n return worse === 'higher' ? { goal, worse: 'higher' as const } : goal;\n });\n const named = [...secondary, ...guardrails.map((g) => (typeof g === 'string' ? g : g.goal))];\n if (named.length) {\n if (!primary) fail('USAGE', 'Secondary metrics and guardrails need a primary goal.', 'Pass --goal too.');\n for (const g of named) checkEventName(g, '--secondary / --guardrail');\n const all = [primary, ...named].map((g) => goalKeyFor(goals, g));\n if (new Set(all).size !== all.length) fail('INVALID_FLAG', 'A goal is listed twice across --goal, --secondary and --guardrail.');\n out.metrics = { ...(secondary.length ? { secondary } : {}), ...(guardrails.length ? { guardrails } : {}) };\n }\n const layer = str(flags.layer);\n if (layer) {\n const m = /^([a-z0-9][a-z0-9_-]{0,63}):(\\d{1,3})-(\\d{1,3})$/.exec(layer);\n const start = Number(m?.[2]);\n const end = Number(m?.[3]);\n if (!m || !(start < end) || end > 100) fail('INVALID_FLAG', `--layer \"${layer}\" must look like key:start-end with 0 <= start < end <= 100.`, 'For example --layer checkout:0-50; another experiment in checkout:50-100 never shares a visitor.');\n out.layer = { key: m[1]!, range: [start, end] };\n }\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY,OAAO;AACnB,SAAS,oBAAoB,YAAY,mBAA+D;AACxG,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,MAAM,gBAAgB;AAQ/B,IAAM,MAAM;AAEZ,SAAS,IAAI,GAAgC;AAC3C,SAAO,OAAO,MAAM,YAAY,EAAE,SAAS,IAAI,IAAI;AACrD;AACA,SAAS,KAAK,GAAsB;AAClC,MAAI,MAAM,QAAQ,CAAC,EAAG,QAAO,EAAE,IAAI,MAAM;AACzC,MAAI,OAAO,MAAM,SAAU,QAAO,CAAC,CAAC;AACpC,SAAO,CAAC;AACV;AACA,SAAS,WAAW,OAAyC;AAC3D,QAAM,MAA8B,CAAC;AACrC,aAAW,QAAQ,OAAO;AACxB,UAAM,IAAI,KAAK,QAAQ,GAAG;AAC1B,QAAI,IAAI,EAAG,KAAI,KAAK,MAAM,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC;AAAA,EAC5D;AACA,SAAO;AACT;AACA,SAAS,OAAO,GAAmB;AACjC,SAAO,EAAE,QAAQ,uBAAuB,CAAC,GAAG,IAAI,OAAe,GAAG,YAAY,CAAC;AACjF;AAEA,eAAe,IAAO,SAA0C;AAC9D,QAAM,IAAI,MAAM;AAChB,MAAM,WAAS,CAAC,GAAG;AACjB,IAAE,SAAO,YAAY;AACrB,YAAQ,KAAK,CAAC;AAAA,EAChB;AAC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SAAS,IAAI,OAAQ,MAAK,gBAAgB,oEAAoE;AAC/H,QAAI,UAAU,EAAE,GAAI,UAAU,SAAS,EAAE,UAAU,IAAI,CAAC,GAAI,GAAI,WAAW,SAAS,EAAE,WAAW,IAAI,CAAC,EAAG;AAAA,EAC3G;AACA,QAAM,QAAQ,IAAI,MAAM,KAAK;AAC7B,MAAI,OAAO;AACT,UAAM,IAAI,mDAAmD,KAAK,KAAK;AACvE,UAAM,QAAQ,OAAO,IAAI,CAAC,CAAC;AAC3B,UAAM,MAAM,OAAO,IAAI,CAAC,CAAC;AACzB,QAAI,CAAC,KAAK,EAAE,QAAQ,QAAQ,MAAM,IAAK,MAAK,gBAAgB,YAAY,KAAK,gEAAgE,kGAAkG;AAC/O,QAAI,QAAQ,EAAE,KAAK,EAAE,CAAC,GAAI,OAAO,CAAC,OAAO,GAAG,EAAE;AAAA,EAChD;AACA,SAAO;AACT;","names":["name"]}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
writeWorkflow
|
|
4
|
+
} from "./chunk-RMWW4YMN.js";
|
|
2
5
|
import {
|
|
3
6
|
deviceLogin
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NFZZSF4M.js";
|
|
5
8
|
import {
|
|
6
9
|
installSkills,
|
|
7
10
|
loadSkillFiles
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NYWJZKOO.js";
|
|
9
12
|
import {
|
|
10
13
|
configTemplate,
|
|
11
14
|
nextMiddlewareTemplate,
|
|
12
15
|
nextRouteTemplate
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import {
|
|
15
|
-
cloudTarget,
|
|
16
|
-
loadCredential
|
|
17
|
-
} from "./chunk-4YXB73AZ.js";
|
|
18
|
-
import {
|
|
19
|
-
writeWorkflow
|
|
20
|
-
} from "./chunk-PMER7I7F.js";
|
|
16
|
+
} from "./chunk-OXVLWFSD.js";
|
|
21
17
|
import {
|
|
22
18
|
detectProject,
|
|
23
19
|
installCommand
|
|
24
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-MUDDASN6.js";
|
|
21
|
+
import {
|
|
22
|
+
cloudTarget,
|
|
23
|
+
loadCredential
|
|
24
|
+
} from "./chunk-4OQEIP33.js";
|
|
25
25
|
import {
|
|
26
26
|
c
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-ZISCJRR5.js";
|
|
28
28
|
|
|
29
29
|
// src/commands/init.ts
|
|
30
30
|
import * as p from "@clack/prompts";
|
|
@@ -34,14 +34,14 @@ import { dirname, join, relative } from "path";
|
|
|
34
34
|
|
|
35
35
|
// src/templates-store.ts
|
|
36
36
|
var DB_KINDS = ["sqlite", "postgres", "mysql", "custom"];
|
|
37
|
-
var PG_STORE = `import { countsFromRow, variantCountsSql, type ExperimentSummary, type Store, type StoredEvent, type StoreVariantCounts } from '@splithub/node';
|
|
37
|
+
var PG_STORE = `import { countsFromRow, propertyCountsFromRows, propertyCountsSql, storedEventFromRow, variantCountsSql, type ExperimentSummary, type PropertyCounts, type Store, type StoredEvent, type StoreVariantCounts } from '@splithub/node';
|
|
38
38
|
import { Pool } from 'pg';
|
|
39
39
|
|
|
40
40
|
// SplitHub events in your Postgres. Run once (or add to your migrations):
|
|
41
41
|
export const SCHEMA_SQL = \`
|
|
42
42
|
CREATE TABLE IF NOT EXISTS splithub_events (
|
|
43
43
|
id text PRIMARY KEY,
|
|
44
|
-
type text NOT NULL, -- exposure | goal
|
|
44
|
+
type text NOT NULL, -- exposure | goal | page | event | engage | identify (analytics rows: experiment = property, goal = event name)
|
|
45
45
|
experiment text,
|
|
46
46
|
variant text,
|
|
47
47
|
goal text,
|
|
@@ -62,6 +62,9 @@ CREATE INDEX IF NOT EXISTS splithub_events_goal ON splithub_events (type, goal,
|
|
|
62
62
|
|
|
63
63
|
// The attribution rule shared by every SplitHub store (first exposure, 60 s clock skew, 50 goals per visitor and day).
|
|
64
64
|
const counts = variantCountsSql({ dialect: 'postgres', table: 'splithub_events' });
|
|
65
|
+
// Analytics properties: pageviews, events, engagement and identify rows share the table; raw counts
|
|
66
|
+
// only (users = distinct ids sent with identify).
|
|
67
|
+
const prop = propertyCountsSql({ dialect: 'postgres', table: 'splithub_events' });
|
|
65
68
|
|
|
66
69
|
export function pgStore(pool: Pool = new Pool({ connectionString: process.env.DATABASE_URL })): Store {
|
|
67
70
|
return {
|
|
@@ -90,18 +93,26 @@ export function pgStore(pool: Pool = new Pool({ connectionString: process.env.DA
|
|
|
90
93
|
);
|
|
91
94
|
return r.rows.map((x) => ({ experiment: String(x.experiment), exposures: Number(x.exposures), visitors: Number(x.visitors), firstExposureAt: x.first_ts == null ? null : Number(x.first_ts), lastExposureAt: x.last_ts == null ? null : Number(x.last_ts) }));
|
|
92
95
|
},
|
|
96
|
+
async propertyCounts(property: string, since: number, until?: number): Promise<PropertyCounts> {
|
|
97
|
+
const [totals, events] = await Promise.all([pool.query(prop.totals.sql, prop.totals.bind({ property, since, until })), pool.query(prop.events.sql, prop.events.bind({ property, since, until }))]);
|
|
98
|
+
return propertyCountsFromRows(totals.rows[0], events.rows);
|
|
99
|
+
},
|
|
100
|
+
async propertyEvents(property: string, { before, limit }: { before: number; limit: number }): Promise<StoredEvent[]> {
|
|
101
|
+
const r = await pool.query(prop.rows.sql, prop.rows.bind({ property, before, limit }));
|
|
102
|
+
return r.rows.map(storedEventFromRow);
|
|
103
|
+
},
|
|
93
104
|
close: () => pool.end(),
|
|
94
105
|
};
|
|
95
106
|
}
|
|
96
107
|
`;
|
|
97
|
-
var MYSQL_STORE = `import { countsFromRow, variantCountsSql, type ExperimentSummary, type Store, type StoredEvent, type StoreVariantCounts } from '@splithub/node';
|
|
108
|
+
var MYSQL_STORE = `import { countsFromRow, propertyCountsFromRows, propertyCountsSql, storedEventFromRow, variantCountsSql, type ExperimentSummary, type PropertyCounts, type Store, type StoredEvent, type StoreVariantCounts } from '@splithub/node';
|
|
98
109
|
import mysql, { type Pool } from 'mysql2/promise';
|
|
99
110
|
|
|
100
111
|
// SplitHub events in your MySQL / MariaDB / PlanetScale. Run once (or add to your migrations):
|
|
101
112
|
export const SCHEMA_SQL = \`
|
|
102
113
|
CREATE TABLE IF NOT EXISTS splithub_events (
|
|
103
114
|
id VARCHAR(64) PRIMARY KEY,
|
|
104
|
-
type VARCHAR(16) NOT NULL,
|
|
115
|
+
type VARCHAR(16) NOT NULL, -- exposure | goal | page | event | engage | identify
|
|
105
116
|
experiment VARCHAR(64) NULL,
|
|
106
117
|
variant VARCHAR(64) NULL,
|
|
107
118
|
goal VARCHAR(64) NULL,
|
|
@@ -122,6 +133,9 @@ CREATE TABLE IF NOT EXISTS splithub_events (
|
|
|
122
133
|
|
|
123
134
|
// The attribution rule shared by every SplitHub store (first exposure, 60 s clock skew, 50 goals per visitor and day).
|
|
124
135
|
const counts = variantCountsSql({ dialect: 'mysql', table: 'splithub_events' });
|
|
136
|
+
// Analytics properties: pageviews, events, engagement and identify rows share the table; raw counts
|
|
137
|
+
// only (users = distinct ids sent with identify).
|
|
138
|
+
const prop = propertyCountsSql({ dialect: 'mysql', table: 'splithub_events' });
|
|
125
139
|
|
|
126
140
|
export function mysqlStore(pool: Pool = mysql.createPool(process.env.DATABASE_URL ?? '')): Store {
|
|
127
141
|
return {
|
|
@@ -145,6 +159,14 @@ export function mysqlStore(pool: Pool = mysql.createPool(process.env.DATABASE_UR
|
|
|
145
159
|
);
|
|
146
160
|
return (rows as Array<Record<string, unknown>>).map((x) => ({ experiment: String(x.experiment), exposures: Number(x.exposures), visitors: Number(x.visitors), firstExposureAt: x.first_ts == null ? null : Number(x.first_ts), lastExposureAt: x.last_ts == null ? null : Number(x.last_ts) }));
|
|
147
161
|
},
|
|
162
|
+
async propertyCounts(property: string, since: number, until?: number): Promise<PropertyCounts> {
|
|
163
|
+
const [[totals], [events]] = await Promise.all([pool.query(prop.totals.sql, prop.totals.bind({ property, since, until })), pool.query(prop.events.sql, prop.events.bind({ property, since, until }))]);
|
|
164
|
+
return propertyCountsFromRows((totals as Array<Record<string, unknown>>)[0], events as Array<Record<string, unknown>>);
|
|
165
|
+
},
|
|
166
|
+
async propertyEvents(property: string, { before, limit }: { before: number; limit: number }): Promise<StoredEvent[]> {
|
|
167
|
+
const [rows] = await pool.query(prop.rows.sql, prop.rows.bind({ property, before, limit }));
|
|
168
|
+
return (rows as Array<Record<string, unknown>>).map(storedEventFromRow);
|
|
169
|
+
},
|
|
148
170
|
close: () => pool.end(),
|
|
149
171
|
};
|
|
150
172
|
}
|
|
@@ -164,6 +186,11 @@ var CUSTOM_STORE = `import { attributeVariants, type ExperimentSummary, type Sto
|
|
|
164
186
|
* Columns worth keeping: id (unique, dedupe on it), type, experiment, variant,
|
|
165
187
|
* goal, visitor_id, session_id, ts, url, props (json), received_at, host,
|
|
166
188
|
* country, device, browser.
|
|
189
|
+
* Analytics (optional): \`page\`, \`event\`, \`engage\` and \`identify\` rows carry the
|
|
190
|
+
* property key in \`experiment\` (and the event name in \`goal\`); engage props are
|
|
191
|
+
* { ms, scroll }, identify props { uid, traits }. Store them like the others and add
|
|
192
|
+
* propertyCounts(property, since, until?) (or run propertyCountsSql, which also counts users)
|
|
193
|
+
* to read them with \`splithub analytics\`.
|
|
167
194
|
*/
|
|
168
195
|
export function customStore(): Store {
|
|
169
196
|
return {
|
|
@@ -391,4 +418,4 @@ function cancel2() {
|
|
|
391
418
|
export {
|
|
392
419
|
init
|
|
393
420
|
};
|
|
394
|
-
//# sourceMappingURL=chunk-
|
|
421
|
+
//# sourceMappingURL=chunk-VY342F4X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/init.ts","../src/templates-store.ts"],"sourcesContent":["import * as p from '@clack/prompts';\nimport { execSync } from 'node:child_process';\nimport { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative } from 'node:path';\nimport { cloudTarget } from '../api';\nimport { loadCredential } from '../credentials';\nimport { detectProject, installCommand } from '../project';\nimport { deviceLogin } from './login';\nimport { configTemplate, nextMiddlewareTemplate, nextRouteTemplate } from '../templates';\nimport { DB_KINDS, runtimePackages, storeTemplate, storeUsage, type DbKind } from '../templates-store';\nimport { installSkills, loadSkillFiles } from './skills';\nimport { writeWorkflow } from './ci';\nimport { c } from '../ui';\n\nexport type Flags = Record<string, string | boolean | string[] | undefined>;\n\nfunction str(v: unknown): string | undefined {\n return typeof v === 'string' ? v : undefined;\n}\n\nfunction writeIfMissing(file: string, content: string, created: string[], skipped: string[]): void {\n if (existsSync(file)) {\n skipped.push(file);\n return;\n }\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, content, 'utf8');\n created.push(file);\n}\n\nfunction importPath(fromFile: string, toFile: string): string {\n let rel = relative(dirname(fromFile), toFile).replace(/\\\\/g, '/').replace(/\\.(ts|mts|js|mjs)$/, '');\n if (!rel.startsWith('.')) rel = `./${rel}`;\n return rel;\n}\n\n// Vite apps run the SDK in the browser; this plugin prints what each experiment does in the dev server's terminal.\nconst VITE_PLUGIN_HINT = `// vite.config.ts\nimport { splithub } from '@splithub/core/vite';\n\nexport default defineConfig({ plugins: [react(), splithub()] });`;\n\nexport async function init(flags: Flags): Promise<void> {\n const yes = Boolean(flags.yes);\n const json = Boolean(flags.json);\n const project = detectProject();\n const created: string[] = [];\n const skipped: string[] = [];\n\n if (!json) p.intro(c.bold('splithub init'));\n\n let mode = str(flags.mode) as 'self' | 'cloud' | undefined;\n if (!mode) {\n if (yes) mode = 'self';\n else {\n const picked = await p.select({\n message: 'Where should events be stored?',\n options: [\n { value: 'self', label: 'My own database (self-hosted)', hint: 'free forever, nothing leaves your infra' },\n { value: 'cloud', label: 'SplitHub Cloud', hint: 'hosted dashboard, no server code' },\n ],\n });\n if (p.isCancel(picked)) return cancel();\n mode = picked as 'self' | 'cloud';\n }\n }\n\n // Cloud: connect this directory to a project. A saved login or SPLITHUB_API_KEY\n // is enough; otherwise run the device flow — print a link, the human signs in\n // and picks (or creates) the project, the CLI gets the keys. Works when an\n // agent runs init: it relays the link, the user clicks it.\n // Self mode: which database keeps the events. sqlite needs nothing; postgres / mysql\n // get a ready Store in splithub/store.ts; custom gets a documented stub.\n let db: DbKind = (DB_KINDS as string[]).includes(str(flags.db) ?? '') ? (str(flags.db) as DbKind) : 'sqlite';\n if (mode === 'self' && !flags.db && !yes) {\n const picked = await p.select({\n message: 'Where should events be stored?',\n options: [\n { value: 'sqlite', label: 'SQLite file (zero setup)', hint: './splithub.db via node:sqlite' },\n { value: 'postgres', label: 'Postgres', hint: 'pg + DATABASE_URL, table splithub_events' },\n { value: 'mysql', label: 'MySQL / MariaDB / PlanetScale', hint: 'mysql2 + DATABASE_URL' },\n { value: 'custom', label: 'My own store (Prisma, Drizzle, Supabase, Mongo…)', hint: 'a stub with the three methods to fill in' },\n ],\n });\n if (p.isCancel(picked)) return cancel();\n db = picked as DbKind;\n }\n\n let key = str(flags.key);\n let connected: { projectName: string | null; projectId: string | null } | null = null;\n if (mode === 'cloud') {\n const api = cloudTarget(flags).url;\n const saved = loadCredential(api, project.root);\n if (saved) {\n key ??= saved.publicKey ?? undefined;\n connected = { projectName: saved.projectName, projectId: saved.projectId };\n } else if (!process.env.SPLITHUB_API_KEY && !flags['no-login']) {\n if (!json) p.log.step('Connect to SplitHub Cloud');\n try {\n const cred = await deviceLogin({\n api,\n root: project.root,\n json,\n onCode: json\n ? (s) => console.log(JSON.stringify({ step: 'approve', verifyUrl: s.verifyUrl, userCode: s.userCode, expiresIn: s.expiresIn, hint: 'Show this link to the user and wait; init continues once approved.' }))\n : (s) => p.note(`${c.cyan(s.verifyUrl)}\\n\\nCode ${c.green(s.userCode)} · sign in, pick or create the project, approve.`, 'Open this link'),\n });\n key ??= cred.publicKey ?? undefined;\n connected = { projectName: cred.projectName, projectId: cred.projectId };\n if (!json) p.log.success(`connected to ${c.cyan(cred.projectName ?? cred.projectId ?? 'project')}`);\n } catch (error) {\n if (!json) p.log.warn(`not connected: ${error instanceof Error ? error.message : String(error)}. Run ${c.cyan('npx splithub login')} later.`);\n }\n }\n // An API key in the environment (CI, agents) identifies the project: ask the cloud for its public key.\n if (!key && process.env.SPLITHUB_API_KEY) {\n try {\n const res = await fetch(`${api}/config`, { headers: { authorization: `Bearer ${process.env.SPLITHUB_API_KEY}` } });\n const body = (await res.json().catch(() => ({}))) as { publicKey?: string };\n if (typeof body.publicKey === 'string' && body.publicKey.startsWith('pk_')) {\n key = body.publicKey;\n connected ??= { projectName: null, projectId: null };\n }\n } catch {\n // offline: the first push writes the key into the config anyway\n }\n }\n if (!key && !yes) {\n const k = await p.text({ message: 'Cloud public key (pk_...), leave empty to set later via NEXT_PUBLIC_SPLITHUB_KEY', placeholder: 'pk_' });\n if (p.isCancel(k)) return cancel();\n key = k || undefined;\n }\n }\n\n // 1. config\n const configFile = project.configFile ?? join(project.root, 'splithub.config.ts');\n writeIfMissing(configFile, configTemplate(project.name, mode, key), created, skipped);\n\n // 2a. store for self mode (postgres / mysql / custom); sqlite needs no file.\n const storeBody = mode === 'self' ? storeTemplate(db) : null;\n const storeFile = storeBody ? join(project.root, 'splithub', 'store.ts') : null;\n if (storeFile && storeBody) writeIfMissing(storeFile, storeBody, created, skipped);\n\n // 2. framework files\n if (project.framework === 'next') {\n const mwFile = join(project.root, project.hasSrc ? 'src/middleware.ts' : 'middleware.ts');\n writeIfMissing(mwFile, nextMiddlewareTemplate(importPath(mwFile, configFile)), created, skipped);\n if (mode === 'self' && project.appDir) {\n const routeFile = join(project.root, project.appDir, 'api/splithub/[[...path]]/route.ts');\n writeIfMissing(routeFile, nextRouteTemplate(importPath(routeFile, configFile), storeUsage(db, storeFile ? importPath(routeFile, storeFile) : '')), created, skipped);\n }\n }\n\n // 3. agent skills (+ MCP server registration): the agent learns the library, how to test\n // well, the API and the MCP tools from .claude/skills/*; Cursor gets the rule file.\n let mcp = !flags['no-mcp'];\n if (!yes && !json && mcp) {\n const want = await p.confirm({ message: 'Register the SplitHub MCP server for Claude Code / Cursor (.mcp.json, .cursor/mcp.json)?', initialValue: true });\n if (p.isCancel(want)) return cancel();\n mcp = want;\n }\n const skillsResult = installSkills(project.root, { mcp, ...(await loadSkillFiles(flags)) });\n created.push(...skillsResult.written, ...skillsResult.mcp.map((f) => `${f} (MCP server)`));\n skipped.push(...skillsResult.skipped);\n\n // 3b. GitHub workflow: checks on PRs, results comment on a schedule.\n if (flags['github-action']) {\n const wf = writeWorkflow(project.root, Boolean(flags.force));\n (wf.written ? created : skipped).push(join(project.root, wf.file));\n }\n\n // 4. dependencies\n const runtime = ['@splithub/react', '@splithub/core'];\n if (project.framework === 'next') runtime.push('@splithub/next');\n if (mode === 'self') runtime.push('@splithub/node', ...runtimePackages(db));\n const installRuntime = installCommand(project.packageManager, runtime);\n const installDev = installCommand(project.packageManager, ['splithub'], true);\n let installed = false;\n if (!flags['no-install']) {\n const go = yes ? true : await p.confirm({ message: `Install packages now? (${installRuntime})` });\n if (p.isCancel(go)) return cancel();\n if (go) {\n const s = json ? null : p.spinner();\n s?.start('Installing');\n try {\n execSync(installRuntime, { cwd: project.root, stdio: json ? 'ignore' : 'inherit' });\n execSync(installDev, { cwd: project.root, stdio: json ? 'ignore' : 'inherit' });\n installed = true;\n s?.stop('Installed');\n } catch (error) {\n s?.stop('Install failed; run it manually');\n if (!json) p.log.error(error instanceof Error ? error.message : String(error));\n }\n }\n }\n\n const providerHint =\n project.framework === 'next'\n ? `// ${project.appDir ?? 'app'}/layout.tsx\\nimport { SplitHubNextProvider } from '@splithub/next/client';\\nimport { getSplitHub } from '@splithub/next/server';\\nimport config from '${importPath(join(project.root, project.appDir ?? 'app', 'layout.tsx'), configFile)}';\\n\\nexport default async function RootLayout({ children }) {\\n const sh = await getSplitHub(config);\\n return <html><body><SplitHubNextProvider config={config} visitorId={sh.visitorId ?? undefined} remoteOverrides={sh.overrides}>{children}</SplitHubNextProvider></body></html>;\\n}`\n : `// main.tsx\\nimport { SplitHubProvider } from '@splithub/react';\\nimport config from './splithub.config';\\n\\n<SplitHubProvider config={config}><App /></SplitHubProvider>`;\n\n const warning = mode === 'cloud' && !key ? 'No public key yet: storage.key falls back to process.env.NEXT_PUBLIC_SPLITHUB_KEY. It is written into the config by the first `npx splithub push`, by `npx splithub login` (saved with the credentials), or pass --key pk_… (dashboard → Setup); SPLITHUB_API_KEY in the environment also resolves it.' : null;\n const summary = { project: project.name, framework: project.framework, mode, db: mode === 'self' ? db : null, connected, publicKey: key ?? null, warning, created, skipped, installed, installCommands: installed ? [] : [installRuntime, installDev], nextStep: providerHint, ...(project.framework === 'vite' ? { vitePlugin: VITE_PLUGIN_HINT } : {}) };\n\n if (json) {\n console.log(JSON.stringify(summary));\n return;\n }\n if (warning) p.log.warn(warning);\n if (mode === 'self' && db !== 'sqlite') p.note(db === 'custom' ? 'Fill in the three methods in splithub/store.ts (the comments say what each must return).' : `Set DATABASE_URL and run the SCHEMA_SQL from splithub/store.ts once (or add it to your migrations).`, `Database: ${db}`);\n if (created.length) p.note(created.map((f) => relative(project.root, f) || f).join('\\n'), 'Created');\n if (skipped.length) p.note(skipped.map((f) => relative(project.root, f)).join('\\n'), 'Already present, left untouched');\n if (!installed) p.note(`${installRuntime}\\n${installDev}`, 'Install');\n p.note(providerHint, 'Wrap your app once');\n if (project.framework === 'vite') p.note(VITE_PLUGIN_HINT, 'Notes in your dev terminal');\n p.outro(`Next: ${c.cyan('npx splithub create')} to add your first experiment, ${c.cyan('npx splithub push')} to sync it, ${c.cyan('npx splithub doctor')} to verify.`);\n}\n\n\nfunction cancel(): void {\n p.cancel('Cancelled.');\n process.exit(0);\n}\n","// Store templates for self-hosted mode: `splithub init --mode self --db postgres|mysql|custom`\n// writes splithub/store.ts from one of these. Each implements the Store interface\n// from @splithub/node (insertEvents, variantCounts, summaries, and the raw analytics\n// reads propertyCounts / propertyEvents) with the same\n// attribution rule as the cloud, through variantCountsSql from @splithub/node.\n\nexport type DbKind = 'sqlite' | 'postgres' | 'mysql' | 'custom';\nexport const DB_KINDS: DbKind[] = ['sqlite', 'postgres', 'mysql', 'custom'];\n\nexport const PG_STORE = `import { countsFromRow, propertyCountsFromRows, propertyCountsSql, storedEventFromRow, variantCountsSql, type ExperimentSummary, type PropertyCounts, type Store, type StoredEvent, type StoreVariantCounts } from '@splithub/node';\nimport { Pool } from 'pg';\n\n// SplitHub events in your Postgres. Run once (or add to your migrations):\nexport const SCHEMA_SQL = \\`\nCREATE TABLE IF NOT EXISTS splithub_events (\n id text PRIMARY KEY,\n type text NOT NULL, -- exposure | goal | page | event | engage | identify (analytics rows: experiment = property, goal = event name)\n experiment text,\n variant text,\n goal text,\n visitor_id text NOT NULL,\n session_id text NOT NULL,\n ts bigint NOT NULL, -- client clock, unix ms\n url text,\n props jsonb,\n received_at bigint NOT NULL, -- server clock, unix ms\n host text,\n country text,\n device text,\n browser text\n);\nCREATE INDEX IF NOT EXISTS splithub_events_exp ON splithub_events (type, experiment, visitor_id, ts);\nCREATE INDEX IF NOT EXISTS splithub_events_goal ON splithub_events (type, goal, visitor_id, ts);\n\\`;\n\n// The attribution rule shared by every SplitHub store (first exposure, 60 s clock skew, 50 goals per visitor and day).\nconst counts = variantCountsSql({ dialect: 'postgres', table: 'splithub_events' });\n// Analytics properties: pageviews, events, engagement and identify rows share the table; raw counts\n// only (users = distinct ids sent with identify).\nconst prop = propertyCountsSql({ dialect: 'postgres', table: 'splithub_events' });\n\nexport function pgStore(pool: Pool = new Pool({ connectionString: process.env.DATABASE_URL })): Store {\n return {\n async insertEvents(events: StoredEvent[]) {\n if (events.length === 0) return 0;\n const cols = 15;\n const values: unknown[] = [];\n const rows = events.map((e, i) => {\n values.push(e.id, e.type, e.experiment, e.variant, e.goal, e.visitorId, e.sessionId, e.ts, e.url, e.props ? JSON.stringify(e.props) : null, e.receivedAt, e.host ?? null, e.country ?? null, e.device ?? null, e.browser ?? null);\n return '(' + Array.from({ length: cols }, (_, j) => '$' + (i * cols + j + 1)).join(', ') + ')';\n });\n const r = await pool.query(\n 'INSERT INTO splithub_events (id, type, experiment, variant, goal, visitor_id, session_id, ts, url, props, received_at, host, country, device, browser) VALUES ' + rows.join(', ') + ' ON CONFLICT (id) DO NOTHING',\n values\n );\n return r.rowCount ?? 0;\n },\n async variantCounts(experiment: string, goal: string): Promise<StoreVariantCounts[]> {\n const r = await pool.query(counts.sql, counts.bind({ experiment, goal }));\n return r.rows.map(countsFromRow);\n },\n async summaries(): Promise<ExperimentSummary[]> {\n const r = await pool.query(\n \\`SELECT experiment, COUNT(*)::int AS exposures, COUNT(DISTINCT visitor_id)::int AS visitors, MIN(ts)::bigint AS first_ts, MAX(ts)::bigint AS last_ts\n FROM splithub_events WHERE type = 'exposure' GROUP BY experiment\\`\n );\n return r.rows.map((x) => ({ experiment: String(x.experiment), exposures: Number(x.exposures), visitors: Number(x.visitors), firstExposureAt: x.first_ts == null ? null : Number(x.first_ts), lastExposureAt: x.last_ts == null ? null : Number(x.last_ts) }));\n },\n async propertyCounts(property: string, since: number, until?: number): Promise<PropertyCounts> {\n const [totals, events] = await Promise.all([pool.query(prop.totals.sql, prop.totals.bind({ property, since, until })), pool.query(prop.events.sql, prop.events.bind({ property, since, until }))]);\n return propertyCountsFromRows(totals.rows[0], events.rows);\n },\n async propertyEvents(property: string, { before, limit }: { before: number; limit: number }): Promise<StoredEvent[]> {\n const r = await pool.query(prop.rows.sql, prop.rows.bind({ property, before, limit }));\n return r.rows.map(storedEventFromRow);\n },\n close: () => pool.end(),\n };\n}\n`;\n\nexport const MYSQL_STORE = `import { countsFromRow, propertyCountsFromRows, propertyCountsSql, storedEventFromRow, variantCountsSql, type ExperimentSummary, type PropertyCounts, type Store, type StoredEvent, type StoreVariantCounts } from '@splithub/node';\nimport mysql, { type Pool } from 'mysql2/promise';\n\n// SplitHub events in your MySQL / MariaDB / PlanetScale. Run once (or add to your migrations):\nexport const SCHEMA_SQL = \\`\nCREATE TABLE IF NOT EXISTS splithub_events (\n id VARCHAR(64) PRIMARY KEY,\n type VARCHAR(16) NOT NULL, -- exposure | goal | page | event | engage | identify\n experiment VARCHAR(64) NULL,\n variant VARCHAR(64) NULL,\n goal VARCHAR(64) NULL,\n visitor_id VARCHAR(64) NOT NULL,\n session_id VARCHAR(64) NOT NULL,\n ts BIGINT NOT NULL,\n url VARCHAR(512) NULL,\n props JSON NULL,\n received_at BIGINT NOT NULL,\n host VARCHAR(255) NULL,\n country VARCHAR(8) NULL,\n device VARCHAR(16) NULL,\n browser VARCHAR(32) NULL,\n INDEX splithub_events_exp (type, experiment, visitor_id, ts),\n INDEX splithub_events_goal (type, goal, visitor_id, ts)\n);\n\\`;\n\n// The attribution rule shared by every SplitHub store (first exposure, 60 s clock skew, 50 goals per visitor and day).\nconst counts = variantCountsSql({ dialect: 'mysql', table: 'splithub_events' });\n// Analytics properties: pageviews, events, engagement and identify rows share the table; raw counts\n// only (users = distinct ids sent with identify).\nconst prop = propertyCountsSql({ dialect: 'mysql', table: 'splithub_events' });\n\nexport function mysqlStore(pool: Pool = mysql.createPool(process.env.DATABASE_URL ?? '')): Store {\n return {\n async insertEvents(events: StoredEvent[]) {\n if (events.length === 0) return 0;\n const values = events.map((e) => [e.id, e.type, e.experiment, e.variant, e.goal, e.visitorId, e.sessionId, e.ts, e.url, e.props ? JSON.stringify(e.props) : null, e.receivedAt, e.host ?? null, e.country ?? null, e.device ?? null, e.browser ?? null]);\n const [r] = await pool.query(\n 'INSERT IGNORE INTO splithub_events (id, type, experiment, variant, goal, visitor_id, session_id, ts, url, props, received_at, host, country, device, browser) VALUES ?',\n [values]\n );\n return (r as { affectedRows: number }).affectedRows;\n },\n async variantCounts(experiment: string, goal: string): Promise<StoreVariantCounts[]> {\n const [rows] = await pool.query(counts.sql, counts.bind({ experiment, goal }));\n return (rows as Array<Record<string, unknown>>).map(countsFromRow);\n },\n async summaries(): Promise<ExperimentSummary[]> {\n const [rows] = await pool.query(\n \\`SELECT experiment, COUNT(*) AS exposures, COUNT(DISTINCT visitor_id) AS visitors, MIN(ts) AS first_ts, MAX(ts) AS last_ts\n FROM splithub_events WHERE type = 'exposure' GROUP BY experiment\\`\n );\n return (rows as Array<Record<string, unknown>>).map((x) => ({ experiment: String(x.experiment), exposures: Number(x.exposures), visitors: Number(x.visitors), firstExposureAt: x.first_ts == null ? null : Number(x.first_ts), lastExposureAt: x.last_ts == null ? null : Number(x.last_ts) }));\n },\n async propertyCounts(property: string, since: number, until?: number): Promise<PropertyCounts> {\n const [[totals], [events]] = await Promise.all([pool.query(prop.totals.sql, prop.totals.bind({ property, since, until })), pool.query(prop.events.sql, prop.events.bind({ property, since, until }))]);\n return propertyCountsFromRows((totals as Array<Record<string, unknown>>)[0], events as Array<Record<string, unknown>>);\n },\n async propertyEvents(property: string, { before, limit }: { before: number; limit: number }): Promise<StoredEvent[]> {\n const [rows] = await pool.query(prop.rows.sql, prop.rows.bind({ property, before, limit }));\n return (rows as Array<Record<string, unknown>>).map(storedEventFromRow);\n },\n close: () => pool.end(),\n };\n}\n`;\n\nexport const CUSTOM_STORE = `import { attributeVariants, type ExperimentSummary, type Store, type StoredEvent, type StoreVariantCounts } from '@splithub/node';\n\n/**\n * Your own store (Prisma, Drizzle, Supabase, Mongo, anything). Three methods.\n * Attribution rule (keep it, so results match the dashboard):\n * a visitor counts once per experiment, in the variant of their earliest\n * exposure (same ts: smallest variant key), and converts when they sent the\n * goal at or after that exposure (60 s of clock skew allowed); only the first\n * 50 events of one goal per visitor and UTC day count; count unique visitors.\n * SQL database: run variantCountsSql({ dialect }) from @splithub/node.\n * Anything else: load the experiment's exposures and the goal's events and\n * return attributeVariants(events, experiment, goal).\n * Columns worth keeping: id (unique, dedupe on it), type, experiment, variant,\n * goal, visitor_id, session_id, ts, url, props (json), received_at, host,\n * country, device, browser.\n * Analytics (optional): \\`page\\`, \\`event\\`, \\`engage\\` and \\`identify\\` rows carry the\n * property key in \\`experiment\\` (and the event name in \\`goal\\`); engage props are\n * { ms, scroll }, identify props { uid, traits }. Store them like the others and add\n * propertyCounts(property, since, until?) (or run propertyCountsSql, which also counts users)\n * to read them with \\`splithub analytics\\`.\n */\nexport function customStore(): Store {\n return {\n async insertEvents(events: StoredEvent[]): Promise<number> {\n // Insert, skipping ids that already exist. Return how many were inserted.\n throw new Error('implement insertEvents ' + events.length);\n },\n async variantCounts(experiment: string, goal: string): Promise<StoreVariantCounts[]> {\n // Per variant: exposures, conversions, revenueSum and revenueSumSq (per-visitor revenue).\n // Load the exposures of this experiment and the events of this goal, then apply the shared rule.\n const events: StoredEvent[] = [];\n if (events.length === 0) throw new Error('implement variantCounts ' + experiment + ' ' + goal);\n return attributeVariants(events, experiment, goal);\n },\n async summaries(): Promise<ExperimentSummary[]> {\n // Per experiment: exposures, unique visitors, first and last exposure ts (unix ms).\n throw new Error('implement summaries');\n },\n };\n}\n`;\n\nexport function storeTemplate(db: DbKind): string | null {\n return db === 'postgres' ? PG_STORE : db === 'mysql' ? MYSQL_STORE : db === 'custom' ? CUSTOM_STORE : null;\n}\n\n/** Import line + factory call used by the route template. */\nexport function storeUsage(db: DbKind, storeImport: string): { imports: string; factory: string } {\n switch (db) {\n case 'postgres':\n return { imports: `import { pgStore } from '${storeImport}';`, factory: 'pgStore()' };\n case 'mysql':\n return { imports: `import { mysqlStore } from '${storeImport}';`, factory: 'mysqlStore()' };\n case 'custom':\n return { imports: `import { customStore } from '${storeImport}';`, factory: 'customStore()' };\n default:\n return { imports: `import { sqliteStore } from '@splithub/adapter-sqlite';`, factory: `sqliteStore({ file: process.env.SPLITHUB_DB ?? './splithub.db' })` };\n }\n}\n\nexport function runtimePackages(db: DbKind): string[] {\n return db === 'postgres' ? ['pg'] : db === 'mysql' ? ['mysql2'] : db === 'sqlite' ? ['@splithub/adapter-sqlite'] : [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY,OAAO;AACnB,SAAS,gBAAgB;AACzB,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,SAAS,MAAM,gBAAgB;;;ACIjC,IAAM,WAAqB,CAAC,UAAU,YAAY,SAAS,QA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