Skip to content

Commit 6fdd764

Browse files
committed
feature: add tag_regexes flag into the frontend
1 parent e10b9bd commit 6fdd764

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

clients/ts-sdk/openapi.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8170,6 +8170,13 @@
81708170
"type": "boolean",
81718171
"description": "This option will ingest all variants as individual chunks and place them in groups by product id. Turning this off will only scrape 1 variant per product. default: true",
81728172
"nullable": true
8173+
},
8174+
"tag_regexes": {
8175+
"type": "array",
8176+
"items": {
8177+
"type": "string"
8178+
},
8179+
"nullable": true
81738180
}
81748181
}
81758182
},

clients/ts-sdk/src/types.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ export type CrawlShopifyOptions = {
610610
* This option will ingest all variants as individual chunks and place them in groups by product id. Turning this off will only scrape 1 variant per product. default: true
611611
*/
612612
group_variants?: (boolean) | null;
613+
tag_regexes?: Array<(string)> | null;
613614
};
614615

615616
export type CreateApiKeyReqPayload = {

frontends/dashboard/src/pages/dataset/CrawlingSettings.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type FlatCrawlOptions = Omit<CrawlOptions, "scrape_options"> & {
3737
openapi_schema_url?: string;
3838
openapi_tag?: string;
3939
group_variants?: boolean | null;
40+
tag_regexes?: string[] | null;
4041
};
4142

4243
export const unflattenCrawlOptions = (
@@ -79,6 +80,7 @@ export const unflattenCrawlOptions = (
7980
scrape_options: {
8081
type: "shopify",
8182
group_variants: options.group_variants,
83+
tag_regexes: options.tag_regexes ?? [],
8284
},
8385
};
8486
}
@@ -111,6 +113,7 @@ export const flattenCrawlOptions = (
111113
...options,
112114
type: "shopify",
113115
group_variants: options.scrape_options.group_variants,
116+
tag_regexes: options.scrape_options.tag_regexes,
114117
};
115118
} else {
116119
return {
@@ -426,7 +429,7 @@ const RealCrawlingSettings = (props: RealCrawlingSettingsProps) => {
426429

427430
<div class="flex items-center gap-2 py-2 pt-4">
428431
<Show when={isShopify()}>
429-
<label class="block pl-4">Group Product Variants?</label>
432+
<label class="block">Group Product Variants?</label>
430433
<input
431434
onChange={(e) =>
432435
setOptions("group_variants", e.currentTarget.checked)
@@ -437,6 +440,28 @@ const RealCrawlingSettings = (props: RealCrawlingSettingsProps) => {
437440
/>
438441
</Show>
439442
</div>
443+
<div class="items-center gap-2 py-2 pt-4">
444+
<Show when={isShopify()}>
445+
<div class="flex items-center gap-2">
446+
<div>Important Product Tags (regex)</div>
447+
<Tooltip
448+
tooltipText="Regex pattern of tags to use from the Shopify API, e.g. 'Men' to include 'Men' if it exists in a product tag."
449+
body={<FaRegularCircleQuestion class="h-3 w-3 text-black" />}
450+
/>
451+
</div>
452+
<MultiStringInput
453+
disabled={!isShopify()}
454+
placeholder="Men"
455+
addClass="bg-magenta-100/40 px-2 text-sm rounded border border-magenta-300/40"
456+
addLabel="Add Product Tag"
457+
onChange={(value) => {
458+
setOptions("tag_regexes", value);
459+
}}
460+
value={options.tag_regexes || []}
461+
/>
462+
<Error error={errors.tag_regexes} />
463+
</Show>
464+
</div>
440465

441466
<div classList={{ "flex gap-4 pt-2": true, "opacity-40": isShopify() }}>
442467
<div>

0 commit comments

Comments
 (0)