/
[Solution] Admin tool - Add Customer Tier Information

[Solution] Admin tool - Add Customer Tier Information

 

Document Status

Reviewed

Document Owner(s)

@Goncalves, Felipe

Reviewers

@Raphael Ferreira Gomes
@Ruani, Andrea
@Garozzo de Sobral, Wellington
@Franca, Helio
@Augusto Romao, Vinicius
@Caes, Guilherme

Potential Solutions

Note: this section should be short and sweet, documenting notes about different solutions that were considered during ideation. Can just be a link to a whiteboard for example. Expected outcome: one solution is chosen and documented in more detail under Proposed Solution.

The best solution is to present the tier data directly to the admin-app user. This information is already available in the Loyalty repository, and the admin-app can access it. With this approach, we aim to display the tier-related data for the customer, enabling the support user to respond to some inquiries promptly and efficiently.

Proposed Solution

Description of the proposed solution.

In this solution, we plan to create a new query in the Loyalty provider. With this single new query, we will retrieve tier information related to both the Customer and the Market. With this data, we will be able to display more details about the customer current level and points, along with market information that includes the period and the number of points required for the user to level up or maintain a higher level.

Figma file

https://www.figma.com/design/Ti8Qr6jeSEPaencIDyYfcJ/branch/BWG0jdWLD56nLea7jNklPq/Burger-King?node-id=3292-6851&t=dFfOhVKnNLluzx2k-0

Development

Add Feature Flag

Create an FF enable-customer-tier, this flag will be temporary.

In Sanity, there is already a flag to enable the Loyalty Tier, but this flag controls this feature in the WL-App. Therefore, for safety reasons, we will use the Sanity flag in conjunction with the LaunchDarkly flag. This way, if any issues arise in the Admin-app, we can disable only the LD flag without impacting Sanity and the WL-App.

Backend:

Customer Tier and Market Tier

We will need tier information on the customer screen, including details about the User Tier and the Market Tier. To address this, we will create a new function in the Loyalty Provider that will retrieve both pieces of information, allowing us to utilize them in any screen.

We can see it in this diagram bellow.

  • File: services/graphql/src/providers/intl-loyalty.ts

  • Create a new function to get this information about the Loyalty Tier:

    • enableLoyaltyTiers: It is the flag on the Sanity to enable the Loyalty tier in the market

    • customerTier: It is the information about the customer tier, like tier level and points in the current tier.

    • configurationTier: It is the information about the market tier, like the maximum period and the target points to maintain or elevate the user tier

  • New Function name getLoyaltyTierConfiguration

  • Create a new type to return this information with the name CustomerLoyaltyTierConfig

    • export type CustomerLoyaltyTierConfig = { enableLoyaltyTiers?: boolean; customerTier?: MdwEngineILoyaltyTier; configurationTier?: MdwEngineILoyaltyTiersEntranceBehaviorConfiguration; };
  • You will need to use in this new function the functions loyaltyApi.getUser to get the data about user and loyaltyApi.getConfiguration to get the data about the market tier

    • public async getLoyaltyTierConfiguration( loyaltyId: string, region?: string, ): Promise<CustomerLoyaltyTierConfig> { try { const header = region ? { headers: { 'x-region': region } } : {}; const { data: userLoyalty } = await this.loyaltyApi.getUser(loyaltyId, header); const { data: engineSettings } = await this.loyaltyApi.getConfiguration(); const result: CustomerLoyaltyTierConfig = { configurationTier: engineSettings.loyaltyTiersEntranceBehaviorConfigurations?.[0], customerTier: userLoyalty.loyaltyTier, enableLoyaltyTiers: engineSettings.enableLoyaltyTiers, }; return result; } catch (err) { this.logger.error( { err, }, 'Error occurred when get loyalty tier configuration', ); throw new GenericINTLLoyaltyError(`Failed to fetch the loyalty tier configuration`); } }
  • File: services/graphql/src/schemas/intl-loyalty.ts

  • First create a schema and types of tier information

  • Create 3 types, one to customer information, one to market information and one to join the data

    • type INTLCustomerLoyaltyTierConfig { enableLoyaltyTiers: Boolean customerTier: INTLCustomerTier configurationTier: INTLLoyaltyTierConfiguration } type INTLCustomerTier { loyaltyTierExpiryDate: String loyaltyTierKey: String pointsEarnedInTimeConstraint: Int startAt: String } type INTLLoyaltyTierConfiguration { loyaltyTierKey: String pointsNeeded: Int pointsToEnterCalculationTimeUnit: String pointsToEnterCalculationTimeInterval: Int pointsNeededToMaintain: Int pointsToMaintainCalculationTimeUnit: String pointsToMaintainCalculationTimeInterval: Int }
  • Add the function on query of schemas as well

  • Run yarn build this command runs the types of GraphQL and build the app.

  • After this, check if this created the new types and query on file graphql.ts

  • File: services/graphql/src/schemas/intl-loyalty.ts

  • The function name need to be the same of the schema intlCustomerLoyaltyTierConfig

  • In this new function get the provider getLoyaltyTierConfiguration

  • This function need to pass a loyaltyId on attributes.

  • Create a new auditLogger to our function GET_INTL_LOYALTY_TIER_CONFIGURATION_BY_LOYALTY_ID

  • File: new file on src/remote/queries

  • File name: intl-loyalty-tier-configuration.ts

  • In this query we need only some information.

    • enableLoyaltyTiers: It is the flag on the Sanity to enable the Loyalty tier in the market;

    • customerTier.loyaltyTierExpiryDate: It is the expiration date of the user tier;

    • customerTier.loyaltyTierKey: It is the user level tier;

    • customerTier.pointsEarnedInTimeConstraint: It is the user points earned (to upgrade or maintain) in this period and tier;

    • customerTier.startAt: It is the user tier period start date

    • configurationTier.loyaltyTierKey: It is the Market level of market

    • configurationTier.pointsNeeded: It is the necessary points to pass to next level

    • configurationTier.pointsNeededToMaintain: It is the necessary point to maintain the level 2 (Super Tier)

 

Frontend

Common Functions

  • Local to create a file: src/utils create a new folder to Loyalty Tier

  • The code sent a Tier level as a key Tier_1 or Tier_2

    • BK:

      • Tier_1 => King

      • Tier_2 => SuperKing

    • PLK and FHS:

      • Tier_1 => Normal

      • Tier_2 => Super

Screen Customer

image-20250116-190722.png

 

POC

https://github.com/rbilabs/intl-admin-app/pull/824

Acceptance Criteria

1 - Display Tier Information on Customer Screen

image-20250120-115020.png
Loyalty Panel Component
  • Given that the user accesses the Customer screens,

  • When the customer data is loaded,

  • Then the system should display the following information in Loyalty Panel:

    • Loyalty Points Balance

    • Current Loyalty Tier

      • This label changes if the user changes the Tier level

    • Loyalty Tier Period

    • Points earned in this Tier and how much need to change or maintain the Tier

      • This label changes if the user changes the Tier level

2 - Feature Flag

  • Given that there is new data to be displayed,

  • When the feature flag is activated,

  • Then the new data should be displayed in the user interface.

  • And when the feature flag is deactivated, the new data should be hidden.

    • PS: This flag is temporary

3 - Tier Market

  • Given some brand has the loyalty tier enable in Sanity,

  • Then we need to display the informations on Admin-app.

Potential Challenges

Cost

Configuration

LaunchDarkly

Create a new Feature Flag called enable-customer-tier on LD Intl Tech - Platform, this flag is temporary, and we will create a technical debt to remove this flag.

How configure the Customer Tier

To configure a customer tier in a market, we can follow this document.
To understand the architecture is this document.

Metrics

This metric can be obtained through the number of tickets opened for the support team, particularly considering the duration of the tickets and whether a resolution was achieved on the first contact. And we can reach out to the agent support stakeholders and gather their feedback. The goal of this requirement is to streamline access to the customer's tier information, enabling the support user to resolve tickets more efficiently.

Delivery Plan

The delivery will be separate in two parts:

  1. Tier information on Customer Screen.

  2. Tier information on Loyalty Transaction Screen, this screen we can see the Tier Point in each order. [Solution] Summary & historical data from Customer Tier in Loyalty Transaction

QA Plan

Test Scenario

Expected Result

Test Scenario

Expected Result

if FF enable-customer-tier is disabled or enableLoyaltyTiers Flag Sanity is disabled

No Tier Information is showed

if FF enable-customer-tier is enabled AND enableLoyaltyTiers Flag Sanity is enabled

Show Tier information and Balance points

If the user is Tier_1 (Normal Tier)

Show first level information label, icon, period and destination points

If the user is Tier_2 (Super Tier)

Show second level information label, icon, period and destination points

If the user moves from level 1 to level 2

Show second level information label, icon, period and destination points

If the user moves from level 2 to level 1

Show first level information label, icon, period and destination points

If the deadline expires, or the level changes

Level points need to change to 0

Call-outs

All information related to the Tier, both for users and the market, is sourced from the loyalty system. Thus, all calculations, date periods, and levels originate from this system, and in the admin app, these data will only be displayed, without any calculations or alterations to the values. If any value is being returned incorrectly, the issue should be addressed in the loyalty repository with the loyalty team.

Related content

[Solution] Summary & historical data from Customer Tier in Loyalty Transaction
[Solution] Summary & historical data from Customer Tier in Loyalty Transaction
More like this
[Opportunity] Admin tool - Add Customer Tier Information
[Opportunity] Admin tool - Add Customer Tier Information
More like this
[Solution] Admin tool - loyalty balance information
[Solution] Admin tool - loyalty balance information
More like this
[Solution] Ability to audit per store available and unavailable products (DOP)
[Solution] Ability to audit per store available and unavailable products (DOP)
Read with this
[Business Requirements] Admin tool - Add Customer Tier Information
[Business Requirements] Admin tool - Add Customer Tier Information
More like this
[Solution] Complete your menu (WIP)
[Solution] Complete your menu (WIP)
Read with this