1.5.0 • Published 4 years ago

vcs-cdk v1.5.0

Weekly downloads
5
License
-
Repository
-
Last release
4 years ago

VOUCHER SYSTEM (VCS)

VCS is a distributed system for Voucher generation, validation and rewards payout.

A Voucher grants a player one or mores rewards (game resources or currencies), as long as the player profile matches the conditions of the voucher configuration.

Marketing campaigns can include vouchers to be created and used within a specific game or cross-promotion vouchers which are generated within a game and redeemed from a different game.

Architecture

Diagram architecture diagram

Main components:

CDK - AWS Stack definition

RestAPI

  • Lamdba to retrieve feature flags & enter-code dialog URL
  • Lambda to generate single-use cross-promo vouchers
  • Lambda for voucher validation

UI insert Voucher Code

Dialog opened by games ( Iframe or WebView )

Backend

Dynamo DB to store voucher configuration, voucher usages and SQS queue to handle payouts

Voucher Admin

UI to manage the configuration of vouchers (see vouchers-admin repo )

Deployment and Development

Currently there are 3 stage / environment / stacks defined:

  • dev
  • staging
  • production

To deploy each stack run (both validation backend and validation-dialogs)

npm run deploy -- vcs-YOUR_STAGE

###Specific Commands to build only parts of the Stack

commands to build stack

  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template

Conditions of Voucher Configuration

Voucher validation happens through a set of conditions defined in the VCS Admin and saved to DynamoTable These conditions are compiled into a set of rules which are applied with JSON logic

to know more check

Cache Invalidation

RestAPI is served via Cloudfront. Cloudfront does not cache POST methods ( but it caches OPTIONS, so run an invalidation if CORS is modified) GET methods are currently being cached ( configuration in stack definition) Whenever we edit the FeatureFlag Lambda (either it's code, or it's configuration like GAME_ID) we need to create a Cache Invalidation

If you are activating or deactivating the voucher feature flag for a specific game remember to RUN the invalidation

To trigger a cache invalidation for the feature flag, run

npm run invalidateFeatureFlags -- YOUR_STAGE

that is a shorthand for invoking a js file with predifined path "invalidateFeatureFlags": "node shared/invalidate.js /vouchers-flag/38 ( currently it just invalidates BFMH update script or remove defaults when more games are activated)

if you want to customize the invalidation and pass multiple paths just separate them with ,

node shared/invalidate.js /vouchers-flag/38,/vouchers-flag/12, YOUR_STAGE

or to invalidate the entire featureflags

node shared/invalidate.js "/vouchers-flag/*", YOUR_STAGE

See UI documentation for specific cache invalidation of Dialogs and Translations

Cross Promo Vouchers / Autogenerated codes (Validation workflow)

After a code has been generated from the SourceGame ( via /generate API) and player of TargetGame has validated it ( via /validate ) this are the logical steps taken by the validation logic.

Voucher code is decoded to extract RootCode and GNIP ie bfstory-qwerty-123456 becomes bfstory and gameId 51 networkId 1 instanceId 255 playerId 123456

  • Voucher configuration is loaded from Admin Tool
  • GNIP of player that generated code is validated with Hydra
  • GNIP of player using the voucher is validated with Hydra
  • Voucher conditions are run against Target Player profile
  • Root code and GNIP of TargetPlayer are saved to DB
  • Generated code and GNIP of SourcePlayer are saved to DB Usage of rootCode voucher is saved
  • On both DB record information about the referring code and player are stored to match and crossreference usages ( and to prevent multiple usages)

The same player of BigFarmClassic cannot use more than one autogenerated code from Story for the same campaignId The same player of BigFarmStory can generate only one code for the same campaignId. The same generated code by a specific Story player cannot be used by more than one player in BigFarm Classic

QA Test Cases

QA test cases for validation has been moved to the Vouchers Admin tool repo, since it is stricly related with the creation of the vouchers and vouchers conditions