From c71a23051318b15382f3d98e1c1510b7708de30d Mon Sep 17 00:00:00 2001 From: Joseph Thomas Date: Wed, 17 Mar 2021 11:19:53 -0700 Subject: [PATCH] fix(types): fix webhooks config types (#154) --- README.md | 6 ++++++ packages/server/README.md | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d3557f8..1707902 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,12 @@ This plugin does not manage orders or customer carts. You will need to use Shopi # Alpha Changelog +### 0.20.0 + +The config for `@sane-shopify/server` has changed. `onError` is now part of the main config object. Instead of `createWebhooks({ config, onError })`, do `createWebhooks(config)`. See the [`@sane-shopify/server` Readme](packages/server/README.md) + +Source data now includes shopify media. Thanks @liqueflies for adding this! + ### 0.11.0 `@sane-shopify/server` now exports functions that can be used to handle Shopify's webhooks. diff --git a/packages/server/README.md b/packages/server/README.md index ac582c1..5988513 100644 --- a/packages/server/README.md +++ b/packages/server/README.md @@ -45,6 +45,15 @@ if (!authToken) throw new Error('You must provide a sanity auth token') if (!shopName) throw new Error('You must provide a shopify shop name') if (!accessToken) throw new Error('You must provide a shopify access token') + +// optional, see below +const handleError = (err: Error) => { + Sentry.captureException(err) +} + + +// 🚨 Alpha breaking change: This configuration changed in 0.20.0. If you are getting errors after updating, put your `onError` handler on the `config` object, and pass that object into `createWebhooks` as the sole argument. + const config = { secrets: { sanity: { @@ -57,16 +66,14 @@ const config = { accessToken, }, }, + onError: handleError } -// optional, see below -const onError = Sentry.captureException(error) - -export const webhooks = createNextWebhooks({ config, onError }) +export const webhooks = createNextWebhooks(config) // or -// export const webhooks = createAWSWebhooks({ config, onError }) +// export const webhooks = createAWSWebhooks(config) // or -// export const webhooks = createWebhooks({ config, onError }) +// export const webhooks = createWebhooks(config) ``` ### Error Handling