Skip to content

Commit

Permalink
adds tracking consent metafields
Browse files Browse the repository at this point in the history
  • Loading branch information
rcaplanshopify committed May 21, 2024
1 parent 7f560c0 commit 106e015
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/ui-extensions/src/surfaces/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export type {
ApplyTrackingConsentChangeType,
CustomerPrivacy,
TrackingConsentChangeResult,
TrackingConsentChangeResultError,
TrackingConsentMetafield,
TrackingConsentMetafieldChange,
VisitorConsent,
VisitorConsentChange,
VisitorError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ export interface StandardApi<Target extends ExtensionTarget = ExtensionTarget> {
customerPrivacy: StatefulRemoteSubscribable<CustomerPrivacy>;

/**
* Allows setting and updating customer privacy consent settings.
* Allows setting and updating customer privacy consent settings and tracking consent metafields.
*
* > Note: Requires the [`customer_privacy` capability](https://shopify.dev/docs/api/checkout-ui-extensions/unstable/configuration#collect-buyer-consent) to be set to `true`.
*
Expand Down Expand Up @@ -1776,7 +1776,43 @@ export interface VisitorConsent {
saleOfData?: boolean;
}

export interface TrackingConsentMetafield {
/**
* The name of the metafield. It must be between 3 and 30 characters in
* length (inclusive).
*/
key: string;
/**
* The information to be stored as metadata.
*
* @example 'any string', '', or a stringified JSON object
*/
value: string;
}

export interface TrackingConsentMetafieldChange {
/**
* The name of the metafield. It must be between 3 and 30 characters in
* length (inclusive).
*/
key: string;
/**
* The information to be stored as metadata. If the value is `null`, the metafield will be deleted.
*
* @example 'any string', `null`, or a stringified JSON object
*/
value: string | null;
}

export interface VisitorConsentChange extends VisitorConsent {
/**
* Tracking consent metafield data to be saved.
*
* If the value is `null`, the metafield will be deleted.
*
* @example `[{key: 'granularAnalytics', value: 'true'}, {key: 'granularMarketing', value: 'false'}]`
*/
metafields?: TrackingConsentMetafieldChange[];
type: 'changeVisitorConsent';
}

Expand Down Expand Up @@ -1810,6 +1846,15 @@ export interface CustomerPrivacy {
* An object containing flags for each consent property denoting whether they can be processed based on visitor consent, merchant configuration, and user location.
*/
allowedProcessing: AllowedProcessing;
/**
* Stored tracking consent metafield data.
*
* @example `[{key: 'analyticsType', value: 'granular'}, {key: 'marketingType', value: 'granular'}]`, or `[]`
*/
metafields: TrackingConsentMetafield[];
/**
* An object containing the customer's current privacy consent settings.
* *
* @example `true` — the customer has actively granted consent, `false` — the customer has actively denied consent, or `undefined` — the customer has not yet made a decision.
*/
visitorConsent: VisitorConsent;
Expand Down

0 comments on commit 106e015

Please sign in to comment.