Skip to content

Commit cd29ed5

Browse files
authored
Merge pull request #3074 from Shopify/add-analytics-api-to-customer-ui-extension-2025-07-lh
[2025-07]Move analytics api from osp api to standard api in customer account ui extension.
2 parents ef5f869 + 59e3207 commit cd29ed5

File tree

5 files changed

+56
-12
lines changed

5 files changed

+56
-12
lines changed

.changeset/cuddly-coins-deliver.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/ui-extensions': patch
3+
---
4+
5+
Move analytics api from osp api to standard api in customer account ui extension.

packages/ui-extensions/src/surfaces/customer-account/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export type {
6666
Company,
6767
Customer,
6868
SessionToken,
69+
Analytics,
6970
ApplyTrackingConsentChangeType,
7071
CustomerPrivacy,
7172
TrackingConsentChangeResult,

packages/ui-extensions/src/surfaces/customer-account/api/order-status/order-status.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,6 @@ export interface OrderStatusLocalization {
184184
export type AuthenticationState = 'fully_authenticated' | 'pre_authenticated';
185185

186186
export interface OrderStatusApi<Target extends ExtensionTarget> {
187-
/**
188-
* Methods for interacting with [Web Pixels](https://shopify.dev/docs/apps/marketing), such as emitting an event.
189-
*/
190-
analytics: Analytics;
191-
192187
/**
193188
* Gift Cards that have been applied to the order.
194189
*/
@@ -952,13 +947,6 @@ export interface StoreCreditAccount {
952947
balance: Money;
953948
}
954949

955-
export interface Analytics {
956-
/**
957-
* Publish method to emit analytics events to [Web Pixels](https://shopify.dev/docs/apps/marketing).
958-
*/
959-
publish(name: string, data: {[key: string]: unknown}): Promise<boolean>;
960-
}
961-
962950
/**
963951
* Represents the delivery information and options available for one or
964952
* more cart lines.

packages/ui-extensions/src/surfaces/customer-account/api/shared.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,50 @@ export interface SessionToken {
448448
get(): Promise<string>;
449449
}
450450

451+
export interface Analytics {
452+
/**
453+
* Publish method to emit analytics events to [Web Pixels](https://shopify.dev/docs/apps/marketing).
454+
*/
455+
publish(name: string, data: Record<string, unknown>): Promise<boolean>;
456+
457+
/**
458+
* A method for capturing details about a visitor on the online store.
459+
*/
460+
visitor(data: {email?: string; phone?: string}): Promise<VisitorResult>;
461+
}
462+
/**
463+
* Represents a visitor result.
464+
*/
465+
export type VisitorResult = VisitorSuccess | VisitorError;
466+
467+
/**
468+
* Represents a successful visitor result.
469+
*/
470+
export interface VisitorSuccess {
471+
/**
472+
* Indicates that the visitor information was validated and submitted.
473+
*/
474+
type: 'success';
475+
}
476+
477+
/**
478+
* Represents an unsuccessful visitor result.
479+
*/
480+
export interface VisitorError {
481+
/**
482+
* Indicates that the visitor information is invalid and wasn't submitted.
483+
* Examples are using the wrong data type or missing a required property.
484+
*/
485+
type: 'error';
486+
487+
/**
488+
* A message that explains the error. This message is useful for debugging.
489+
* It's **not** localized, and therefore should not be presented directly
490+
* to the buyer.
491+
*/
492+
message: string;
493+
}
494+
451495
export interface AllowedProcessing {
452496
/**
453497
* Can collect customer analytics about how the shop was used and interactions made on the shop.

packages/ui-extensions/src/surfaces/customer-account/api/standard-api/standard-api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
StorefrontApiVersion,
1010
Ui,
1111
SessionToken,
12+
Analytics,
1213
CustomerPrivacy,
1314
ApplyTrackingConsentChangeType,
1415
} from '../shared';
@@ -79,6 +80,11 @@ export interface StandardApi<Target extends ExtensionTarget = ExtensionTarget> {
7980
*/
8081
sessionToken: SessionToken;
8182

83+
/**
84+
* Methods for interacting with [Web Pixels](https://shopify.dev/docs/apps/marketing), such as emitting an event.
85+
*/
86+
analytics: Analytics;
87+
8288
/**
8389
* The settings matching the settings definition written in the
8490
* [`shopify.ui.extension.toml`](https://shopify.dev/docs/api/customer-account-ui-extensions/configuration) file.

0 commit comments

Comments
 (0)