Show the invite in the lobby before they log off
A player has just finished their third match of the session and has not entered the event that opened this week. The invite goes out on a schedule, as a push or an email, and it tends to reach them after they have logged off for the night. The lobby they are about to see is the better place for it, with the event one tap away and the player still in the mood for another match.
matches_session- Matches they have finished this session
event_entries- Times they have entered the event since it opened
Shows the event invite on the lobby screen when a player has finished a match this session and has no entry to the event, and tells your messaging tool the invite was shown so the scheduled push skips them.
from datetime import timedelta
from snowplow_signals import Attribute, Event, StreamAttributeGroup, user_id
match_ended = Event(name="match_ended", vendor="com.example", version="1-0-0")
event_entered = Event(name="event_entered", vendor="com.example", version="1-0-0")
# Keyed on the player, so a rolling two hours stands in for the session.
matches_session = Attribute(
name="matches_session",
type="int32",
events=[match_ended],
aggregation="counter",
period=timedelta(hours=2),
default_value=0,
)
# The event runs for two weeks, so the window is the event window.
event_entries = Attribute(
name="event_entries",
type="int32",
events=[event_entered],
aggregation="counter",
period=timedelta(days=14),
default_value=0,
)
game_events_lobby = StreamAttributeGroup(
name="game_events_lobby",
version=1,
attribute_key=user_id,
owner="you@example.com",
attributes=[matches_session, event_entries],
)// In the server code that builds the lobby after a match
const player = await signals.getServiceAttributes({
name: "game_events_lobby",
attribute_key: "user_id",
identifier: playerId,
});
// { matches_session: 3, event_entries: 0 }
if (player.matches_session >= 1 && player.event_entries === 0) {
lobby.show({ card: "event_invite", event: "spring_cup" });
messaging.suppress({ campaign: "event_invite_push", playerId });
}