@okendo/shopify-hydrogen 1.2.4 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### ⚠️ Shopify [has deprecated Hydrogen v1](https://hydrogen.shopify.dev/updates) ⚠️ — Please use [the latest version of this package](https://www.npmjs.com/package/@okendo/shopify-hydrogen) if your store is built with Hydrogen v2 (based on Remix).
2
+
3
+ ### ⚠️ Only use the following if you are using a legacy Hydrogen v1 store ⚠️
4
+
1
5
  # Okendo Hydrogen React Components
2
6
 
3
7
  This is the React component library to support Okendo Widget Plus Widgets in Shopify Hydrogen Projects.
@@ -298,7 +302,7 @@ mutation {
298
302
 
299
303
  ## Installation
300
304
 
301
- 1. In your Hydrogen app directory, run `npm install @okendo/shopify-hydrogen` inside a terminal or PowerShell window.
305
+ 1. In your Hydrogen app directory, run `npm install @okendo/shopify-hydrogen@^1` inside a terminal or PowerShell window.
302
306
  2. **Optional:** Create (or add to) your `.env` file at the top level of your project (next to **hydrogen.config.ts**) the following, where `<your_subscriber_id>` is replaced with your Okendo Subscriber ID:
303
307
 
304
308
  ```sh
@@ -1,16 +1,15 @@
1
+ import { CacheCustom, Head, fetchSync, gql, useShopQuery } from '@shopify/hydrogen';
1
2
  import React from 'react';
2
- import { fetchSync, useShopQuery, gql, CacheShort } from '@shopify/hydrogen';
3
- import { Head } from '@shopify/hydrogen';
4
3
  import { okendoError } from '../shared/errorUtils';
5
- import { useOkendoRequestContext } from '../shared/server/requestUtils';
6
4
  import { logger } from '../shared/logger';
5
+ import { useOkendoRequestContext } from '../shared/server/requestUtils';
7
6
  const kDefaultOkendoApiDomain = 'api.okendo.io/v1';
8
7
  const kDefaultOkendoCdnDomain = 'cdn-static.okendo.io';
9
8
  export const OkendoProvider = ({ apiDomain, cdnDomain, children, productUrlFormatOverride, subscriberId }) => {
10
9
  const okendoRequestContext = useOkendoRequestContext();
11
10
  // Download subscriber widget plus settings.
12
11
  const url = `https://${apiDomain ?? kDefaultOkendoApiDomain}/stores/${subscriberId}/widget_plus_settings`;
13
- const settingsResponse = fetchSync(url, { preload: true });
12
+ const settingsResponse = fetchSync(url, { cache: CacheCustom({ maxAge: 60, staleWhileRevalidate: 300 }) });
14
13
  if (!settingsResponse.ok) {
15
14
  logger.error(okendoError('Failed to retrieve subscriber settings. Please check your environment variables.'));
16
15
  okendoRequestContext.setupFailed = true;
@@ -21,8 +20,7 @@ export const OkendoProvider = ({ apiDomain, cdnDomain, children, productUrlForma
21
20
  const customCssNormalized = customCss ? customCss.replace('<style id="oke-reviews-custom-css">', '').replace('</style>', '') : '';
22
21
  // Download contents of widget initialisation script.
23
22
  const initScriptResponse = fetchSync(`https://${cdnDomain ?? kDefaultOkendoCdnDomain}/reviews-widget-plus/js/okendo-reviews.js`, {
24
- cache: CacheShort(),
25
- preload: true
23
+ cache: CacheCustom({ maxAge: 60, staleWhileRevalidate: 300 })
26
24
  });
27
25
  if (!initScriptResponse.ok) {
28
26
  logger.error(okendoError('Failed to retrieve widget initialization script.'));
@@ -51,7 +49,7 @@ const OkendoProviderContent = ({ children, productUrlFormatOverride, subscriberI
51
49
  `;
52
50
  const { data: { shop: { widgetPreRenderStyleTags } } } = useShopQuery({
53
51
  query,
54
- preload: true
52
+ cache: CacheCustom({ maxAge: 60, staleWhileRevalidate: 300 })
55
53
  });
56
54
  const preRenderStyleTags = widgetPreRenderStyleTags?.value ?? '';
57
55
  if (!preRenderStyleTags) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okendo/shopify-hydrogen",
3
- "version": "1.2.4",
3
+ "version": "1.3.1",
4
4
  "description": "A component library containing Okendo Reviews React components.",
5
5
  "main": "dist/esnext/index.js",
6
6
  "engines": {