@koda-sl/baker-cli 0.312.0 → 0.313.0-dev.64ea8cd98
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/{chunk-WONWYE7B.js → chunk-PY7R67NE.js} +4 -4
- package/dist/chunk-PY7R67NE.js.map +1 -0
- package/dist/cli.js +227 -82
- package/dist/cli.js.map +1 -1
- package/dist/engine/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-WONWYE7B.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
validateCanvasDeep,
|
|
68
68
|
withoutCastName,
|
|
69
69
|
ytDlpBlockSignal
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-PY7R67NE.js";
|
|
71
71
|
import {
|
|
72
72
|
csvOrJson,
|
|
73
73
|
daysAgoIso,
|
|
@@ -10749,14 +10749,14 @@ function collectionLine(collection) {
|
|
|
10749
10749
|
}
|
|
10750
10750
|
function accountsInTree(nodes) {
|
|
10751
10751
|
const accounts = /* @__PURE__ */ new Set();
|
|
10752
|
-
const
|
|
10752
|
+
const walk = (node) => {
|
|
10753
10753
|
accounts.add(node.customerId);
|
|
10754
10754
|
for (const child of node.children) {
|
|
10755
|
-
|
|
10755
|
+
walk(child);
|
|
10756
10756
|
}
|
|
10757
10757
|
};
|
|
10758
10758
|
for (const node of nodes) {
|
|
10759
|
-
|
|
10759
|
+
walk(node);
|
|
10760
10760
|
}
|
|
10761
10761
|
return accounts;
|
|
10762
10762
|
}
|
|
@@ -21383,14 +21383,14 @@ function collectionLine2(collection) {
|
|
|
21383
21383
|
}
|
|
21384
21384
|
function accountsInTree2(nodes) {
|
|
21385
21385
|
const accounts = /* @__PURE__ */ new Set();
|
|
21386
|
-
const
|
|
21386
|
+
const walk = (node) => {
|
|
21387
21387
|
accounts.add(node.accountId);
|
|
21388
21388
|
for (const child of node.children) {
|
|
21389
|
-
|
|
21389
|
+
walk(child);
|
|
21390
21390
|
}
|
|
21391
21391
|
};
|
|
21392
21392
|
for (const node of nodes) {
|
|
21393
|
-
|
|
21393
|
+
walk(node);
|
|
21394
21394
|
}
|
|
21395
21395
|
return accounts;
|
|
21396
21396
|
}
|
|
@@ -26995,14 +26995,14 @@ function collectionLine3(collection) {
|
|
|
26995
26995
|
}
|
|
26996
26996
|
function accountsInTree3(nodes) {
|
|
26997
26997
|
const accounts = /* @__PURE__ */ new Set();
|
|
26998
|
-
const
|
|
26998
|
+
const walk = (node) => {
|
|
26999
26999
|
accounts.add(node.accountId);
|
|
27000
27000
|
for (const child of node.children) {
|
|
27001
|
-
|
|
27001
|
+
walk(child);
|
|
27002
27002
|
}
|
|
27003
27003
|
};
|
|
27004
27004
|
for (const node of nodes) {
|
|
27005
|
-
|
|
27005
|
+
walk(node);
|
|
27006
27006
|
}
|
|
27007
27007
|
return accounts;
|
|
27008
27008
|
}
|
|
@@ -28820,6 +28820,55 @@ Full guides: __tooling__/docs/tools/baker/ads-<platform>.md (google|meta|linkedi
|
|
|
28820
28820
|
// src/commands/analytics/index.ts
|
|
28821
28821
|
import { readFileSync as readFileSync12 } from "fs";
|
|
28822
28822
|
|
|
28823
|
+
// ../api/src/analytics/flowEventKeys.ts
|
|
28824
|
+
function flowNodes(node, acc = []) {
|
|
28825
|
+
if (!node || typeof node !== "object") return acc;
|
|
28826
|
+
const record = node;
|
|
28827
|
+
acc.push(record);
|
|
28828
|
+
if (Array.isArray(record.children)) for (const child of record.children) flowNodes(child, acc);
|
|
28829
|
+
return acc;
|
|
28830
|
+
}
|
|
28831
|
+
function flowEventKeys(tree, slug) {
|
|
28832
|
+
const primary = [];
|
|
28833
|
+
const secondary = [];
|
|
28834
|
+
const nodes = flowNodes(tree).filter((node) => typeof node.id === "string" && node.id !== "");
|
|
28835
|
+
if (nodes.length === 0) return [];
|
|
28836
|
+
for (const node of nodes) {
|
|
28837
|
+
const id = node.id;
|
|
28838
|
+
const triggers = flowNodeTriggers(node.nodeData);
|
|
28839
|
+
for (const triggerId of triggers.available) {
|
|
28840
|
+
const candidate = {
|
|
28841
|
+
eventKey: formEventKey(slug, id, triggerId),
|
|
28842
|
+
nodeId: id,
|
|
28843
|
+
nodeName: typeof node.name === "string" ? node.name : id,
|
|
28844
|
+
nodeType: triggers.type,
|
|
28845
|
+
triggerId,
|
|
28846
|
+
isCompletion: triggers.completion === triggerId
|
|
28847
|
+
};
|
|
28848
|
+
(candidate.isCompletion ? primary : secondary).push(candidate);
|
|
28849
|
+
}
|
|
28850
|
+
}
|
|
28851
|
+
return [
|
|
28852
|
+
...primary,
|
|
28853
|
+
...secondary,
|
|
28854
|
+
{
|
|
28855
|
+
eventKey: `submit:${slug}`,
|
|
28856
|
+
nodeId: null,
|
|
28857
|
+
nodeName: "the Form ran out of steps",
|
|
28858
|
+
nodeType: null,
|
|
28859
|
+
triggerId: null,
|
|
28860
|
+
// A Form reaching its last node is as primary as an outcome gets for a
|
|
28861
|
+
// Form with no widget in it — but it never fires on one that ends in a
|
|
28862
|
+
// booking widget or a redirect, so it does not lead the list.
|
|
28863
|
+
isCompletion: false
|
|
28864
|
+
}
|
|
28865
|
+
];
|
|
28866
|
+
}
|
|
28867
|
+
function suggestedEnding(endings) {
|
|
28868
|
+
const deepestFirst = [...endings].reverse();
|
|
28869
|
+
return deepestFirst.find((row) => row.isCompletion && row.nodeType !== "text") ?? deepestFirst.find((row) => row.isCompletion) ?? endings[endings.length - 1] ?? null;
|
|
28870
|
+
}
|
|
28871
|
+
|
|
28823
28872
|
// ../api/src/event-ingest/arrivals.ts
|
|
28824
28873
|
import { z as z33 } from "zod";
|
|
28825
28874
|
|
|
@@ -29999,56 +30048,14 @@ function mergeStoredWithCounts(stored, reported) {
|
|
|
29999
30048
|
}
|
|
30000
30049
|
|
|
30001
30050
|
// src/commands/analytics/flowConversionKeys.ts
|
|
30002
|
-
function walk(node, acc = []) {
|
|
30003
|
-
if (!node || typeof node !== "object") return acc;
|
|
30004
|
-
const record = node;
|
|
30005
|
-
acc.push(record);
|
|
30006
|
-
if (Array.isArray(record.children)) for (const child of record.children) walk(child, acc);
|
|
30007
|
-
return acc;
|
|
30008
|
-
}
|
|
30009
|
-
function flowConversionCandidates(tree, slug) {
|
|
30010
|
-
const primary = [];
|
|
30011
|
-
const secondary = [];
|
|
30012
|
-
for (const node of walk(tree)) {
|
|
30013
|
-
const id = typeof node.id === "string" ? node.id : null;
|
|
30014
|
-
if (!id) continue;
|
|
30015
|
-
const triggers = flowNodeTriggers(node.nodeData);
|
|
30016
|
-
for (const triggerId of triggers.available) {
|
|
30017
|
-
const candidate = {
|
|
30018
|
-
eventKey: formEventKey(slug, id, triggerId),
|
|
30019
|
-
nodeId: id,
|
|
30020
|
-
nodeName: typeof node.name === "string" ? node.name : id,
|
|
30021
|
-
nodeType: triggers.type,
|
|
30022
|
-
triggerId,
|
|
30023
|
-
isCompletion: triggers.completion === triggerId
|
|
30024
|
-
};
|
|
30025
|
-
(candidate.isCompletion ? primary : secondary).push(candidate);
|
|
30026
|
-
}
|
|
30027
|
-
}
|
|
30028
|
-
return [
|
|
30029
|
-
...primary,
|
|
30030
|
-
...secondary,
|
|
30031
|
-
{
|
|
30032
|
-
eventKey: `submit:${slug}`,
|
|
30033
|
-
nodeId: null,
|
|
30034
|
-
nodeName: "the Form ran out of steps",
|
|
30035
|
-
nodeType: null,
|
|
30036
|
-
triggerId: null,
|
|
30037
|
-
// A Form reaching its last node is as primary as an outcome gets for a
|
|
30038
|
-
// Form with no widget in it — but it never fires on one that ends in a
|
|
30039
|
-
// booking widget or a redirect, so it does not lead the list.
|
|
30040
|
-
isCompletion: false
|
|
30041
|
-
}
|
|
30042
|
-
];
|
|
30043
|
-
}
|
|
30044
30051
|
function formKeyRefusal(eventKey, tree, slug) {
|
|
30045
30052
|
const parsed = parseEventKey(eventKey);
|
|
30046
30053
|
if (!parsed || parsed.family !== "form" || parsed.flowSlug !== slug) return null;
|
|
30047
|
-
const node =
|
|
30054
|
+
const node = flowNodes(tree).find((candidate) => candidate.id === parsed.nodeId);
|
|
30048
30055
|
if (!node) {
|
|
30049
30056
|
return {
|
|
30050
30057
|
message: `"${slug}" has no step with id "${parsed.nodeId}", so this key would be stored and count zero forever.`,
|
|
30051
|
-
fix: `Steps in this Form: ${
|
|
30058
|
+
fix: `Steps in this Form: ${flowNodes(tree).map((n) => `${String(n.id)} (${String(n.name ?? "unnamed")})`).join(", ")}. \`baker analytics conversions --flow ${slug}\` prints each one already spelled as an event key.`
|
|
30052
30059
|
};
|
|
30053
30060
|
}
|
|
30054
30061
|
const triggers = flowNodeTriggers(node.nodeData);
|
|
@@ -30079,8 +30086,7 @@ function flowConversionHints(slug, rows, noConversionReason) {
|
|
|
30079
30086
|
`Nothing here is counted, and that is on purpose: this Form declares no outcome \u2014 "${noConversionReason}". Leave it alone unless that has stopped being true.`
|
|
30080
30087
|
];
|
|
30081
30088
|
}
|
|
30082
|
-
const
|
|
30083
|
-
const suggestion = deepestFirst.find((row) => row.isCompletion && row.nodeType !== "text") ?? deepestFirst.find((row) => row.isCompletion) ?? rows[rows.length - 1];
|
|
30089
|
+
const suggestion = suggestedEnding(rows);
|
|
30084
30090
|
return [
|
|
30085
30091
|
`Nothing on "${slug}" is counted, so it converts nobody on every report however many people finish it \u2014 Baker never guesses which ending is the point of a Form.`,
|
|
30086
30092
|
...suggestion ? [
|
|
@@ -30091,7 +30097,7 @@ function flowConversionHints(slug, rows, noConversionReason) {
|
|
|
30091
30097
|
}
|
|
30092
30098
|
function flowCoverage(forms, definitions) {
|
|
30093
30099
|
return forms.map(({ slug, tree }) => {
|
|
30094
|
-
const rows = joinFlowConversions(
|
|
30100
|
+
const rows = joinFlowConversions(flowEventKeys(tree, slug), definitions);
|
|
30095
30101
|
const declared = tree?.noConversion?.reason;
|
|
30096
30102
|
const seen = /* @__PURE__ */ new Set();
|
|
30097
30103
|
return {
|
|
@@ -32109,7 +32115,7 @@ function readFlowConversions2(slug, definitions) {
|
|
|
32109
32115
|
return {
|
|
32110
32116
|
slug,
|
|
32111
32117
|
noConversionReason: reason,
|
|
32112
|
-
endings: joinFlowConversions(
|
|
32118
|
+
endings: joinFlowConversions(flowEventKeys(tree, slug), definitions)
|
|
32113
32119
|
};
|
|
32114
32120
|
}
|
|
32115
32121
|
function conversionsEnvelope(args4, definitions, candidates) {
|
|
@@ -47226,8 +47232,54 @@ Full guide: __tooling__/docs/tools/baker/flows.md`
|
|
|
47226
47232
|
});
|
|
47227
47233
|
|
|
47228
47234
|
// src/commands/funnel/index.ts
|
|
47235
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
47229
47236
|
import { defineCommand as defineCommand129 } from "citty";
|
|
47230
47237
|
|
|
47238
|
+
// src/commands/funnel/formMoments.ts
|
|
47239
|
+
var MAX_NAMED_FORMS = 8;
|
|
47240
|
+
function formMoments(events, forms) {
|
|
47241
|
+
const seen = new Set(events.map((event) => event.eventKey));
|
|
47242
|
+
const rows = [];
|
|
47243
|
+
for (const form of forms) {
|
|
47244
|
+
const outcome = suggestedEnding(flowEventKeys(form.tree, form.slug));
|
|
47245
|
+
if (outcome === null || seen.has(outcome.eventKey)) continue;
|
|
47246
|
+
seen.add(outcome.eventKey);
|
|
47247
|
+
rows.push({
|
|
47248
|
+
eventKey: outcome.eventKey,
|
|
47249
|
+
origin: "site",
|
|
47250
|
+
flowSlug: form.slug,
|
|
47251
|
+
...outcome.nodeType === null ? {} : { nodeType: outcome.nodeType },
|
|
47252
|
+
events: 0,
|
|
47253
|
+
sessions: 0,
|
|
47254
|
+
step: outcome.nodeName,
|
|
47255
|
+
seen: false,
|
|
47256
|
+
outcome: true
|
|
47257
|
+
});
|
|
47258
|
+
}
|
|
47259
|
+
return rows;
|
|
47260
|
+
}
|
|
47261
|
+
function withFormMoments(moments, forms) {
|
|
47262
|
+
return { ...moments, events: [...moments.events, ...formMoments(moments.events, forms)] };
|
|
47263
|
+
}
|
|
47264
|
+
function unplacedFormHints(steps, forms) {
|
|
47265
|
+
const onAStep = new Set(
|
|
47266
|
+
steps.flatMap((step) => (step.triggers ?? []).flatMap((trigger) => trigger.eventKey ? [trigger.eventKey] : []))
|
|
47267
|
+
);
|
|
47268
|
+
const unplaced = [];
|
|
47269
|
+
for (const form of forms) {
|
|
47270
|
+
const endings = flowEventKeys(form.tree, form.slug);
|
|
47271
|
+
if (endings.some((ending) => onAStep.has(ending.eventKey))) continue;
|
|
47272
|
+
const outcome = suggestedEnding(endings);
|
|
47273
|
+
if (outcome !== null) unplaced.push(`${form.slug} \u2192 \`${outcome.eventKey}\` ("${outcome.nodeName}")`);
|
|
47274
|
+
}
|
|
47275
|
+
if (unplaced.length === 0) return [];
|
|
47276
|
+
const shown = unplaced.slice(0, MAX_NAMED_FORMS);
|
|
47277
|
+
const rest = unplaced.length - shown.length;
|
|
47278
|
+
return [
|
|
47279
|
+
`${unplaced.length} Form(s) in this workspace reach no funnel step, so they move nobody along it however many people finish them: ${shown.join("; ")}${rest > 0 ? `; and ${rest} more` : ""}. Place one with \`baker funnel --add-trigger <step> --event <key>\`, which adds that one way in and leaves the rest of the step alone (\`baker funnel\` with no flags lists the step keys). If you also count a Form as a page conversion, count THAT SAME key, or the two numbers disagree for ever. A Form's other endings \u2014 a booking widget mid-flow, an embed's own signals \u2014 are listed by \`baker analytics conversions --flow <slug>\`.`
|
|
47280
|
+
];
|
|
47281
|
+
}
|
|
47282
|
+
|
|
47231
47283
|
// ../api/src/funnel/vocabulary.ts
|
|
47232
47284
|
var FUNNEL_STEP_CLASSES = [
|
|
47233
47285
|
/** Saw the offer: a landing opened, an ad clicked through. */
|
|
@@ -47520,6 +47572,18 @@ var funnelRequestSchema = z44.object({
|
|
|
47520
47572
|
step: funnelStepSchema.optional(),
|
|
47521
47573
|
/** One step taken out by key; whatever came after it moves up to whatever came before it. */
|
|
47522
47574
|
removeStep: z44.string().min(1).max(64).optional(),
|
|
47575
|
+
/**
|
|
47576
|
+
* ONE way in added to a step, leaving the rest of that step alone.
|
|
47577
|
+
*
|
|
47578
|
+
* `step` takes a whole step, so adding a way in through it means restating
|
|
47579
|
+
* the step's name, stage, `after[]` and every trigger it already had — and a
|
|
47580
|
+
* trigger left out of that restatement is silently removed. This is the door
|
|
47581
|
+
* for the thing that is actually being asked ("this Form's booking should
|
|
47582
|
+
* count here"), and it cannot drop anything.
|
|
47583
|
+
*/
|
|
47584
|
+
addTrigger: z44.object({ stepKey: z44.string().min(1).max(64), eventKey: z44.string().min(1).max(320) }).optional(),
|
|
47585
|
+
/** ONE way in taken off a step, by the event key it listens for. */
|
|
47586
|
+
removeTrigger: z44.object({ stepKey: z44.string().min(1).max(64), eventKey: z44.string().min(1).max(320) }).optional(),
|
|
47523
47587
|
/** One of the ready-made graphs, instead of stating steps. */
|
|
47524
47588
|
preset: z44.enum(FUNNEL_VERTICALS).optional(),
|
|
47525
47589
|
/** Also return the suggestion library and the presets. */
|
|
@@ -47597,7 +47661,30 @@ var funnelResponseSchema = z44.object({
|
|
|
47597
47661
|
events: z44.number(),
|
|
47598
47662
|
sessions: z44.number(),
|
|
47599
47663
|
/** The name it is counted under as a page conversion, when the company counts it. Informational. */
|
|
47600
|
-
countedAs: z44.string().optional()
|
|
47664
|
+
countedAs: z44.string().optional(),
|
|
47665
|
+
/**
|
|
47666
|
+
* The step of the Form this happens on, in the Form's own words —
|
|
47667
|
+
* never a node id. Present on a Form's ending read from the Form
|
|
47668
|
+
* itself, which is the only place the name is known.
|
|
47669
|
+
*/
|
|
47670
|
+
step: z44.string().optional(),
|
|
47671
|
+
/**
|
|
47672
|
+
* `true` on the ONE ending of a Form that is its outcome — the
|
|
47673
|
+
* booking on a Form that books, the submit on a Form that submits.
|
|
47674
|
+
* A Form raises several events and only one of them is the point;
|
|
47675
|
+
* without this the agent is handed five equal-looking keys and the
|
|
47676
|
+
* lifecycle noise a widget raises about itself sits among them.
|
|
47677
|
+
* Same rule as `baker analytics conversions` recommends, so the
|
|
47678
|
+
* conversion and the funnel step land on the same event.
|
|
47679
|
+
*/
|
|
47680
|
+
outcome: z44.boolean().optional(),
|
|
47681
|
+
/**
|
|
47682
|
+
* `false` on an ending a Form raises natively but nobody has fired
|
|
47683
|
+
* yet — derived from the Form, offered at zero, exactly as a
|
|
47684
|
+
* Source is offered before its first send. Absent means it came
|
|
47685
|
+
* from the event store and therefore happened.
|
|
47686
|
+
*/
|
|
47687
|
+
seen: z44.boolean().optional()
|
|
47601
47688
|
})
|
|
47602
47689
|
),
|
|
47603
47690
|
/** The company's sources: a system of theirs that posts events to Baker, by the event name it raises. */
|
|
@@ -47653,9 +47740,15 @@ function parseFunnelArgs(raw) {
|
|
|
47653
47740
|
const step = parseStep(raw.step);
|
|
47654
47741
|
const removeStep = parseRemoveStep(raw["remove-step"] ?? raw.removeStep);
|
|
47655
47742
|
const preset = parsePreset(raw.preset);
|
|
47656
|
-
const
|
|
47743
|
+
const addTrigger = parseWayIn(raw["add-trigger"] ?? raw.addTrigger, raw.event, "--add-trigger");
|
|
47744
|
+
const removeTrigger = parseWayIn(raw["remove-trigger"] ?? raw.removeTrigger, raw.event, "--remove-trigger");
|
|
47745
|
+
const doors = [steps, step, removeStep, preset, addTrigger, removeTrigger].filter(
|
|
47746
|
+
(door) => door !== void 0
|
|
47747
|
+
).length;
|
|
47657
47748
|
if (doors > 1) {
|
|
47658
|
-
throw new FunnelArgsError(
|
|
47749
|
+
throw new FunnelArgsError(
|
|
47750
|
+
"Give one of --steps, --step, --remove-step, --preset, --add-trigger or --remove-trigger, not two."
|
|
47751
|
+
);
|
|
47659
47752
|
}
|
|
47660
47753
|
const days = raw.days === void 0 ? void 0 : Number(raw.days);
|
|
47661
47754
|
if (days !== void 0 && (!Number.isInteger(days) || days <= 0 || days > 400)) {
|
|
@@ -47666,6 +47759,8 @@ function parseFunnelArgs(raw) {
|
|
|
47666
47759
|
...step === void 0 ? {} : { step },
|
|
47667
47760
|
...removeStep === void 0 ? {} : { removeStep },
|
|
47668
47761
|
...preset === void 0 ? {} : { preset },
|
|
47762
|
+
...addTrigger === void 0 ? {} : { addTrigger },
|
|
47763
|
+
...removeTrigger === void 0 ? {} : { removeTrigger },
|
|
47669
47764
|
templates: raw.templates === true,
|
|
47670
47765
|
moments: raw.moments === true,
|
|
47671
47766
|
...days === void 0 ? {} : { days }
|
|
@@ -47677,6 +47772,8 @@ function funnelWrite(args4) {
|
|
|
47677
47772
|
...args4.step === void 0 ? {} : { step: args4.step },
|
|
47678
47773
|
...args4.removeStep === void 0 ? {} : { removeStep: args4.removeStep },
|
|
47679
47774
|
...args4.preset === void 0 ? {} : { preset: args4.preset },
|
|
47775
|
+
...args4.addTrigger === void 0 ? {} : { addTrigger: args4.addTrigger },
|
|
47776
|
+
...args4.removeTrigger === void 0 ? {} : { removeTrigger: args4.removeTrigger },
|
|
47680
47777
|
...args4.templates ? { templates: true } : {},
|
|
47681
47778
|
...args4.moments ? { moments: true } : {},
|
|
47682
47779
|
...args4.days === void 0 ? {} : { days: args4.days }
|
|
@@ -47786,6 +47883,26 @@ function parsePreset(raw) {
|
|
|
47786
47883
|
}
|
|
47787
47884
|
return raw;
|
|
47788
47885
|
}
|
|
47886
|
+
function parseWayIn(stepKey, eventKey, flag) {
|
|
47887
|
+
if (stepKey === void 0) return void 0;
|
|
47888
|
+
if (typeof stepKey !== "string" || stepKey.trim() === "") {
|
|
47889
|
+
throw new FunnelArgsError(`${flag} takes the key of the step to change: \`${flag} lead\`.`);
|
|
47890
|
+
}
|
|
47891
|
+
if (typeof eventKey !== "string" || eventKey.trim() === "") {
|
|
47892
|
+
throw new FunnelArgsError(`${flag} needs --event, naming what gets somebody there.`, {
|
|
47893
|
+
action: "read_the_moments",
|
|
47894
|
+
explanation: `Run \`baker funnel --moments\` and copy an \`events[].eventKey\` \u2014 a Form's own outcome is listed there at zero before anybody has filled it in. Then: \`${flag} ${stepKey.trim()} --event "<key>"\`.`
|
|
47895
|
+
});
|
|
47896
|
+
}
|
|
47897
|
+
const key = eventKey.trim();
|
|
47898
|
+
if (flag === "--add-trigger" && parseEventKey(key) === null) {
|
|
47899
|
+
throw new FunnelArgsError(`"${key}" is not an event key, so nothing would ever reach that step through it.`, {
|
|
47900
|
+
action: "read_the_moments",
|
|
47901
|
+
explanation: "Run `baker funnel --moments` and copy an `events[].eventKey`. They look like form:<form>:<step>:<trigger>, submit:<form>, page:<name> or view:<landing>."
|
|
47902
|
+
});
|
|
47903
|
+
}
|
|
47904
|
+
return { stepKey: stepKey.trim(), eventKey: key };
|
|
47905
|
+
}
|
|
47789
47906
|
|
|
47790
47907
|
// src/commands/funnel/index.ts
|
|
47791
47908
|
var args3 = {
|
|
@@ -47799,6 +47916,21 @@ var args3 = {
|
|
|
47799
47916
|
description: 'ONE step as a JSON object, in the same shape as an entry of --steps. It is added to the funnel as it now stands, or replaces the step with the same `key`, and every other step is left exactly as it is \u2014 the door for adding or changing a stage without restating the rest. Example: --step \'{"key":"demo","displayName":"Demo held","stepClass":"engaged","after":["lead"],"triggers":[{"id":"t1","kind":"event","eventKey":"page:demo_held"}]}\'',
|
|
47800
47917
|
required: false
|
|
47801
47918
|
},
|
|
47919
|
+
"add-trigger": {
|
|
47920
|
+
type: "string",
|
|
47921
|
+
description: 'The key of ONE step to add a way in to, with `--event` naming what gets somebody there: `--add-trigger lead --event "submit:contact"`. Start here for "this Form should count as a lead" \u2014 it adds that one way in and leaves the step\'s name, stage, `after[]` and every other trigger exactly as they are. Prefer it to `--step`, which takes a WHOLE step and therefore silently removes any trigger the restatement forgets. Adding a key the step already listens for changes nothing. Take the key from `--moments`, never from memory',
|
|
47922
|
+
required: false
|
|
47923
|
+
},
|
|
47924
|
+
"remove-trigger": {
|
|
47925
|
+
type: "string",
|
|
47926
|
+
description: 'The key of ONE step to take a way in OFF, with `--event` naming which: `--remove-trigger lead --event "submit:contact"`. By event key rather than by trigger id, because the id is not something you ever saw. Everything else about the step is untouched',
|
|
47927
|
+
required: false
|
|
47928
|
+
},
|
|
47929
|
+
event: {
|
|
47930
|
+
type: "string",
|
|
47931
|
+
description: "The event key `--add-trigger` or `--remove-trigger` acts on \u2014 an `events[].eventKey` from `--moments`, never invented. A Form's own outcome is listed there at zero, marked `outcome: true`, before anybody has filled the Form in",
|
|
47932
|
+
required: false
|
|
47933
|
+
},
|
|
47802
47934
|
"remove-step": {
|
|
47803
47935
|
type: "string",
|
|
47804
47936
|
description: "The key of one step to take off the funnel. Whatever came after it moves up to whatever came before it, so the chain stays joined. The response lists it under `removed`",
|
|
@@ -47811,7 +47943,7 @@ var args3 = {
|
|
|
47811
47943
|
},
|
|
47812
47944
|
moments: {
|
|
47813
47945
|
type: "boolean",
|
|
47814
|
-
description: "Also return everything a trigger can name, so a trigger is PICKED rather than invented: `events` (every event this company's Forms, pages and systems
|
|
47946
|
+
description: "Also return everything a trigger can name, so a trigger is PICKED rather than invented: `events` (every event this company's Forms, pages and systems produced in the window, with volume, the Form it belongs to, `origin` \u2014 `site` for a page or Form, `systems` for the client's own server, `both` \u2014 and `countedAs` when the company also counts it as a page conversion, which a trigger does not need; PLUS **one row per Form in this workspace \u2014 its OUTCOME** \u2014 at zero, with `outcome: true`, `seen: false` and the `step` it happens on, so a Form built minutes ago is pickable with nothing set up first. It is the booking on a Form that books, the submit on a Form that submits, and it is the same ending `baker analytics conversions` recommends counting, so the step and the conversion land on the same event. One row and not all seven a Form raises: the rest are rarely what a step wants, and `baker analytics conversions --flow <slug>` lists every ending of one Form when they are before anybody has filled it in), `sources` (the client's own systems that post events to Baker, by the `page:<name>` key each raises, pickable before its first send arrives) and `landings` (its pages, by the id a `landing` trigger takes). Use this before writing any `triggers`: a key typed from memory saves, publishes and counts nobody forever. A Form's events need NOTHING set up first \u2014 no Source, no conversion: a Baker page raises them by itself",
|
|
47815
47947
|
required: false
|
|
47816
47948
|
},
|
|
47817
47949
|
days: {
|
|
@@ -47833,17 +47965,20 @@ registerSchema({
|
|
|
47833
47965
|
var funnelCommand2 = defineCommand129({
|
|
47834
47966
|
meta: {
|
|
47835
47967
|
name: "funnel",
|
|
47836
|
-
description: 'Start here: run with no flags to see the funnel this company has, with the last 30 days of PEOPLE counted beside every step \u2014 `people` reached it, `atLeast` got at least that far, `before` got as far as the step before, `share` is the ratio, and `worstStep` names where the most people are lost. Every company has one from the day it exists: Visited (any landing) \u2192 Became a lead \u2192 Became a customer, the last two with no way in until somebody gives them one. Then `--moments` for everything a trigger can name (every event the company\'s Forms, pages and systems
|
|
47968
|
+
description: 'Start here: run with no flags to see the funnel this company has, with the last 30 days of PEOPLE counted beside every step \u2014 `people` reached it, `atLeast` got at least that far, `before` got as far as the step before, `share` is the ratio, and `worstStep` names where the most people are lost. Every company has one from the day it exists: Visited (any landing) \u2192 Became a lead \u2192 Became a customer, the last two with no way in until somebody gives them one. Then `--moments` for everything a trigger can name (every event the company\'s Forms, pages and systems produced, its sources, its landings, plus each Form\'s own outcome at zero). **To make an event count on a step \u2014 the usual job \u2014 use `--add-trigger <step> --event <key>`:** it adds that one way in and touches nothing else about the step. `--step \'<json>\'` is for adding or renaming a STEP; it replaces the step with that key, so it means restating its `after` and every trigger it keeps, and one left out is gone. A step is reached by three kinds of thing and nothing else: an event by its own key (`{"id":"t1","kind":"event","eventKey":"<from moments.events or moments.sources>"}`), one landing being viewed (`{"id":"t2","kind":"landing","landingId":"<from moments.landings>"}`) or any landing (`{"id":"t3","kind":"any_landing"}`). Nothing has to be named first. Pick every trigger from `--moments`, never from memory. A step with no `triggers` advances NOBODY and reports zero forever without warning \u2014 that is what the hints keep pointing at. There is no default door: a Form is only counted where a trigger names it. Keep it true: a chat that adds a Form, a Source or an event that moves people forward places it on its step in the same chat. Each step comes back with `sends[]`, read-only: where the people who reach it are sent and what happened, read off the system events behind its ways in. A send is set on the event with `baker analytics sends`, never on a step, and once published it spends ad budget \u2014 a failed one is named in the hints. Everything here is STAGED: it becomes the company\'s funnel in one piece when the chat is published \u2014 the client sees it on the canvas in this chat and can edit it there too \u2014 and the previous version stays on file so what was already measured under it is not lost.'
|
|
47837
47969
|
},
|
|
47838
47970
|
args: args3,
|
|
47839
47971
|
run: async ({ args: raw }) => {
|
|
47840
47972
|
try {
|
|
47841
47973
|
const parsed = parseFunnelArgs(raw);
|
|
47842
47974
|
const response = await apiPost("/api/funnel", funnelWrite(parsed));
|
|
47975
|
+
const forms = workspaceForms();
|
|
47976
|
+
const data = response.data.moments === void 0 ? response.data : { ...response.data, moments: withFormMoments(response.data.moments, forms) };
|
|
47977
|
+
const hints2 = [...response.hints ?? [], ...unplacedFormHints(response.data.steps ?? [], forms)];
|
|
47843
47978
|
writeJsonEnvelope({
|
|
47844
47979
|
ok: true,
|
|
47845
|
-
data
|
|
47846
|
-
...
|
|
47980
|
+
data,
|
|
47981
|
+
...hints2.length > 0 ? { hints: hints2 } : {}
|
|
47847
47982
|
});
|
|
47848
47983
|
} catch (err) {
|
|
47849
47984
|
handleError4(err);
|
|
@@ -47868,6 +48003,16 @@ function handleError4(err) {
|
|
|
47868
48003
|
});
|
|
47869
48004
|
process.exit(1);
|
|
47870
48005
|
}
|
|
48006
|
+
function workspaceForms() {
|
|
48007
|
+
const forms = [];
|
|
48008
|
+
for (const slug of listFlowSlugs()) {
|
|
48009
|
+
try {
|
|
48010
|
+
forms.push({ slug, tree: JSON.parse(readFileSync15(flowDataPath(slug), "utf-8")) });
|
|
48011
|
+
} catch {
|
|
48012
|
+
}
|
|
48013
|
+
}
|
|
48014
|
+
return forms;
|
|
48015
|
+
}
|
|
47871
48016
|
|
|
47872
48017
|
// src/commands/ga4/index.ts
|
|
47873
48018
|
import { defineCommand as defineCommand136 } from "citty";
|
|
@@ -47997,7 +48142,7 @@ Examples:
|
|
|
47997
48142
|
import { defineCommand as defineCommand131 } from "citty";
|
|
47998
48143
|
|
|
47999
48144
|
// src/commands/ga4/shared.ts
|
|
48000
|
-
import { readFileSync as
|
|
48145
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
48001
48146
|
function failValidation3(message) {
|
|
48002
48147
|
writeJsonEnvelope({ ok: false, error: { code: "VALIDATION_ERROR", message } });
|
|
48003
48148
|
process.exit(1);
|
|
@@ -48013,7 +48158,7 @@ function requireTarget5(args4, entity) {
|
|
|
48013
48158
|
function readJsonSource(args4, flag) {
|
|
48014
48159
|
const inline = args4[flag];
|
|
48015
48160
|
const file = args4.file;
|
|
48016
|
-
const raw = typeof file === "string" && file.length > 0 ?
|
|
48161
|
+
const raw = typeof file === "string" && file.length > 0 ? readFileSync16(file, "utf8") : typeof inline === "string" && inline.length > 0 ? inline : void 0;
|
|
48017
48162
|
if (raw === void 0) {
|
|
48018
48163
|
failValidation3(`pass --${flag} with inline JSON or --file with a path to a JSON file`);
|
|
48019
48164
|
}
|
|
@@ -48364,7 +48509,7 @@ Examples:
|
|
|
48364
48509
|
});
|
|
48365
48510
|
|
|
48366
48511
|
// src/commands/ga4/query.ts
|
|
48367
|
-
import { appendFileSync as appendFileSync2, existsSync as existsSync7, readFileSync as
|
|
48512
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync7, readFileSync as readFileSync17, writeFileSync as writeFileSync4 } from "fs";
|
|
48368
48513
|
import { resolve as resolve2 } from "path";
|
|
48369
48514
|
import { defineCommand as defineCommand134 } from "citty";
|
|
48370
48515
|
|
|
@@ -48455,7 +48600,7 @@ function writeRowsToFile2(filePath, rows, append) {
|
|
|
48455
48600
|
writeFileSync4(filePath, content, "utf-8");
|
|
48456
48601
|
}
|
|
48457
48602
|
} else if (append && existsSync7(filePath)) {
|
|
48458
|
-
const existing = JSON.parse(
|
|
48603
|
+
const existing = JSON.parse(readFileSync17(filePath, "utf-8"));
|
|
48459
48604
|
writeFileSync4(filePath, JSON.stringify([...existing, ...rows], null, 2), "utf-8");
|
|
48460
48605
|
} else {
|
|
48461
48606
|
writeFileSync4(filePath, JSON.stringify(rows, null, 2), "utf-8");
|
|
@@ -49307,7 +49452,7 @@ Full guide: __tooling__/docs/tools/baker/ga4.md`
|
|
|
49307
49452
|
import { defineCommand as defineCommand140 } from "citty";
|
|
49308
49453
|
|
|
49309
49454
|
// src/commands/gsc/query.ts
|
|
49310
|
-
import { appendFileSync as appendFileSync3, existsSync as existsSync8, readFileSync as
|
|
49455
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync8, readFileSync as readFileSync18, writeFileSync as writeFileSync5 } from "fs";
|
|
49311
49456
|
import { resolve as resolve3 } from "path";
|
|
49312
49457
|
import { defineCommand as defineCommand137 } from "citty";
|
|
49313
49458
|
|
|
@@ -49455,7 +49600,7 @@ function writeRowsToFile3(filePath, rows, append) {
|
|
|
49455
49600
|
writeFileSync5(filePath, content, "utf-8");
|
|
49456
49601
|
}
|
|
49457
49602
|
} else if (append && existsSync8(filePath)) {
|
|
49458
|
-
const existing = JSON.parse(
|
|
49603
|
+
const existing = JSON.parse(readFileSync18(filePath, "utf-8"));
|
|
49459
49604
|
writeFileSync5(filePath, JSON.stringify([...existing, ...rows], null, 2), "utf-8");
|
|
49460
49605
|
} else {
|
|
49461
49606
|
writeFileSync5(filePath, JSON.stringify(rows, null, 2), "utf-8");
|
|
@@ -56333,7 +56478,7 @@ var inPageCollectUsedCss = (selector) => {
|
|
|
56333
56478
|
}
|
|
56334
56479
|
return false;
|
|
56335
56480
|
};
|
|
56336
|
-
const
|
|
56481
|
+
const walk = (rules, sink) => {
|
|
56337
56482
|
for (const rule of Array.from(rules)) {
|
|
56338
56483
|
totalRules++;
|
|
56339
56484
|
if (rule instanceof CSSStyleRule) {
|
|
@@ -56354,7 +56499,7 @@ var inPageCollectUsedCss = (selector) => {
|
|
|
56354
56499
|
const grouping = rule instanceof CSSMediaRule || rule instanceof CSSSupportsRule || typeof CSSLayerBlockRule !== "undefined" && rule instanceof CSSLayerBlockRule || typeof CSSContainerRule !== "undefined" && rule instanceof CSSContainerRule;
|
|
56355
56500
|
if (grouping) {
|
|
56356
56501
|
const inner = [];
|
|
56357
|
-
|
|
56502
|
+
walk(rule.cssRules, inner);
|
|
56358
56503
|
if (inner.length === 0) continue;
|
|
56359
56504
|
const condition = rule.conditionText ?? "";
|
|
56360
56505
|
const prelude = rule instanceof CSSMediaRule ? `@media ${condition}` : rule.cssText.split("{")[0]?.trim();
|
|
@@ -56368,7 +56513,7 @@ ${inner.join("\n")}
|
|
|
56368
56513
|
const owner = sheet.ownerNode;
|
|
56369
56514
|
if (owner?.hasAttribute?.("data-baker-freeze")) continue;
|
|
56370
56515
|
try {
|
|
56371
|
-
|
|
56516
|
+
walk(sheet.cssRules, kept);
|
|
56372
56517
|
} catch {
|
|
56373
56518
|
if (sheet.href) unreadableHrefs.push(sheet.href);
|
|
56374
56519
|
}
|
|
@@ -56819,7 +56964,7 @@ var inPageCollectMotion = (selector) => {
|
|
|
56819
56964
|
else if (infinite) loop.push(effect);
|
|
56820
56965
|
else entrance.push(effect);
|
|
56821
56966
|
};
|
|
56822
|
-
const
|
|
56967
|
+
const walk = (rules, insideScrollTimeline) => {
|
|
56823
56968
|
for (const rule of Array.from(rules)) {
|
|
56824
56969
|
if (rule instanceof CSSKeyframesRule) {
|
|
56825
56970
|
keyframesByName.set(rule.name, rule.cssText);
|
|
@@ -56837,17 +56982,17 @@ var inPageCollectMotion = (selector) => {
|
|
|
56837
56982
|
respectsReducedMotion = true;
|
|
56838
56983
|
continue;
|
|
56839
56984
|
}
|
|
56840
|
-
|
|
56985
|
+
walk(rule.cssRules, insideScrollTimeline);
|
|
56841
56986
|
continue;
|
|
56842
56987
|
}
|
|
56843
56988
|
const grouping = rule;
|
|
56844
|
-
if (grouping.cssRules)
|
|
56989
|
+
if (grouping.cssRules) walk(grouping.cssRules, insideScrollTimeline);
|
|
56845
56990
|
}
|
|
56846
56991
|
};
|
|
56847
56992
|
for (const sheet of Array.from(document.styleSheets)) {
|
|
56848
56993
|
if (sheet.ownerNode?.hasAttribute?.("data-baker-freeze")) continue;
|
|
56849
56994
|
try {
|
|
56850
|
-
|
|
56995
|
+
walk(sheet.cssRules, false);
|
|
56851
56996
|
} catch {
|
|
56852
56997
|
}
|
|
56853
56998
|
}
|
|
@@ -62686,7 +62831,7 @@ import { defineCommand as defineCommand217 } from "citty";
|
|
|
62686
62831
|
import { defineCommand as defineCommand214 } from "citty";
|
|
62687
62832
|
|
|
62688
62833
|
// src/commands/tag-manager/shared.ts
|
|
62689
|
-
import { readFileSync as
|
|
62834
|
+
import { readFileSync as readFileSync19 } from "fs";
|
|
62690
62835
|
function failValidation5(message) {
|
|
62691
62836
|
writeJsonEnvelope({ ok: false, error: { code: "VALIDATION_ERROR", message } });
|
|
62692
62837
|
process.exit(1);
|
|
@@ -62702,7 +62847,7 @@ function requireTarget6(args4, entity) {
|
|
|
62702
62847
|
function loadJsonArg2(args4, flag = "json") {
|
|
62703
62848
|
const inline = args4[flag];
|
|
62704
62849
|
const file = args4.file;
|
|
62705
|
-
const raw = typeof file === "string" && file.length > 0 ?
|
|
62850
|
+
const raw = typeof file === "string" && file.length > 0 ? readFileSync19(file, "utf8") : typeof inline === "string" && inline.length > 0 ? inline : void 0;
|
|
62706
62851
|
if (raw === void 0) {
|
|
62707
62852
|
failValidation5(`pass --${flag} with inline JSON or --file with a path to a JSON file`);
|
|
62708
62853
|
}
|
|
@@ -65981,7 +66126,7 @@ function refuseUnknownFlags(root, argv) {
|
|
|
65981
66126
|
}
|
|
65982
66127
|
|
|
65983
66128
|
// src/version.ts
|
|
65984
|
-
import { readFileSync as
|
|
66129
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
65985
66130
|
function packageJsonUrl() {
|
|
65986
66131
|
return new URL("../package.json", import.meta.url);
|
|
65987
66132
|
}
|
|
@@ -65993,7 +66138,7 @@ function parsePackageVersion(raw) {
|
|
|
65993
66138
|
throw new Error("Invalid CLI package.json: missing version");
|
|
65994
66139
|
}
|
|
65995
66140
|
function getCliVersion() {
|
|
65996
|
-
return parsePackageVersion(
|
|
66141
|
+
return parsePackageVersion(readFileSync20(packageJsonUrl(), "utf8"));
|
|
65997
66142
|
}
|
|
65998
66143
|
|
|
65999
66144
|
// src/cli.ts
|