Deployments are triggered when a series of conditions are all met. These conditions are written in Javascript in the dashboard.
In the dashboard, you may have the conditions:
// the deployment can only be triggered up to 5 times per sessionsession.deployments["deployment_id"].views < 5
// the deployment can only be triggered up to 20 in the users lifetimeuser.deployments["deployment_id"].views < 20
// the deployment is triggered every other time the event is triggered in the sessionsession.events.event_id.count % 2 === 1
Only when all three of these conditions are met at the same time will the deployment be triggered. The user must have triggered the event 1, 3, 5, 7 etc.. times and cannot have seen the deployment more than 5 times in a given session and 20 times over their life.
Most deployments will have either a session view cap and a lifetime view cap. Otherwise it will show on page load every single time.
Data in the session object is retained only for the duration of the session.
// represents the session of the user that is detroyed when the user closes the websiteexport type session = { events: { [event_id: string]: { // how many times the event has been triggered in the session count: number; }; }; deployments: { [deployment_id: string]: { // how many times the deployment has been viewed in the session views: number; }; }; // when querying against session.duration, always use > or < because its unlikely to be equal to the duration. duration: number; // seconds};
Data in the user object is retained over the lifetime of the user.
// properties in the user object are retained over the lifetime of the user.export type user = { events: { [eventId: string]: { // counts in the user's lifetime count: number; }; }; deployments: { [event_id: string]: { // how many times the deployment has been triggered in the user's lifetime views: number; lastViewed: Date; }; }; sessions: { // how many sessions over the users lifetime count: number; };};