splithub 0.4.3 → 0.5.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/README.md +10 -4
- package/dist/{alerts-HBGZM7QO.js → alerts-RXUG22S7.js} +4 -4
- package/dist/analytics-3TFARFQE.js +24 -0
- package/dist/{chunk-6T652N3X.js → chunk-4B2SGVPD.js} +2 -2
- package/dist/{chunk-KV7D6SB7.js → chunk-56WHXKGA.js} +3 -3
- package/dist/{chunk-N7TBMCZY.js → chunk-5JKDO4IN.js} +3 -3
- package/dist/{chunk-RMWW4YMN.js → chunk-5UN2NKIF.js} +2 -2
- package/dist/{chunk-U7Z5VYNX.js → chunk-5Y6HUYA6.js} +5 -4
- package/dist/chunk-5Y6HUYA6.js.map +1 -0
- package/dist/{chunk-MUDDASN6.js → chunk-6K3MHBT7.js} +26 -2
- package/dist/chunk-6K3MHBT7.js.map +1 -0
- package/dist/chunk-CB2SJFHK.js +22 -0
- package/dist/chunk-CB2SJFHK.js.map +1 -0
- package/dist/{chunk-BC2MAJMM.js → chunk-FCV7PQN6.js} +5 -5
- package/dist/chunk-FCV7PQN6.js.map +1 -0
- package/dist/{chunk-LMZVU72P.js → chunk-G2URJ423.js} +2 -2
- package/dist/{chunk-6MWK7QV4.js → chunk-JZH4ZC2R.js} +39 -5
- package/dist/chunk-JZH4ZC2R.js.map +1 -0
- package/dist/{chunk-ILEPMQNT.js → chunk-K5GDEVMA.js} +17 -9
- package/dist/chunk-K5GDEVMA.js.map +1 -0
- package/dist/{chunk-UKBZMXXB.js → chunk-LWJSVUMI.js} +4 -4
- package/dist/{chunk-SPWK5RVA.js → chunk-OXQZJCAC.js} +82 -10
- package/dist/chunk-OXQZJCAC.js.map +1 -0
- package/dist/{chunk-J6ZZVUUR.js → chunk-Q4W6H7XO.js} +4 -4
- package/dist/{chunk-6GP534WA.js → chunk-RBV5NIMY.js} +2 -2
- package/dist/{chunk-XDLMDC5U.js → chunk-SXFGWWE7.js} +128 -39
- package/dist/chunk-SXFGWWE7.js.map +1 -0
- package/dist/{chunk-4K2OUYZJ.js → chunk-WQETHW5W.js} +3 -3
- package/dist/chunk-WV6RNTIM.js +205 -0
- package/dist/chunk-WV6RNTIM.js.map +1 -0
- package/dist/{chunk-H7UWKOP3.js → chunk-XTHEBWKY.js} +3 -3
- package/dist/{chunk-MY2IORYY.js → chunk-YRHCGHV7.js} +2 -2
- package/dist/{chunk-HIUYWB24.js → chunk-YZPQK4N7.js} +13 -5
- package/dist/chunk-YZPQK4N7.js.map +1 -0
- package/dist/{chunk-I5YPJR2U.js → chunk-Z2LTGGUG.js} +2 -2
- package/dist/{chunk-BJ5LGERX.js → chunk-ZHM47JI5.js} +19 -12
- package/dist/chunk-ZHM47JI5.js.map +1 -0
- package/dist/{ci-4SY2X2CU.js → ci-W72GPWEB.js} +3 -3
- package/dist/{connect-RDKOJNRQ.js → connect-SHXP65T2.js} +29 -16
- package/dist/connect-SHXP65T2.js.map +1 -0
- package/dist/{create-TRKY4P4Y.js → create-HRROFCS2.js} +5 -5
- package/dist/{dev-YNKPWJHX.js → dev-4O4ZVVKH.js} +3 -3
- package/dist/doctor-GCAMTBJG.js +17 -0
- package/dist/{experiment-reports-UPT2SW7Y.js → experiment-reports-WMODMYBX.js} +5 -5
- package/dist/{holdout-JJEP6673.js → holdout-BRW4HAT7.js} +3 -3
- package/dist/index.js +28 -28
- package/dist/index.js.map +1 -1
- package/dist/init-X2D3YAMU.js +19 -0
- package/dist/lifecycle-C6RF5MC6.js +12 -0
- package/dist/{links-H4I57ZRT.js → links-JWPXODYS.js} +4 -4
- package/dist/{menu-JHG7QPAZ.js → menu-XMAEYJNC.js} +24 -22
- package/dist/{menu-JHG7QPAZ.js.map → menu-XMAEYJNC.js.map} +1 -1
- package/dist/{notes-IQFQ67FF.js → notes-QN5XW2TI.js} +4 -4
- package/dist/{plan-44334RQS.js → plan-UHBAQXRB.js} +2 -2
- package/dist/{push-L2IRGUDM.js → push-UJHOXRO3.js} +4 -4
- package/dist/{refs-5DTSKMXU.js → refs-5RMWQPHX.js} +4 -4
- package/dist/{remove-PVVTBBWX.js → remove-MSEG2USQ.js} +4 -4
- package/dist/{report-JVMKVZTS.js → report-E6EJECSP.js} +2 -2
- package/dist/{results-PSSIKQ2V.js → results-OJJKMZ4O.js} +6 -6
- package/dist/{ship-UP6DLCJN.js → ship-6A6EWZEX.js} +11 -16
- package/dist/ship-6A6EWZEX.js.map +1 -0
- package/dist/{skills-6ZBIPCCU.js → skills-4G73YN3S.js} +4 -4
- package/dist/status-SDXLN4SE.js +17 -0
- package/package.json +16 -5
- package/dist/analytics-EMQ6D3OR.js +0 -22
- package/dist/chunk-6MWK7QV4.js.map +0 -1
- package/dist/chunk-BC2MAJMM.js.map +0 -1
- package/dist/chunk-BJ5LGERX.js.map +0 -1
- package/dist/chunk-HIUYWB24.js.map +0 -1
- package/dist/chunk-ILEPMQNT.js.map +0 -1
- package/dist/chunk-MUDDASN6.js.map +0 -1
- package/dist/chunk-SPWK5RVA.js.map +0 -1
- package/dist/chunk-U7Z5VYNX.js.map +0 -1
- package/dist/chunk-XDLMDC5U.js.map +0 -1
- package/dist/connect-RDKOJNRQ.js.map +0 -1
- package/dist/doctor-BKS7TUAT.js +0 -14
- package/dist/init-JEAYD5YD.js +0 -15
- package/dist/lifecycle-3GUIJ74P.js +0 -12
- package/dist/ship-UP6DLCJN.js.map +0 -1
- package/dist/status-AVNRW6D2.js +0 -17
- /package/dist/{alerts-HBGZM7QO.js.map → alerts-RXUG22S7.js.map} +0 -0
- /package/dist/{analytics-EMQ6D3OR.js.map → analytics-3TFARFQE.js.map} +0 -0
- /package/dist/{chunk-6T652N3X.js.map → chunk-4B2SGVPD.js.map} +0 -0
- /package/dist/{chunk-KV7D6SB7.js.map → chunk-56WHXKGA.js.map} +0 -0
- /package/dist/{chunk-N7TBMCZY.js.map → chunk-5JKDO4IN.js.map} +0 -0
- /package/dist/{chunk-RMWW4YMN.js.map → chunk-5UN2NKIF.js.map} +0 -0
- /package/dist/{chunk-LMZVU72P.js.map → chunk-G2URJ423.js.map} +0 -0
- /package/dist/{chunk-UKBZMXXB.js.map → chunk-LWJSVUMI.js.map} +0 -0
- /package/dist/{chunk-J6ZZVUUR.js.map → chunk-Q4W6H7XO.js.map} +0 -0
- /package/dist/{chunk-6GP534WA.js.map → chunk-RBV5NIMY.js.map} +0 -0
- /package/dist/{chunk-4K2OUYZJ.js.map → chunk-WQETHW5W.js.map} +0 -0
- /package/dist/{chunk-H7UWKOP3.js.map → chunk-XTHEBWKY.js.map} +0 -0
- /package/dist/{chunk-MY2IORYY.js.map → chunk-YRHCGHV7.js.map} +0 -0
- /package/dist/{chunk-I5YPJR2U.js.map → chunk-Z2LTGGUG.js.map} +0 -0
- /package/dist/{ci-4SY2X2CU.js.map → ci-W72GPWEB.js.map} +0 -0
- /package/dist/{create-TRKY4P4Y.js.map → create-HRROFCS2.js.map} +0 -0
- /package/dist/{dev-YNKPWJHX.js.map → dev-4O4ZVVKH.js.map} +0 -0
- /package/dist/{doctor-BKS7TUAT.js.map → doctor-GCAMTBJG.js.map} +0 -0
- /package/dist/{experiment-reports-UPT2SW7Y.js.map → experiment-reports-WMODMYBX.js.map} +0 -0
- /package/dist/{holdout-JJEP6673.js.map → holdout-BRW4HAT7.js.map} +0 -0
- /package/dist/{init-JEAYD5YD.js.map → init-X2D3YAMU.js.map} +0 -0
- /package/dist/{lifecycle-3GUIJ74P.js.map → lifecycle-C6RF5MC6.js.map} +0 -0
- /package/dist/{links-H4I57ZRT.js.map → links-JWPXODYS.js.map} +0 -0
- /package/dist/{notes-IQFQ67FF.js.map → notes-QN5XW2TI.js.map} +0 -0
- /package/dist/{plan-44334RQS.js.map → plan-UHBAQXRB.js.map} +0 -0
- /package/dist/{push-L2IRGUDM.js.map → push-UJHOXRO3.js.map} +0 -0
- /package/dist/{refs-5DTSKMXU.js.map → refs-5RMWQPHX.js.map} +0 -0
- /package/dist/{remove-PVVTBBWX.js.map → remove-MSEG2USQ.js.map} +0 -0
- /package/dist/{report-JVMKVZTS.js.map → report-E6EJECSP.js.map} +0 -0
- /package/dist/{results-PSSIKQ2V.js.map → results-OJJKMZ4O.js.map} +0 -0
- /package/dist/{skills-6ZBIPCCU.js.map → skills-4G73YN3S.js.map} +0 -0
- /package/dist/{status-AVNRW6D2.js.map → status-SDXLN4SE.js.map} +0 -0
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
findTypeScript
|
|
4
|
+
} from "./chunk-CB2SJFHK.js";
|
|
2
5
|
import {
|
|
3
6
|
writeWorkflow
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5UN2NKIF.js";
|
|
8
|
+
import {
|
|
9
|
+
appPackages,
|
|
10
|
+
appProviderSnippet,
|
|
11
|
+
findAppEntry,
|
|
12
|
+
isNativeApp,
|
|
13
|
+
isReactNativeApp,
|
|
14
|
+
nativeSetup,
|
|
15
|
+
patchAppEntry,
|
|
16
|
+
screenTracking
|
|
17
|
+
} from "./chunk-WV6RNTIM.js";
|
|
5
18
|
import {
|
|
6
19
|
deviceLogin
|
|
7
20
|
} from "./chunk-NFZZSF4M.js";
|
|
8
21
|
import {
|
|
9
22
|
installSkills,
|
|
10
23
|
loadSkillFiles
|
|
11
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-XTHEBWKY.js";
|
|
12
25
|
import {
|
|
13
26
|
configTemplate,
|
|
14
27
|
nextMiddlewareTemplate,
|
|
15
28
|
nextRouteTemplate
|
|
16
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-OXQZJCAC.js";
|
|
17
30
|
import {
|
|
18
31
|
detectProject,
|
|
19
32
|
installCommand
|
|
20
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-6K3MHBT7.js";
|
|
21
34
|
import {
|
|
22
35
|
cloudTarget,
|
|
23
36
|
loadCredential
|
|
@@ -29,7 +42,7 @@ import {
|
|
|
29
42
|
// src/commands/init.ts
|
|
30
43
|
import * as p from "@clack/prompts";
|
|
31
44
|
import { execSync } from "child_process";
|
|
32
|
-
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
45
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
33
46
|
import { dirname, join, relative } from "path";
|
|
34
47
|
|
|
35
48
|
// src/templates-store.ts
|
|
@@ -54,10 +67,14 @@ CREATE TABLE IF NOT EXISTS splithub_events (
|
|
|
54
67
|
host text,
|
|
55
68
|
country text,
|
|
56
69
|
device text,
|
|
57
|
-
browser text
|
|
70
|
+
browser text,
|
|
71
|
+
platform text, -- web | ios | android | macos | windows | linux
|
|
72
|
+
app_version text -- the app's version; null on websites
|
|
58
73
|
);
|
|
59
74
|
CREATE INDEX IF NOT EXISTS splithub_events_exp ON splithub_events (type, experiment, visitor_id, ts);
|
|
60
75
|
CREATE INDEX IF NOT EXISTS splithub_events_goal ON splithub_events (type, goal, visitor_id, ts);
|
|
76
|
+
-- Tables from before the app columns (the store also adds them on its first insert):
|
|
77
|
+
ALTER TABLE splithub_events ADD COLUMN IF NOT EXISTS platform text, ADD COLUMN IF NOT EXISTS app_version text;
|
|
61
78
|
\`;
|
|
62
79
|
|
|
63
80
|
// The attribution rule shared by every SplitHub store (first exposure, 60 s clock skew, 50 goals per visitor and day).
|
|
@@ -67,17 +84,29 @@ const counts = variantCountsSql({ dialect: 'postgres', table: 'splithub_events'
|
|
|
67
84
|
const prop = propertyCountsSql({ dialect: 'postgres', table: 'splithub_events' });
|
|
68
85
|
|
|
69
86
|
export function pgStore(pool: Pool = new Pool({ connectionString: process.env.DATABASE_URL })): Store {
|
|
87
|
+
// A table made before the app columns gets them on the first insert. Without ALTER rights they are left out.
|
|
88
|
+
let appColumns: Promise<boolean> | null = null;
|
|
89
|
+
const ensureAppColumns = (): Promise<boolean> =>
|
|
90
|
+
(appColumns ??= (async () => {
|
|
91
|
+
const have = async () =>
|
|
92
|
+
(await pool.query("SELECT column_name FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'splithub_events' AND column_name IN ('platform', 'app_version')")).rows.length === 2;
|
|
93
|
+
if (await have()) return true;
|
|
94
|
+
await pool.query('ALTER TABLE splithub_events ADD COLUMN IF NOT EXISTS platform text, ADD COLUMN IF NOT EXISTS app_version text').catch(() => undefined);
|
|
95
|
+
return have();
|
|
96
|
+
})().catch(() => false));
|
|
70
97
|
return {
|
|
71
98
|
async insertEvents(events: StoredEvent[]) {
|
|
72
99
|
if (events.length === 0) return 0;
|
|
73
|
-
const
|
|
100
|
+
const app = await ensureAppColumns();
|
|
101
|
+
const cols = app ? 17 : 15;
|
|
74
102
|
const values: unknown[] = [];
|
|
75
103
|
const rows = events.map((e, i) => {
|
|
76
104
|
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);
|
|
105
|
+
if (app) values.push(e.platform ?? null, e.app_version ?? null);
|
|
77
106
|
return '(' + Array.from({ length: cols }, (_, j) => '$' + (i * cols + j + 1)).join(', ') + ')';
|
|
78
107
|
});
|
|
79
108
|
const r = await pool.query(
|
|
80
|
-
'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',
|
|
109
|
+
'INSERT INTO splithub_events (id, type, experiment, variant, goal, visitor_id, session_id, ts, url, props, received_at, host, country, device, browser' + (app ? ', platform, app_version' : '') + ') VALUES ' + rows.join(', ') + ' ON CONFLICT (id) DO NOTHING',
|
|
81
110
|
values
|
|
82
111
|
);
|
|
83
112
|
return r.rowCount ?? 0;
|
|
@@ -126,6 +155,8 @@ CREATE TABLE IF NOT EXISTS splithub_events (
|
|
|
126
155
|
country VARCHAR(8) NULL,
|
|
127
156
|
device VARCHAR(16) NULL,
|
|
128
157
|
browser VARCHAR(32) NULL,
|
|
158
|
+
platform VARCHAR(16) NULL, -- web | ios | android | macos | windows | linux
|
|
159
|
+
app_version VARCHAR(32) NULL, -- the app's version; null on websites
|
|
129
160
|
INDEX splithub_events_exp (type, experiment, visitor_id, ts),
|
|
130
161
|
INDEX splithub_events_goal (type, goal, visitor_id, ts)
|
|
131
162
|
);
|
|
@@ -138,12 +169,26 @@ const counts = variantCountsSql({ dialect: 'mysql', table: 'splithub_events' });
|
|
|
138
169
|
const prop = propertyCountsSql({ dialect: 'mysql', table: 'splithub_events' });
|
|
139
170
|
|
|
140
171
|
export function mysqlStore(pool: Pool = mysql.createPool(process.env.DATABASE_URL ?? '')): Store {
|
|
172
|
+
// A table made before the app columns gets them on the first insert. Without ALTER rights they are left out.
|
|
173
|
+
let appColumns: Promise<boolean> | null = null;
|
|
174
|
+
const ensureAppColumns = (): Promise<boolean> =>
|
|
175
|
+
(appColumns ??= (async () => {
|
|
176
|
+
const have = async () => {
|
|
177
|
+
const [rows] = await pool.query("SELECT COLUMN_NAME AS name FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'splithub_events' AND COLUMN_NAME IN ('platform', 'app_version')");
|
|
178
|
+
return new Set((rows as Array<{ name: string }>).map((r) => r.name));
|
|
179
|
+
};
|
|
180
|
+
const found = await have();
|
|
181
|
+
if (!found.has('platform')) await pool.query('ALTER TABLE splithub_events ADD COLUMN platform VARCHAR(16) NULL').catch(() => undefined);
|
|
182
|
+
if (!found.has('app_version')) await pool.query('ALTER TABLE splithub_events ADD COLUMN app_version VARCHAR(32) NULL').catch(() => undefined);
|
|
183
|
+
return (await have()).size === 2;
|
|
184
|
+
})().catch(() => false));
|
|
141
185
|
return {
|
|
142
186
|
async insertEvents(events: StoredEvent[]) {
|
|
143
187
|
if (events.length === 0) return 0;
|
|
144
|
-
const
|
|
188
|
+
const app = await ensureAppColumns();
|
|
189
|
+
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, ...(app ? [e.platform ?? null, e.app_version ?? null] : [])]);
|
|
145
190
|
const [r] = await pool.query(
|
|
146
|
-
'INSERT IGNORE INTO splithub_events (id, type, experiment, variant, goal, visitor_id, session_id, ts, url, props, received_at, host, country, device, browser) VALUES ?',
|
|
191
|
+
'INSERT IGNORE INTO splithub_events (id, type, experiment, variant, goal, visitor_id, session_id, ts, url, props, received_at, host, country, device, browser' + (app ? ', platform, app_version' : '') + ') VALUES ?',
|
|
147
192
|
[values]
|
|
148
193
|
);
|
|
149
194
|
return (r as { affectedRows: number }).affectedRows;
|
|
@@ -185,7 +230,8 @@ var CUSTOM_STORE = `import { attributeVariants, type ExperimentSummary, type Sto
|
|
|
185
230
|
* return attributeVariants(events, experiment, goal).
|
|
186
231
|
* Columns worth keeping: id (unique, dedupe on it), type, experiment, variant,
|
|
187
232
|
* goal, visitor_id, session_id, ts, url, props (json), received_at, host,
|
|
188
|
-
* country, device, browser
|
|
233
|
+
* country, device, browser, platform (web | ios | android | macos | windows | linux)
|
|
234
|
+
* and app_version (apps only).
|
|
189
235
|
* Analytics (optional): \`page\`, \`event\`, \`engage\` and \`identify\` rows carry the
|
|
190
236
|
* property key in \`experiment\` (and the event name in \`goal\`); engage props are
|
|
191
237
|
* { ms, scroll }, identify props { uid, traits }. Store them like the others and add
|
|
@@ -260,23 +306,26 @@ async function init(flags) {
|
|
|
260
306
|
const created = [];
|
|
261
307
|
const skipped = [];
|
|
262
308
|
if (!json) p.intro(c.bold("splithub init"));
|
|
309
|
+
const rn = isReactNativeApp(project.app);
|
|
310
|
+
const native = isNativeApp(project.app);
|
|
311
|
+
const notes = [];
|
|
263
312
|
let mode = str(flags.mode);
|
|
313
|
+
if (native && mode === "self") {
|
|
314
|
+
notes.push("Native apps read their experiments from SplitHub Cloud, so this project is set up for the cloud.");
|
|
315
|
+
mode = "cloud";
|
|
316
|
+
}
|
|
264
317
|
if (!mode) {
|
|
265
|
-
if (yes) mode = "self";
|
|
318
|
+
if (yes || native) mode = project.app ? "cloud" : "self";
|
|
266
319
|
else {
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
{ value: "self", label: "My own database (self-hosted)", hint: "free forever, nothing leaves your infra" },
|
|
271
|
-
{ value: "cloud", label: "SplitHub Cloud", hint: "hosted dashboard, no server code" }
|
|
272
|
-
]
|
|
273
|
-
});
|
|
320
|
+
const self = { value: "self", label: "My own database (self-hosted)", hint: rn ? "your server keeps the events; experiments ship with each release" : "free forever, nothing leaves your infra" };
|
|
321
|
+
const cloud = { value: "cloud", label: "SplitHub Cloud", hint: rn ? "start and change experiments without a store release" : "hosted dashboard, no server code" };
|
|
322
|
+
const picked = await p.select({ message: "Where should events be stored?", options: rn ? [cloud, self] : [self, cloud] });
|
|
274
323
|
if (p.isCancel(picked)) return cancel2();
|
|
275
324
|
mode = picked;
|
|
276
325
|
}
|
|
277
326
|
}
|
|
278
327
|
let db = DB_KINDS.includes(str(flags.db) ?? "") ? str(flags.db) : "sqlite";
|
|
279
|
-
if (mode === "self" && !flags.db && !yes) {
|
|
328
|
+
if (mode === "self" && !project.app && !flags.db && !yes) {
|
|
280
329
|
const picked = await p.select({
|
|
281
330
|
message: "Where should events be stored?",
|
|
282
331
|
options: [
|
|
@@ -333,8 +382,22 @@ Code ${c.green(s.userCode)} \xB7 sign in, pick or create the project, approve.`,
|
|
|
333
382
|
}
|
|
334
383
|
}
|
|
335
384
|
const configFile = project.configFile ?? join(project.root, "splithub.config.ts");
|
|
336
|
-
writeIfMissing(configFile, configTemplate(project.name, mode, key), created, skipped);
|
|
337
|
-
const storeBody = mode === "self" ? storeTemplate(db) : null;
|
|
385
|
+
if (!native) writeIfMissing(configFile, configTemplate(project.name, mode, key, { app: rn }), created, skipped);
|
|
386
|
+
const storeBody = mode === "self" && !project.app ? storeTemplate(db) : null;
|
|
387
|
+
if (rn && mode === "self") notes.push("Self-hosted: the app sends to storage.endpoint in the config. Point it at your server, and run npx splithub init --mode self there for the ingest route.");
|
|
388
|
+
const screens = screenTracking(project);
|
|
389
|
+
let entry = null;
|
|
390
|
+
if (rn) {
|
|
391
|
+
const file = findAppEntry(project.root, project.expoRouter);
|
|
392
|
+
const ts = file ? await findTypeScript(project.root) : null;
|
|
393
|
+
if (!file) entry = { file: null, patch: { source: null, status: "manual", screens: false, reason: project.expoRouter ? "no app/_layout.tsx" : "no App.tsx" } };
|
|
394
|
+
else if (!ts) entry = { file, patch: { source: null, status: "manual", screens: false, reason: "TypeScript is not installed, so the entry was left as it is" } };
|
|
395
|
+
else {
|
|
396
|
+
const patch = patchAppEntry(ts, file, readFileSync(file, "utf8"), { configImport: importPath(file, configFile), screens });
|
|
397
|
+
if (patch.source !== null) writeFileSync(file, patch.source, "utf8");
|
|
398
|
+
entry = { file, patch };
|
|
399
|
+
}
|
|
400
|
+
}
|
|
338
401
|
const storeFile = storeBody ? join(project.root, "splithub", "store.ts") : null;
|
|
339
402
|
if (storeFile && storeBody) writeIfMissing(storeFile, storeBody, created, skipped);
|
|
340
403
|
if (project.framework === "next") {
|
|
@@ -358,21 +421,23 @@ Code ${c.green(s.userCode)} \xB7 sign in, pick or create the project, approve.`,
|
|
|
358
421
|
const wf = writeWorkflow(project.root, Boolean(flags.force));
|
|
359
422
|
(wf.written ? created : skipped).push(join(project.root, wf.file));
|
|
360
423
|
}
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
if (
|
|
424
|
+
const pkgs = rn ? appPackages(project) : null;
|
|
425
|
+
const runtime = pkgs ? pkgs.runtime : ["@splithub/react", "@splithub/core"];
|
|
426
|
+
if (project.framework === "next" && !rn) runtime.push("@splithub/next");
|
|
427
|
+
if (mode === "self" && !project.app) runtime.push("@splithub/node", ...runtimePackages(db));
|
|
364
428
|
const installRuntime = installCommand(project.packageManager, runtime);
|
|
429
|
+
const installExpo = pkgs?.expo.length ? `npx expo install ${pkgs.expo.join(" ")}` : null;
|
|
365
430
|
const installDev = installCommand(project.packageManager, ["splithub"], true);
|
|
431
|
+
const commands = native ? [] : [installRuntime, ...installExpo ? [installExpo] : [], installDev];
|
|
366
432
|
let installed = false;
|
|
367
|
-
if (!flags["no-install"]) {
|
|
368
|
-
const go = yes ? true : await p.confirm({ message: `Install packages now? (${
|
|
433
|
+
if (!flags["no-install"] && commands.length) {
|
|
434
|
+
const go = yes ? true : await p.confirm({ message: `Install packages now? (${commands.slice(0, -1).join(" && ")})` });
|
|
369
435
|
if (p.isCancel(go)) return cancel2();
|
|
370
436
|
if (go) {
|
|
371
437
|
const s = json ? null : p.spinner();
|
|
372
438
|
s?.start("Installing");
|
|
373
439
|
try {
|
|
374
|
-
execSync(
|
|
375
|
-
execSync(installDev, { cwd: project.root, stdio: json ? "ignore" : "inherit" });
|
|
440
|
+
for (const cmd of commands) execSync(cmd, { cwd: project.root, stdio: json ? "ignore" : "inherit" });
|
|
376
441
|
installed = true;
|
|
377
442
|
s?.stop("Installed");
|
|
378
443
|
} catch (error) {
|
|
@@ -381,7 +446,11 @@ Code ${c.green(s.userCode)} \xB7 sign in, pick or create the project, approve.`,
|
|
|
381
446
|
}
|
|
382
447
|
}
|
|
383
448
|
}
|
|
384
|
-
const
|
|
449
|
+
const entryFile = entry?.file ?? join(project.root, project.expoRouter ? "app/_layout.tsx" : "App.tsx");
|
|
450
|
+
const nativeKit = native ? nativeSetup(project.app, key ?? null) : null;
|
|
451
|
+
const providerHint = nativeKit ? `${nativeKit.install}
|
|
452
|
+
|
|
453
|
+
${nativeKit.quickStart}` : rn ? appProviderSnippet(importPath(entryFile, configFile), screens) : project.framework === "next" ? `// ${project.appDir ?? "app"}/layout.tsx
|
|
385
454
|
import { SplitHubNextProvider } from '@splithub/next/client';
|
|
386
455
|
import { getSplitHub } from '@splithub/next/server';
|
|
387
456
|
import config from '${importPath(join(project.root, project.appDir ?? "app", "layout.tsx"), configFile)}';
|
|
@@ -394,21 +463,40 @@ import { SplitHubProvider } from '@splithub/react';
|
|
|
394
463
|
import config from './splithub.config';
|
|
395
464
|
|
|
396
465
|
<SplitHubProvider config={config}><App /></SplitHubProvider>`;
|
|
397
|
-
const warning = mode === "cloud" && !key ? "No public key yet: storage.key falls back to process.env
|
|
398
|
-
|
|
466
|
+
const warning = mode === "cloud" && !key ? native ? "No public key yet: run `npx splithub login` (or pass --key pk_\u2026, dashboard \u2192 Setup) and put it in SplitHub.start." : `No public key yet: storage.key falls back to process.env.${rn ? "EXPO_PUBLIC_SPLITHUB_KEY" : "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_\u2026 (dashboard \u2192 Setup); SPLITHUB_API_KEY in the environment also resolves it.` : null;
|
|
467
|
+
if (rn && entry?.file && entry.patch.status === "added") created.push(`${entry.file} (wrapped in <SplitHubProvider>${entry.patch.screens && screens ? ", screens tracked" : ""})`);
|
|
468
|
+
if (rn && entry?.patch.status === "added" && !entry.patch.screens && screens) notes.push(`Screens: add <NavigationScreens /> inside your <NavigationContainer> (from @splithub/react-native).`);
|
|
469
|
+
if (rn && !screens) notes.push("Screens: call useScreen('Home') in each screen (from @splithub/react-native).");
|
|
470
|
+
if (project.app) notes.push("Experiments in splithub.config.ts ship inside the app binary. Create them in the dashboard to start them without a store release.");
|
|
471
|
+
const app = project.app ? {
|
|
472
|
+
kind: project.app,
|
|
473
|
+
screens: rn ? screens ?? "useScreen" : null,
|
|
474
|
+
entry: entry ? { file: entry.file ? relative(project.root, entry.file).replace(/\\/g, "/") : null, status: entry.patch.status, screens: entry.patch.screens, ...entry.patch.reason ? { reason: entry.patch.reason } : {} } : null,
|
|
475
|
+
...nativeKit ? { install: nativeKit.install, quickStart: nativeKit.quickStart } : {}
|
|
476
|
+
} : null;
|
|
477
|
+
const providerDone = entry?.patch.status === "added" || entry?.patch.status === "already";
|
|
478
|
+
const summary = { project: project.name, framework: project.framework, app, mode, db: mode === "self" && !project.app ? db : null, connected, publicKey: key ?? null, warning, notes, created, skipped, installed, installCommands: installed ? [] : commands, nextStep: providerDone ? null : providerHint, ...project.framework === "vite" && !rn ? { vitePlugin: VITE_PLUGIN_HINT } : {} };
|
|
399
479
|
if (json) {
|
|
400
480
|
console.log(JSON.stringify(summary));
|
|
401
481
|
return;
|
|
402
482
|
}
|
|
403
483
|
if (warning) p.log.warn(warning);
|
|
404
|
-
|
|
484
|
+
for (const note2 of notes) p.log.info(note2);
|
|
485
|
+
if (mode === "self" && !project.app && 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}`);
|
|
405
486
|
if (created.length) p.note(created.map((f) => relative(project.root, f) || f).join("\n"), "Created");
|
|
406
487
|
if (skipped.length) p.note(skipped.map((f) => relative(project.root, f)).join("\n"), "Already present, left untouched");
|
|
407
|
-
if (!installed) p.note(
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
488
|
+
if (!installed && commands.length) p.note(commands.join("\n"), "Install");
|
|
489
|
+
if (nativeKit) {
|
|
490
|
+
p.note(nativeKit.install, project.app === "ios" ? "Add the Swift package" : "Add the Gradle dependency");
|
|
491
|
+
p.note(nativeKit.quickStart, "Quick start");
|
|
492
|
+
p.outro(`Next: create an experiment in the dashboard, then ${c.cyan("npx splithub status")} and ${c.cyan("npx splithub results <id>")} read it here.`);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
if (rn && entry?.patch.status === "manual") p.log.warn(`Left ${entry.file ? relative(project.root, entry.file) : "the entry"} as it is: ${entry.patch.reason}. Add the provider by hand.`);
|
|
496
|
+
if (!providerDone) p.note(providerHint, "Wrap your app once");
|
|
497
|
+
if (project.framework === "vite" && !rn) p.note(VITE_PLUGIN_HINT, "Notes in your dev terminal");
|
|
498
|
+
const analyticsNext = rn ? `, ${c.cyan("npx splithub analytics connect")} for screens and retention` : "";
|
|
499
|
+
p.outro(`Next: ${c.cyan("npx splithub create")} to add your first experiment, ${c.cyan("npx splithub push")} to sync it${analyticsNext}, ${c.cyan("npx splithub doctor")} to verify.`);
|
|
412
500
|
}
|
|
413
501
|
function cancel2() {
|
|
414
502
|
p.cancel("Cancelled.");
|
|
@@ -416,6 +504,7 @@ function cancel2() {
|
|
|
416
504
|
}
|
|
417
505
|
|
|
418
506
|
export {
|
|
507
|
+
importPath,
|
|
419
508
|
init
|
|
420
509
|
};
|
|
421
|
-
//# sourceMappingURL=chunk-
|
|
510
|
+
//# sourceMappingURL=chunk-SXFGWWE7.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, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative } from 'node:path';\nimport { cloudTarget } from '../api';\nimport { appPackages, appProviderSnippet, findAppEntry, isNativeApp, isReactNativeApp, nativeSetup, patchAppEntry, screenTracking, type EntryPatch } from '../app-setup';\nimport { findTypeScript } from '../typescript';\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\nexport function 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 // Apps: React Native / Expo get the npm package and a wrapped entry; native iOS / Android get install lines.\n const rn = isReactNativeApp(project.app);\n const native = isNativeApp(project.app);\n const notes: string[] = [];\n\n let mode = str(flags.mode) as 'self' | 'cloud' | undefined;\n if (native && mode === 'self') {\n notes.push('Native apps read their experiments from SplitHub Cloud, so this project is set up for the cloud.');\n mode = 'cloud';\n }\n if (!mode) {\n // An app cannot reach a self-hosted endpoint without a server URL, and only the cloud starts experiments without a release.\n if (yes || native) mode = project.app ? 'cloud' : 'self';\n else {\n const self = { value: 'self', label: 'My own database (self-hosted)', hint: rn ? 'your server keeps the events; experiments ship with each release' : 'free forever, nothing leaves your infra' };\n const cloud = { value: 'cloud', label: 'SplitHub Cloud', hint: rn ? 'start and change experiments without a store release' : 'hosted dashboard, no server code' };\n const picked = await p.select({ message: 'Where should events be stored?', options: rn ? [cloud, self] : [self, cloud] });\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' && !project.app && !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 // Native apps never read the file (the SDK gets experiments from the cloud), so they get none.\n const configFile = project.configFile ?? join(project.root, 'splithub.config.ts');\n if (!native) writeIfMissing(configFile, configTemplate(project.name, mode, key, { app: rn }), created, skipped);\n\n // 2a. store for self mode (postgres / mysql / custom); sqlite needs no file. An app's events go to a server set up on its own.\n const storeBody = mode === 'self' && !project.app ? storeTemplate(db) : null;\n if (rn && mode === 'self') notes.push('Self-hosted: the app sends to storage.endpoint in the config. Point it at your server, and run npx splithub init --mode self there for the ingest route.');\n\n // 2b. app entry: wrap it in <SplitHubProvider>, with screen tracking.\n const screens = screenTracking(project);\n let entry: { file: string | null; patch: EntryPatch } | null = null;\n if (rn) {\n const file = findAppEntry(project.root, project.expoRouter);\n const ts = file ? await findTypeScript(project.root) : null;\n if (!file) entry = { file: null, patch: { source: null, status: 'manual', screens: false, reason: project.expoRouter ? 'no app/_layout.tsx' : 'no App.tsx' } };\n else if (!ts) entry = { file, patch: { source: null, status: 'manual', screens: false, reason: 'TypeScript is not installed, so the entry was left as it is' } };\n else {\n const patch = patchAppEntry(ts, file, readFileSync(file, 'utf8'), { configImport: importPath(file, configFile), screens });\n if (patch.source !== null) writeFileSync(file, patch.source, 'utf8');\n entry = { file, patch };\n }\n }\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 pkgs = rn ? appPackages(project) : null;\n const runtime = pkgs ? pkgs.runtime : ['@splithub/react', '@splithub/core'];\n if (project.framework === 'next' && !rn) runtime.push('@splithub/next');\n if (mode === 'self' && !project.app) runtime.push('@splithub/node', ...runtimePackages(db));\n const installRuntime = installCommand(project.packageManager, runtime);\n // Expo picks the native module version that matches the app's SDK.\n const installExpo = pkgs?.expo.length ? `npx expo install ${pkgs.expo.join(' ')}` : null;\n const installDev = installCommand(project.packageManager, ['splithub'], true);\n const commands = native ? [] : [installRuntime, ...(installExpo ? [installExpo] : []), installDev];\n let installed = false;\n if (!flags['no-install'] && commands.length) {\n const go = yes ? true : await p.confirm({ message: `Install packages now? (${commands.slice(0, -1).join(' && ')})` });\n if (p.isCancel(go)) return cancel();\n if (go) {\n const s = json ? null : p.spinner();\n s?.start('Installing');\n try {\n for (const cmd of commands) execSync(cmd, { 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 entryFile = entry?.file ?? join(project.root, project.expoRouter ? 'app/_layout.tsx' : 'App.tsx');\n const nativeKit = native ? nativeSetup(project.app as 'ios' | 'android', key ?? null) : null;\n const providerHint = nativeKit\n ? `${nativeKit.install}\\n\\n${nativeKit.quickStart}`\n : rn\n ? appProviderSnippet(importPath(entryFile, configFile), screens)\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 =\n mode === 'cloud' && !key\n ? native\n ? 'No public key yet: run `npx splithub login` (or pass --key pk_…, dashboard → Setup) and put it in SplitHub.start.'\n : `No public key yet: storage.key falls back to process.env.${rn ? 'EXPO_PUBLIC_SPLITHUB_KEY' : '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.`\n : null;\n if (rn && entry?.file && entry.patch.status === 'added') created.push(`${entry.file} (wrapped in <SplitHubProvider>${entry.patch.screens && screens ? ', screens tracked' : ''})`);\n if (rn && entry?.patch.status === 'added' && !entry.patch.screens && screens) notes.push(`Screens: add <NavigationScreens /> inside your <NavigationContainer> (from @splithub/react-native).`);\n if (rn && !screens) notes.push(\"Screens: call useScreen('Home') in each screen (from @splithub/react-native).\");\n if (project.app) notes.push('Experiments in splithub.config.ts ship inside the app binary. Create them in the dashboard to start them without a store release.');\n const app = project.app\n ? {\n kind: project.app,\n screens: rn ? screens ?? 'useScreen' : null,\n entry: entry ? { file: entry.file ? relative(project.root, entry.file).replace(/\\\\/g, '/') : null, status: entry.patch.status, screens: entry.patch.screens, ...(entry.patch.reason ? { reason: entry.patch.reason } : {}) } : null,\n ...(nativeKit ? { install: nativeKit.install, quickStart: nativeKit.quickStart } : {}),\n }\n : null;\n const providerDone = entry?.patch.status === 'added' || entry?.patch.status === 'already';\n const summary = { project: project.name, framework: project.framework, app, mode, db: mode === 'self' && !project.app ? db : null, connected, publicKey: key ?? null, warning, notes, created, skipped, installed, installCommands: installed ? [] : commands, nextStep: providerDone ? null : providerHint, ...(project.framework === 'vite' && !rn ? { 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 for (const note of notes) p.log.info(note);\n if (mode === 'self' && !project.app && 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 && commands.length) p.note(commands.join('\\n'), 'Install');\n if (nativeKit) {\n p.note(nativeKit.install, project.app === 'ios' ? 'Add the Swift package' : 'Add the Gradle dependency');\n p.note(nativeKit.quickStart, 'Quick start');\n p.outro(`Next: create an experiment in the dashboard, then ${c.cyan('npx splithub status')} and ${c.cyan('npx splithub results <id>')} read it here.`);\n return;\n }\n if (rn && entry?.patch.status === 'manual') p.log.warn(`Left ${entry.file ? relative(project.root, entry.file) : 'the entry'} as it is: ${entry.patch.reason}. Add the provider by hand.`);\n if (!providerDone) p.note(providerHint, 'Wrap your app once');\n if (project.framework === 'vite' && !rn) p.note(VITE_PLUGIN_HINT, 'Notes in your dev terminal');\n const analyticsNext = rn ? `, ${c.cyan('npx splithub analytics connect')} for screens and retention` : '';\n p.outro(`Next: ${c.cyan('npx splithub create')} to add your first experiment, ${c.cyan('npx splithub push')} to sync it${analyticsNext}, ${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 platform text, -- web | ios | android | macos | windows | linux\n app_version text -- the app's version; null on websites\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-- Tables from before the app columns (the store also adds them on its first insert):\nALTER TABLE splithub_events ADD COLUMN IF NOT EXISTS platform text, ADD COLUMN IF NOT EXISTS app_version text;\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 // A table made before the app columns gets them on the first insert. Without ALTER rights they are left out.\n let appColumns: Promise<boolean> | null = null;\n const ensureAppColumns = (): Promise<boolean> =>\n (appColumns ??= (async () => {\n const have = async () =>\n (await pool.query(\"SELECT column_name FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'splithub_events' AND column_name IN ('platform', 'app_version')\")).rows.length === 2;\n if (await have()) return true;\n await pool.query('ALTER TABLE splithub_events ADD COLUMN IF NOT EXISTS platform text, ADD COLUMN IF NOT EXISTS app_version text').catch(() => undefined);\n return have();\n })().catch(() => false));\n return {\n async insertEvents(events: StoredEvent[]) {\n if (events.length === 0) return 0;\n const app = await ensureAppColumns();\n const cols = app ? 17 : 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 if (app) values.push(e.platform ?? null, e.app_version ?? 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' + (app ? ', platform, app_version' : '') + ') 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 platform VARCHAR(16) NULL, -- web | ios | android | macos | windows | linux\n app_version VARCHAR(32) NULL, -- the app's version; null on websites\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 // A table made before the app columns gets them on the first insert. Without ALTER rights they are left out.\n let appColumns: Promise<boolean> | null = null;\n const ensureAppColumns = (): Promise<boolean> =>\n (appColumns ??= (async () => {\n const have = async () => {\n const [rows] = await pool.query(\"SELECT COLUMN_NAME AS name FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'splithub_events' AND COLUMN_NAME IN ('platform', 'app_version')\");\n return new Set((rows as Array<{ name: string }>).map((r) => r.name));\n };\n const found = await have();\n if (!found.has('platform')) await pool.query('ALTER TABLE splithub_events ADD COLUMN platform VARCHAR(16) NULL').catch(() => undefined);\n if (!found.has('app_version')) await pool.query('ALTER TABLE splithub_events ADD COLUMN app_version VARCHAR(32) NULL').catch(() => undefined);\n return (await have()).size === 2;\n })().catch(() => false));\n return {\n async insertEvents(events: StoredEvent[]) {\n if (events.length === 0) return 0;\n const app = await ensureAppColumns();\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, ...(app ? [e.platform ?? null, e.app_version ?? 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' + (app ? ', platform, app_version' : '') + ') 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, platform (web | ios | android | macos | windows | linux)\n * and app_version (apps only).\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,cAAc,qBAAqB;AACnE,SAAS,SAAS,MAAM,gBAAgB;;;ACIjC,IAAM,WAAqB,CAAC,UAAU,YAAY,SAAS,QAAQ;AAEnE,IAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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AqB,CAAC,QAAQ,EAAE,KAAK,2BAA2B,CAAC,gBAAgB;AACrJ;AAAA,EACF;AACA,MAAI,MAAM,OAAO,MAAM,WAAW,SAAU,CAAE,MAAI,KAAK,QAAQ,MAAM,OAAO,SAAS,QAAQ,MAAM,MAAM,IAAI,IAAI,WAAW,cAAc,MAAM,MAAM,MAAM,6BAA6B;AACzL,MAAI,CAAC,aAAc,CAAE,OAAK,cAAc,oBAAoB;AAC5D,MAAI,QAAQ,cAAc,UAAU,CAAC,GAAI,CAAE,OAAK,kBAAkB,4BAA4B;AAC9F,QAAM,gBAAgB,KAAK,KAAK,EAAE,KAAK,gCAAgC,CAAC,+BAA+B;AACvG,EAAE,QAAM,SAAS,EAAE,KAAK,qBAAqB,CAAC,kCAAkC,EAAE,KAAK,mBAAmB,CAAC,cAAc,aAAa,KAAK,EAAE,KAAK,qBAAqB,CAAC,aAAa;AACvL;AAGA,SAASD,UAAe;AACtB,EAAE,SAAO,YAAY;AACrB,UAAQ,KAAK,CAAC;AAChB;","names":["cancel","note"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
analysisLine
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5JKDO4IN.js";
|
|
5
5
|
import {
|
|
6
6
|
detectProject
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-6K3MHBT7.js";
|
|
8
8
|
import {
|
|
9
9
|
fetchStatus,
|
|
10
10
|
resolveTarget
|
|
@@ -89,4 +89,4 @@ export {
|
|
|
89
89
|
status,
|
|
90
90
|
printProperties
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=chunk-
|
|
92
|
+
//# sourceMappingURL=chunk-WQETHW5W.js.map
|