Skip to content

Commit 0d253f1

Browse files
authored
Merge pull request #6451 from Shopify/analytics-logging-issue
Fix theme analytics logging even when a command fails
2 parents 34a7758 + 7b1a963 commit 0d253f1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/theme/src/cli/utilities/theme-command.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ export default abstract class ThemeCommand extends Command {
8888
throw new AbortError(`Path does not exist: ${flags.path}`)
8989
}
9090

91-
await this.command(flags, session, false, args)
92-
await this.logAnalyticsData(session)
91+
try {
92+
await this.command(flags, session, false, args)
93+
} finally {
94+
await this.logAnalyticsData(session)
95+
}
9396
return
9497
}
9598

@@ -267,8 +270,11 @@ export default abstract class ThemeCommand extends Command {
267270
const commandName = this.constructor.name.toLowerCase()
268271
recordEvent(`theme-command:${commandName}:multi-env:authenticated`)
269272

270-
await this.command(flags, session, true, {}, {stdout, stderr})
271-
await this.logAnalyticsData(session)
273+
try {
274+
await this.command(flags, session, true, {}, {stdout, stderr})
275+
} finally {
276+
await this.logAnalyticsData(session)
277+
}
272278
})
273279

274280
// eslint-disable-next-line no-catch-all/no-catch-all
@@ -371,7 +377,6 @@ export default abstract class ThemeCommand extends Command {
371377
if (!session) return
372378

373379
const data = compileData()
374-
375380
await addPublicMetadata(() => ({
376381
store_fqdn_hash: hashString(session.storeFqdn),
377382

0 commit comments

Comments
 (0)