Skip to content

Commit d0c778d

Browse files
authored
Merge pull request #3073 from Shopify/add-analytics-api-to-customer-ui-extension-2025-10-lh
[2025-10]Move analytics api from osp api to standard api in customer account ui extension.
2 parents 788384f + 49a2b92 commit d0c778d

File tree

5 files changed

+56
-12
lines changed

5 files changed

+56
-12
lines changed

.changeset/bright-spiders-jam.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
@@ -437,6 +437,50 @@ export interface SessionToken {
437437
get(): Promise<string>;
438438
}
439439

440+
export interface Analytics {
441+
/**
442+
* Publish method to emit analytics events to [Web Pixels](https://shopify.dev/docs/apps/marketing).
443+
*/
444+
publish(name: string, data: Record<string, unknown>): Promise<boolean>;
445+
446+
/**
447+
* A method for capturing details about a visitor on the online store.
448+
*/
449+
visitor(data: {email?: string; phone?: string}): Promise<VisitorResult>;
450+
}
451+
/**
452+
* Represents a visitor result.
453+
*/
454+
export type VisitorResult = VisitorSuccess | VisitorError;
455+
456+
/**
457+
* Represents a successful visitor result.
458+
*/
459+
export interface VisitorSuccess {
460+
/**
461+
* Indicates that the visitor information was validated and submitted.
462+
*/
463+
type: 'success';
464+
}
465+
466+
/**
467+
* Represents an unsuccessful visitor result.
468+
*/
469+
export interface VisitorError {
470+
/**
471+
* Indicates that the visitor information is invalid and wasn't submitted.
472+
* Examples are using the wrong data type or missing a required property.
473+
*/
474+
type: 'error';
475+
476+
/**
477+
* A message that explains the error. This message is useful for debugging.
478+
* It's **not** localized, and therefore should not be presented directly
479+
* to the buyer.
480+
*/
481+
message: string;
482+
}
483+
440484
export interface AllowedProcessing {
441485
/**
442486
* 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)