Skip to content

Commit

Permalink
Fix app analytics hooks not being called
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacroldan committed May 2, 2024
1 parent 9f66320 commit 00553f0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"./node/plugins/*": {
"import": "./dist/cli/public/plugins/*.js",
"require": "./dist/cli/public/plugins/*.d.ts"
},
"./hooks": {
"import": "./dist/cli/hooks/*.js",
"types": "./dist/cli/hooks/*.d.ts"
}
},
"files": [
Expand Down
9 changes: 7 additions & 2 deletions packages/app/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ import Release from './commands/app/release.js'
import VersionsList from './commands/app/versions/list.js'
import WebhookTrigger from './commands/app/webhook/trigger.js'
import WebhookTriggerDeprecated from './commands/webhook/trigger.js'
import init from './hooks/clear_command_cache.js'
import gatherPublicMetadata from './hooks/public_metadata.js'
import gatherSensitiveMetadata from './hooks/sensitive_metadata.js'

const APP_COMMANDS = {
export const commands = {
'app:build': Build,
'app:deploy': Deploy,
'app:dev': Dev,
Expand All @@ -44,4 +47,6 @@ const APP_COMMANDS = {
'webhook:trigger': WebhookTriggerDeprecated,
}

export default APP_COMMANDS
export const AppSensitiveMetadataHook = gatherSensitiveMetadata
export const AppInitHook = init
export const AppPublicMetadataHook = gatherPublicMetadata
1 change: 1 addition & 0 deletions packages/cli-kit/src/public/node/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function reportAnalyticsEvent(options: ReportAnalyticsEventOptions)
const skipMonorailAnalytics = !alwaysLogAnalytics() && analyticsDisabled()
const skipMetricAnalytics = !alwaysLogMetrics() && analyticsDisabled()
if (skipMonorailAnalytics || skipMetricAnalytics) {
console.log(payload)
outputDebug(outputContent`Skipping command analytics, payload: ${outputToken.json(payload)}`)
}

Expand Down
22 changes: 20 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@
"-h"
],
"hooks": {
"init": "./dist/hooks/init.js",
"init": [
"./dist/hooks/init.js",
{
"target": "./dist/index.js",
"identifier": "AppInitHook"
}
],
"prerun": "./dist/hooks/prerun.js",
"postrun": "./dist/hooks/postrun.js",
"command_not_found": {
Expand All @@ -190,7 +196,19 @@
"update": {
"target": "./dist/index.js",
"identifier": "PluginHook"
}
},
"sensitive_command_metadata": [
{
"target": "./dist/index.js",
"identifier": "AppSensitiveMetadataHook"
}
],
"public_command_metadata": [
{
"target": "./dist/index.js",
"identifier": "AppPublicMetadataHook"
}
]
}
}
}
3 changes: 2 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import KitchenSinkStatic from './cli/commands/kitchen-sink/static.js'
import HydrogenInit from './cli/commands/hydrogen/init.js'
import DocsGenerate from './cli/commands/docs/generate.js'
import HelpCommand from './cli/commands/help.js'
import AppCommands from '@shopify/app'
import ThemeCommands from '@shopify/theme'
import {commands as AppCommands} from '@shopify/app'
import {commands as PluginCommandsCommands} from '@oclif/plugin-commands'
import {commands as PluginPluginsCommands} from '@oclif/plugin-plugins'
import {DidYouMeanCommands} from '@shopify/plugin-did-you-mean'
Expand All @@ -25,6 +25,7 @@ export {DidYouMeanHook} from '@shopify/plugin-did-you-mean'
export {default as TunnelStartHook} from '@shopify/plugin-cloudflare/hooks/tunnel'
export {default as TunnelProviderHook} from '@shopify/plugin-cloudflare/hooks/provider'
export {hooks as PluginHook} from '@oclif/plugin-plugins'
export {AppSensitiveMetadataHook, AppInitHook, AppPublicMetadataHook} from '@shopify/app'

// In some cases (for example when we boot the proxy server), when an exception is
// thrown, no 'exit' signal is sent to the process. We don't understand this fully.
Expand Down

0 comments on commit 00553f0

Please sign in to comment.