cli icon indicating copy to clipboard operation
cli copied to clipboard

[ShopifyVM] 'app logs' Show input query variables in output for FunctionRunLog

Open mssalemi opened this issue 1 year ago β€’ 3 comments

Part of: https://github.com/Shopify/script-service/issues/6233

We're enhancing the debugging experience for developers by providing visibility into the input query variables used during a function run.

WHY are these changes introduced?

This PR will add an input query variables section that will conditionally show based on if input query variables are used. Input query variables will be used when the values are specified in the toml.

WHAT is this pull request doing?

Add input query variables section to the app logs command:

I also added some visual improvements to make the output and input sections more clear for partners to view. And updated the ouput and input sections to match.

Changes: with improved styling

imrpovestyle-no-color
With coloring (also will need to update other sections - alternate idea) new_idea_app_logs

and when no metafield is found: Screenshot 2024-10-03 at 9 59 41β€―AM

How to test your changes?

From local cli, to your spin instance:

SHOPIFY_CLI_ENABLE_APP_LOG_POLLING=1  NODE_TLS_REJECT_UNAUTHORIZED=0 SPIN=1 SPIN_INSTANCE=68fh pnpm run shopify app logs --path=./efficient-capital-app

** replace spin id and app path

Post-release steps

  • part of a CLI release
  • potentially add change log indicating that the input query variables are now present in logs and has visual improvements
  • use of colouring in text, I kept everything white in current commit, but use red text when metafield is not found.
  • NOTE: might be worth splitting up logic for displaying FunctionRunLog and NetworkAccessResponseFromCacheLog, NetworkAccessRequestExecutedLog into separate files.

Measuring impact

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

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

Checklist

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

mssalemi avatar Oct 02 '24 19:10 mssalemi

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-inner-loop

github-actions[bot] avatar Oct 02 '24 19:10 github-actions[bot]

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟑 Statements
72.54% (+0.02% πŸ”Ό)
8413/11597
🟑 Branches
69.08% (+0.05% πŸ”Ό)
4129/5977
🟑 Functions
71.96% (-0.02% πŸ”»)
2199/3056
🟑 Lines
72.82% (+0.02% πŸ”Ό)
7957/10927
Show files with reduced coverage πŸ”»
St.:grey_question:
File Statements Branches Functions Lines
🟒
... / utils.ts
87.25% (-0.11% πŸ”»)
74.51% (+2.17% πŸ”Ό)
82.35% (-5.15% πŸ”»)
86.87% (-0.09% πŸ”»)
🟒
... / ConcurrentOutput.tsx
98.39% (-1.61% πŸ”»)
90.91% (-4.55% πŸ”»)
100%
98.33% (-1.67% πŸ”»)

Test suite run success

1925 tests passing in 873 suites.

Report generated by πŸ§ͺjest coverage report action from 7c39c9cfa4df6ca0470f8fe60ff75abf507cfb35

github-actions[bot] avatar Oct 03 '24 14:10 github-actions[bot]

We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** 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.

github-actions[bot] avatar Oct 03 '24 14:10 github-actions[bot]

Quick video if anyone wants to take a look at changes. Will rebase PR before merging.

mssalemi avatar Oct 17 '24 17:10 mssalemi

Thanks for the video @mssalemi! Things look good in app logs, how do they look in the JSON log file that you might open when using app dev?

nickwesselman avatar Oct 17 '24 17:10 nickwesselman

Thanks for the video @mssalemi! Things look good in app logs, how do they look in the JSON log file that you might open when using app dev?

The variables get added to the payload in the logs:

  "payload": {
.....
    "inputQueryVariablesMetafieldValue": "{\"value\":\"42\"}",
    "inputQueryVariablesMetafieldNamespace": "meow",
    "inputQueryVariablesMetafieldKey": "key"
  }

perhaps we want to decode the the value πŸ‘€

mssalemi avatar Oct 17 '24 18:10 mssalemi

The variables get added to the payload in the logs:

  "payload": {
.....
    "inputQueryVariablesMetafieldValue": "{\"value\":\"42\"}",
    "inputQueryVariablesMetafieldNamespace": "meow",
    "inputQueryVariablesMetafieldKey": "key"
  }

Can we attempt to parse the value and output it as an object if successful?

nickwesselman avatar Oct 17 '24 18:10 nickwesselman

Can we attempt to parse the value and output it as an object if successful?

Updated this so we the value is object instead of string, partners should be able to more easily read them.

Screenshot 2024-10-17 at 3 48 55β€―PM

mssalemi avatar Oct 17 '24 19:10 mssalemi

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.

github-actions[bot] avatar Oct 22 '24 12:10 github-actions[bot]

Apologies, setup up my new laptop and accidentally pushed from my personal account when rebasing this. Will fix this.

mssalemi avatar Oct 22 '24 13:10 mssalemi