npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vcs-cdk

v1.5.0

Published

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

Downloads

10

Readme

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