Here are the steps to troubleshoot your Shopify function in production,
- Create a mechanism in your function to throw exception/cause panic based on a certain trigger, for example, if the first name is entered as “Debug”. This will ensure that this panic is not created in the function randomly when customers enter their details during checkout (Nobody has the first name of debug, right?).
This is how to do it in Rust (Place it near the end of the function, preferably),
if first_name == "Debug" {
panic!("Debug mode activated");
}
- Create a mechanism for merchants to follow and generate and share the error logs with you. For example, you can show them a modal with steps to follow, the steps can look something like this,
-
Use the first name of Debug at the checkout to generate the error.
-
Go to the customization in the settings and click on share the error report with the developer.
- Once the merchant follows your instructions and successfully generates the error and shares with you, you will have all the details of what is going on at their checkout and what output did your function generate in response to the input it received.
Hope this helps.
