NEARFoundation / stats.gallery

Big & fun NEAR account analytics!
https://stats.gallery
GNU General Public License v3.0
33 stars 18 forks source link

Message templates for Pingbox integration #41

Open encody opened 2 years ago

encody commented 2 years ago

@trevorjtclarke

There are two possible messages that stats.gallery could send to users right now:

  1. Earned a badge
  2. Advanced to a new level

Earned a badge

Badge acquisition status is determined by the return value of an SQL query to a PostgreSQL indexer server, for example:

select count(*) as result
where exists(
  select *
  from action_receipt_actions
  where action_kind = 'DEPLOY_CONTRACT'
    and receipt_predecessor_account_id = 'hatchet.near'
)

Queries will return 0 when a badge is not acquired, and >0 when a badge is acquired. If the badge is a boolean badge (such as the one above), it will return 1 when the badge is awarded. Some badges have multiple levels (example), so instead of the badge being awarded at any return value >0, there are some predetermined levels, which are established here on the frontend.

Badge queries are stored in badge-*.sql.js files here.

Messaging

Congratulations, you've earned the <badge-name> badge on stats.gallery!

TODO: I can ask a designer to work on messaging and email design/template if desired.

Advanced to a new level

Levels are awarded based on an exponentially increasing score requirement. A user's score is calculated by awarding certain types of on-chain actions with different point values. Levels names are determined here (lvl 10+ is "Nearkat").

Messaging

You've advanced to level <#> and won the title <level-name> on stats.gallery! Look at you go!