@shopify/hydrogen 2026.4.5 → 2026.4.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.
@@ -90,6 +90,31 @@ type VisitorConsent = {
90
90
  preferences: ConsentStatus;
91
91
  sale_of_data: ConsentStatus;
92
92
  };
93
+ /** Consent choices returned by the Customer Privacy API. */
94
+ type VisitorConsentValues = Record<keyof VisitorConsent, 'yes' | 'no' | ''>;
95
+ type CustomerPrivacyConfiguration = {
96
+ isHeadless?: boolean;
97
+ asyncConsent?: boolean;
98
+ asyncVisitorState?: boolean;
99
+ consentDomain?: string;
100
+ storefrontAccessToken?: string;
101
+ injectedConsent?: string;
102
+ debug?: {
103
+ hydrogen?: {
104
+ generation: number;
105
+ serverTiming: boolean;
106
+ };
107
+ [key: string]: unknown;
108
+ };
109
+ };
110
+ type VisitorConsentCollected = {
111
+ analyticsAllowed: boolean;
112
+ firstPartyMarketingAllowed: boolean;
113
+ marketingAllowed: boolean;
114
+ preferencesAllowed: boolean;
115
+ saleOfDataAllowed: boolean;
116
+ thirdPartyMarketingAllowed: boolean;
117
+ };
93
118
  type CustomerPrivacyConsentConfig = {
94
119
  checkoutRootDomain: string;
95
120
  storefrontRootDomain?: string;
@@ -98,11 +123,11 @@ type CustomerPrivacyConsentConfig = {
98
123
  /** The privacyBanner refers to `language` as `locale` */
99
124
  locale?: LanguageCode;
100
125
  };
101
- type SetConsentHeadlessParams = VisitorConsent & CustomerPrivacyConsentConfig & {
126
+ type SetConsentHeadlessParams = Partial<VisitorConsent> & CustomerPrivacyConsentConfig & {
102
127
  headlessStorefront?: boolean;
103
128
  };
104
129
  /**
105
- Ideally this type should come from the Custoemr Privacy API sdk
130
+ Ideally this type should come from the Customer Privacy API sdk
106
131
  analyticsProcessingAllowed -
107
132
  currentVisitorConsent
108
133
  doesMerchantSupportGranularConsent
@@ -119,7 +144,9 @@ type SetConsentHeadlessParams = VisitorConsent & CustomerPrivacyConsentConfig &
119
144
  thirdPartyMarketingAllowed
120
145
  **/
121
146
  type OriginalCustomerPrivacy = {
122
- currentVisitorConsent: () => VisitorConsent;
147
+ currentVisitorConsent: () => VisitorConsentValues;
148
+ consentStatus?: 'loading' | 'loaded';
149
+ config?: CustomerPrivacyConfiguration;
123
150
  preferencesProcessingAllowed: () => boolean;
124
151
  saleOfDataAllowed: () => boolean;
125
152
  marketingAllowed: () => boolean;
@@ -130,7 +157,7 @@ type OriginalCustomerPrivacy = {
130
157
  shouldShowBanner: () => boolean;
131
158
  };
132
159
  type CustomerPrivacy = Omit<OriginalCustomerPrivacy, 'setTrackingConsent'> & {
133
- setTrackingConsent: (consent: VisitorConsent, // we have already applied the headlessStorefront in the override
160
+ setTrackingConsent: (consent: Partial<VisitorConsent>, // we have already applied the headlessStorefront in the override
134
161
  callback: (data: {
135
162
  error: string;
136
163
  } | undefined) => void) => void;
@@ -139,6 +166,11 @@ type PrivacyBanner = {
139
166
  loadBanner: (options?: Partial<CustomerPrivacyConsentConfig>) => void;
140
167
  showPreferences: (options?: Partial<CustomerPrivacyConsentConfig>) => void;
141
168
  };
169
+ interface CustomEventMap {
170
+ visitorConsentCollected: CustomEvent<VisitorConsentCollected>;
171
+ consentTrackingApiLoaded: Event;
172
+ shopifyCustomerPrivacyApiLoaded: CustomEvent<null>;
173
+ }
142
174
 
143
175
  type WaitUntil = (promise: Promise<unknown>) => void;
144
176
 
@@ -159,9 +191,9 @@ declare global {
159
191
  interface Window {
160
192
  privacyBanner: PrivacyBanner;
161
193
  Shopify: {
162
- customerPrivacy?: Partial<CustomerPrivacy> & {
163
- backendConsentEnabled?: boolean;
164
- };
194
+ country?: string;
195
+ locale?: string;
196
+ customerPrivacy?: Partial<CustomerPrivacy>;
165
197
  };
166
198
  }
167
199
  interface Document {