Skip to content

Commit

Permalink
update web-pixels-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
kiftio committed Jun 6, 2024
1 parent aed3a0d commit 96fd7d5
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/web-pixels-extension/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
75 changes: 75 additions & 0 deletions packages/web-pixels-extension/src/schemas/pixel-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -833,6 +861,7 @@ export const pixelEvents = {
properties: {
id: {
type: 'string',
nullable: true,
metadata: {
description: 'A globally unique identifier.',
},
Expand Down Expand Up @@ -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.',
},
Expand Down Expand Up @@ -995,6 +1026,7 @@ export const pixelEvents = {
properties: {
id: {
type: 'string',
nullable: true,
metadata: {
description: 'The ID of the product.',
},
Expand All @@ -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.',
},
Expand Down Expand Up @@ -1172,6 +1206,7 @@ export const pixelEvents = {
},
id: {
type: 'string',
nullable: true,
metadata: {
description: 'A globally unique identifier.',
},
Expand Down Expand Up @@ -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:
Expand Down
63 changes: 56 additions & 7 deletions packages/web-pixels-extension/src/types/PixelEvents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -706,7 +734,7 @@ export interface Cart {
/**
* A globally unique identifier.
*/
id: string;
id: string | null;
lines: CartLine[];

/**
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -1498,7 +1547,7 @@ export interface Product {
/**
* The ID of the product.
*/
id: string;
id: string | null;

/**
* The product’s title.
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/web-pixels-extension/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type {
CartLine,
Customer,
DiscountApplication,
FormError,
GenericElement,
InputElement,
FormElement,
Expand All @@ -30,6 +31,7 @@ export type {
PixelEventsCheckoutCompleted,
PixelEventsCheckoutStartedData,
PixelEventsCheckoutCompletedData,
PixelEventsFormError,
PricingPercentageValue,
Transaction,
} from './PixelEvents';
Expand Down

0 comments on commit 96fd7d5

Please sign in to comment.