@amplifyup/sdk 0.1.77 → 0.1.78

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
@@ -550,6 +550,8 @@ Pass `pageContext` at provider/init for From-page components. Do not wait until
550
550
 
551
551
  The SDK maps Edge's resolved tree into `layoutTree` and renders it. Edge already applies personalization and CMS projection — the site does not call CMS or Decision APIs for layout. After paint, the overlay calls `POST /v1/select` (or `selectVariants()`) then `/v1/resolve?variants=` so decisions stay on the edge (`clientPersonalization`).
552
552
 
553
+ Wrap your whole site in `AmplifyUpProvider` so every page is tracked. The overlay only runs on pages that render `AmplifyPageContent` (or `AmplifyRenderer` without a `pageConfig`). Pages you build yourself are tracked but never request a layout.
554
+
553
555
  ## Runtime queries
554
556
 
555
557
  Page resolve covers data known at Deploy. For data a visitor asks for — search, load more, a picker — use `queryContent`. The browser asks AmplifyUp, AmplifyUp asks your content source, so no CMS credentials or query syntax live in your site.
@@ -168,6 +168,7 @@ var AWSAdapter = class {
168
168
  return;
169
169
  }
170
170
  const trackingId = eventData?.trackingId || this.config?.trackingId;
171
+ const debug = this.config?.debug;
171
172
  const query = trackingId ? `?tid=${encodeURIComponent(trackingId)}` : "";
172
173
  const url = `${this.apiGatewayUrl}${endpoint}${query}`;
173
174
  try {
@@ -182,15 +183,15 @@ var AWSAdapter = class {
182
183
  keepalive: true
183
184
  });
184
185
  if (!response.ok) {
185
- if (this.config.debug) {
186
+ if (debug) {
186
187
  console.warn(`AmplifyUp SDK: Event tracking failed: ${response.status} ${response.statusText}`);
187
188
  }
188
- } else if (this.config.debug) {
189
+ } else if (debug) {
189
190
  const result = await response.json().catch(() => ({}));
190
191
  console.log("AmplifyUp SDK: Event tracked", result);
191
192
  }
192
193
  } catch (error) {
193
- if (this.config.debug) {
194
+ if (debug) {
194
195
  console.error("AmplifyUp SDK: Event tracking error:", error);
195
196
  }
196
197
  }
@@ -3565,6 +3566,14 @@ function getSDK(adapter) {
3565
3566
  var trackContentView = (contentId, contentType, properties) => getSDK().trackContentView(contentId, contentType, properties);
3566
3567
  var refreshEventTracking = () => getSDK().refreshEventTracking();
3567
3568
  getSDK();
3569
+ var PageContentRegistryContext = react.createContext(null);
3570
+ function useRegisterPageContent(enabled = true) {
3571
+ const register = react.useContext(PageContentRegistryContext);
3572
+ react.useEffect(() => {
3573
+ if (!enabled || !register) return;
3574
+ return register();
3575
+ }, [enabled, register]);
3576
+ }
3568
3577
  function useInComposer(force = false) {
3569
3578
  const [detected, setDetected] = react.useState(false);
3570
3579
  react.useEffect(() => {
@@ -3806,6 +3815,7 @@ function AmplifyRendererInner({
3806
3815
  composerPreview
3807
3816
  }) {
3808
3817
  const clientHook = useAmplifyUp();
3818
+ useRegisterPageContent(!serverPageConfig);
3809
3819
  const composerPreviewFlag = useComposerPreviewFlag(!!composerPreview);
3810
3820
  const pageConfig = serverPageConfig || clientHook.pageConfig || null;
3811
3821
  const loading = serverPageConfig ? false : clientHook.loading;