splithub 0.5.1 → 0.6.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 +1 -1
- package/dist/{alerts-RXUG22S7.js → alerts-B7LKEY3J.js} +4 -4
- package/dist/{analytics-3TFARFQE.js → analytics-YY3O3HGL.js} +5 -5
- package/dist/{chunk-5JKDO4IN.js → chunk-3H7W4UIT.js} +3 -3
- package/dist/{chunk-5Y6HUYA6.js → chunk-4K2CNZYY.js} +2 -2
- package/dist/{chunk-ZHM47JI5.js → chunk-57IKDCOM.js} +5 -5
- package/dist/{chunk-LWJSVUMI.js → chunk-BWYRU47V.js} +2 -2
- package/dist/{chunk-YRHCGHV7.js → chunk-DBGNAB2J.js} +3 -3
- package/dist/{chunk-SXFGWWE7.js → chunk-FSMUHH4G.js} +6 -6
- package/dist/{chunk-NFZZSF4M.js → chunk-H2OU4PJA.js} +2 -2
- package/dist/{chunk-WQETHW5W.js → chunk-K7KLCGYY.js} +3 -3
- package/dist/{chunk-JZH4ZC2R.js → chunk-KXER4ZZ3.js} +3 -3
- package/dist/{chunk-WV6RNTIM.js → chunk-LFEVNQ75.js} +2 -2
- package/dist/{chunk-WV6RNTIM.js.map → chunk-LFEVNQ75.js.map} +1 -1
- package/dist/{chunk-XTHEBWKY.js → chunk-LGL7JY6Y.js} +3 -3
- package/dist/{chunk-OXQZJCAC.js → chunk-LOYPA5WN.js} +6 -6
- package/dist/chunk-LOYPA5WN.js.map +1 -0
- package/dist/{chunk-FCV7PQN6.js → chunk-NQDGMBRF.js} +4 -4
- package/dist/{chunk-YZPQK4N7.js → chunk-OH735OOS.js} +2 -2
- package/dist/{chunk-CAFWOX3S.js → chunk-OTK6B4QC.js} +2 -2
- package/dist/{chunk-Z2LTGGUG.js → chunk-Q6JPYA4Y.js} +3 -3
- package/dist/{chunk-56WHXKGA.js → chunk-QJQKARDO.js} +2 -2
- package/dist/{chunk-RBV5NIMY.js → chunk-RZGKAVA6.js} +2 -2
- package/dist/{chunk-G2URJ423.js → chunk-SAH2BATZ.js} +3 -3
- package/dist/{chunk-4OQEIP33.js → chunk-W66MJG3R.js} +2 -2
- package/dist/chunk-W66MJG3R.js.map +1 -0
- package/dist/{chunk-Q4W6H7XO.js → chunk-X2ICUB5B.js} +5 -5
- package/dist/chunk-X2ICUB5B.js.map +1 -0
- package/dist/{connect-SHXP65T2.js → connect-5TIWPEIS.js} +8 -8
- package/dist/{create-HRROFCS2.js → create-J2WN55LX.js} +3 -3
- package/dist/{dev-4O4ZVVKH.js → dev-4UQ6KKB7.js} +3 -3
- package/dist/{doctor-GCAMTBJG.js → doctor-HYTPYAEW.js} +4 -4
- package/dist/domains-YIY7HXOS.js +10 -0
- package/dist/{experiment-reports-WMODMYBX.js → experiment-reports-WCMLX34L.js} +5 -5
- package/dist/index.js +27 -27
- package/dist/index.js.map +1 -1
- package/dist/init-PTDL6EON.js +19 -0
- package/dist/{lifecycle-C6RF5MC6.js → lifecycle-NKPKM76H.js} +3 -3
- package/dist/{links-JWPXODYS.js → links-YD6QLNKY.js} +4 -4
- package/dist/{login-OT77MNKL.js → login-4OQI2Q45.js} +3 -3
- package/dist/{menu-XMAEYJNC.js → menu-APVGU6TP.js} +22 -22
- package/dist/{notes-QN5XW2TI.js → notes-NSWGMP2V.js} +4 -4
- package/dist/{plan-UHBAQXRB.js → plan-DZGPGSIE.js} +2 -2
- package/dist/{push-UJHOXRO3.js → push-AI2M56OS.js} +3 -3
- package/dist/{remove-MSEG2USQ.js → remove-R3AS4XYY.js} +2 -2
- package/dist/{report-E6EJECSP.js → report-VTJZEITT.js} +2 -2
- package/dist/{results-OJJKMZ4O.js → results-PZERL5HO.js} +6 -6
- package/dist/{review-GIYBPVP3.js → review-IB7Y2OIF.js} +2 -2
- package/dist/{ship-6A6EWZEX.js → ship-CFM5M6N3.js} +2 -2
- package/dist/{skills-4G73YN3S.js → skills-GJGOA4HL.js} +4 -4
- package/dist/status-SOOLWHLW.js +17 -0
- package/package.json +4 -4
- package/dist/chunk-4OQEIP33.js.map +0 -1
- package/dist/chunk-OXQZJCAC.js.map +0 -1
- package/dist/chunk-Q4W6H7XO.js.map +0 -1
- package/dist/domains-CR34APOD.js +0 -10
- package/dist/init-X2D3YAMU.js +0 -19
- package/dist/status-SDXLN4SE.js +0 -17
- /package/dist/{alerts-RXUG22S7.js.map → alerts-B7LKEY3J.js.map} +0 -0
- /package/dist/{analytics-3TFARFQE.js.map → analytics-YY3O3HGL.js.map} +0 -0
- /package/dist/{chunk-5JKDO4IN.js.map → chunk-3H7W4UIT.js.map} +0 -0
- /package/dist/{chunk-5Y6HUYA6.js.map → chunk-4K2CNZYY.js.map} +0 -0
- /package/dist/{chunk-ZHM47JI5.js.map → chunk-57IKDCOM.js.map} +0 -0
- /package/dist/{chunk-LWJSVUMI.js.map → chunk-BWYRU47V.js.map} +0 -0
- /package/dist/{chunk-YRHCGHV7.js.map → chunk-DBGNAB2J.js.map} +0 -0
- /package/dist/{chunk-SXFGWWE7.js.map → chunk-FSMUHH4G.js.map} +0 -0
- /package/dist/{chunk-NFZZSF4M.js.map → chunk-H2OU4PJA.js.map} +0 -0
- /package/dist/{chunk-WQETHW5W.js.map → chunk-K7KLCGYY.js.map} +0 -0
- /package/dist/{chunk-JZH4ZC2R.js.map → chunk-KXER4ZZ3.js.map} +0 -0
- /package/dist/{chunk-XTHEBWKY.js.map → chunk-LGL7JY6Y.js.map} +0 -0
- /package/dist/{chunk-FCV7PQN6.js.map → chunk-NQDGMBRF.js.map} +0 -0
- /package/dist/{chunk-YZPQK4N7.js.map → chunk-OH735OOS.js.map} +0 -0
- /package/dist/{chunk-CAFWOX3S.js.map → chunk-OTK6B4QC.js.map} +0 -0
- /package/dist/{chunk-Z2LTGGUG.js.map → chunk-Q6JPYA4Y.js.map} +0 -0
- /package/dist/{chunk-56WHXKGA.js.map → chunk-QJQKARDO.js.map} +0 -0
- /package/dist/{chunk-RBV5NIMY.js.map → chunk-RZGKAVA6.js.map} +0 -0
- /package/dist/{chunk-G2URJ423.js.map → chunk-SAH2BATZ.js.map} +0 -0
- /package/dist/{connect-SHXP65T2.js.map → connect-5TIWPEIS.js.map} +0 -0
- /package/dist/{create-HRROFCS2.js.map → create-J2WN55LX.js.map} +0 -0
- /package/dist/{dev-4O4ZVVKH.js.map → dev-4UQ6KKB7.js.map} +0 -0
- /package/dist/{doctor-GCAMTBJG.js.map → doctor-HYTPYAEW.js.map} +0 -0
- /package/dist/{domains-CR34APOD.js.map → domains-YIY7HXOS.js.map} +0 -0
- /package/dist/{experiment-reports-WMODMYBX.js.map → experiment-reports-WCMLX34L.js.map} +0 -0
- /package/dist/{init-X2D3YAMU.js.map → init-PTDL6EON.js.map} +0 -0
- /package/dist/{lifecycle-C6RF5MC6.js.map → lifecycle-NKPKM76H.js.map} +0 -0
- /package/dist/{links-JWPXODYS.js.map → links-YD6QLNKY.js.map} +0 -0
- /package/dist/{login-OT77MNKL.js.map → login-4OQI2Q45.js.map} +0 -0
- /package/dist/{menu-XMAEYJNC.js.map → menu-APVGU6TP.js.map} +0 -0
- /package/dist/{notes-QN5XW2TI.js.map → notes-NSWGMP2V.js.map} +0 -0
- /package/dist/{plan-UHBAQXRB.js.map → plan-DZGPGSIE.js.map} +0 -0
- /package/dist/{push-UJHOXRO3.js.map → push-AI2M56OS.js.map} +0 -0
- /package/dist/{remove-MSEG2USQ.js.map → remove-R3AS4XYY.js.map} +0 -0
- /package/dist/{report-E6EJECSP.js.map → report-VTJZEITT.js.map} +0 -0
- /package/dist/{results-OJJKMZ4O.js.map → results-PZERL5HO.js.map} +0 -0
- /package/dist/{review-GIYBPVP3.js.map → review-IB7Y2OIF.js.map} +0 -0
- /package/dist/{ship-6A6EWZEX.js.map → ship-CFM5M6N3.js.map} +0 -0
- /package/dist/{skills-4G73YN3S.js.map → skills-GJGOA4HL.js.map} +0 -0
- /package/dist/{status-SDXLN4SE.js.map → status-SOOLWHLW.js.map} +0 -0
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ npx splithub domains set property sh-x1h78w example.com # only these
|
|
|
62
62
|
| Config `storage.mode` | `status` / `results` read from | Auth |
|
|
63
63
|
|---|---|---|
|
|
64
64
|
| `self` | your app's endpoint on the local dev server (`localhost:3000` for Next.js, `5173` for Vite) or `--url` / `SPLITHUB_URL` | `--token` / `SPLITHUB_ADMIN_TOKEN` when the handler has `adminToken` |
|
|
65
|
-
| `cloud` | `https://go.
|
|
65
|
+
| `cloud` | `https://go.sh2.uk/v1` (or `--api` / `SPLITHUB_API`) | project API key: `--token sk_...`, `SPLITHUB_API_KEY`, or the key saved by `splithub login` |
|
|
66
66
|
|
|
67
67
|
Self-hosted reads are raw numbers: visitors, conversions, rate and revenue per variant, and counts of
|
|
68
68
|
pages and events per property. Verdicts, data-quality stars, recommendations, sample-size planning and the
|
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
ruleBody,
|
|
10
10
|
ruleProgress,
|
|
11
11
|
ruleTarget
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-DBGNAB2J.js";
|
|
13
|
+
import "./chunk-OH735OOS.js";
|
|
14
14
|
import "./chunk-6K3MHBT7.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-W66MJG3R.js";
|
|
16
16
|
import "./chunk-ZISCJRR5.js";
|
|
17
17
|
export {
|
|
18
18
|
ALERT_CONDITIONS,
|
|
@@ -25,4 +25,4 @@ export {
|
|
|
25
25
|
ruleProgress,
|
|
26
26
|
ruleTarget
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=alerts-
|
|
28
|
+
//# sourceMappingURL=alerts-B7LKEY3J.js.map
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
analytics,
|
|
7
7
|
printLive,
|
|
8
8
|
propertyKind
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-57IKDCOM.js";
|
|
10
|
+
import "./chunk-SAH2BATZ.js";
|
|
11
|
+
import "./chunk-OH735OOS.js";
|
|
12
12
|
import "./chunk-K5GDEVMA.js";
|
|
13
13
|
import "./chunk-6K3MHBT7.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-W66MJG3R.js";
|
|
15
15
|
import "./chunk-ZISCJRR5.js";
|
|
16
16
|
export {
|
|
17
17
|
ANALYTICS_BY,
|
|
@@ -21,4 +21,4 @@ export {
|
|
|
21
21
|
printLive,
|
|
22
22
|
propertyKind
|
|
23
23
|
};
|
|
24
|
-
//# sourceMappingURL=analytics-
|
|
24
|
+
//# sourceMappingURL=analytics-YY3O3HGL.js.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
printScope,
|
|
10
10
|
timeline,
|
|
11
11
|
wantsSlice
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NQDGMBRF.js";
|
|
13
13
|
import {
|
|
14
14
|
detectProject
|
|
15
15
|
} from "./chunk-6K3MHBT7.js";
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
fetchResults,
|
|
18
18
|
isRawResults,
|
|
19
19
|
resolveTarget
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-W66MJG3R.js";
|
|
21
21
|
import {
|
|
22
22
|
bar,
|
|
23
23
|
c,
|
|
@@ -178,4 +178,4 @@ export {
|
|
|
178
178
|
analysisLine,
|
|
179
179
|
metricsText
|
|
180
180
|
};
|
|
181
|
-
//# sourceMappingURL=chunk-
|
|
181
|
+
//# sourceMappingURL=chunk-3H7W4UIT.js.map
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
apiError,
|
|
15
15
|
cloudTarget,
|
|
16
16
|
requireCloudToken
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-W66MJG3R.js";
|
|
18
18
|
import {
|
|
19
19
|
c,
|
|
20
20
|
fail,
|
|
@@ -201,4 +201,4 @@ export {
|
|
|
201
201
|
push,
|
|
202
202
|
pull
|
|
203
203
|
};
|
|
204
|
-
//# sourceMappingURL=chunk-
|
|
204
|
+
//# sourceMappingURL=chunk-4K2CNZYY.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
noteKind
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SAH2BATZ.js";
|
|
5
5
|
import {
|
|
6
6
|
change,
|
|
7
7
|
cloudOnly,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
segmentFilters,
|
|
21
21
|
segments,
|
|
22
22
|
str
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-OH735OOS.js";
|
|
24
24
|
import {
|
|
25
25
|
insertProperty,
|
|
26
26
|
loadConfig,
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
cloudTarget,
|
|
38
38
|
request,
|
|
39
39
|
resolveTarget
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-W66MJG3R.js";
|
|
41
41
|
import {
|
|
42
42
|
bar,
|
|
43
43
|
c,
|
|
@@ -66,7 +66,7 @@ async function analytics(args, flags) {
|
|
|
66
66
|
if (!first) return listProperties(flags);
|
|
67
67
|
if (SUBCOMMANDS.has(first)) {
|
|
68
68
|
if (first === "create") return createProperty(second ?? newPropertyId(), flags);
|
|
69
|
-
if (first === "connect") return (await import("./connect-
|
|
69
|
+
if (first === "connect") return (await import("./connect-5TIWPEIS.js")).connect(second, flags);
|
|
70
70
|
if (first === "segments") return segments(args.slice(1), flags);
|
|
71
71
|
if (!second) fail("USAGE", `Which property? npx splithub analytics ${first} <id>`);
|
|
72
72
|
if (first === "events") return rawEvents(second, flags);
|
|
@@ -353,4 +353,4 @@ export {
|
|
|
353
353
|
afterAdded,
|
|
354
354
|
printLive
|
|
355
355
|
};
|
|
356
|
-
//# sourceMappingURL=chunk-
|
|
356
|
+
//# sourceMappingURL=chunk-57IKDCOM.js.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "./chunk-K5GDEVMA.js";
|
|
10
10
|
import {
|
|
11
11
|
componentVariantTemplate
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LOYPA5WN.js";
|
|
13
13
|
import {
|
|
14
14
|
requireConfig
|
|
15
15
|
} from "./chunk-6K3MHBT7.js";
|
|
@@ -339,4 +339,4 @@ export {
|
|
|
339
339
|
parseLimits,
|
|
340
340
|
parseExtras
|
|
341
341
|
};
|
|
342
|
-
//# sourceMappingURL=chunk-
|
|
342
|
+
//# sourceMappingURL=chunk-BWYRU47V.js.map
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
cloudOnly,
|
|
4
4
|
n,
|
|
5
5
|
str
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OH735OOS.js";
|
|
7
7
|
import {
|
|
8
8
|
request,
|
|
9
9
|
requireCloudToken
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-W66MJG3R.js";
|
|
11
11
|
import {
|
|
12
12
|
CliError,
|
|
13
13
|
c,
|
|
@@ -267,4 +267,4 @@ export {
|
|
|
267
267
|
addRule,
|
|
268
268
|
alerts
|
|
269
269
|
};
|
|
270
|
-
//# sourceMappingURL=chunk-
|
|
270
|
+
//# sourceMappingURL=chunk-DBGNAB2J.js.map
|
|
@@ -14,19 +14,19 @@ import {
|
|
|
14
14
|
nativeSetup,
|
|
15
15
|
patchAppEntry,
|
|
16
16
|
screenTracking
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-LFEVNQ75.js";
|
|
18
18
|
import {
|
|
19
19
|
deviceLogin
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-H2OU4PJA.js";
|
|
21
21
|
import {
|
|
22
22
|
installSkills,
|
|
23
23
|
loadSkillFiles
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-LGL7JY6Y.js";
|
|
25
25
|
import {
|
|
26
26
|
configTemplate,
|
|
27
27
|
nextMiddlewareTemplate,
|
|
28
28
|
nextRouteTemplate
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-LOYPA5WN.js";
|
|
30
30
|
import {
|
|
31
31
|
detectProject,
|
|
32
32
|
installCommand
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
import {
|
|
35
35
|
cloudTarget,
|
|
36
36
|
loadCredential
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-W66MJG3R.js";
|
|
38
38
|
import {
|
|
39
39
|
c
|
|
40
40
|
} from "./chunk-ZISCJRR5.js";
|
|
@@ -507,4 +507,4 @@ export {
|
|
|
507
507
|
importPath,
|
|
508
508
|
init
|
|
509
509
|
};
|
|
510
|
-
//# sourceMappingURL=chunk-
|
|
510
|
+
//# sourceMappingURL=chunk-FSMUHH4G.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
removeCredential,
|
|
9
9
|
requireCloudToken,
|
|
10
10
|
saveCredential
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-W66MJG3R.js";
|
|
12
12
|
import {
|
|
13
13
|
CliError,
|
|
14
14
|
c,
|
|
@@ -110,4 +110,4 @@ export {
|
|
|
110
110
|
whoami,
|
|
111
111
|
projects
|
|
112
112
|
};
|
|
113
|
-
//# sourceMappingURL=chunk-
|
|
113
|
+
//# sourceMappingURL=chunk-H2OU4PJA.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
analysisLine
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3H7W4UIT.js";
|
|
5
5
|
import {
|
|
6
6
|
detectProject
|
|
7
7
|
} from "./chunk-6K3MHBT7.js";
|
|
8
8
|
import {
|
|
9
9
|
fetchStatus,
|
|
10
10
|
resolveTarget
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-W66MJG3R.js";
|
|
12
12
|
import {
|
|
13
13
|
bar,
|
|
14
14
|
c,
|
|
@@ -89,4 +89,4 @@ export {
|
|
|
89
89
|
status,
|
|
90
90
|
printProperties
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=chunk-
|
|
92
|
+
//# sourceMappingURL=chunk-K7KLCGYY.js.map
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
isReactNativeApp,
|
|
10
10
|
nativeSdkInstalled,
|
|
11
11
|
nativeSetup
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-LFEVNQ75.js";
|
|
13
13
|
import {
|
|
14
14
|
versionReport
|
|
15
15
|
} from "./chunk-HFIBLDUA.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "./chunk-6K3MHBT7.js";
|
|
24
24
|
import {
|
|
25
25
|
resolveTarget
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-W66MJG3R.js";
|
|
27
27
|
import {
|
|
28
28
|
c,
|
|
29
29
|
printJson
|
|
@@ -151,4 +151,4 @@ export {
|
|
|
151
151
|
doctor,
|
|
152
152
|
appChecks
|
|
153
153
|
};
|
|
154
|
-
//# sourceMappingURL=chunk-
|
|
154
|
+
//# sourceMappingURL=chunk-KXER4ZZ3.js.map
|
|
@@ -156,7 +156,7 @@ ${childIndent}<${tracker.name} />${body.slice(at)}`;
|
|
|
156
156
|
var IOS_PACKAGE_URL = "https://github.com/splithub-io/splithub-sdk";
|
|
157
157
|
var ANDROID_ARTIFACT = "io.splithub:splithub";
|
|
158
158
|
var ANDROID_COMPOSE_ARTIFACT = "io.splithub:splithub-compose";
|
|
159
|
-
var NATIVE_SDK_VERSION = "0.
|
|
159
|
+
var NATIVE_SDK_VERSION = "0.6.1";
|
|
160
160
|
function nativeSetup(app, publicKey, property = null) {
|
|
161
161
|
const key = publicKey ?? "pk_\u2026";
|
|
162
162
|
const prop = property ?? "sh-\u2026";
|
|
@@ -202,4 +202,4 @@ export {
|
|
|
202
202
|
nativeSetup,
|
|
203
203
|
nativeSdkInstalled
|
|
204
204
|
};
|
|
205
|
-
//# sourceMappingURL=chunk-
|
|
205
|
+
//# sourceMappingURL=chunk-LFEVNQ75.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/app-setup.ts"],"sourcesContent":["// Apps (React Native / Expo, native iOS and Android) in `splithub init`, `analytics connect` and `doctor`.\n//\n// React Native / Expo: install @splithub/react-native and wrap the app entry (App.tsx, or app/_layout.tsx with\n// Expo Router) in <SplitHubProvider>, with the screen tracker for the navigation library in use. The entry is\n// rewritten with the TypeScript compiler (the project's own, else the CLI's); without it, or when the entry has\n// a shape we do not recognise, the snippet is printed instead. Native projects get install lines only.\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\nimport type { AppKind, ProjectInfo } from './project';\n\nexport const RN_PACKAGE = '@splithub/react-native';\nexport const ASYNC_STORAGE = '@react-native-async-storage/async-storage';\n\n/** How screens are reported: a tracker component per navigation library, or `useScreen()` by hand. */\nexport type ScreenTracking = 'expo-router' | 'react-navigation' | null;\n\nconst TRACKERS: Record<Exclude<ScreenTracking, null>, { name: string }> = {\n 'expo-router': { name: 'ExpoRouterScreens' },\n 'react-navigation': { name: 'NavigationScreens' },\n};\n\nconst providerImport = (tracker: { name: string } | null) => `import { SplitHubProvider${tracker ? `, ${tracker.name}` : ''} } from '${RN_PACKAGE}';`;\n\nexport function screenTracking(project: Pick<ProjectInfo, 'expoRouter' | 'reactNavigation'>): ScreenTracking {\n return project.expoRouter ? 'expo-router' : project.reactNavigation ? 'react-navigation' : null;\n}\n\nexport const isReactNativeApp = (app: AppKind | null): app is 'expo' | 'react-native' => app === 'expo' || app === 'react-native';\nexport const isNativeApp = (app: AppKind | null): app is 'ios' | 'android' => app === 'ios' || app === 'android';\n\n/** npm packages for a React Native app; Expo installs the storage module with `expo install` (the version matching its SDK). */\nexport function appPackages(project: Pick<ProjectInfo, 'app' | 'deps'>): { runtime: string[]; expo: string[] } {\n const storage = project.deps[ASYNC_STORAGE] ? [] : [ASYNC_STORAGE];\n if (project.app === 'expo') return { runtime: [RN_PACKAGE, '@splithub/core'], expo: storage };\n return { runtime: [RN_PACKAGE, '@splithub/core', ...storage], expo: [] };\n}\n\n/** The file that renders the whole app: the root layout with Expo Router, else App.tsx. */\nexport function findAppEntry(root: string, expoRouter: boolean): string | null {\n const names = expoRouter ? ['app/_layout', 'src/app/_layout'] : ['App', 'src/App', 'app/App'];\n for (const name of names) {\n for (const ext of ['.tsx', '.jsx', '.js', '.ts']) {\n const file = join(root, name + ext);\n if (existsSync(file)) return file;\n }\n }\n return null;\n}\n\nexport interface EntryPatch {\n /** The new source; null when nothing changes. */\n source: string | null;\n status: 'added' | 'already' | 'manual';\n /** Whether the screen tracker was placed (false: add it by hand, see the snippet). */\n screens: boolean;\n reason?: string;\n}\n\n/** The provider snippet to paste when the entry cannot be rewritten. */\nexport function appProviderSnippet(configImport: string, screens: ScreenTracking): string {\n const tracker = screens ? TRACKERS[screens] : null;\n const imports = [providerImport(tracker), `import config from '${configImport}';`];\n if (screens === 'expo-router')\n return `// app/_layout.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}>\\n <ExpoRouterScreens />\\n <Stack />\\n</SplitHubProvider>`;\n if (screens === 'react-navigation')\n return `// App.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}>\\n <NavigationContainer>\\n <NavigationScreens />\\n {/* your navigators */}\\n </NavigationContainer>\\n</SplitHubProvider>`;\n return `// App.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}><App /></SplitHubProvider>\\n// screens: useScreen('Home') in each screen (from ${RN_PACKAGE})`;\n}\n\nfunction scriptKind(ts: typeof TS, file: string): TS.ScriptKind {\n if (/\\.tsx$/.test(file)) return ts.ScriptKind.TSX;\n if (/\\.ts$/.test(file)) return ts.ScriptKind.TS;\n return ts.ScriptKind.JSX;\n}\n\ntype Fn = TS.FunctionDeclaration | TS.FunctionExpression | TS.ArrowFunction;\n\n/** The component behind `export default`: a function, `export default App`, or a wrapper call like `Sentry.wrap(App)`. */\nfunction defaultComponent(ts: typeof TS, sf: TS.SourceFile): Fn | null {\n const byName = (name: string): Fn | null => {\n for (const st of sf.statements) {\n if (ts.isFunctionDeclaration(st) && st.name?.text === name) return st;\n if (ts.isVariableStatement(st)) {\n for (const d of st.declarationList.declarations) {\n if (ts.isIdentifier(d.name) && d.name.text === name && d.initializer && (ts.isArrowFunction(d.initializer) || ts.isFunctionExpression(d.initializer))) return d.initializer;\n }\n }\n }\n return null;\n };\n const fromExpr = (e: TS.Expression): Fn | null => {\n if (ts.isArrowFunction(e) || ts.isFunctionExpression(e)) return e;\n if (ts.isIdentifier(e)) return byName(e.text);\n if (ts.isCallExpression(e) && e.arguments[0]) return fromExpr(e.arguments[0]);\n if (ts.isParenthesizedExpression(e)) return fromExpr(e.expression);\n return null;\n };\n for (const st of sf.statements) {\n if (ts.isFunctionDeclaration(st) && st.modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword)) return st;\n if (ts.isExportAssignment(st) && !st.isExportEquals) return fromExpr(st.expression);\n }\n return null;\n}\n\nconst isJsx = (ts: typeof TS, n: TS.Node) => ts.isJsxElement(n) || ts.isJsxSelfClosingElement(n) || ts.isJsxFragment(n);\n\nfunction indentAt(src: string, pos: number): string {\n const lineStart = src.lastIndexOf('\\n', pos - 1) + 1;\n return /^[ \\t]*/.exec(src.slice(lineStart))![0];\n}\n\n/** Move lines 2..n of `text` by the difference between where its first line starts and where it will start. */\nfunction shift(text: string, fromCol: number, toCol: number): string {\n const d = toCol - fromCol;\n if (d === 0) return text;\n return text\n .split('\\n')\n .map((line, i) => (i === 0 || !line.trim() ? line : d > 0 ? ' '.repeat(d) + line : line.replace(new RegExp(`^[ \\\\t]{0,${-d}}`), '')))\n .join('\\n');\n}\n\n/**\n * Wraps what the entry's default component returns in <SplitHubProvider config={config}> and adds the imports.\n * Pure: the caller reads and writes the file.\n */\nexport function patchAppEntry(ts: typeof TS, file: string, src: string, opts: { configImport: string; screens: ScreenTracking }): EntryPatch {\n if (/<SplitHubProvider\\b/.test(src)) return { source: null, status: 'already', screens: true };\n const sf = ts.createSourceFile(file, src, ts.ScriptTarget.Latest, true, scriptKind(ts, file));\n const fn = defaultComponent(ts, sf);\n if (!fn?.body) return { source: null, status: 'manual', screens: false, reason: 'no default-exported component' };\n\n // The returned JSX: the last top-level `return <…>` of a block body, or an arrow's expression body.\n let outer: TS.Expression | undefined;\n if (ts.isBlock(fn.body)) {\n const ret = [...fn.body.statements].reverse().find((s): s is TS.ReturnStatement => ts.isReturnStatement(s) && Boolean(s.expression));\n outer = ret?.expression;\n } else outer = fn.body;\n let inner = outer;\n while (inner && ts.isParenthesizedExpression(inner)) inner = inner.expression;\n if (!outer || !inner || !isJsx(ts, inner)) return { source: null, status: 'manual', screens: false, reason: 'the component does not return JSX directly' };\n\n const tracker = opts.screens ? TRACKERS[opts.screens] : null;\n const start = inner.getStart(sf);\n let body = src.slice(start, inner.end);\n let screensPlaced = !tracker;\n let trackerLine = '';\n if (tracker && opts.screens === 'react-navigation') {\n // Inside <NavigationContainer>, where its ref context is available.\n let container: TS.JsxElement | undefined;\n const find = (n: TS.Node): void => {\n if (!container && ts.isJsxElement(n) && n.openingElement.tagName.getText(sf) === 'NavigationContainer') container = n;\n else ts.forEachChild(n, find);\n };\n find(inner);\n if (container) {\n const at = container.openingElement.end - start;\n const firstChild = container.children.find((ch) => !(ts.isJsxText(ch) && ch.containsOnlyTriviaWhiteSpaces));\n const childIndent = firstChild ? indentAt(src, firstChild.getStart(sf)) : indentAt(src, container.getStart(sf)) + ' ';\n body = `${body.slice(0, at)}\\n${childIndent}<${tracker.name} />${body.slice(at)}`;\n screensPlaced = true;\n }\n } else if (tracker) {\n trackerLine = `<${tracker.name} />`;\n screensPlaced = true;\n }\n\n const configName = /\\bconfig\\b/.test(src) ? 'splithubConfig' : 'config';\n const base = indentAt(src, outer.getStart(sf));\n const col = start - (src.lastIndexOf('\\n', start - 1) + 1);\n const inside = base + ' ';\n const wrapped = [\n '(',\n `${base} <SplitHubProvider config={${configName}}>`,\n ...(trackerLine ? [`${inside}${trackerLine}`] : []),\n `${inside}${shift(body, col, inside.length)}`,\n `${base} </SplitHubProvider>`,\n `${base})`,\n ].join('\\n');\n let out = src.slice(0, outer.getStart(sf)) + wrapped + src.slice(outer.end);\n\n const imports = [providerImport(tracker && screensPlaced ? tracker : null), `import ${configName} from '${opts.configImport}';`].join('\\n');\n const lastImport = [...sf.statements].filter(ts.isImportDeclaration).pop();\n if (lastImport) out = out.slice(0, lastImport.end) + '\\n' + imports + out.slice(lastImport.end);\n else out = imports + '\\n\\n' + out;\n return { source: out, status: 'added', screens: screensPlaced };\n}\n\n// ---------------------------------------------------------------------------\n// Native SDKs: install lines and a quick start, no patching.\n// ---------------------------------------------------------------------------\n\n// The same values as sdks/ios/README.md, sdks/android/README.md and the dashboard's install tabs.\nexport const IOS_PACKAGE_URL = 'https://github.com/splithub-io/splithub-sdk';\nexport const ANDROID_ARTIFACT = 'io.splithub:splithub';\nexport const ANDROID_COMPOSE_ARTIFACT = 'io.splithub:splithub-compose';\nexport const NATIVE_SDK_VERSION = '0.5.1';\n\nexport function nativeSetup(app: 'ios' | 'android', publicKey: string | null, property: string | null = null): { install: string; quickStart: string } {\n const key = publicKey ?? 'pk_…';\n const prop = property ?? 'sh-…';\n if (app === 'ios')\n return {\n install: `// Xcode: File → Add Package Dependencies → ${IOS_PACKAGE_URL}, then add SplitHub to the target\\n.package(url: \"${IOS_PACKAGE_URL}\", from: \"${NATIVE_SDK_VERSION}\")`,\n quickStart: `import SplitHub\\n\\nSplitHub.start(publicKey: \"${key}\", property: \"${prop}\") // once, at launch\\nlet cta = SplitHub.variant(\"hero-cta\") // \"control\", \"bold\", ...\\nSplitHub.screen(\"Settings\") // each screen\\nSplitHub.track(\"Signup\") // any event; a goal when marked as one`,\n };\n return {\n install: `// app/build.gradle.kts\\nimplementation(\"${ANDROID_ARTIFACT}:${NATIVE_SDK_VERSION}\")\\nimplementation(\"${ANDROID_COMPOSE_ARTIFACT}:${NATIVE_SDK_VERSION}\") // optional: Experiment(id) { variant -> }, TrackScreen(name)`,\n quickStart: `import io.splithub.SplitHub\\n\\nSplitHub.start(this, \"${key}\", property = \"${prop}\") // once, in Application.onCreate\\nval cta = SplitHub.variant(\"hero-cta\") // \"control\", \"bold\", ...\\nSplitHub.screen(\"Settings\") // each screen\\nSplitHub.track(\"Signup\") // any event; a goal when marked as one`,\n };\n}\n\n/** Whether the native project already depends on the SDK (Package.swift, Podfile, project.pbxproj, Gradle files). */\nexport function nativeSdkInstalled(root: string, app: 'ios' | 'android', read: (file: string) => string | null): boolean {\n const files = app === 'ios' ? ['Package.swift', 'Podfile', 'Package.resolved'] : ['build.gradle', 'build.gradle.kts', 'app/build.gradle', 'app/build.gradle.kts', 'gradle/libs.versions.toml'];\n const needle = app === 'ios' ? /splithub/i : /io\\.splithub/;\n return files.some((f) => needle.test(read(join(root, f)) ?? ''));\n}\n"],"mappings":";;;AAMA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAId,IAAM,aAAa;AACnB,IAAM,gBAAgB;AAK7B,IAAM,WAAoE;AAAA,EACxE,eAAe,EAAE,MAAM,oBAAoB;AAAA,EAC3C,oBAAoB,EAAE,MAAM,oBAAoB;AAClD;AAEA,IAAM,iBAAiB,CAAC,YAAqC,4BAA4B,UAAU,KAAK,QAAQ,IAAI,KAAK,EAAE,YAAY,UAAU;AAE1I,SAAS,eAAe,SAA8E;AAC3G,SAAO,QAAQ,aAAa,gBAAgB,QAAQ,kBAAkB,qBAAqB;AAC7F;AAEO,IAAM,mBAAmB,CAAC,QAAwD,QAAQ,UAAU,QAAQ;AAC5G,IAAM,cAAc,CAAC,QAAkD,QAAQ,SAAS,QAAQ;AAGhG,SAAS,YAAY,SAAmF;AAC7G,QAAM,UAAU,QAAQ,KAAK,aAAa,I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AAoB,oBAAoB,wBAAwB,2BAA2B;AAC7L,QAAM,SAAS,QAAQ,QAAQ,cAAc;AAC7C,SAAO,MAAM,KAAK,CAAC,MAAM,OAAO,KAAK,KAAK,KAAK,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;AACjE;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/app-setup.ts"],"sourcesContent":["// Apps (React Native / Expo, native iOS and Android) in `splithub init`, `analytics connect` and `doctor`.\n//\n// React Native / Expo: install @splithub/react-native and wrap the app entry (App.tsx, or app/_layout.tsx with\n// Expo Router) in <SplitHubProvider>, with the screen tracker for the navigation library in use. The entry is\n// rewritten with the TypeScript compiler (the project's own, else the CLI's); without it, or when the entry has\n// a shape we do not recognise, the snippet is printed instead. Native projects get install lines only.\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\nimport type { AppKind, ProjectInfo } from './project';\n\nexport const RN_PACKAGE = '@splithub/react-native';\nexport const ASYNC_STORAGE = '@react-native-async-storage/async-storage';\n\n/** How screens are reported: a tracker component per navigation library, or `useScreen()` by hand. */\nexport type ScreenTracking = 'expo-router' | 'react-navigation' | null;\n\nconst TRACKERS: Record<Exclude<ScreenTracking, null>, { name: string }> = {\n 'expo-router': { name: 'ExpoRouterScreens' },\n 'react-navigation': { name: 'NavigationScreens' },\n};\n\nconst providerImport = (tracker: { name: string } | null) => `import { SplitHubProvider${tracker ? `, ${tracker.name}` : ''} } from '${RN_PACKAGE}';`;\n\nexport function screenTracking(project: Pick<ProjectInfo, 'expoRouter' | 'reactNavigation'>): ScreenTracking {\n return project.expoRouter ? 'expo-router' : project.reactNavigation ? 'react-navigation' : null;\n}\n\nexport const isReactNativeApp = (app: AppKind | null): app is 'expo' | 'react-native' => app === 'expo' || app === 'react-native';\nexport const isNativeApp = (app: AppKind | null): app is 'ios' | 'android' => app === 'ios' || app === 'android';\n\n/** npm packages for a React Native app; Expo installs the storage module with `expo install` (the version matching its SDK). */\nexport function appPackages(project: Pick<ProjectInfo, 'app' | 'deps'>): { runtime: string[]; expo: string[] } {\n const storage = project.deps[ASYNC_STORAGE] ? [] : [ASYNC_STORAGE];\n if (project.app === 'expo') return { runtime: [RN_PACKAGE, '@splithub/core'], expo: storage };\n return { runtime: [RN_PACKAGE, '@splithub/core', ...storage], expo: [] };\n}\n\n/** The file that renders the whole app: the root layout with Expo Router, else App.tsx. */\nexport function findAppEntry(root: string, expoRouter: boolean): string | null {\n const names = expoRouter ? ['app/_layout', 'src/app/_layout'] : ['App', 'src/App', 'app/App'];\n for (const name of names) {\n for (const ext of ['.tsx', '.jsx', '.js', '.ts']) {\n const file = join(root, name + ext);\n if (existsSync(file)) return file;\n }\n }\n return null;\n}\n\nexport interface EntryPatch {\n /** The new source; null when nothing changes. */\n source: string | null;\n status: 'added' | 'already' | 'manual';\n /** Whether the screen tracker was placed (false: add it by hand, see the snippet). */\n screens: boolean;\n reason?: string;\n}\n\n/** The provider snippet to paste when the entry cannot be rewritten. */\nexport function appProviderSnippet(configImport: string, screens: ScreenTracking): string {\n const tracker = screens ? TRACKERS[screens] : null;\n const imports = [providerImport(tracker), `import config from '${configImport}';`];\n if (screens === 'expo-router')\n return `// app/_layout.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}>\\n <ExpoRouterScreens />\\n <Stack />\\n</SplitHubProvider>`;\n if (screens === 'react-navigation')\n return `// App.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}>\\n <NavigationContainer>\\n <NavigationScreens />\\n {/* your navigators */}\\n </NavigationContainer>\\n</SplitHubProvider>`;\n return `// App.tsx\\n${imports.join('\\n')}\\n\\n<SplitHubProvider config={config}><App /></SplitHubProvider>\\n// screens: useScreen('Home') in each screen (from ${RN_PACKAGE})`;\n}\n\nfunction scriptKind(ts: typeof TS, file: string): TS.ScriptKind {\n if (/\\.tsx$/.test(file)) return ts.ScriptKind.TSX;\n if (/\\.ts$/.test(file)) return ts.ScriptKind.TS;\n return ts.ScriptKind.JSX;\n}\n\ntype Fn = TS.FunctionDeclaration | TS.FunctionExpression | TS.ArrowFunction;\n\n/** The component behind `export default`: a function, `export default App`, or a wrapper call like `Sentry.wrap(App)`. */\nfunction defaultComponent(ts: typeof TS, sf: TS.SourceFile): Fn | null {\n const byName = (name: string): Fn | null => {\n for (const st of sf.statements) {\n if (ts.isFunctionDeclaration(st) && st.name?.text === name) return st;\n if (ts.isVariableStatement(st)) {\n for (const d of st.declarationList.declarations) {\n if (ts.isIdentifier(d.name) && d.name.text === name && d.initializer && (ts.isArrowFunction(d.initializer) || ts.isFunctionExpression(d.initializer))) return d.initializer;\n }\n }\n }\n return null;\n };\n const fromExpr = (e: TS.Expression): Fn | null => {\n if (ts.isArrowFunction(e) || ts.isFunctionExpression(e)) return e;\n if (ts.isIdentifier(e)) return byName(e.text);\n if (ts.isCallExpression(e) && e.arguments[0]) return fromExpr(e.arguments[0]);\n if (ts.isParenthesizedExpression(e)) return fromExpr(e.expression);\n return null;\n };\n for (const st of sf.statements) {\n if (ts.isFunctionDeclaration(st) && st.modifiers?.some((m) => m.kind === ts.SyntaxKind.DefaultKeyword)) return st;\n if (ts.isExportAssignment(st) && !st.isExportEquals) return fromExpr(st.expression);\n }\n return null;\n}\n\nconst isJsx = (ts: typeof TS, n: TS.Node) => ts.isJsxElement(n) || ts.isJsxSelfClosingElement(n) || ts.isJsxFragment(n);\n\nfunction indentAt(src: string, pos: number): string {\n const lineStart = src.lastIndexOf('\\n', pos - 1) + 1;\n return /^[ \\t]*/.exec(src.slice(lineStart))![0];\n}\n\n/** Move lines 2..n of `text` by the difference between where its first line starts and where it will start. */\nfunction shift(text: string, fromCol: number, toCol: number): string {\n const d = toCol - fromCol;\n if (d === 0) return text;\n return text\n .split('\\n')\n .map((line, i) => (i === 0 || !line.trim() ? line : d > 0 ? ' '.repeat(d) + line : line.replace(new RegExp(`^[ \\\\t]{0,${-d}}`), '')))\n .join('\\n');\n}\n\n/**\n * Wraps what the entry's default component returns in <SplitHubProvider config={config}> and adds the imports.\n * Pure: the caller reads and writes the file.\n */\nexport function patchAppEntry(ts: typeof TS, file: string, src: string, opts: { configImport: string; screens: ScreenTracking }): EntryPatch {\n if (/<SplitHubProvider\\b/.test(src)) return { source: null, status: 'already', screens: true };\n const sf = ts.createSourceFile(file, src, ts.ScriptTarget.Latest, true, scriptKind(ts, file));\n const fn = defaultComponent(ts, sf);\n if (!fn?.body) return { source: null, status: 'manual', screens: false, reason: 'no default-exported component' };\n\n // The returned JSX: the last top-level `return <…>` of a block body, or an arrow's expression body.\n let outer: TS.Expression | undefined;\n if (ts.isBlock(fn.body)) {\n const ret = [...fn.body.statements].reverse().find((s): s is TS.ReturnStatement => ts.isReturnStatement(s) && Boolean(s.expression));\n outer = ret?.expression;\n } else outer = fn.body;\n let inner = outer;\n while (inner && ts.isParenthesizedExpression(inner)) inner = inner.expression;\n if (!outer || !inner || !isJsx(ts, inner)) return { source: null, status: 'manual', screens: false, reason: 'the component does not return JSX directly' };\n\n const tracker = opts.screens ? TRACKERS[opts.screens] : null;\n const start = inner.getStart(sf);\n let body = src.slice(start, inner.end);\n let screensPlaced = !tracker;\n let trackerLine = '';\n if (tracker && opts.screens === 'react-navigation') {\n // Inside <NavigationContainer>, where its ref context is available.\n let container: TS.JsxElement | undefined;\n const find = (n: TS.Node): void => {\n if (!container && ts.isJsxElement(n) && n.openingElement.tagName.getText(sf) === 'NavigationContainer') container = n;\n else ts.forEachChild(n, find);\n };\n find(inner);\n if (container) {\n const at = container.openingElement.end - start;\n const firstChild = container.children.find((ch) => !(ts.isJsxText(ch) && ch.containsOnlyTriviaWhiteSpaces));\n const childIndent = firstChild ? indentAt(src, firstChild.getStart(sf)) : indentAt(src, container.getStart(sf)) + ' ';\n body = `${body.slice(0, at)}\\n${childIndent}<${tracker.name} />${body.slice(at)}`;\n screensPlaced = true;\n }\n } else if (tracker) {\n trackerLine = `<${tracker.name} />`;\n screensPlaced = true;\n }\n\n const configName = /\\bconfig\\b/.test(src) ? 'splithubConfig' : 'config';\n const base = indentAt(src, outer.getStart(sf));\n const col = start - (src.lastIndexOf('\\n', start - 1) + 1);\n const inside = base + ' ';\n const wrapped = [\n '(',\n `${base} <SplitHubProvider config={${configName}}>`,\n ...(trackerLine ? [`${inside}${trackerLine}`] : []),\n `${inside}${shift(body, col, inside.length)}`,\n `${base} </SplitHubProvider>`,\n `${base})`,\n ].join('\\n');\n let out = src.slice(0, outer.getStart(sf)) + wrapped + src.slice(outer.end);\n\n const imports = [providerImport(tracker && screensPlaced ? tracker : null), `import ${configName} from '${opts.configImport}';`].join('\\n');\n const lastImport = [...sf.statements].filter(ts.isImportDeclaration).pop();\n if (lastImport) out = out.slice(0, lastImport.end) + '\\n' + imports + out.slice(lastImport.end);\n else out = imports + '\\n\\n' + out;\n return { source: out, status: 'added', screens: screensPlaced };\n}\n\n// ---------------------------------------------------------------------------\n// Native SDKs: install lines and a quick start, no patching.\n// ---------------------------------------------------------------------------\n\n// The same values as sdks/ios/README.md, sdks/android/README.md and the dashboard's install tabs.\nexport const IOS_PACKAGE_URL = 'https://github.com/splithub-io/splithub-sdk';\nexport const ANDROID_ARTIFACT = 'io.splithub:splithub';\nexport const ANDROID_COMPOSE_ARTIFACT = 'io.splithub:splithub-compose';\nexport const NATIVE_SDK_VERSION = '0.6.1';\n\nexport function nativeSetup(app: 'ios' | 'android', publicKey: string | null, property: string | null = null): { install: string; quickStart: string } {\n const key = publicKey ?? 'pk_…';\n const prop = property ?? 'sh-…';\n if (app === 'ios')\n return {\n install: `// Xcode: File → Add Package Dependencies → ${IOS_PACKAGE_URL}, then add SplitHub to the target\\n.package(url: \"${IOS_PACKAGE_URL}\", from: \"${NATIVE_SDK_VERSION}\")`,\n quickStart: `import SplitHub\\n\\nSplitHub.start(publicKey: \"${key}\", property: \"${prop}\") // once, at launch\\nlet cta = SplitHub.variant(\"hero-cta\") // \"control\", \"bold\", ...\\nSplitHub.screen(\"Settings\") // each screen\\nSplitHub.track(\"Signup\") // any event; a goal when marked as one`,\n };\n return {\n install: `// app/build.gradle.kts\\nimplementation(\"${ANDROID_ARTIFACT}:${NATIVE_SDK_VERSION}\")\\nimplementation(\"${ANDROID_COMPOSE_ARTIFACT}:${NATIVE_SDK_VERSION}\") // optional: Experiment(id) { variant -> }, TrackScreen(name)`,\n quickStart: `import io.splithub.SplitHub\\n\\nSplitHub.start(this, \"${key}\", property = \"${prop}\") // once, in Application.onCreate\\nval cta = SplitHub.variant(\"hero-cta\") // \"control\", \"bold\", ...\\nSplitHub.screen(\"Settings\") // each screen\\nSplitHub.track(\"Signup\") // any event; a goal when marked as one`,\n };\n}\n\n/** Whether the native project already depends on the SDK (Package.swift, Podfile, project.pbxproj, Gradle files). */\nexport function nativeSdkInstalled(root: string, app: 'ios' | 'android', read: (file: string) => string | null): boolean {\n const files = app === 'ios' ? ['Package.swift', 'Podfile', 'Package.resolved'] : ['build.gradle', 'build.gradle.kts', 'app/build.gradle', 'app/build.gradle.kts', 'gradle/libs.versions.toml'];\n const needle = app === 'ios' ? /splithub/i : /io\\.splithub/;\n return files.some((f) => needle.test(read(join(root, f)) ?? ''));\n}\n"],"mappings":";;;AAMA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAId,IAAM,aAAa;AACnB,IAAM,gBAAgB;AAK7B,IAAM,WAAoE;AAAA,EACxE,eAAe,EAAE,MAAM,oBAAoB;AAAA,EAC3C,oBAAoB,EAAE,MAAM,oBAAoB;AAClD;AAEA,IAAM,iBAAiB,CAAC,YAAqC,4BAA4B,UAAU,KAAK,QAAQ,IAAI,KAAK,EAAE,YAAY,UAAU;AAE1I,SAAS,eAAe,SAA8E;AAC3G,SAAO,QAAQ,aAAa,gBAAgB,QAAQ,kBAAkB,qBAAqB;AAC7F;AAEO,IAAM,mBAAmB,CAAC,QAAwD,QAAQ,UAAU,QAAQ;AAC5G,IAAM,cAAc,CAAC,QAAkD,QAAQ,SAAS,QAAQ;AAGhG,SAAS,YAAY,SAAmF;AAC7G,QAAM,UAAU,QAAQ,K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,gBAAgB,oBAAoB,oBAAoB,wBAAwB,2BAA2B;AAC7L,QAAM,SAAS,QAAQ,QAAQ,cAAc;AAC7C,SAAO,MAAM,KAAK,CAAC,MAAM,OAAO,KAAK,KAAK,KAAK,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;AACjE;","names":[]}
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
CURSOR_RULE,
|
|
5
5
|
MCP_SERVER_ENTRY,
|
|
6
6
|
SKILLS
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LOYPA5WN.js";
|
|
8
8
|
import {
|
|
9
9
|
detectProject
|
|
10
10
|
} from "./chunk-6K3MHBT7.js";
|
|
11
11
|
import {
|
|
12
12
|
fetchSkills
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-W66MJG3R.js";
|
|
14
14
|
import {
|
|
15
15
|
c
|
|
16
16
|
} from "./chunk-ZISCJRR5.js";
|
|
@@ -111,4 +111,4 @@ export {
|
|
|
111
111
|
installSkills,
|
|
112
112
|
skills
|
|
113
113
|
};
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-LGL7JY6Y.js.map
|
|
@@ -202,7 +202,7 @@ There are no variants and no verdicts: reports are counts.
|
|
|
202
202
|
experiments whose goal is that event. Only what the app passes to \`track()\` is sent.
|
|
203
203
|
- Users: \`const identify = useIdentify(); identify(user.id, { plan: 'pro' })\` after sign-in (\`identify(null)\` on sign-out;
|
|
204
204
|
sh.js: \`splithub.identify(id, traits)\`) ties visits to the app's user; reports then count \`users\`. No emails or names in traits.
|
|
205
|
-
- No SDK: \`<script src="https://go.
|
|
205
|
+
- No SDK: \`<script src="https://go.sh2.uk/sh.js" data-key="pk_\u2026" async></script>\` sends pageviews (SPA navigations
|
|
206
206
|
included) and \`window.splithub.track(name, props)\` once the tag has \`data-property="sh-x1h78w"\`.
|
|
207
207
|
- One install covers analytics and experiments: the provider (or sh.js) with \`property\` collects pageviews and runs
|
|
208
208
|
experiments. Each \`track()\` sends one event row and each page one page row; experiments whose goal is that event or
|
|
@@ -375,7 +375,7 @@ Events go to the app's own database (self mode) or to SplitHub Cloud (cloud mode
|
|
|
375
375
|
|---|---|---|---|
|
|
376
376
|
| \`value\` | only data changes: text, number, image URL, price, JSON. The default choice: no new components. | \`--variants control,bold --value control="Old text" --value bold="New text"\` | \`const text = useValue<string>('<id>')\`; server components: \`getValue\` from \`@splithub/next\`; no SDK: \`sh.value('<id>')\` |
|
|
377
377
|
| \`component\` | structure changes: a layout, a section, a flow, a different component per variant | \`--variants control,bold\` (the CLI scaffolds \`splithub/<id>/<Variant>.tsx\` stubs) | \`<Experiment id="<id>"><Variant name="control">\u2026</Variant><Variant name="bold">\u2026</Variant></Experiment>\`, or \`useVariant('<id>')\` in a switch |
|
|
378
|
-
| \`redirect\` | a whole page changes: another URL per variant | \`--match / --to control=/ --to v2=/home-v2\` | nothing: \`@splithub/next\` middleware or the drop-in script \`<script src="https://go.
|
|
378
|
+
| \`redirect\` | a whole page changes: another URL per variant | \`--match / --to control=/ --to v2=/home-v2\` | nothing: \`@splithub/next\` middleware or the drop-in script \`<script src="https://go.sh2.uk/sh.js" data-key="pk_\u2026">\` sends visitors there |
|
|
379
379
|
| \`mvt\` | several things change at once (headline \xD7 button \xD7 image) and the user wants to know which of them matters; every combination is tested and each factor is read on its own | \`--factor headline=old:"Old text",new:"New text" --factor button=blue:#2563eb,green:#16a34a\` (no \`--variants\`; first level = control; at most 4 factors \xD7 4 levels, 16 combinations) | \`const { headline, button } = useValue<{ headline: string; button: string }>('<id>')\` |
|
|
380
380
|
|
|
381
381
|
mvt needs more visitors than a two-variant experiment: every combination must reach the minimum on its own (the results show the
|
|
@@ -548,7 +548,7 @@ description: Use the SplitHub Cloud HTTP API directly: public key event ingest,
|
|
|
548
548
|
|
|
549
549
|
# SplitHub Cloud API
|
|
550
550
|
|
|
551
|
-
Base URL: \`https://go.
|
|
551
|
+
Base URL: \`https://go.sh2.uk\`. JSON in, JSON out (no envelope under \`/v1/*\`). Two credentials:
|
|
552
552
|
|
|
553
553
|
- **Public key \`pk_\u2026\`**: identifies the project to browsers and SDKs. Safe to ship. Can only send events and read
|
|
554
554
|
the public overrides JSON.
|
|
@@ -602,7 +602,7 @@ Server-side sending: a key with \`events:write\` can post to \`POST /v1/events\`
|
|
|
602
602
|
so there is no origin check; keep it on the server.
|
|
603
603
|
|
|
604
604
|
\`\`\`bash
|
|
605
|
-
curl -X POST https://go.
|
|
605
|
+
curl -X POST https://go.sh2.uk/v1/events \\
|
|
606
606
|
-H "Authorization: Bearer $SPLITHUB_API_KEY" -H "Content-Type: application/json" \\
|
|
607
607
|
-d '{ "sdk": "server/1.0", "events": [
|
|
608
608
|
{ "id": "g_order_1042", "type": "goal", "goal": "purchase", "vid": "v_abc", "ts": 1760000010000, "props": { "revenue": 49 } },
|
|
@@ -679,7 +679,7 @@ Scripts should prefer the API-key endpoints above; the session ones exist for th
|
|
|
679
679
|
|
|
680
680
|
## Drop-in script (no SDK)
|
|
681
681
|
|
|
682
|
-
\`<script src="https://go.
|
|
682
|
+
\`<script src="https://go.sh2.uk/sh.js" data-key="pk_live_\u2026"></script>\` in \`<head>\`: redirect experiments, page-visit and
|
|
683
683
|
click goals from the cloud config, \`window.splithub.track(name, props)\` for every event (goals included), pageviews
|
|
684
684
|
for analytics properties (\`data-property="site"\`). An app with the SDK does not need it: one install per property,
|
|
685
685
|
or only the first of the two collects pageviews.
|
|
@@ -896,4 +896,4 @@ export {
|
|
|
896
896
|
AGENTS_SECTION,
|
|
897
897
|
CURSOR_RULE
|
|
898
898
|
};
|
|
899
|
-
//# sourceMappingURL=chunk-
|
|
899
|
+
//# sourceMappingURL=chunk-LOYPA5WN.js.map
|