@shopify/ui-extensions
Advanced tools
Comparing version 0.0.0-unstable-20230919120147 to 0.0.0-unstable-20230920161200
import type { StandardApi } from '../standard/standard'; | ||
import type { I18n } from '../../../../api'; | ||
import type { ExtensionTarget as AnyExtensionTarget } from '../../extension-targets'; | ||
type CustomerSegmentationFeature = 'productsPurchasedByTags' | 'aggregateFilters'; | ||
type CustomerSegmentationFeature = 'b2bEnabled'; | ||
export interface CustomerSegmentTemplateApi<ExtensionTarget extends AnyExtensionTarget> extends StandardApi<ExtensionTarget> { | ||
@@ -6,0 +6,0 @@ i18n: I18n; |
@@ -1,2 +0,2 @@ | ||
export type CustomerSegmentTemplateIcon = 'categoriesMajor' | 'firstVisitMajor' | 'heartMajor' | 'marketingMajor' | 'checkoutMajor' | 'ordersMajor' | 'locationMajor' | 'emailNewsletterMajor' | 'firstOrderMajor' | 'billingStatementDollarMajor' | 'diamondAlertMajor' | 'abandonedCartMajor' | 'calendarMajor' | 'productsMajor' | 'globeMajor' | 'flagMajor' | 'uploadMajor' | 'buyButtonMajor' | 'followUpEmailMajor' | 'confettiMajor' | 'viewMajor' | 'buyButtonMajor'; | ||
export type CustomerSegmentTemplateIcon = 'categoriesMajor' | 'firstVisitMajor' | 'heartMajor' | 'marketingMajor' | 'checkoutMajor' | 'ordersMajor' | 'locationMajor' | 'emailNewsletterMajor' | 'firstOrderMajor' | 'billingStatementDollarMajor' | 'diamondAlertMajor' | 'abandonedCartMajor' | 'calendarMajor' | 'productsMajor' | 'globeMajor' | 'flagMajor' | 'uploadMajor' | 'buyButtonMajor' | 'followUpEmailMajor' | 'confettiMajor' | 'viewMajor'; | ||
export type CustomerSegmentTemplateCategory = 'firstTimeBuyers' | 'highValueCustomers' | 'reEngageCustomers' | 'abandonedCheckout' | 'purchaseBehaviour' | 'location'; | ||
@@ -3,0 +3,0 @@ /** |
{ | ||
"name": "@shopify/ui-extensions", | ||
"version": "0.0.0-unstable-20230919120147", | ||
"version": "0.0.0-unstable-20230920161200", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "docs:admin": "sh ./docs/surfaces/admin/build-docs.sh \"admin\"", |
@@ -7,6 +7,4 @@ import type {StandardApi} from '../standard/standard'; | ||
type CustomerSegmentationFeature = | ||
/* Allows merchants to segment on products purchased by tags. For example: products_purchased(tag: 'Red hats') = true */ | ||
| 'productsPurchasedByTags' | ||
/* Enables count aggregates on functions. For example: shopify_email.opened(count_at_least: 5) = true */ | ||
| 'aggregateFilters'; | ||
/* Enables templates using filters only available when B2B is enabled. For example: companies IS NOT NULL */ | ||
'b2bEnabled'; | ||
@@ -13,0 +11,0 @@ export interface CustomerSegmentTemplateApi< |
@@ -9,26 +9,34 @@ import { | ||
(root, {i18n, __enabledFeatures}) => { | ||
const productsPurchasedOnTagsEnabled = __enabledFeatures.includes('productsPurchasedByTags'); | ||
const productTemplate = root.createComponent(InternalCustomerSegmentTemplate, { | ||
title: i18n.translate('product.title'), | ||
description: i18n.translate('product.description'), | ||
icon: 'productsMajor', | ||
query: productsPurchasedOnTagsEnabled | ||
? 'products_purchased(tag: (product_tag)) = true' | ||
: 'products_purchased(id: (product_id)) = true', | ||
queryToInsert: productsPurchasedOnTagsEnabled | ||
? 'products_purchased(tag:' | ||
: 'products_purchased(id:', | ||
dateAdded: new Date('2023-01-15').toISOString(), | ||
category: 'reEngageCustomers', | ||
}); | ||
const b2bEnabled = | ||
__enabledFeatures.includes('b2bEnabled'); | ||
const companiesTemplate = root.createComponent( | ||
InternalCustomerSegmentTemplate, | ||
{ | ||
title: i18n.translate('companies.title'), | ||
description: i18n.translate('companies.description'), | ||
icon: 'buyButtonMajor', | ||
query: 'companies IS NOT NULL', | ||
dateAdded: new Date('2023-01-15').toISOString(), | ||
category: 'reEngageCustomers', | ||
}, | ||
); | ||
const locationTemplate = root.createComponent(InternalCustomerSegmentTemplate, { | ||
title: i18n.translate('location.title'), | ||
description: [i18n.translate('location.firstParagraph'), i18n.translate('location.secondParagraph')], | ||
icon: 'locationMajor', | ||
query: "customer_cities CONTAINS 'US-NY-NewYorkCity'", | ||
category: 'location', | ||
}); | ||
const locationTemplate = root.createComponent( | ||
InternalCustomerSegmentTemplate, | ||
{ | ||
title: i18n.translate('location.title'), | ||
description: [ | ||
i18n.translate('location.firstParagraph'), | ||
i18n.translate('location.secondParagraph'), | ||
], | ||
icon: 'locationMajor', | ||
query: "customer_cities CONTAINS 'US-NY-NewYorkCity'", | ||
category: 'location', | ||
}, | ||
); | ||
root.appendChild(productTemplate); | ||
if (b2bEnabled) { | ||
root.appendChild(companiesTemplate); | ||
} | ||
root.appendChild(locationTemplate); | ||
@@ -35,0 +43,0 @@ |
@@ -24,4 +24,3 @@ import {createRemoteComponent} from '@remote-ui/core'; | ||
| 'confettiMajor' | ||
| 'viewMajor' | ||
| 'buyButtonMajor'; | ||
| 'viewMajor'; | ||
@@ -28,0 +27,0 @@ export type CustomerSegmentTemplateCategory = |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
31255
1483643