Skip to content

Commit

Permalink
updates enabledFeatures on CustomerSegmentTemplateApi
Browse files Browse the repository at this point in the history
  • Loading branch information
lauramann committed Sep 19, 2023
1 parent e3296a5 commit 7fc0e51
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-turkeys-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/ui-extensions': patch
---

Adds shopifyPlusPlan enabledFeature on CustomerSegmentTemplateApi
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import type {ExtensionTarget as AnyExtensionTarget} from '../../extension-target

/* List of enabled query language features during a progressive rollout */
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 on the plus plan. For example: companies IS NOT NULL */
'shopifyPlusPlan';

export interface CustomerSegmentTemplateApi<
ExtensionTarget extends AnyExtensionTarget,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export type CustomerSegmentTemplateIcon =
| 'buyButtonMajor'
| 'followUpEmailMajor'
| 'confettiMajor'
| 'viewMajor'
| 'buyButtonMajor';
| 'viewMajor';

export type CustomerSegmentTemplateCategory =
| 'firstTimeBuyers'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,38 @@ import {
export default extension(
'admin.customers.segmentation-templates.render',
(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 shopifyPlusPlanEnabled =
__enabledFeatures.includes('shopifyPlusPlan');
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',
},
);

if (shopifyPlusPlanEnabled) {
root.appendChild(companiesTemplate);
}

root.appendChild(productTemplate);
root.appendChild(locationTemplate);

root.mount();
Expand Down

0 comments on commit 7fc0e51

Please sign in to comment.