Offer the small bundle of what the player just ran out of
A player has run out of gems two rooms from the end of a level, and the store opens on the standard bundle because that is what was configured before the session began. The bundle is sized for a planned purchase. What this player wants is enough gems to finish the room they are standing in, and by the time the catalog is retuned the level is over. The small gem bundle, offered where they ran out, is the purchase that fits.
last_currency_depleted- The premium currency they most recently ran out of
depleted_at- The level they were in when it ran out
minutes_since_depleted- Minutes since it happened
Opens the store on the small bundle of the currency that just ran out, placed at the point in the level where it happened, when the depletion is a few minutes old. Which bundle counts as small, and its price, come from your monetization team's rules.
from snowplow_signals import Attribute, Event, EventProperty, StreamAttributeGroup, user_id
currency_depleted = Event(name="currency_depleted", vendor="com.example", version="1-0-0")
last_currency_depleted = Attribute(
name="last_currency_depleted",
type="string",
events=[currency_depleted],
aggregation="last",
property=EventProperty(vendor="com.example", name="currency_depleted", major_version=1, path="currency"),
)
depleted_at = Attribute(
name="depleted_at",
type="string",
events=[currency_depleted],
aggregation="last",
property=EventProperty(vendor="com.example", name="currency_depleted", major_version=1, path="level_id"),
)
minutes_since_depleted = Attribute(
name="minutes_since_depleted",
type="double",
events=[currency_depleted],
aggregation="time_since_last",
time_unit="min",
)
# Players are signed in, so the game server asks by player id.
game_store_depleted = StreamAttributeGroup(
name="game_store_depleted",
version=1,
attribute_key=user_id,
owner="you@example.com",
attributes=[last_currency_depleted, depleted_at, minutes_since_depleted],
)// In the game server, when the client asks for the store
const player = await signals.getServiceAttributes({
name: "game_store_depleted",
attribute_key: "user_id",
identifier: playerId,
});
// { last_currency_depleted: "gems", depleted_at: "w3_l7", minutes_since_depleted: 1.4 }
if (player.minutes_since_depleted < 10) {
store.open({
lead: bundles.small(player.last_currency_depleted),
placement: { level: player.depleted_at },
});
}