From 96fd7d50fc68a4ff9d3472d34f87c0d0fc11553b Mon Sep 17 00:00:00 2001 From: Daniel Kift Date: Wed, 5 Jun 2024 21:16:41 +0000 Subject: [PATCH] update web-pixels-schema --- packages/web-pixels-extension/package.json | 2 +- .../src/schemas/pixel-events.ts | 75 +++++++++++++++++++ .../src/types/PixelEvents/index.ts | 63 ++++++++++++++-- .../web-pixels-extension/src/types/index.ts | 2 + 4 files changed, 134 insertions(+), 8 deletions(-) diff --git a/packages/web-pixels-extension/package.json b/packages/web-pixels-extension/package.json index ce295895f..bee9af062 100644 --- a/packages/web-pixels-extension/package.json +++ b/packages/web-pixels-extension/package.json @@ -1,7 +1,7 @@ { "name": "@shopify/web-pixels-extension", "description": "Provides tools to author Web Pixels extension", - "version": "2.4.0", + "version": "2.5.0", "publishConfig": { "access": "public", "@shopify:registry": "https://registry.npmjs.org" diff --git a/packages/web-pixels-extension/src/schemas/pixel-events.ts b/packages/web-pixels-extension/src/schemas/pixel-events.ts index 0107cb35d..21502ee29 100644 --- a/packages/web-pixels-extension/src/schemas/pixel-events.ts +++ b/packages/web-pixels-extension/src/schemas/pixel-events.ts @@ -511,6 +511,34 @@ export const pixelEvents = { }, }, }, + FormError: { + metadata: { + description: 'A container for information related to a form error.', + }, + properties: { + field: { + type: 'string', + nullable: true, + metadata: { + description: + 'The name of the field that the error is associated with.', + }, + }, + section: { + type: 'string', + metadata: { + description: + 'The section of the of the form where the error ocurred. (e.g. checkout-shipping-address)', + }, + }, + type: { + type: 'string', + metadata: { + description: "The type of error that occurred, (e.g. 'too long').", + }, + }, + }, + }, Checkout: { metadata: { description: @@ -833,6 +861,7 @@ export const pixelEvents = { properties: { id: { type: 'string', + nullable: true, metadata: { description: 'A globally unique identifier.', }, @@ -868,12 +897,14 @@ export const pixelEvents = { }, title: { type: 'string', + nullable: true, metadata: { description: 'The product variant’s title.', }, }, untranslatedTitle: { type: 'string', + nullable: true, metadata: { description: 'The product variant’s untranslated title.', }, @@ -995,6 +1026,7 @@ export const pixelEvents = { properties: { id: { type: 'string', + nullable: true, metadata: { description: 'The ID of the product.', }, @@ -1007,12 +1039,14 @@ export const pixelEvents = { }, untranslatedTitle: { type: 'string', + nullable: true, metadata: { description: 'The product’s untranslated title.', }, }, url: { type: 'string', + nullable: true, metadata: { description: 'The relative URL of the product.', }, @@ -1172,6 +1206,7 @@ export const pixelEvents = { }, id: { type: 'string', + nullable: true, metadata: { description: 'A globally unique identifier.', }, @@ -1656,6 +1691,46 @@ export const pixelEvents = { }, }, properties: { + form_error: { + metadata: { + description: + 'The `form_error` event logs an instance of a customer encountering an error while interacting with a form.', + }, + properties: { + id: { + ref: 'Id', + }, + clientId: { + ref: 'ClientId', + }, + type: { + type: 'string', + metadata: { + typescriptType: 'EventType.Standard', + }, + }, + name: { + type: 'string', + metadata: { + description: 'The name of the customer event', + typescriptType: "'form_error'", + }, + }, + timestamp: { + ref: 'Timestamp', + }, + context: { + ref: 'Context', + }, + data: { + properties: { + formError: { + ref: 'FormError', + }, + }, + }, + }, + }, checkout_address_info_submitted: { metadata: { description: diff --git a/packages/web-pixels-extension/src/types/PixelEvents/index.ts b/packages/web-pixels-extension/src/types/PixelEvents/index.ts index daec8c124..454ab9ea0 100644 --- a/packages/web-pixels-extension/src/types/PixelEvents/index.ts +++ b/packages/web-pixels-extension/src/types/PixelEvents/index.ts @@ -178,6 +178,28 @@ export interface PixelEventsCollectionViewed { type: EventType.Standard; } +export interface PixelEventsFormErrorData { + formError: FormError; +} + +/** + * The `form_error` event logs an instance of a customer encountering an error + * while interacting with a form. + */ +export interface PixelEventsFormError { + clientId: ClientId; + context: Context; + data: PixelEventsFormErrorData; + id: Id; + + /** + * The name of the customer event + */ + name: 'form_error'; + timestamp: Timestamp; + type: EventType.Standard; +} + export interface PixelEventsFormSubmittedData { element: FormElement; } @@ -474,6 +496,12 @@ export interface PixelEvents { */ collection_viewed: PixelEventsCollectionViewed; + /** + * The `form_error` event logs an instance of a customer encountering an error + * while interacting with a form. + */ + form_error: PixelEventsFormError; + /** * The `form_submitted` event logs an instance where a form element on the * page has been submitted @@ -706,7 +734,7 @@ export interface Cart { /** * A globally unique identifier. */ - id: string; + id: string | null; lines: CartLine[]; /** @@ -1140,6 +1168,27 @@ export interface FormElement { id: string | null; } +/** + * A container for information related to a form error. + */ +export interface FormError { + /** + * The name of the field that the error is associated with. + */ + field: string | null; + + /** + * The section of the of the form where the error ocurred. (e.g. checkout- + * shipping-address) + */ + section: string; + + /** + * The type of error that occurred, (e.g. 'too long'). + */ + type: string; +} + /** * An object that contains data about a generic element type */ @@ -1498,7 +1547,7 @@ export interface Product { /** * The ID of the product. */ - id: string; + id: string | null; /** * The product’s title. @@ -1515,12 +1564,12 @@ export interface Product { /** * The product’s untranslated title. */ - untranslatedTitle: string; + untranslatedTitle: string | null; /** * The relative URL of the product. */ - url: string; + url: string | null; /** * The product’s vendor name. @@ -1536,7 +1585,7 @@ export interface ProductVariant { /** * A globally unique identifier. */ - id: string; + id: string | null; /** * Image associated with the product variant. This field falls back to the @@ -1562,12 +1611,12 @@ export interface ProductVariant { /** * The product variant’s title. */ - title: string; + title: string | null; /** * The product variant’s untranslated title. */ - untranslatedTitle: string; + untranslatedTitle: string | null; } /** diff --git a/packages/web-pixels-extension/src/types/index.ts b/packages/web-pixels-extension/src/types/index.ts index 8669c3988..83c48b8b2 100644 --- a/packages/web-pixels-extension/src/types/index.ts +++ b/packages/web-pixels-extension/src/types/index.ts @@ -11,6 +11,7 @@ export type { CartLine, Customer, DiscountApplication, + FormError, GenericElement, InputElement, FormElement, @@ -30,6 +31,7 @@ export type { PixelEventsCheckoutCompleted, PixelEventsCheckoutStartedData, PixelEventsCheckoutCompletedData, + PixelEventsFormError, PricingPercentageValue, Transaction, } from './PixelEvents';