Skip to content

Integrates subscribe and fetchAppLogs with developer dashboard #5498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

mssalemi
Copy link
Contributor

@mssalemi mssalemi commented Mar 10, 2025

Requires: #5497
Requires: Partners - js.app-logs-prototype-2Request: Core - 03-07-expose_dev_dash_route_to_manage_app_logs
Part of: https://github.com/Shopify/temp-project-mover-Archetypically-20250320163947/issues/137

WHY are these changes introduced?

This PR adds app logs functionality to the AppManagementClient, allowing app logs to be fetched through the Developer Platform client interface.

Key changes:

  • Implemented subscribeToAppLogs and appLogs methods in AppManagementClient
  • Updated the DeveloperPlatformClient interface to include organizationId and appId parameters
    • PartnersClient will ignore them
  • Added new fetchAppLogsDevDashboard in utils
  • Updated all app logs related components to pass through organizationId and appId

WHAT is this pull request doing?

How to test your changes?

All tests have been updated to include the new required parameters. The implementation has been tested with both Partners API and Developer Dashboard API backends.

Currently need different shops / app setup.

With app that lives in partners (I used prod):

pnpm run shopify app logs --path=./path-to-app

pnpm run shopify app dev --path=./path-to-app

Spin Dev Dashboard Setup

USE_APP_MANAGEMENT_API=1 SHOPIFY_SERVICE_ENV=spin pnpm run shopify app dev --path=./spin-dev-dash-app
USE_APP_MANAGEMENT_API=1 SHOPIFY_SERVICE_ENV=spin pnpm run shopify app logs --path=./spin-dev-dash-app

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@mssalemi mssalemi changed the title Ms.update amclient with app logs Integrates subscribe and fetchAppLogs with developer dashboard Mar 10, 2025
@mssalemi mssalemi force-pushed the ms.add-app-logs-to-devp branch from 65127cf to 120f6ff Compare March 10, 2025 17:45
@mssalemi mssalemi force-pushed the ms.add-app-logs-to-devp branch from 120f6ff to c645803 Compare March 10, 2025 19:12
@mssalemi mssalemi force-pushed the ms.update-amclient-with-app-logs branch from 0f2fa07 to d916529 Compare March 10, 2025 19:13
Copy link
Contributor

github-actions bot commented Mar 11, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
76.22% (-0.09% 🔻)
9294/12194
🟡 Branches
71.43% (-0.07% 🔻)
4553/6374
🟡 Functions
75.89% (-0.1% 🔻)
2418/3186
🟡 Lines
76.77% (-0.1% 🔻)
8785/11443
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / app-management-client.ts
42.12% (-1.67% 🔻)
38.46% (-2.35% 🔻)
39.6% (-1.21% 🔻)
40.59% (-1.7% 🔻)
🔴
... / partners-client.ts
25.64% (-0.02% 🔻)
31.58%
16.67% (-0.28% 🔻)
25.33% (-0.01% 🔻)

Test suite run success

2116 tests passing in 931 suites.

Report generated by 🧪jest coverage report action from b3ae5f7

@mssalemi mssalemi marked this pull request as ready for review March 12, 2025 13:43
@mssalemi mssalemi requested a review from a team as a code owner March 12, 2025 13:43
Copy link
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.

@@ -1067,3 +1104,78 @@ function appModuleVersion(mod: ReleasedAppModuleFragment): Required<AppModuleVer
},
}
}

interface AppLogsSubscribeQueryVariables {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe once the core PR is merged, we can import these types. Leaving here for now.

@mssalemi mssalemi force-pushed the ms.update-amclient-with-app-logs branch from 2c025a3 to e755a53 Compare March 12, 2025 15:29
@mssalemi mssalemi requested review from shauns and jacobsteves March 12, 2025 18:59
@mssalemi mssalemi force-pushed the ms.update-amclient-with-app-logs branch from 3ae5b5b to 54a0f72 Compare March 13, 2025 17:14
Copy link
Member

@jacobsteves jacobsteves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good! A couple small questions

Comment on lines 154 to 171
const fqdn = await appManagementFqdn()
let url = `https://${fqdn}/app_management/unstable/organizations/${organizationId}/app_logs/poll`

if (!cursor) {
return url
}

url += `?cursor=${cursor}`

if (filters?.status) {
url += `&status=${filters.status}`
}
if (filters?.source) {
url += `&source=${filters.source}`
}

return url
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is duplicated logic with generateFetchAppLogUrl. What if we created a helper that handled the url params and generateFetchAppLogUrl and generateFetchAppLogUrlDevDashboard can call that function with whatever url they need?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea good idea, I refactored this a bit in the previous PR by moving some of these helpers around. But I kept a general url builder helper in the utils addCursorAndFiltersToAppLogsUrl, then within each client they handle the URL portion.

@mssalemi mssalemi force-pushed the ms.add-app-logs-to-devp branch from 49c65b6 to fa530fe Compare March 13, 2025 19:34
@mssalemi mssalemi force-pushed the ms.update-amclient-with-app-logs branch from 54a0f72 to fc01c3f Compare March 13, 2025 20:49
@mssalemi mssalemi force-pushed the ms.add-app-logs-to-devp branch from fa530fe to 431253f Compare March 14, 2025 10:47
@mssalemi mssalemi force-pushed the ms.update-amclient-with-app-logs branch from 5c07499 to b255d6a Compare March 14, 2025 11:51
Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@mssalemi mssalemi force-pushed the ms.update-amclient-with-app-logs branch from b255d6a to a40c0a1 Compare March 14, 2025 12:06
@mssalemi mssalemi force-pushed the ms.update-amclient-with-app-logs branch from a40c0a1 to e1c562b Compare March 14, 2025 12:50
@mssalemi mssalemi requested a review from jacobsteves March 14, 2025 13:34
@mssalemi
Copy link
Contributor Author

mssalemi commented Mar 14, 2025

Sorry @jacobsteves , opened up a new stack here, pulled over the same changed.

https://app.graphite.dev/github/pr/Shopify/cli/5526/Add-%60appLogs%60-to-DeveloperPlatformClient-interface

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants