version: 2

models:
  - name: int_subscription_span
    description: Consolidates subscription periods into continuous spans, grouping periods that are within 15 minutes of each other.
    config:
      group: subscriptions
      tags: ["cadence=daily", "dbt"]
    columns:
      - name: user_id
        description: Unique identifier for the user
      - name: first_subscription_ts
        description: Timestamp of when the subscription span started
      - name: last_active_ts
        description: Timestamp of when the subscription span ends. Can be in the future, especially for annual plans.
      - name: last_period_canceled_at_ts
        description: Timestamp of when the last subscription in this span was canceled (if any)
      - name: months_active
        description: Number of months between first subscription ts and last active ts
      - name: subscribed_on_platform
        description: Platform where the subscription was purchased
      - name: initial_subscription_plan_id
        description: The subscription plan at the start of the span
      - name: final_subscription_plan_id
        description: The subscription plan at the end of the span
      - name: initial_renewal_interval
        description: The renewal interval (in days) at the start of the span
      - name: final_renewal_interval
        description: The renewal interval (in days) at the end of the span
      - name: count_separate_subscriptions
        description: The number of separate subscription purchases within this continuous span
      - name: is_user_first_subscription_span
        description: Boolean indicating if this is the user's first subscription span ever
  - name: int_subscription_history_summary
    description: Summary of a user's historical subscription activity.
    config:
      group: subscriptions
      tags: ["cadence=daily", "dbt"]
    columns:
      - name: user_id
        description: Unique identifier for the user
      - name: user_uid
        description: Unique identifier for the user
      - name: first_subscription_start_ts
        description: Timestamp of when the user's first subscription started
      - name: last_subscription_end_ts
        description: Timestamp of when the user's last subscription ended
      - name: first_subscription_platform
        description: Platform where the user's first subscription was purchased
      - name: first_subscription_billing_provider
        description: Billing provider for the user's first subscription
      - name: first_subscription_tier
        description: Tier of the user's first subscription
      - name: first_subscription_renewal_interval
        description: Renewal interval (in days) for the user's first subscription
      - name: last_subscription_platform
        description: Platform where the user's last subscription was purchased
      - name: last_subscription_billing_provider
        description: Billing provider for the user's last subscription
      - name: last_subscription_tier
        description: Tier of the user's last subscription
      - name: last_subscription_renewal_interval
        description: Renewal interval (in days) for the user's last subscription
      - name: total_subscription_days
        description: Total number of days the user was subscribed
      - name: total_subscription_days_pro
        description: Total number of days the user was subscribed to a Pro plan
      - name: total_subscription_days_premier
        description: Total number of days the user was subscribed to a Premier plan
      - name: n_distinct_subscriptions
        description: The number of distinct subscription purchases by this user (not periods, but new subscriptions)
      - name: has_had_annual_subscription
        description: Boolean indicating if the user has had an annual subscription
