@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.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { C as CDPAdapter, A as AmplifyUpConfig, E as EventProperties, I as IdentifyTraits, a as AmplifyUpTarget, b as EventTrackingConfig$1 } from './types-B2Swk8BW.mjs';
|
|
2
2
|
export { P as PageConfig, Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, c as resolveAmplifyUpUrls } from './types-B2Swk8BW.mjs';
|
|
3
|
+
export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* AmplifyUp Tracking SDK
|
|
@@ -59,6 +60,8 @@ declare class AmplifyUpSDK {
|
|
|
59
60
|
* Resolves local | dev | production targets for ingestion + personalization URLs.
|
|
60
61
|
*/
|
|
61
62
|
init(config: AmplifyUpConfig): Promise<void>;
|
|
63
|
+
/** Attach console helpers to window (idempotent; survives Fast Refresh). */
|
|
64
|
+
ensureWindowBridge(): void;
|
|
62
65
|
private performInit;
|
|
63
66
|
/**
|
|
64
67
|
* Check if SDK is initialized
|
|
@@ -243,6 +246,11 @@ declare class AmplifyUpSDK {
|
|
|
243
246
|
*/
|
|
244
247
|
cleanup(): void;
|
|
245
248
|
}
|
|
249
|
+
declare global {
|
|
250
|
+
interface Window {
|
|
251
|
+
__AMPLIFYUP_SDK__?: AmplifyUpSDK;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
246
254
|
/**
|
|
247
255
|
* Get or create the SDK instance
|
|
248
256
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { C as CDPAdapter, A as AmplifyUpConfig, E as EventProperties, I as IdentifyTraits, a as AmplifyUpTarget, b as EventTrackingConfig$1 } from './types-B2Swk8BW.js';
|
|
2
2
|
export { P as PageConfig, Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, c as resolveAmplifyUpUrls } from './types-B2Swk8BW.js';
|
|
3
|
+
export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* AmplifyUp Tracking SDK
|
|
@@ -59,6 +60,8 @@ declare class AmplifyUpSDK {
|
|
|
59
60
|
* Resolves local | dev | production targets for ingestion + personalization URLs.
|
|
60
61
|
*/
|
|
61
62
|
init(config: AmplifyUpConfig): Promise<void>;
|
|
63
|
+
/** Attach console helpers to window (idempotent; survives Fast Refresh). */
|
|
64
|
+
ensureWindowBridge(): void;
|
|
62
65
|
private performInit;
|
|
63
66
|
/**
|
|
64
67
|
* Check if SDK is initialized
|
|
@@ -243,6 +246,11 @@ declare class AmplifyUpSDK {
|
|
|
243
246
|
*/
|
|
244
247
|
cleanup(): void;
|
|
245
248
|
}
|
|
249
|
+
declare global {
|
|
250
|
+
interface Window {
|
|
251
|
+
__AMPLIFYUP_SDK__?: AmplifyUpSDK;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
246
254
|
/**
|
|
247
255
|
* Get or create the SDK instance
|
|
248
256
|
*/
|
package/dist/index.js
CHANGED
|
@@ -277,6 +277,32 @@ function resolveAmplifyUpUrls(target) {
|
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
// src/preview.ts
|
|
281
|
+
function isPreviewRequest(searchParams) {
|
|
282
|
+
if (searchParams instanceof URLSearchParams) {
|
|
283
|
+
return searchParams.get("preview") === "true" || searchParams.get("visualEditor") === "true";
|
|
284
|
+
}
|
|
285
|
+
const preview = searchParams.preview;
|
|
286
|
+
const visualEditor = searchParams.visualEditor;
|
|
287
|
+
return preview === "true" || visualEditor === "true";
|
|
288
|
+
}
|
|
289
|
+
function isComposerPreview() {
|
|
290
|
+
if (typeof window === "undefined") return false;
|
|
291
|
+
if (window.__AMPLIFYUP_PREVIEW_MODE__ === true) return true;
|
|
292
|
+
const params = new URLSearchParams(window.location.search);
|
|
293
|
+
if (isPreviewRequest(params)) return true;
|
|
294
|
+
if (window.self !== window.top && document.referrer) {
|
|
295
|
+
try {
|
|
296
|
+
const refUrl = new URL(document.referrer);
|
|
297
|
+
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/")) {
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
} catch {
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
|
|
280
306
|
// src/index.ts
|
|
281
307
|
function readPreviewQueryOverrides() {
|
|
282
308
|
if (typeof window === "undefined") return {};
|
|
@@ -399,6 +425,7 @@ var AmplifyUpSDK = class {
|
|
|
399
425
|
*/
|
|
400
426
|
async init(config) {
|
|
401
427
|
if (this.initialized && this.adapter?.isInitialized()) {
|
|
428
|
+
this.ensureWindowBridge();
|
|
402
429
|
return;
|
|
403
430
|
}
|
|
404
431
|
if (this.initPromise) {
|
|
@@ -411,6 +438,32 @@ var AmplifyUpSDK = class {
|
|
|
411
438
|
this.initPromise = null;
|
|
412
439
|
}
|
|
413
440
|
}
|
|
441
|
+
/** Attach console helpers to window (idempotent; survives Fast Refresh). */
|
|
442
|
+
ensureWindowBridge() {
|
|
443
|
+
if (typeof window === "undefined") return;
|
|
444
|
+
window.AmplifyUp = {
|
|
445
|
+
getInstanceId: () => this.getInstanceId(),
|
|
446
|
+
getUserId: () => this.getUserId(),
|
|
447
|
+
getTrackingId: () => this.getTrackingId(),
|
|
448
|
+
getTarget: () => this.getTarget(),
|
|
449
|
+
getDiagnostics: () => this.getDiagnostics(),
|
|
450
|
+
getStatus: () => {
|
|
451
|
+
console.log(this.getStatus());
|
|
452
|
+
return this.getDiagnostics();
|
|
453
|
+
},
|
|
454
|
+
testTracking: () => this.testTracking(),
|
|
455
|
+
verifyAWSConnection: () => {
|
|
456
|
+
const result = this.verifyAWSConnection();
|
|
457
|
+
console.log("AWS Connection Verification:", result.message);
|
|
458
|
+
console.log("Full details:", result);
|
|
459
|
+
return result;
|
|
460
|
+
},
|
|
461
|
+
isInitialized: () => this.isInitialized(),
|
|
462
|
+
page: (url, properties) => this.page(url, properties),
|
|
463
|
+
track: (eventName, properties) => this.track(eventName, properties),
|
|
464
|
+
identify: (userId, traits) => this.identify(userId, traits)
|
|
465
|
+
};
|
|
466
|
+
}
|
|
414
467
|
async performInit(config) {
|
|
415
468
|
if (!this.adapter) {
|
|
416
469
|
this.adapter = new AWSAdapter();
|
|
@@ -449,34 +502,10 @@ var AmplifyUpSDK = class {
|
|
|
449
502
|
};
|
|
450
503
|
await this.adapter.init(adapterConfig);
|
|
451
504
|
this.initialized = this.adapter.isInitialized();
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
getTrackingId: () => this.getTrackingId(),
|
|
457
|
-
getTarget: () => this.getTarget(),
|
|
458
|
-
getDiagnostics: () => this.getDiagnostics(),
|
|
459
|
-
getStatus: () => {
|
|
460
|
-
console.log(this.getStatus());
|
|
461
|
-
return this.getDiagnostics();
|
|
462
|
-
},
|
|
463
|
-
testTracking: () => this.testTracking(),
|
|
464
|
-
verifyAWSConnection: () => {
|
|
465
|
-
const result = this.verifyAWSConnection();
|
|
466
|
-
console.log("AWS Connection Verification:", result.message);
|
|
467
|
-
console.log("Full details:", result);
|
|
468
|
-
return result;
|
|
469
|
-
},
|
|
470
|
-
isInitialized: () => this.isInitialized(),
|
|
471
|
-
// Re-export main tracking methods for convenience
|
|
472
|
-
page: (url, properties) => this.page(url, properties),
|
|
473
|
-
track: (eventName, properties) => this.track(eventName, properties),
|
|
474
|
-
identify: (userId, traits) => this.identify(userId, traits)
|
|
475
|
-
};
|
|
476
|
-
if (this.config?.debug) {
|
|
477
|
-
console.log("AmplifyUp SDK: Diagnostic methods available on window.AmplifyUp");
|
|
478
|
-
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.testTracking()");
|
|
479
|
-
}
|
|
505
|
+
this.ensureWindowBridge();
|
|
506
|
+
if (this.config?.debug) {
|
|
507
|
+
console.log("AmplifyUp SDK: Diagnostic methods available on window.AmplifyUp");
|
|
508
|
+
console.log("Try: AmplifyUp.getStatus() or AmplifyUp.testTracking()");
|
|
480
509
|
}
|
|
481
510
|
this.clearTrackingIntervals();
|
|
482
511
|
if (this.isPreviewMode()) {
|
|
@@ -1487,10 +1516,17 @@ Available Console Commands:
|
|
|
1487
1516
|
}
|
|
1488
1517
|
};
|
|
1489
1518
|
var sdkInstance = null;
|
|
1519
|
+
if (typeof window !== "undefined" && window.__AMPLIFYUP_SDK__) {
|
|
1520
|
+
sdkInstance = window.__AMPLIFYUP_SDK__;
|
|
1521
|
+
}
|
|
1490
1522
|
function getSDK(adapter) {
|
|
1491
1523
|
if (!sdkInstance) {
|
|
1492
1524
|
sdkInstance = new AmplifyUpSDK(adapter);
|
|
1525
|
+
if (typeof window !== "undefined") {
|
|
1526
|
+
window.__AMPLIFYUP_SDK__ = sdkInstance;
|
|
1527
|
+
}
|
|
1493
1528
|
}
|
|
1529
|
+
sdkInstance.ensureWindowBridge();
|
|
1494
1530
|
return sdkInstance;
|
|
1495
1531
|
}
|
|
1496
1532
|
async function init(config) {
|
|
@@ -1549,6 +1585,8 @@ exports.getUserId = getUserId2;
|
|
|
1549
1585
|
exports.identify = identify;
|
|
1550
1586
|
exports.init = init;
|
|
1551
1587
|
exports.isAmplifyUpTarget = isAmplifyUpTarget;
|
|
1588
|
+
exports.isComposerPreview = isComposerPreview;
|
|
1589
|
+
exports.isPreviewRequest = isPreviewRequest;
|
|
1552
1590
|
exports.normalizeAmplifyUpTarget = normalizeAmplifyUpTarget;
|
|
1553
1591
|
exports.page = page;
|
|
1554
1592
|
exports.refreshEventTracking = refreshEventTracking;
|