Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for fetching, translating and inserting variables into templates #172

Merged
merged 8 commits into from
Oct 2, 2024

Conversation

michaelfarrell76
Copy link
Member

@michaelfarrell76 michaelfarrell76 commented Aug 7, 2024

Related Issues

This pull request implements the following APIs:

/**
 * Input for fetching a policy from Transcend and inserting template variables
 */
export type GetTranscendPolicies = {
  /** The language to fetch policy for - defaults to currently selected language key */
  locale?: LanguageKey;
  /** Template variables to dynamically inject into the policy */
  variables?: ObjByString;
  /**
   * The UUID of the policies defined in Transcend to fetch
   *
   * This can be pulled from the URL
   * @see https://app.transcend.io/privacy-center/policies
   */
  policyIds?: string[];
  /**
   * The titles of the policies defined in Transcend to fetch
   *
   * This can be pulled from the URL
   * @see https://app.transcend.io/privacy-center/policies
   */
  policyTitles?: string[];
};

/**
 * The returning Transcend policy
 */
export type TranscendPolicy = {
  /** The policy UUID */
  id: string;
  /** The policy title */
  title: string;
  /** The policy content */
  content: string;
};

type ConsentManageApi = { 
  ...
  /** Get the current active language */
  getTranscendPolicies: (
    input?: GetTranscendPolicies,
  ) => Promise<TranscendPolicy[]>;
  /** Callback that sets any dynamic variables that should be exposed to the consent UI messages */
  setTranscendUiVariables: (variables: ObjByString) => Promise<void>;
  /** Get the current value of Transcend UI variables */
  getTranscendUiVariables: () => ObjByString;
    /** Get the currently active locale */
  getActiveLocale: () => ConsentManagerLanguageKey;
}

This adds the usage of "global variables" that can be templated into any of the messages that are shown in a consent banner. Policies can also be fetched from the Transcend privacy center CDN and inserted into the dom.

Copy link

vercel bot commented Aug 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
consent-manager-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 2, 2024 3:53am

@michaelfarrell76 michaelfarrell76 changed the title [WIP] API for fetching, translating and inserting variables into templates API for fetching, translating and inserting variables into templates Oct 2, 2024
@michaelfarrell76 michaelfarrell76 requested review from banzzai, shaunlichti and a team October 2, 2024 03:41
@michaelfarrell76 michaelfarrell76 merged commit ec7d8dd into main Oct 2, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants