Offer the bonus to the player who keeps opening the cashier
A player has opened the cashier twice this session and closed it both times without depositing. The bonus was set before the session for a whole segment, so it either showed on the first open, before this player had hesitated, or it waits for tomorrow's campaign. The second close is the moment a bonus would change the answer, and the player is still in the session.
cashier_opens_1h- Times the cashier was opened in the last hour
deposits_1h- Deposits completed in the last hour
deposits_30d- Deposits completed in the last 30 days
Shows the deposit bonus your rules allow for this player once the cashier has been opened twice this session without a deposit, and keeps the standard cashier for a player who has opened it once.
from datetime import timedelta
from snowplow_signals import Attribute, Event, StreamAttributeGroup, user_id
cashier_opened = Event(name="cashier_opened", vendor="com.example", version="1-0-0")
deposit = Event(name="deposit", vendor="com.example", version="1-0-0")
# Keyed on the player, so a one-hour window stands in for the session.
cashier_opens_1h = Attribute(
name="cashier_opens_1h",
type="int32",
events=[cashier_opened],
aggregation="counter",
period=timedelta(hours=1),
default_value=0,
)
deposits_1h = Attribute(
name="deposits_1h",
type="int32",
events=[deposit],
aggregation="counter",
period=timedelta(hours=1),
default_value=0,
)
deposits_30d = Attribute(
name="deposits_30d",
type="int32",
events=[deposit],
aggregation="counter",
period=timedelta(days=30),
default_value=0,
)
game_cashier_hesitation = StreamAttributeGroup(
name="game_cashier_hesitation",
version=1,
attribute_key=user_id,
owner="you@example.com",
attributes=[cashier_opens_1h, deposits_1h, deposits_30d],
)// In the code that renders the cashier
const player = await signals.getServiceAttributes({
name: "game_cashier_hesitation",
attribute_key: "user_id",
identifier: playerId,
});
// { cashier_opens_1h: 2, deposits_1h: 0, deposits_30d: 1 }
if (player.cashier_opens_1h >= 2 && player.deposits_1h === 0) {
cashier.show({
bonus: bonusRules.offerFor(playerId),
headline: "Add to your next deposit",
});
}