fragment-headless-sdk 2.3.2 → 2.3.3
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/dist/utils/fetch-resource.js +3 -1
- package/docs/CHANGELOG.md +9 -1
- package/package.json +8 -4
- package/readme.md +9 -4
|
@@ -119,6 +119,9 @@ async function performRequest({ baseUrl, apiKey, type, params = {}, fetchImpl, c
|
|
|
119
119
|
url.searchParams.set("page", params.pageFilter);
|
|
120
120
|
if (params.search)
|
|
121
121
|
url.searchParams.set("search", params.search);
|
|
122
|
+
// API key in the URL so Vercel's CDN can cache the response.
|
|
123
|
+
// Requests with an Authorization header are never cached by the CDN.
|
|
124
|
+
url.searchParams.set("apiKey", apiKey);
|
|
122
125
|
// Merge default cache config with user-provided options
|
|
123
126
|
const finalCacheOptions = {
|
|
124
127
|
...getDefaultCacheConfig(type),
|
|
@@ -128,7 +131,6 @@ async function performRequest({ baseUrl, apiKey, type, params = {}, fetchImpl, c
|
|
|
128
131
|
const fetchOptions = {
|
|
129
132
|
method: "GET",
|
|
130
133
|
headers: {
|
|
131
|
-
Authorization: `Bearer ${apiKey}`,
|
|
132
134
|
"Content-Type": "application/json",
|
|
133
135
|
},
|
|
134
136
|
cache: finalCacheOptions.cache,
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
### [Unreleased]
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### [2.3.3] - 2026-03-07
|
|
11
|
+
|
|
12
|
+
#### Changed
|
|
13
|
+
|
|
14
|
+
- **`fetchResource` default caching** – Environment-aware defaults for better performance and freshness:
|
|
15
|
+
- **Next.js production**: Defaults to `force-cache` with 60-second revalidation and resource-type cache tags (`fragment-hero-banners`, `fragment-announcements`) so responses are cached at the edge while staying reasonably fresh.
|
|
16
|
+
- **Next.js development / non–Next.js**: Defaults to `cache: "default"` with no revalidation.
|
|
17
|
+
- User-provided `cacheOptions` still override these defaults.
|
|
18
|
+
- **Request deduplication**: Cache keys now normalize `status` to `"enabled"` when omitted, so identical requests are deduplicated consistently.
|
|
11
19
|
|
|
12
20
|
### [2.3.2] - 2026-02-27
|
|
13
21
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fragment-headless-sdk",
|
|
3
|
-
"version": "2.3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.3.3",
|
|
4
|
+
"description": "Official SDK for Fragment-Shopify CMS: React components, TypeScript types, and utilities for headless Shopify storefronts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -29,15 +29,19 @@
|
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
|
-
"url": "https://github.com/sevenbrand/fragment-monorepo",
|
|
32
|
+
"url": "git+https://github.com/sevenbrand/fragment-monorepo.git",
|
|
33
33
|
"directory": "packages/sdk"
|
|
34
34
|
},
|
|
35
|
+
"homepage": "https://github.com/sevenbrand/fragment-monorepo/tree/main/packages/sdk#readme",
|
|
36
|
+
"bugs": "https://github.com/sevenbrand/fragment-monorepo/issues",
|
|
35
37
|
"keywords": [
|
|
36
38
|
"shopify",
|
|
37
39
|
"headless",
|
|
38
40
|
"fragment",
|
|
39
41
|
"sdk",
|
|
40
|
-
"storefront"
|
|
42
|
+
"storefront",
|
|
43
|
+
"cms",
|
|
44
|
+
"react"
|
|
41
45
|
],
|
|
42
46
|
"dependencies": {
|
|
43
47
|
"@heroicons/react": "^2.2.0"
|
package/readme.md
CHANGED
|
@@ -4,7 +4,7 @@ The official SDK for integrating with Fragment-Shopify CMS. Provides React compo
|
|
|
4
4
|
|
|
5
5
|
## ✨ What's New
|
|
6
6
|
|
|
7
|
-
**v2.3.
|
|
7
|
+
**v2.3.3** – `fetchResource` uses environment-aware default caching: Next.js production defaults to 60s revalidation and resource-type cache tags; development and non–Next.js use `cache: "default"`. Request deduplication normalizes `status` for consistent cache keys.
|
|
8
8
|
|
|
9
9
|
> See [CHANGELOG.md](./docs/CHANGELOG.md) for full release history
|
|
10
10
|
|
|
@@ -80,7 +80,7 @@ Fragment-Shopify App (CMS) → API Endpoint → fragment-headless-sdk (Consumer)
|
|
|
80
80
|
- 🛡️ **Graceful Fallback**: Works even if GA4 is not configured (doesn't break functionality)
|
|
81
81
|
- 📦 **Exported Types**: `SectionType` enum available for consumer use
|
|
82
82
|
|
|
83
|
-
### Attribution Tracking System (v2.
|
|
83
|
+
### Attribution Tracking System (v2.3.0+)
|
|
84
84
|
|
|
85
85
|
- 🎯 **Session-Based Attribution**: Tracks which section was clicked for purchase/add-to-cart attribution
|
|
86
86
|
- 💾 **SessionStorage Integration**: Uses sessionStorage for session-scoped attribution (last-click wins)
|
|
@@ -330,10 +330,15 @@ Fetches sections from your Fragment-Shopify app with intelligent request dedupli
|
|
|
330
330
|
|
|
331
331
|
**CacheOptions:**
|
|
332
332
|
|
|
333
|
-
- `cache?: RequestCache` - Request cache mode
|
|
334
|
-
- `revalidate?: number | false` - Next.js revalidation time in seconds
|
|
333
|
+
- `cache?: RequestCache` - Request cache mode
|
|
334
|
+
- `revalidate?: number | false` - Next.js revalidation time in seconds
|
|
335
335
|
- `tags?: string[]` - Next.js cache tags for selective invalidation
|
|
336
336
|
|
|
337
|
+
**Default cache behavior:**
|
|
338
|
+
|
|
339
|
+
- **Next.js production**: `force-cache` with `revalidate: 60` and tags `fragment-{type}`. Override with `cacheOptions` for different behavior.
|
|
340
|
+
- **Next.js development or non–Next.js**: `cache: "default"`; no revalidation or tags unless you pass `cacheOptions`.
|
|
341
|
+
|
|
337
342
|
**ResourceType Options:**
|
|
338
343
|
|
|
339
344
|
- `ResourceType.HeroBanners` - Fetch hero banners
|