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

Add GDPR and Uninstall Jobs to Generator #1597

Merged
merged 11 commits into from
Dec 1, 2022

Conversation

klenotiw
Copy link
Contributor

@klenotiw klenotiw commented Nov 30, 2022

What this PR does

Out of the box our shopify_app generator doesn't handle uninstall properly. It also doesn't provide any scaffolding for GDPR jobs. So this PR adds an uninstall webhook and creates a template for the three GDPR jobs we are expecting in the app review process.

Since this adds an uninstall webhook an app should pass our automated review process by simply running the rails generate shopify_app command.

Reviewer's guide to testing

Please test this out yourself, and run it against our automated tests. You can also load up a new app and see if the database is removing the shop information on uninstall.

Things to focus on

  1. How do we feel about the GDPR templates? (they were ripped out of the ruby template so if we want to change them here we should change them there)
  2. Read through the documentation I added about our GDPR mandatory webhooks

Checklist

Before submitting the PR, please consider if any of the following are needed:

  • Update CHANGELOG.md if the changes would impact users
  • Update README.md, if appropriate.
  • Update any relevant pages in /docs, if necessary
  • For security fixes, the Disclosure Policy must be followed.

@klenotiw klenotiw changed the title add uninstall job to generator Add GDPR and Uninstall jobs to generator Dec 1, 2022
@klenotiw klenotiw changed the title Add GDPR and Uninstall jobs to generator Add GDPR and Uninstall Jobs to Generator Dec 1, 2022
end

shop.with_shopify_session do
logger.info("#{self.class} started for shop '#{shop_domain}'")
Copy link
Contributor Author

@klenotiw klenotiw Dec 1, 2022

Choose a reason for hiding this comment

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

Im not sure if anyone has any context on why this log message is here but not in the others? (In case you missed it in the description this was ripped right out of the ruby template)

Copy link
Contributor

Choose a reason for hiding this comment

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

My guess is oversight. Can we use our new shopify app logger for all of these? We should be logging all of these and allowing users to turn log levels down if they are too loud.

@klenotiw klenotiw marked this pull request as ready for review December 1, 2022 05:05
@klenotiw klenotiw requested a review from cquemin December 1, 2022 13:56
shop = Shop.find_by(shopify_domain: shop_domain)

if shop.nil?
logger.error("#{self.class} failed: cannot find shop with domain '#{shop_domain}'")
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should be raising an error and failing jobs if we can't find their shop domain 🤔

Sidekiq and Active Job have cool tooling for jobs that fail. If devs aren't watching logs, they might be missing out on key information that jobs are failing.

Raising an error will be available with exception handing software (bugsnag, airbake, rollbar, etc) as well as job monitoring dashboards like sidekiq's.

Copy link
Contributor

@nelsonwittwer nelsonwittwer Dec 1, 2022

Choose a reason for hiding this comment

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

This pattern seems to be in other jobs as well. I'd recommend logging in addition to failing the job. Failing a job means the job raised an exception during its run.

Copy link
Contributor

Choose a reason for hiding this comment

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

I realize you are probably boosting these from templates, but this is a good opportunity for improvement 😄 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I just added a raise StandardError I thought I remember you saying to raise NotFound error? I couldn't find it anywhere maybe you said a different error, my bad for forgetting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@nelsonwittwer nelsonwittwer Dec 1, 2022

Choose a reason for hiding this comment

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

Alternatively, you could use find_by! instead of find_by whiches raise an active record not found error automagically by the power of rails. We'd lose the logging with that approach though

end

shop.with_shopify_session do
logger.info("#{self.class} started for shop '#{shop_domain}'")
Copy link
Contributor

Choose a reason for hiding this comment

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

My guess is oversight. Can we use our new shopify app logger for all of these? We should be logging all of these and allowing users to turn log levels down if they are too loud.

@nelsonwittwer
Copy link
Contributor

Thanks for adding these generators! Super helpful to setup users for success as they go to approval and see what is needed! 🎉 💪

Copy link
Contributor

@nelsonwittwer nelsonwittwer left a comment

Choose a reason for hiding this comment

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

🎉 Style wise, I'd prefer we use the RecordNotFoundError but this is great functionality you've added here!

@nelsonwittwer
Copy link
Contributor

🎩 'd your branch, everything appears to be working well!

@klenotiw
Copy link
Contributor Author

klenotiw commented Dec 1, 2022

🎩 'd your branch, everything appears to be working well!

Shipping now, had to fix the webhook names or it wasn't find it on rails generate shopify_app

@klenotiw klenotiw merged commit 6a5ba61 into main Dec 1, 2022
@klenotiw klenotiw deleted the klenotiw/add-gdpr-jobs-generator branch December 1, 2022 20:14
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems December 9, 2022 17:09 Inactive
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.

None yet

2 participants