@amplifyup/sdk 0.1.5 → 0.1.6
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 +37 -0
- package/dist/AmplifyRenderer.js +38 -28
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +38 -28
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +66 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -29
- package/dist/index.mjs.map +1 -1
- package/dist/preview-BMrIgUvp.d.mts +13 -0
- package/dist/preview-BMrIgUvp.d.ts +13 -0
- package/dist/react.d.mts +28 -2
- package/dist/react.d.ts +28 -2
- package/dist/react.js +125 -47
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +123 -48
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,43 @@ NEXT_PUBLIC_AMPLIFYUP_TARGET=local
|
|
|
28
28
|
|
|
29
29
|
Check active URLs in the browser: `AmplifyUp.getStatus()`
|
|
30
30
|
|
|
31
|
+
### Hybrid pages (native content + Composer)
|
|
32
|
+
|
|
33
|
+
For pages with native content that should only appear for real visitors:
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
// app/insights/page.tsx (server)
|
|
37
|
+
import { isPreviewRequest } from '@amplifyup/sdk';
|
|
38
|
+
import { AmplifyPageContent } from '@amplifyup/sdk/react';
|
|
39
|
+
|
|
40
|
+
export default async function InsightsPage({ searchParams }) {
|
|
41
|
+
const params = await searchParams;
|
|
42
|
+
|
|
43
|
+
if (isPreviewRequest(params)) {
|
|
44
|
+
// Composer: no blog fetch, no native fallback HTML
|
|
45
|
+
return (
|
|
46
|
+
<Layout>
|
|
47
|
+
<AmplifyPageContent renderComponent={renderAmplifyComponent} />
|
|
48
|
+
</Layout>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const posts = await getPosts();
|
|
53
|
+
return (
|
|
54
|
+
<Layout>
|
|
55
|
+
<PostsProvider value={posts}>
|
|
56
|
+
<AmplifyPageContent
|
|
57
|
+
fallback={<InsightsFallback />}
|
|
58
|
+
renderComponent={renderAmplifyComponent}
|
|
59
|
+
/>
|
|
60
|
+
</PostsProvider>
|
|
61
|
+
</Layout>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
In Composer preview, `AmplifyPageContent` shows an empty layout canvas — never `fallback`.
|
|
67
|
+
|
|
31
68
|
## Installation
|
|
32
69
|
|
|
33
70
|
```bash
|
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -407,6 +407,7 @@ var AmplifyUpSDK = class {
|
|
|
407
407
|
*/
|
|
408
408
|
async init(config) {
|
|
409
409
|
if (this.initialized && this.adapter?.isInitialized()) {
|
|
410
|
+
this.ensureWindowBridge();
|
|
410
411
|
return;
|
|
411
412
|
}
|
|
412
413
|
if (this.initPromise) {
|
|
@@ -419,6 +420,32 @@ var AmplifyUpSDK = class {
|
|
|
419
420
|
this.initPromise = null;
|
|
420
421
|
}
|
|
421
422
|
}
|
|
423
|
+
/** Attach console helpers to window (idempotent; survives Fast Refresh). */
|
|
424
|
+
ensureWindowBridge() {
|
|
425
|
+
if (typeof window === "undefined") return;
|
|
426
|
+
window.AmplifyUp = {
|
|
427
|
+
getInstanceId: () => this.getInstanceId(),
|
|
428
|
+
getUserId: () => this.getUserId(),
|
|
429
|
+
getTrackingId: () => this.getTrackingId(),
|
|
430
|
+
getTarget: () => this.getTarget(),
|
|
431
|
+
getDiagnostics: () => this.getDiagnostics(),
|
|
432
|
+
getStatus: () => {
|
|
433
|
+
console.log(this.getStatus());
|
|
434
|
+
return this.getDiagnostics();
|
|
435
|
+
},
|
|
436
|
+
testTracking: () => this.testTracking(),
|
|
437
|
+
verifyAWSConnection: () => {
|
|
438
|
+
const result = this.verifyAWSConnection();
|
|
439
|
+
console.log("AWS Connection Verification:", result.message);
|
|
440
|
+
console.log("Full details:", result);
|
|
441
|
+
return result;
|
|
442
|
+
},
|
|
443
|
+
isInitialized: () => this.isInitialized(),
|
|
444
|
+
page: (url, properties) => this.page(url, properties),
|
|
445
|
+
track: (eventName, properties) => this.track(eventName, properties),
|
|
446
|
+
identify: (userId, traits) => this.identify(userId, traits)
|
|
447
|
+
};
|
|
448
|
+
}
|
|
422
449
|
async performInit(config) {
|
|
423
450
|
if (!this.adapter) {
|
|
424
451
|
this.adapter = new AWSAdapter();
|
|
@@ -457,34 +484,10 @@ var AmplifyUpSDK = class {
|
|
|
457
484
|
};
|
|
458
485
|
await this.adapter.init(adapterConfig);
|
|
459
486
|
this.initialized = this.adapter.isInitialized();
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
getTrackingId: () => this.getTrackingId(),
|
|
465
|
-
getTarget: () => this.getTarget(),
|
|
466
|
-
getDiagnostics: () => this.getDiagnostics(),
|
|
467
|
-
getStatus: () => {
|
|
468
|
-
console.log(this.getStatus());
|
|
469
|
-
return this.getDiagnostics();
|
|
470
|
-
},
|
|
471
|
-
testTracking: () => this.testTracking(),
|
|
472
|
-
verifyAWSConnection: () => {
|
|
473
|
-
const result = this.verifyAWSConnection();
|
|
474
|
-
console.log("AWS Connection Verification:", result.message);
|
|
475
|
-
console.log("Full details:", result);
|
|
476
|
-
return result;
|
|
477
|
-
},
|
|
478
|
-
isInitialized: () => this.isInitialized(),
|
|
479
|
-
// Re-export main tracking methods for convenience
|
|
480
|
-
page: (url, properties) => this.page(url, properties),
|
|
481
|
-
track: (eventName, properties) => this.track(eventName, properties),
|
|
482
|
-
identify: (userId, traits) => this.identify(userId, traits)
|
|
483
|
-
};
|
|
484
|
-
if (this.config?.debug) {
|
|
485
|
-
console.log("AmplifyUp SDK: Diagnostic methods available on window.AmplifyUp");
|
|
486
|
-
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.testTracking()");
|
|
487
|
-
}
|
|
487
|
+
this.ensureWindowBridge();
|
|
488
|
+
if (this.config?.debug) {
|
|
489
|
+
console.log("AmplifyUp SDK: Diagnostic methods available on window.AmplifyUp");
|
|
490
|
+
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.testTracking()");
|
|
488
491
|
}
|
|
489
492
|
this.clearTrackingIntervals();
|
|
490
493
|
if (this.isPreviewMode()) {
|
|
@@ -1495,10 +1498,17 @@ Available Console Commands:
|
|
|
1495
1498
|
}
|
|
1496
1499
|
};
|
|
1497
1500
|
var sdkInstance = null;
|
|
1501
|
+
if (typeof window !== "undefined" && window.__AMPLIFYUP_SDK__) {
|
|
1502
|
+
sdkInstance = window.__AMPLIFYUP_SDK__;
|
|
1503
|
+
}
|
|
1498
1504
|
function getSDK(adapter) {
|
|
1499
1505
|
if (!sdkInstance) {
|
|
1500
1506
|
sdkInstance = new AmplifyUpSDK(adapter);
|
|
1507
|
+
if (typeof window !== "undefined") {
|
|
1508
|
+
window.__AMPLIFYUP_SDK__ = sdkInstance;
|
|
1509
|
+
}
|
|
1501
1510
|
}
|
|
1511
|
+
sdkInstance.ensureWindowBridge();
|
|
1502
1512
|
return sdkInstance;
|
|
1503
1513
|
}
|
|
1504
1514
|
var trackContentView = (contentId, contentType, properties) => getSDK().trackContentView(contentId, contentType, properties);
|