@amplifyup/sdk 0.1.5 → 0.1.7
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 +57 -98
- 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/dist/index.mjs
CHANGED
|
@@ -273,6 +273,32 @@ function resolveAmplifyUpUrls(target) {
|
|
|
273
273
|
};
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
+
// src/preview.ts
|
|
277
|
+
function isPreviewRequest(searchParams) {
|
|
278
|
+
if (searchParams instanceof URLSearchParams) {
|
|
279
|
+
return searchParams.get("preview") === "true" || searchParams.get("visualEditor") === "true";
|
|
280
|
+
}
|
|
281
|
+
const preview = searchParams.preview;
|
|
282
|
+
const visualEditor = searchParams.visualEditor;
|
|
283
|
+
return preview === "true" || visualEditor === "true";
|
|
284
|
+
}
|
|
285
|
+
function isComposerPreview() {
|
|
286
|
+
if (typeof window === "undefined") return false;
|
|
287
|
+
if (window.__AMPLIFYUP_PREVIEW_MODE__ === true) return true;
|
|
288
|
+
const params = new URLSearchParams(window.location.search);
|
|
289
|
+
if (isPreviewRequest(params)) return true;
|
|
290
|
+
if (window.self !== window.top && document.referrer) {
|
|
291
|
+
try {
|
|
292
|
+
const refUrl = new URL(document.referrer);
|
|
293
|
+
if (refUrl.hostname === "amplifyup.ai" || refUrl.hostname.endsWith(".amplifyup.ai") || refUrl.hostname === "localhost" && refUrl.port === "5001" || refUrl.pathname.includes("/dashboard/composer") || refUrl.pathname.includes("/dashboard/routes/")) {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
} catch {
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
|
|
276
302
|
// src/index.ts
|
|
277
303
|
function readPreviewQueryOverrides() {
|
|
278
304
|
if (typeof window === "undefined") return {};
|
|
@@ -395,6 +421,7 @@ var AmplifyUpSDK = class {
|
|
|
395
421
|
*/
|
|
396
422
|
async init(config) {
|
|
397
423
|
if (this.initialized && this.adapter?.isInitialized()) {
|
|
424
|
+
this.ensureWindowBridge();
|
|
398
425
|
return;
|
|
399
426
|
}
|
|
400
427
|
if (this.initPromise) {
|
|
@@ -407,6 +434,32 @@ var AmplifyUpSDK = class {
|
|
|
407
434
|
this.initPromise = null;
|
|
408
435
|
}
|
|
409
436
|
}
|
|
437
|
+
/** Attach console helpers to window (idempotent; survives Fast Refresh). */
|
|
438
|
+
ensureWindowBridge() {
|
|
439
|
+
if (typeof window === "undefined") return;
|
|
440
|
+
window.AmplifyUp = {
|
|
441
|
+
getInstanceId: () => this.getInstanceId(),
|
|
442
|
+
getUserId: () => this.getUserId(),
|
|
443
|
+
getTrackingId: () => this.getTrackingId(),
|
|
444
|
+
getTarget: () => this.getTarget(),
|
|
445
|
+
getDiagnostics: () => this.getDiagnostics(),
|
|
446
|
+
getStatus: () => {
|
|
447
|
+
console.log(this.getStatus());
|
|
448
|
+
return this.getDiagnostics();
|
|
449
|
+
},
|
|
450
|
+
testTracking: () => this.testTracking(),
|
|
451
|
+
verifyAWSConnection: () => {
|
|
452
|
+
const result = this.verifyAWSConnection();
|
|
453
|
+
console.log("AWS Connection Verification:", result.message);
|
|
454
|
+
console.log("Full details:", result);
|
|
455
|
+
return result;
|
|
456
|
+
},
|
|
457
|
+
isInitialized: () => this.isInitialized(),
|
|
458
|
+
page: (url, properties) => this.page(url, properties),
|
|
459
|
+
track: (eventName, properties) => this.track(eventName, properties),
|
|
460
|
+
identify: (userId, traits) => this.identify(userId, traits)
|
|
461
|
+
};
|
|
462
|
+
}
|
|
410
463
|
async performInit(config) {
|
|
411
464
|
if (!this.adapter) {
|
|
412
465
|
this.adapter = new AWSAdapter();
|
|
@@ -445,34 +498,10 @@ var AmplifyUpSDK = class {
|
|
|
445
498
|
};
|
|
446
499
|
await this.adapter.init(adapterConfig);
|
|
447
500
|
this.initialized = this.adapter.isInitialized();
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
getTrackingId: () => this.getTrackingId(),
|
|
453
|
-
getTarget: () => this.getTarget(),
|
|
454
|
-
getDiagnostics: () => this.getDiagnostics(),
|
|
455
|
-
getStatus: () => {
|
|
456
|
-
console.log(this.getStatus());
|
|
457
|
-
return this.getDiagnostics();
|
|
458
|
-
},
|
|
459
|
-
testTracking: () => this.testTracking(),
|
|
460
|
-
verifyAWSConnection: () => {
|
|
461
|
-
const result = this.verifyAWSConnection();
|
|
462
|
-
console.log("AWS Connection Verification:", result.message);
|
|
463
|
-
console.log("Full details:", result);
|
|
464
|
-
return result;
|
|
465
|
-
},
|
|
466
|
-
isInitialized: () => this.isInitialized(),
|
|
467
|
-
// Re-export main tracking methods for convenience
|
|
468
|
-
page: (url, properties) => this.page(url, properties),
|
|
469
|
-
track: (eventName, properties) => this.track(eventName, properties),
|
|
470
|
-
identify: (userId, traits) => this.identify(userId, traits)
|
|
471
|
-
};
|
|
472
|
-
if (this.config?.debug) {
|
|
473
|
-
console.log("AmplifyUp SDK: Diagnostic methods available on window.AmplifyUp");
|
|
474
|
-
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.testTracking()");
|
|
475
|
-
}
|
|
501
|
+
this.ensureWindowBridge();
|
|
502
|
+
if (this.config?.debug) {
|
|
503
|
+
console.log("AmplifyUp SDK: Diagnostic methods available on window.AmplifyUp");
|
|
504
|
+
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.testTracking()");
|
|
476
505
|
}
|
|
477
506
|
this.clearTrackingIntervals();
|
|
478
507
|
if (this.isPreviewMode()) {
|
|
@@ -1483,10 +1512,17 @@ Available Console Commands:
|
|
|
1483
1512
|
}
|
|
1484
1513
|
};
|
|
1485
1514
|
var sdkInstance = null;
|
|
1515
|
+
if (typeof window !== "undefined" && window.__AMPLIFYUP_SDK__) {
|
|
1516
|
+
sdkInstance = window.__AMPLIFYUP_SDK__;
|
|
1517
|
+
}
|
|
1486
1518
|
function getSDK(adapter) {
|
|
1487
1519
|
if (!sdkInstance) {
|
|
1488
1520
|
sdkInstance = new AmplifyUpSDK(adapter);
|
|
1521
|
+
if (typeof window !== "undefined") {
|
|
1522
|
+
window.__AMPLIFYUP_SDK__ = sdkInstance;
|
|
1523
|
+
}
|
|
1489
1524
|
}
|
|
1525
|
+
sdkInstance.ensureWindowBridge();
|
|
1490
1526
|
return sdkInstance;
|
|
1491
1527
|
}
|
|
1492
1528
|
async function init(config) {
|
|
@@ -1528,6 +1564,6 @@ var verifyAWSConnection = () => {
|
|
|
1528
1564
|
};
|
|
1529
1565
|
var index_default = getSDK();
|
|
1530
1566
|
|
|
1531
|
-
export { AmplifyUpSDK, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, index_default as default, fetchPageConfig, getDiagnostics, getInstanceId2 as getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTarget, getTrackingId, getUserId2 as getUserId, identify, init, isAmplifyUpTarget, normalizeAmplifyUpTarget, page, refreshEventTracking, reset, resolveAmplifyUpTarget, resolveAmplifyUpUrls, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
1567
|
+
export { AmplifyUpSDK, buildLayoutProviderUrl, buildPageRenderUrl, cleanupEventTracking, index_default as default, fetchPageConfig, getDiagnostics, getInstanceId2 as getInstanceId, getOrchestratorUrl, getSDK, getStatus, getTarget, getTrackingId, getUserId2 as getUserId, identify, init, isAmplifyUpTarget, isComposerPreview, isPreviewRequest, normalizeAmplifyUpTarget, page, refreshEventTracking, reset, resolveAmplifyUpTarget, resolveAmplifyUpUrls, setupEventTracking, testTracking, track, trackClick, trackContentEngagement, trackContentView, trackFormFieldInteraction, trackFormSubmit, verifyAWSConnection };
|
|
1532
1568
|
//# sourceMappingURL=index.mjs.map
|
|
1533
1569
|
//# sourceMappingURL=index.mjs.map
|