Backend
Player offers and marketing opt-outs
A Java gRPC service for Rocket that tracks which offers CubeCraft players see, when each can show again, and the marketing they've opted out of.
The problem
CubeCraft prompts players with offers. Without one place keeping track, nothing stopped the same player seeing the same prompt over and over, and there was no single place to honor someone saying “don’t send me this kind of thing.”
What I built
- A Java service on gRPC that tracks the offers each player has been prompted with, and when each one can next be shown
- A record of the events around each offer, so the team can see how players respond
- Marketing opt-outs per category, so a player can turn off one kind of message without losing the rest
- The whole thing exposed through Rocket’s GraphQL edge, so the game and the web use the same rules
- Game or webwants to show offer X
- GraphQL edgeasks the offers service
- Opted out?by category
- Cooldown passed?next-show time
- Show itrecord the event and the next time
Deciding whether to show an offer
fn can_show(player, offer) -> bool:
if opt_outs.contains(player, offer.category):
return false
last = prompts.last(player, offer.id)
if last != null and now() < last.next_eligible_at:
return false
return true
fn record_prompt(player, offer):
prompts.save(player, offer.id,
shown_at = now(),
next_eligible_at = now() + offer.cooldown)
events.emit("offer.prompted", player, offer.id)
Why it matters
Respecting a player’s choices shouldn’t depend on every feature remembering to check. With it in one service, the check happens the same way for everyone who asks.