@amplifyup/sdk 0.1.29 → 0.1.31

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/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, a as CDPAdapter, b as AmplifyUpConfig, E as EventProperties, I as IdentifyInput, c as IdentifyTraits, d as ProfileFieldsInput, e as AmplifyUpTarget, f as EventTrackingConfig$1 } from './types-BxpG9Gsy.mjs';
2
- export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-BxpG9Gsy.mjs';
1
+ import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-npF_lNoq.mjs';
2
+ export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-npF_lNoq.mjs';
3
3
  export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.mjs';
4
4
 
5
5
  interface FetchContentResult {
@@ -46,6 +46,8 @@ interface EdgeResolvedPayload {
46
46
  version: number;
47
47
  zones: Record<string, EdgeResolvedComponent[]>;
48
48
  tree?: EdgeResolvedComponent[];
49
+ /** Composer event bindings baked into the published snapshot. */
50
+ eventTracking?: EventTrackingConfig$1[];
49
51
  meta: {
50
52
  variantKeys: Record<string, string>;
51
53
  audienceLookup?: {
@@ -120,6 +122,7 @@ interface EventTrackingConfig {
120
122
  selector?: string;
121
123
  description?: string;
122
124
  properties?: string[];
125
+ staticProperties?: Record<string, string>;
123
126
  enabled?: boolean;
124
127
  componentId?: string | null;
125
128
  componentName?: string | null;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, a as CDPAdapter, b as AmplifyUpConfig, E as EventProperties, I as IdentifyInput, c as IdentifyTraits, d as ProfileFieldsInput, e as AmplifyUpTarget, f as EventTrackingConfig$1 } from './types-BxpG9Gsy.js';
2
- export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-BxpG9Gsy.js';
1
+ import { P as PageConfig, C as ContentSource, A as AmplifyContentMeta, E as EventTrackingConfig$1, a as CDPAdapter, b as AmplifyUpConfig, c as EventProperties, I as IdentifyInput, d as IdentifyTraits, e as ProfileFieldsInput, f as AmplifyUpTarget } from './types-npF_lNoq.js';
2
+ export { Z as ZoneConfig, i as isAmplifyUpTarget, n as normalizeAmplifyUpTarget, r as resolveAmplifyUpTarget, g as resolveAmplifyUpUrls } from './types-npF_lNoq.js';
3
3
  export { i as isComposerPreview, a as isPreviewRequest } from './preview-BMrIgUvp.js';
4
4
 
5
5
  interface FetchContentResult {
@@ -46,6 +46,8 @@ interface EdgeResolvedPayload {
46
46
  version: number;
47
47
  zones: Record<string, EdgeResolvedComponent[]>;
48
48
  tree?: EdgeResolvedComponent[];
49
+ /** Composer event bindings baked into the published snapshot. */
50
+ eventTracking?: EventTrackingConfig$1[];
49
51
  meta: {
50
52
  variantKeys: Record<string, string>;
51
53
  audienceLookup?: {
@@ -120,6 +122,7 @@ interface EventTrackingConfig {
120
122
  selector?: string;
121
123
  description?: string;
122
124
  properties?: string[];
125
+ staticProperties?: Record<string, string>;
123
126
  enabled?: boolean;
124
127
  componentId?: string | null;
125
128
  componentName?: string | null;
package/dist/index.js CHANGED
@@ -433,7 +433,8 @@ function mapResolvedToPageConfig(payload) {
433
433
  meta: {
434
434
  // Stash edge meta for diagnostics (not visitor-facing)
435
435
  description: payload.meta?.degraded ? "degraded" : void 0
436
- }
436
+ },
437
+ ...payload.eventTracking && payload.eventTracking.length > 0 ? { eventTracking: payload.eventTracking } : {}
437
438
  };
438
439
  }
439
440
  function collectDegraded(payload) {
@@ -1608,6 +1609,11 @@ Available Console Commands:
1608
1609
  if (config.componentName) {
1609
1610
  properties.componentName = config.componentName;
1610
1611
  }
1612
+ if (config.staticProperties) {
1613
+ for (const [key, value] of Object.entries(config.staticProperties)) {
1614
+ if (key) properties[key] = value;
1615
+ }
1616
+ }
1611
1617
  if (config.properties && config.properties.length > 0) {
1612
1618
  config.properties.forEach((prop) => {
1613
1619
  const dataAttrValue = element.getAttribute(`data-${prop}`);
@@ -1974,13 +1980,23 @@ Available Console Commands:
1974
1980
  document.removeEventListener("click", this.eventSelectionClickHandler, true);
1975
1981
  this.eventSelectionClickHandler = null;
1976
1982
  }
1983
+ if (enabled && typeof window !== "undefined" && window.__AMPLIFYUP_PREVIEW_MODE__) {
1984
+ return;
1985
+ }
1977
1986
  if (enabled) {
1978
1987
  this.eventSelectionClickHandler = (e) => {
1979
- const target = e.target;
1980
- if (!target) return;
1988
+ const raw = e.target;
1989
+ if (!raw) return;
1990
+ const interactive = raw.closest(
1991
+ 'a, button, [role="button"], input, select, textarea, [data-el], [data-amplifyup-component], [data-component-id]'
1992
+ );
1993
+ const target = interactive instanceof HTMLElement ? interactive : raw;
1994
+ e.preventDefault();
1995
+ e.stopPropagation();
1996
+ e.stopImmediatePropagation();
1981
1997
  const selector = this.generateSelectorForElement(target);
1982
1998
  const tagName = target.tagName.toLowerCase();
1983
- const text = target.textContent?.trim().substring(0, 50) || "";
1999
+ const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
1984
2000
  if (window.parent && window.parent !== window) {
1985
2001
  window.parent.postMessage({
1986
2002
  type: "ELEMENT_CLICKED_FOR_EVENT",
@@ -1989,9 +2005,6 @@ Available Console Commands:
1989
2005
  text
1990
2006
  }, "*");
1991
2007
  }
1992
- if (tagName === "a") {
1993
- e.preventDefault();
1994
- }
1995
2008
  };
1996
2009
  document.addEventListener("click", this.eventSelectionClickHandler, true);
1997
2010
  if (this.config?.debug) {