@amplifyup/sdk 0.1.3 → 0.1.4

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/react.js CHANGED
@@ -284,6 +284,26 @@ function resolveAmplifyUpUrls(target) {
284
284
  }
285
285
 
286
286
  // src/index.ts
287
+ function readPreviewQueryOverrides() {
288
+ if (typeof window === "undefined") return {};
289
+ const params = new URLSearchParams(window.location.search);
290
+ if (params.get("preview") !== "true" && params.get("visualEditor") !== "true") {
291
+ return {};
292
+ }
293
+ const overrides = {};
294
+ const orchestratorFromQuery = params.get("orchestratorUrl");
295
+ if (orchestratorFromQuery) {
296
+ try {
297
+ overrides.orchestratorUrl = new URL(orchestratorFromQuery).origin.replace(/\/$/, "");
298
+ } catch {
299
+ }
300
+ }
301
+ const trackingFromQuery = params.get("trackingId");
302
+ if (trackingFromQuery) {
303
+ overrides.trackingId = trackingFromQuery;
304
+ }
305
+ return overrides;
306
+ }
287
307
  var AmplifyUpSDK = class {
288
308
  constructor(adapter) {
289
309
  this.config = null;
@@ -409,8 +429,12 @@ var AmplifyUpSDK = class {
409
429
  this.apiGatewayUrl = urls.apiGatewayUrl;
410
430
  this.orchestratorUrl = urls.orchestratorUrl;
411
431
  this.decisionApiUrl = urls.decisionApiUrl;
432
+ const previewOverrides = readPreviewQueryOverrides();
433
+ if (previewOverrides.orchestratorUrl) {
434
+ this.orchestratorUrl = previewOverrides.orchestratorUrl;
435
+ }
412
436
  this.config = {
413
- trackingId: config.trackingId,
437
+ trackingId: previewOverrides.trackingId || config.trackingId,
414
438
  debug: config.debug ?? true,
415
439
  // Enable debug by default
416
440
  target: this.target,