Skip to content

Commit a3931bf

Browse files
feat: enrich cli_command_push telemetry with actorId and wasCreated (#1152)
## Summary - Adds `push.actorId` and `push.wasCreated` to the unified `cli_command` telemetry payload so each `cli_command_push` event carries the Actor ID being pushed and whether the push created a new Actor vs. updated an existing one. - After Keboola ETL refresh, this flattens to `push_actor_id` / `push_was_created` columns in Snowflake (mirroring the existing `create.*` pattern), unlocking per-surface attribution and dedup'd new-Actor counts. Closes #1151 --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ff4923b commit a3931bf

4 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/commands/actors/push.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ export class ActorsPushCommand extends ApifyCommand<typeof ActorsPushCommand> {
239239
}
240240
}
241241

242+
this.telemetryData.push = {
243+
actorId,
244+
wasCreated: isActorCreatedNow,
245+
};
246+
242247
const actorClient = apifyClient.actor(actorId);
243248

244249
info({ message: `Deploying Actor '${actorConfig!.name}' to Apify.` });

src/lib/command-framework/apify-command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,8 @@ export async function internalRunCommand<Cmd extends typeof BuiltApifyCommand>(
959959

960960
// eslint-disable-next-line dot-notation
961961
await instance['_run'](rawObject);
962+
963+
return instance;
962964
}
963965

964966
export declare class BuiltApifyCommand extends ApifyCommand {

src/lib/hooks/telemetry/trackEvent.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ interface CliCommandEvent {
3535
templateLanguage?: string;
3636
};
3737

38+
push?: {
39+
actorId?: string;
40+
wasCreated?: boolean;
41+
};
42+
3843
// init command
3944
actorWrapper?: string;
4045

test/api/commands/push.test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ describe('[api] apify push', () => {
8989
};
9090
writeFileSync(joinPath(LOCAL_CONFIG_PATH), JSON.stringify(actorJson, null, '\t'), { flag: 'w' });
9191

92-
await testRunCommand(ActorsPushCommand, { flags_noPrompt: true, flags_force: true });
92+
const pushInstance = await testRunCommand(ActorsPushCommand, {
93+
flags_noPrompt: true,
94+
flags_force: true,
95+
});
9396

9497
const userInfo = await getLocalUserInfo();
9598
const { name } = actorJson;
@@ -115,6 +118,12 @@ describe('[api] apify push', () => {
115118
// TODO: vlad, fix this too
116119
expect((createdActorVersion as any)!.sourceFiles.sort()).to.be.eql(sourceFiles.sort());
117120
expect(createdActorVersion!.sourceType).to.be.eql(ACTOR_SOURCE_TYPES.SOURCE_FILES);
121+
122+
// eslint-disable-next-line dot-notation
123+
expect(pushInstance['telemetryData'].push).to.be.eql({
124+
actorId: createdActor!.id,
125+
wasCreated: true,
126+
});
118127
},
119128
TEST_TIMEOUT,
120129
);
@@ -126,7 +135,7 @@ describe('[api] apify push', () => {
126135
const testActorClient = testUserClient.actor(testActor.id);
127136
const actorJson = JSON.parse(readFileSync(joinPath(LOCAL_CONFIG_PATH), 'utf8'));
128137

129-
await testRunCommand(ActorsPushCommand, {
138+
const pushInstance = await testRunCommand(ActorsPushCommand, {
130139
args_actorId: testActor.id,
131140
flags_noPrompt: true,
132141
flags_force: true,
@@ -152,6 +161,12 @@ describe('[api] apify push', () => {
152161
]);
153162
expect((testActorVersion as any).sourceFiles.sort()).to.be.eql(sourceFiles.sort());
154163
expect(testActorVersion!.sourceType).to.be.eql(ACTOR_SOURCE_TYPES.SOURCE_FILES);
164+
165+
// eslint-disable-next-line dot-notation
166+
expect(pushInstance['telemetryData'].push).to.be.eql({
167+
actorId: testActor.id,
168+
wasCreated: false,
169+
});
155170
},
156171
TEST_TIMEOUT,
157172
);

0 commit comments

Comments
 (0)