@blotoutio/providers-shop-gpt-sdk 1.12.1 → 1.13.0

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/index.cjs.js CHANGED
@@ -728,6 +728,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
728
728
  timestamp: Date.now(),
729
729
  productHandle,
730
730
  threadId,
731
+ pageUrl: window.location.href,
731
732
  }),
732
733
  credentials: 'include',
733
734
  });
@@ -1877,6 +1878,8 @@ const productItemStyles = i$4 `
1877
1878
  display: flex;
1878
1879
  gap: 16px;
1879
1880
  cursor: pointer;
1881
+ text-decoration: none;
1882
+ height: 100%;
1880
1883
 
1881
1884
  img {
1882
1885
  width: 150px;
@@ -2017,15 +2020,15 @@ class ProductItem extends i$1 {
2017
2020
  ${this.getLocalPrice(comparedAtPrice)}
2018
2021
  </p>`;
2019
2022
  }
2020
- openProduct(url) {
2023
+ getProductUrl(url) {
2021
2024
  if (!url) {
2022
- return;
2025
+ return '';
2023
2026
  }
2024
2027
  const link = new URL(url);
2025
2028
  link.searchParams.set('utm_source', 'shopgpt');
2026
2029
  link.searchParams.set('utm_medium', 'chat');
2027
2030
  link.searchParams.set('et_u_id', this.userId);
2028
- open(link, '_self');
2031
+ return link.toString();
2029
2032
  }
2030
2033
  renderVariantTitles() {
2031
2034
  if (this.product.hasOnlyDefaultVariant) {
@@ -2053,11 +2056,14 @@ class ProductItem extends i$1 {
2053
2056
  bubbles: true,
2054
2057
  }));
2055
2058
  }
2056
- this.openProduct(product.url);
2057
2059
  }
2058
2060
  render() {
2059
2061
  return x `
2060
- <div class="product" @click=${() => this.productClicked(this.product)}>
2062
+ <a
2063
+ class="product"
2064
+ href=${this.getProductUrl(this.product.url)}
2065
+ @click=${() => this.productClicked(this.product)}
2066
+ >
2061
2067
  <img src=${this.product.image.url} alt=${this.product.image.alt} />
2062
2068
  <div class="content">
2063
2069
  <p class="product-name" title=${this.product.title}>
@@ -2070,7 +2076,7 @@ class ProductItem extends i$1 {
2070
2076
  </div>
2071
2077
  <button class="btn-view-product">View Product</button>
2072
2078
  </div>
2073
- </div>
2079
+ </a>
2074
2080
  `;
2075
2081
  }
2076
2082
  }
@@ -4999,8 +5005,9 @@ class ShopGPT extends i$1 {
4999
5005
  else if (this.view === 'modal') {
5000
5006
  const searchParams = new URLSearchParams(window.location.search);
5001
5007
  const hasSource = searchParams.get('utm_source') === 'shopgpt';
5008
+ const isDesktop = window.innerWidth > 768;
5002
5009
  // If the url has `utm_source` open the popup when reloaded
5003
- if (hasSource) {
5010
+ if (hasSource && isDesktop) {
5004
5011
  this.modalState = 'open';
5005
5012
  }
5006
5013
  }
package/index.js CHANGED
@@ -729,6 +729,7 @@ var ProvidersShopGptSdk = (function () {
729
729
  timestamp: Date.now(),
730
730
  productHandle,
731
731
  threadId,
732
+ pageUrl: window.location.href,
732
733
  }),
733
734
  credentials: 'include',
734
735
  });
@@ -1878,6 +1879,8 @@ var ProvidersShopGptSdk = (function () {
1878
1879
  display: flex;
1879
1880
  gap: 16px;
1880
1881
  cursor: pointer;
1882
+ text-decoration: none;
1883
+ height: 100%;
1881
1884
 
1882
1885
  img {
1883
1886
  width: 150px;
@@ -2018,15 +2021,15 @@ var ProvidersShopGptSdk = (function () {
2018
2021
  ${this.getLocalPrice(comparedAtPrice)}
2019
2022
  </p>`;
2020
2023
  }
2021
- openProduct(url) {
2024
+ getProductUrl(url) {
2022
2025
  if (!url) {
2023
- return;
2026
+ return '';
2024
2027
  }
2025
2028
  const link = new URL(url);
2026
2029
  link.searchParams.set('utm_source', 'shopgpt');
2027
2030
  link.searchParams.set('utm_medium', 'chat');
2028
2031
  link.searchParams.set('et_u_id', this.userId);
2029
- open(link, '_self');
2032
+ return link.toString();
2030
2033
  }
2031
2034
  renderVariantTitles() {
2032
2035
  if (this.product.hasOnlyDefaultVariant) {
@@ -2054,11 +2057,14 @@ var ProvidersShopGptSdk = (function () {
2054
2057
  bubbles: true,
2055
2058
  }));
2056
2059
  }
2057
- this.openProduct(product.url);
2058
2060
  }
2059
2061
  render() {
2060
2062
  return x `
2061
- <div class="product" @click=${() => this.productClicked(this.product)}>
2063
+ <a
2064
+ class="product"
2065
+ href=${this.getProductUrl(this.product.url)}
2066
+ @click=${() => this.productClicked(this.product)}
2067
+ >
2062
2068
  <img src=${this.product.image.url} alt=${this.product.image.alt} />
2063
2069
  <div class="content">
2064
2070
  <p class="product-name" title=${this.product.title}>
@@ -2071,7 +2077,7 @@ var ProvidersShopGptSdk = (function () {
2071
2077
  </div>
2072
2078
  <button class="btn-view-product">View Product</button>
2073
2079
  </div>
2074
- </div>
2080
+ </a>
2075
2081
  `;
2076
2082
  }
2077
2083
  }
@@ -5000,8 +5006,9 @@ ${this.comment ? this.comment : E}</textarea
5000
5006
  else if (this.view === 'modal') {
5001
5007
  const searchParams = new URLSearchParams(window.location.search);
5002
5008
  const hasSource = searchParams.get('utm_source') === 'shopgpt';
5009
+ const isDesktop = window.innerWidth > 768;
5003
5010
  // If the url has `utm_source` open the popup when reloaded
5004
- if (hasSource) {
5011
+ if (hasSource && isDesktop) {
5005
5012
  this.modalState = 'open';
5006
5013
  }
5007
5014
  }
package/index.mjs CHANGED
@@ -726,6 +726,7 @@ const createShopGPTAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, st
726
726
  timestamp: Date.now(),
727
727
  productHandle,
728
728
  threadId,
729
+ pageUrl: window.location.href,
729
730
  }),
730
731
  credentials: 'include',
731
732
  });
@@ -1875,6 +1876,8 @@ const productItemStyles = i$4 `
1875
1876
  display: flex;
1876
1877
  gap: 16px;
1877
1878
  cursor: pointer;
1879
+ text-decoration: none;
1880
+ height: 100%;
1878
1881
 
1879
1882
  img {
1880
1883
  width: 150px;
@@ -2015,15 +2018,15 @@ class ProductItem extends i$1 {
2015
2018
  ${this.getLocalPrice(comparedAtPrice)}
2016
2019
  </p>`;
2017
2020
  }
2018
- openProduct(url) {
2021
+ getProductUrl(url) {
2019
2022
  if (!url) {
2020
- return;
2023
+ return '';
2021
2024
  }
2022
2025
  const link = new URL(url);
2023
2026
  link.searchParams.set('utm_source', 'shopgpt');
2024
2027
  link.searchParams.set('utm_medium', 'chat');
2025
2028
  link.searchParams.set('et_u_id', this.userId);
2026
- open(link, '_self');
2029
+ return link.toString();
2027
2030
  }
2028
2031
  renderVariantTitles() {
2029
2032
  if (this.product.hasOnlyDefaultVariant) {
@@ -2051,11 +2054,14 @@ class ProductItem extends i$1 {
2051
2054
  bubbles: true,
2052
2055
  }));
2053
2056
  }
2054
- this.openProduct(product.url);
2055
2057
  }
2056
2058
  render() {
2057
2059
  return x `
2058
- <div class="product" @click=${() => this.productClicked(this.product)}>
2060
+ <a
2061
+ class="product"
2062
+ href=${this.getProductUrl(this.product.url)}
2063
+ @click=${() => this.productClicked(this.product)}
2064
+ >
2059
2065
  <img src=${this.product.image.url} alt=${this.product.image.alt} />
2060
2066
  <div class="content">
2061
2067
  <p class="product-name" title=${this.product.title}>
@@ -2068,7 +2074,7 @@ class ProductItem extends i$1 {
2068
2074
  </div>
2069
2075
  <button class="btn-view-product">View Product</button>
2070
2076
  </div>
2071
- </div>
2077
+ </a>
2072
2078
  `;
2073
2079
  }
2074
2080
  }
@@ -4997,8 +5003,9 @@ class ShopGPT extends i$1 {
4997
5003
  else if (this.view === 'modal') {
4998
5004
  const searchParams = new URLSearchParams(window.location.search);
4999
5005
  const hasSource = searchParams.get('utm_source') === 'shopgpt';
5006
+ const isDesktop = window.innerWidth > 768;
5000
5007
  // If the url has `utm_source` open the popup when reloaded
5001
- if (hasSource) {
5008
+ if (hasSource && isDesktop) {
5002
5009
  this.modalState = 'open';
5003
5010
  }
5004
5011
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-shop-gpt-sdk",
3
- "version": "1.12.1",
3
+ "version": "1.13.0",
4
4
  "description": "Shop GPT SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",