Skip to content
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

[ShopifyVM] Dev Dash - app logs #5490

Closed
wants to merge 4 commits into from
Closed

Conversation

mssalemi
Copy link
Contributor

@mssalemi mssalemi commented Mar 5, 2025

Part of: https://github.com/Shopify/shopify-functions/issues/605

Note:

We will need the relevant Core and Partners PR to be merged and do not have them merged. Hoping to get review on the approach I've taken, specically around how we fetch the app logs.

For polling app logs, in dev and logs, I've added this to determine which client to use.

  const response: Response = isDevDashboard
    ? await fetchAppLogsDevDashboard(jwtToken, orgId, appId, cursor)
    : await fetchAppLogs(jwtToken, cursor)

Another option or alternative, is we can move the fetchAppLogs to the DeveloperPlatformClient, but think this would involved a larger refactor and would prefer to tackle in another PR or issue.


WHY are these changes introduced?

This PR is for integrating app logs polling with the developer dashboard.

Background:

There is 2 steps for polling:

  1. Subscribe - This is done through the DeveloperPlatformClient

    • I updated the interface to accept organizationId: string, we also need appId for the request, we alraedy have access to that through the cli context
    • CLI will make a 'subscribe' request to receive a JWT token from partners
    • simple approach we can just implement the method and make request to dev dash endpoint
  2. Fetch App Logs - is a bit more complicated since we dont use the DeveloperPlatformClient

    • polling app logs is called through separate but similar code paths for dev and logs
    • Currently, how we call pollAppLogs in the CLI, there is no concept of what client is being used (to know whether to make request to partners or app management)
    • added fetchAppLogsDevDashboard

WHAT is this pull request doing?

  1. Update the subscribeToAppLogs for the app-management-client to make request to new core endpoint (which will proxy request to partners for now) Endpoint on this branch.

    • Needs Jacob's core branch js.add-app-log-endpoints-2
    • need to pass appId, and orgId for app management requests, which are now passed in
  2. Update polling app logs for dev and logs

  • Since this is not on the developer platform client, CLI will not know where to make the request
  • Added the organizationSource to know which endpoint to make request to
  • implemented similar changes for both commands

How to test your changes?

Will need:

Core:  03-07-expose_dev_dash_route_to_manage_app_logs
Partners: js.app-logs-prototype-2

🎩

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

pnpm run shopify app logs --path=./path-to-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 force-pushed the ms.proto2-dev-dash-app-logs branch 3 times, most recently from 6502b14 to dbd1ed9 Compare March 6, 2025 13:53
Copy link
Contributor

github-actions bot commented Mar 6, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 76.36% 9318/12203
🟡 Branches 71.61% 4564/6373
🟡 Functions 76.06% 2421/3183
🟡 Lines 76.92% 8807/11450

Test suite run success

2112 tests passing in 930 suites.

Report generated by 🧪jest coverage report action from 421666b

@mssalemi mssalemi marked this pull request as ready for review March 6, 2025 20:17
@mssalemi mssalemi requested a review from a team as a code owner March 6, 2025 20:17
Copy link
Contributor

github-actions bot commented Mar 6, 2025

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.

@mssalemi mssalemi force-pushed the ms.proto2-dev-dash-app-logs branch from 421666b to d55416e Compare March 7, 2025 15:07
expect(shopifyFetch).toHaveBeenCalledWith(expectedUrl, {
method: 'GET',
headers: {
Authorization: 'Bearer jwtToken',

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

The hard-coded value "Bearer jwtToken" is used as
authorization header
.
@mssalemi mssalemi requested a review from shauns March 10, 2025 13:26
@mssalemi mssalemi closed this Mar 10, 2025
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.

1 participant