@shopify/hydrogen 2024.7.5 → 2024.7.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.
@@ -511,7 +511,7 @@ var errorOnce = (string) => {
511
511
  };
512
512
 
513
513
  // src/version.ts
514
- var LIB_VERSION = "2024.7.5";
514
+ var LIB_VERSION = "2024.7.7";
515
515
 
516
516
  // src/utils/graphql.ts
517
517
  function minifyQuery(string) {
@@ -4250,6 +4250,7 @@ function useCustomerPrivacy(props) {
4250
4250
  config
4251
4251
  });
4252
4252
  setLoaded.privacyBanner();
4253
+ emitCustomerPrivacyApiLoaded();
4253
4254
  }
4254
4255
  }
4255
4256
  };
@@ -4292,6 +4293,7 @@ function useCustomerPrivacy(props) {
4292
4293
  customerPrivacy: customCustomerPrivacy
4293
4294
  };
4294
4295
  setLoaded.customerPrivacy();
4296
+ emitCustomerPrivacyApiLoaded();
4295
4297
  }
4296
4298
  }
4297
4299
  });
@@ -4311,6 +4313,13 @@ function useCustomerPrivacy(props) {
4311
4313
  }
4312
4314
  return result;
4313
4315
  }
4316
+ var hasEmitted = false;
4317
+ function emitCustomerPrivacyApiLoaded() {
4318
+ if (hasEmitted) return;
4319
+ hasEmitted = true;
4320
+ const event = new CustomEvent("shopifyCustomerPrivacyApiLoaded");
4321
+ document.dispatchEvent(event);
4322
+ }
4314
4323
  function useApisLoaded({
4315
4324
  withPrivacyBanner,
4316
4325
  onLoaded
@@ -4360,12 +4369,13 @@ function overrideCustomerPrivacySetTrackingConsent({
4360
4369
  config
4361
4370
  }) {
4362
4371
  const original = customerPrivacy.setTrackingConsent;
4372
+ const { locale, country, ...rest } = config;
4363
4373
  function updatedSetTrackingConsent(consent, callback) {
4364
4374
  original(
4365
4375
  {
4366
- ...consent,
4376
+ ...rest,
4367
4377
  headlessStorefront: true,
4368
- ...config
4378
+ ...consent
4369
4379
  },
4370
4380
  callback
4371
4381
  );
@@ -4408,6 +4418,11 @@ function getPrivacyBanner() {
4408
4418
  return null;
4409
4419
  }
4410
4420
  }
4421
+
4422
+ // package.json
4423
+ var version = "2024.7.7";
4424
+
4425
+ // src/analytics-manager/ShopifyAnalytics.tsx
4411
4426
  function getCustomerPrivacyRequired() {
4412
4427
  const customerPrivacy = getCustomerPrivacy();
4413
4428
  if (!customerPrivacy) {
@@ -4486,11 +4501,15 @@ function prepareBasePageViewPayload(payload) {
4486
4501
  }
4487
4502
  const eventPayload = {
4488
4503
  shopifySalesChannel: "hydrogen",
4504
+ assetVersionId: version,
4489
4505
  ...payload.shop,
4490
4506
  hasUserConsent,
4491
4507
  ...hydrogenReact.getClientBrowserParameters(),
4492
4508
  ccpaEnforced: !customerPrivacy.saleOfDataAllowed(),
4493
- gdprEnforced: !(customerPrivacy.marketingAllowed() && customerPrivacy.analyticsProcessingAllowed())
4509
+ gdprEnforced: !(customerPrivacy.marketingAllowed() && customerPrivacy.analyticsProcessingAllowed()),
4510
+ analyticsAllowed: customerPrivacy.analyticsProcessingAllowed(),
4511
+ marketingAllowed: customerPrivacy.marketingAllowed(),
4512
+ saleOfDataAllowed: customerPrivacy.saleOfDataAllowed()
4494
4513
  };
4495
4514
  return eventPayload;
4496
4515
  }
@@ -4549,7 +4568,8 @@ function collectionViewHandler(payload) {
4549
4568
  eventPayload = {
4550
4569
  ...eventPayload,
4551
4570
  ...viewPayload,
4552
- collectionHandle: payload.collection.handle
4571
+ collectionHandle: payload.collection.handle,
4572
+ collectionId: payload.collection.id
4553
4573
  };
4554
4574
  hydrogenReact.sendShopifyAnalytics({
4555
4575
  eventName: hydrogenReact.AnalyticsEventName.COLLECTION_VIEW,
@@ -4587,7 +4607,7 @@ function sendCartAnalytics({
4587
4607
  }) {
4588
4608
  const product = {
4589
4609
  id: matchedLine.merchandise.product.id,
4590
- variantId: matchedLine.id,
4610
+ variantId: matchedLine.merchandise.id,
4591
4611
  title: matchedLine.merchandise.product.title,
4592
4612
  variantTitle: matchedLine.merchandise.title,
4593
4613
  vendor: matchedLine.merchandise.product.vendor,