Skip to content

Latest commit

 

History

History
95 lines (76 loc) · 5.45 KB

PROMO.md

File metadata and controls

95 lines (76 loc) · 5.45 KB

Local Vault-Promo-Services Setup

Creators uses promo services to create promo codes for our referral program.

Some usages:

  • Attach codes to new channels for top referrers
    • This is done manually in the console whenever upon request
    • Via Promo::RegisterChannelForPromoJob
  • The referrers can see the stats via the dashboard and nightly emails
    • The admin side also will display the stats for referral codes for referrers
    • See Promo::EmailBreakdownsService where we hit a stats/promo services ReferralDownload redshift table
  • Marketing can create unattached marketing codes for marketing drives
    • Marketing uses pretty much all of the unattached promo registrations admin dashboard
  • Stats will call these endpoints for promo data
    • /api/v1/stats/publishers/totals
    • /api/v1/public/channels/totals

As far as the code base, here are the usages classified:

  • To get a promo code to attach to a channel. See Promo::RegisterChannelForPromoJob
    • Here we call the service with the base URL defined here which leads ultimately to the controller in promo-services here.
    • Calls /api/1/promo/publishers
  • https://publishers.basicattentiontoken.org/admin/unattached_promo_registrations
    • Used by Marketing to manage marketing codes and update their status
  • ChannelOwnerUpdater
    • Called twice in the codebase, for when we delete a user or when a channel changes ownership
    • Calls /api/1/promo/publishers/#{@referral_code}
  • PeerToPeer
    • No longer used. Ice it.
    • Calls "api/2/promo/referral_code/p2p/{id}?cap={cap}"
  • reporting.rb
  • owner_registrar.rb
    • We used to attach codes to creators, but not anymore. We just attach them to channels now. You can see the original PR when this was added that we call this service to attach the code to the creator. Now it's not used. That same controller these days attaches them to the channels.
    • Calls /api/2/promo/referral_code/unattached?number=#{@number}"
  • registration_getter.rb
    • Used in switching promo codes to a different channel
    • Calls "/api/2/promo/referral_code/channel/#{@channel.channel_id}?#{cap_params}"
  • registration_installer_type_setter.rb
  • registration_stats_fetcher.rb
    • Exactly what is sounds like, we fetch the stats every morning to display to the user (for channels)
    • Calls "/api/2/promo/statsByReferralCode#{query_string}"
  • unattached_registrar.rb
    • The class that creates the unattached codes in the referral service for marketing
    • Calls "/api/2/promo/referral_code/unattached?number=#{@number}"
  • unattached_registration_status_updater.rb
    • Updates status of unattached codes
    • Calls "/api/2/promo/referral#{query_string}"

Read below if you wish to get promo services running locally.

Note: This documentation has not been reviewed for some time and may be incomplete/innaccurate.

  1. Request access to Vault-Promo-Services and ip2tags
  2. Follow the setup instructions
  3. Create and run a vault-promo-services.sh start script like this
export DATABASE_URL="services"
export PGDATABASE="services"
export AUTH_TOKEN=1234
export S3_KEY="X"
export S3_SECRET="x"
export WINIA32_DOWNLOAD_KEY="/"
export WINX64_DOWNLOAD_KEY="/"
export OSX_DOWNLOAD_KEY="/"
export TEST=1

dropdb services
createdb services
for folder in ./migrations/*; do
  psql services < ${folder}/up.sql
done
npm start
  • If you run into an issue about a missing .mmdb file, run fetch.sh in node_modules/ip2tags
  1. Add the following into your Publishers start script
export API_PROMO_BASE_URI="http://127.0.0.1:8194"
export API_PROMO_KEY="1234"