Skip to content

Commit 8aebe4f

Browse files
committed
feat: enrich Segment events with starter context from config
Persist the `starter` field in slicemachine.config.json during init when `--starter` is used, and auto-enrich all Segment events with it in TelemetryManager.track(). This lets us track migration funnel progression (e.g. changes:pushed) for projects originating from the agentic-migration-starter. Made-with: Cursor
1 parent 72bb68c commit 8aebe4f

6 files changed

Lines changed: 19 additions & 0 deletions

File tree

packages/init/src/SliceMachineInitProcess.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,9 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
10841084
...config,
10851085
repositoryName: this.context.repository.domain,
10861086
adapter: this.context.framework.adapterName,
1087+
...(this.options.starter
1088+
? { starter: this.options.starter }
1089+
: {}),
10871090
},
10881091
});
10891092
parentTask.title = "Updated Slice Machine configuration";
@@ -1098,6 +1101,9 @@ ${chalk.cyan("?")} Your Prismic repository name`.replace("\n", ""),
10981101
repositoryName: this.context.repository.domain,
10991102
adapter: this.context.framework.adapterName,
11001103
libraries: ["./slices"],
1104+
...(this.options.starter
1105+
? { starter: this.options.starter }
1106+
: {}),
11011107
},
11021108
path: sliceMachineConfigPath,
11031109
});

packages/manager/src/lib/decodeSliceMachineConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const SliceMachineConfigCodec = t.intersection([
2727
localSliceSimulatorURL: t.string,
2828
plugins: t.array(SliceMachineConfigPluginRegistrationCodec),
2929
labs: t.partial({ legacySliceUpgrader: t.boolean }),
30+
starter: t.string,
3031
}),
3132
]);
3233

packages/manager/src/managers/telemetry/TelemetryManager.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ export class TelemetryManager extends BaseManager {
111111
}
112112
}
113113

114+
let starter: string | undefined;
115+
try {
116+
const config = await this.project.getSliceMachineConfig();
117+
starter = config.starter;
118+
} catch {
119+
// noop, happen only when the user is not in a project
120+
}
121+
114122
let environmentKind: Environment["kind"] | "_unknown" | undefined =
115123
undefined;
116124
if (_includeEnvironmentKind) {
@@ -150,6 +158,7 @@ export class TelemetryManager extends BaseManager {
150158
properties: {
151159
nodeVersion: process.versions.node,
152160
environmentKind,
161+
starter,
153162
...properties,
154163
},
155164
context: { ...this._context },

packages/manager/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export type SliceMachineConfig = {
3232
adapter: SliceMachineConfigPluginRegistration;
3333
plugins?: SliceMachineConfigPluginRegistration[];
3434
labs?: { legacySliceUpgrader?: boolean };
35+
starter?: string;
3536
};
3637

3738
export type OnlyHookErrors<

packages/plugin-kit/src/lib/decodeSliceMachineConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const SliceMachineConfigCodec = t.intersection([
2727
localSliceSimulatorURL: t.string,
2828
plugins: t.array(SliceMachineConfigPluginRegistrationCodec),
2929
labs: t.partial({ legacySliceUpgrader: t.boolean }),
30+
starter: t.string,
3031
}),
3132
]);
3233

packages/plugin-kit/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type SliceMachineConfig = {
7070
adapter: SliceMachineConfigPluginRegistration;
7171
plugins?: SliceMachineConfigPluginRegistration[];
7272
labs?: { legacySliceUpgrader?: boolean };
73+
starter?: string;
7374
};
7475

7576
/**

0 commit comments

Comments
 (0)