asyncapi: 3.0.0
info:
  title: Business Objects - Analytics Events
  version: 0.0.1
  description: |
    This AsyncAPI document describes analytics and tracking events related to the Business Objects application.
    These events are primarily used for lifecycle tracking and product usage analysis within the d.velop Analytics
    Platform.
  contact:
    name: Team-PPD-Business-Objects
    email: team-businessobjects@d-velop.de

servers:
  dap_cdp:
    host: cdp.prod.dap.d-velop.cloud
    protocol: https
    description: Server endpoint for publishing analytics events to the d.velop Analytics Platform (DAP)

channels:
  analytics:
    description: Channel used for emitting analytics events, such as application subscription updates
    messages:
      AppSubscribed: 
          $ref: '#/components/messages/AppSubscribed'
      AppResubscribed:
          $ref: '#/components/messages/AppResubscribed'
      AppUnsubscribed:
          $ref: '#/components/messages/AppUnsubscribed'
      AppPurgeReceived:
          $ref: '#/components/messages/AppPurgeReceived'
      TenantComputedTierChanged:
          $ref: '#/components/messages/TenantComputedTierChanged'
      DatabaseStatisticsBuilt:
          $ref: '#/components/messages/DatabaseStatisticsBuilt'
      EntitySetStatisticsBuilt:
          $ref: '#/components/messages/EntitySetStatisticsBuilt'
      TenantDatabaseStatisticsBuilt:
          $ref: '#/components/messages/TenantDatabaseStatisticsBuilt'
    servers:
      - $ref: '#/servers/dap_cdp'

operations:
  sendAppSubscribed:
    action: send
    channel:
      $ref: '#/channels/analytics'
    messages:
      - $ref: '#/channels/analytics/messages/AppSubscribed'
    description: |
      Publishes an `AppSubscribed` event to the analytics channel, indicating that a tenant has subscribed to Business
      Objects
  sendAppResubscribed:
    action: send
    channel:
      $ref: '#/channels/analytics'
    messages:
      - $ref: '#/channels/analytics/messages/AppResubscribed'
    description: |
      Publishes an `AppResubscribed` event to the analytics channel, indicating that a tenant has re-subscribed to
      Business Objects
  sendAppUnsubscribed:
    action: send
    channel:
      $ref: '#/channels/analytics'
    messages:
      - $ref: '#/channels/analytics/messages/AppUnsubscribed'
    description: |
      Publishes an `AppUnsubscribed` event to the analytics channel, indicating that a tenant has unsubscribed from
      Business Objects
  sendAppPurgeReceived:
    action: send
    channel:
      $ref: '#/channels/analytics'
    messages:
      - $ref: '#/channels/analytics/messages/AppPurgeReceived'
    description: |
      Publishes an `AppPurgeReceived` event to the analytics channel, indicating that a purge request has been received.
  sendTenantComputedTierChanged:
    action: send
    channel:
      $ref: '#/channels/analytics'
    messages:
      - $ref: '#/channels/analytics/messages/TenantComputedTierChanged'
    description: |
      Publishes a `TenantComputedTierChanged` event to the analytics channel, indicating that a tenant's computed tier
      has changed.
  sendDatabaseStatisticsBuilt:
    action: send
    channel:
      $ref: '#/channels/analytics'
    messages:
      - $ref: '#/channels/analytics/messages/DatabaseStatisticsBuilt'
    description: |
      Publishes a `DatabaseStatisticsBuilt` event to the analytics channel, indicating that database statistics have
      been successfully built.
  sendEntitySetStatisticsBuilt:
    action: send
    channel:
      $ref: '#/channels/analytics'
    messages:
      - $ref: '#/channels/analytics/messages/EntitySetStatisticsBuilt'
    description: |
      Publishes an `EntitySetStatisticsBuilt` event to the analytics channel, indicating that entity set statistics
      have been successfully built.
  sendTenantDatabaseStatisticsBuilt:
    action: send
    channel:
      $ref: '#/channels/analytics'
    messages:
      - $ref: '#/channels/analytics/messages/TenantDatabaseStatisticsBuilt'
    description: |
      Publishes a `TenantDatabaseStatisticsBuilt` event to the analytics channel, indicating that tenant database
      statistics have been successfully built.

components:
  messages:
    AppSubscribed:
      name: AppSubscribed
      title: App Subscription Event
      summary: Indicates that a tenant has successfully subscribed to Business Objects
      contentType: application/json
      payload:
        $ref: '#/components/schemas/AppSubscribedPayload'
    AppResubscribed:
      name: AppResubscribed
      title: App Resubscription Event
      summary: Indicates that a tenant has re-subscribed to Business Objects
      contentType: application/json
      payload:
        $ref: '#/components/schemas/AppResubscribedPayload'
    AppUnsubscribed:
      name: AppUnsubscribed
      title: App Unsubscription Event
      summary: Indicates that a tenant has unsubscribed from Business Objects
      contentType: application/json
      payload:
        $ref: '#/components/schemas/AppUnsubscribedPayload'
    AppPurgeReceived:
      name: AppPurgeReceived
      title: App Purge Received Event
      summary: Indicates that a purge request has been received
      contentType: application/json
      payload:
        $ref: '#/components/schemas/AppPurgeReceivedPayload'
    TenantComputedTierChanged:
      name: TenantComputedTierChanged
      title: Tenant Computed Tier Changed Event
      summary: Indicates that a tenant's computed tier has changed
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TenantComputedTierChangedPayload'
    DatabaseStatisticsBuilt:
      name: DatabaseStatisticsBuilt
      title: Database Statistics Built Event
      summary: Indicates that database statistics have been successfully built
      contentType: application/json
      payload:
        $ref: '#/components/schemas/DatabaseStatisticsBuiltPayload'
    EntitySetStatisticsBuilt:
      name: EntitySetStatisticsBuilt
      title: Entity Set Statistics Built Event
      summary: Indicates that entity set statistics have been successfully built
      contentType: application/json
      payload:
        $ref: '#/components/schemas/EntitySetStatisticsBuiltPayload'
    TenantDatabaseStatisticsBuilt:
      name: TenantDatabaseStatisticsBuilt
      title: Tenant Database Statistics Built Event
      summary: Indicates that tenant database statistics have been successfully built
      contentType: application/json
      payload:
        $ref: '#/components/schemas/TenantDatabaseStatisticsBuiltPayload'
    

  schemas:
    AppSubscribedPayload:
      allOf:
        - $ref: '../../../base/base-event.yaml#/BaseEvent'
        - type: object
          title: Specific event properties
          properties:
            event:
              const: "AppSubscribed"
            properties:
              type: object
              properties: 
                tn:
                  type: string
                  description: Unique identifier of the subscribing tenant
                  example: "3b1"
                baseUri:
                  type: string
                  format: uri
                  description: Base URL of the tenant's cloud environment
                  example: "https://example.d-velop.cloud"
                received:
                  type: string
                  format: date-time
                  description: Timestamp indicating when the tenant's app subscription was received
                  example: "2025-07-08T10:31:11.311Z"
                referenceId:
                  type: string
                  description: Unique reference identifier of this event instance
                  example: "01JZAGPG76SXYC523XJAA7XNM7"
                comment:
                  type: string
                  description: Information that the event was backfilled
                  example: "backfilled"  
    AppResubscribedPayload:
      allOf:
        - $ref: '../../../base/base-event.yaml#/BaseEvent'
        - type: object
          title: Specific event properties
          properties:
            event:
              const: "AppResubscribed"
            properties:
              type: object
              properties: 
                tn:
                  type: string
                  description: Unique identifier of the re-subscribing tenant
                  example: "3b1"
                baseUri:
                  type: string
                  format: uri
                  description: Base URL of the tenant's cloud environment
                  example: "https://example.d-velop.cloud"
                received:
                  type: string
                  format: date-time
                  description: Timestamp indicating when the tenant's app re-subscription was received
                  example: "2025-07-08T10:31:11.311Z"
                referenceId:
                  type: string
                  description: Unique reference identifier of this event instance
                  example: "01JZAGPG76SXYC523XJAA7XNM7"
                comment:
                  type: string
                  description: Information that the event was backfilled
                  example: "backfilled"
    AppUnsubscribedPayload:
      allOf:
        - $ref: '../../../base/base-event.yaml#/BaseEvent'
        - type: object
          title: Specific event properties
          properties:
            event:
              const: "AppUnsubscribed"
            properties:
              type: object
              properties: 
                tn:
                  type: string
                  description: Unique identifier of the unsubscribing tenant
                  example: "3b1"
                baseUri:
                  type: string
                  format: uri
                  description: Base URL of the tenant's cloud environment
                  example: "https://example.d-velop.cloud"
                received:
                  type: string
                  format: date-time
                  description: Timestamp indicating when the tenant's app unsubscription was received
                  example: "2025-07-08T10:31:11.311Z"
                referenceId:
                  type: string
                  description: Unique reference identifier of this event instance
                  example: "01JZAGPG76SXYC523XJAA7XNM7"
                comment:
                  type: string
                  description: Information that the event was backfilled
                  example: "backfilled"
    AppPurgeReceivedPayload:
      allOf:
        - $ref: '../../../base/base-event.yaml#/BaseEvent'
        - type: object
          title: Specific event properties
          properties:
            event:
              const: "AppPurgeReceived"
            properties:
              type: object
              properties: 
                tn:
                  type: string
                  description: Unique identifier of the tenant for which the purge request was received
                  example: "3b1"
                baseUri:
                  type: string
                  format: uri
                  description: Base URL of the tenant's cloud environment
                  example: "https://example.d-velop.cloud"
                received:
                  type: string
                  format: date-time
                  description: Timestamp indicating when the purge request was received
                  example: "2025-07-08T10:31:11.311Z"
                referenceId:
                  type: string
                  description: Unique reference identifier of this event instance
                  example: "01JZAGPG76SXYC523XJAA7XNM7"
                comment:
                  type: string
                  description: Information that the event was backfilled
                  example: "backfilled"
    TenantComputedTierChangedPayload:
      allOf:
        - $ref: '../../../base/base-event.yaml#/BaseEvent'
        - type: object
          title: Tenant computed tier change event
          properties:
            event:
              const: "TenantComputedTierChanged"
            properties:
              type: object
              properties:
                tn:
                  type: string
                  description: Unique identifier of the tenant
                  example: "3b1"
                oldTier:
                  type: string
                  description: The previous computed tier of the tenant
                  example: "standard"
                newTier:
                  type: string
                  description: The new computed tier of the tenant
                  example: "basic"
                tierDeterminants:
                  type: string
                  description: The factors that determined the new tier calculation
                  example: "TotalEntityCount: 925, EntitySetMaxEntityCount382"
    DatabaseStatisticsBuiltPayload:
      allOf:
        - $ref: '../../../base/base-event.yaml#/BaseEvent'
        - type: object
          title: Database statistics that summarize the database statistics for all tenants
          properties:
            event:
              const: "DatabaseStatisticsBuilt"
            properties:
              type: object
              properties:
                id:
                  type: string
                  description: The unique identifier under which the statistics is stored
                  example: "01JZAGPG76SXYC523XJAA7XNM7"
                created:
                  type: string
                  format: date-time
                  description: The time the statistics were created
                  example: "2025-11-03T10:31:11.311Z"
                tenantCount:
                  type: integer
                  format: int64
                  description: The number of tenants included in the statistics
                  example: 150
                totalEntitySetCount:
                  type: integer
                  format: int64
                  description: The total number of entity sets
                  example: 1500
                totalDataSize:
                  type: integer
                  format: int64
                  description: The total size of the data held in the database (KiB)
                  example: 2097152
                totalEntityCount:
                  type: integer
                  format: int64
                  description: The total number of entities
                  example: 50000
                totalIndexSize:
                  type: integer
                  format: int64
                  description: The total size of all indexes (KiB)
                  example: 131072
                totalIndexCount:
                  type: integer
                  format: int64
                  description: The total number of indexes
                  example: 300
                modelCount:
                  type: integer
                  format: int64
                  description: The total number of custom models in use
                  example: 25
                entityTypeCount:
                  type: integer
                  format: int64
                  description: The total number of (custom) entity types in use
                  example: 150
                entitySetCount:
                  type: integer
                  format: int64
                  description: The total number of entity sets in use
                  example: 1200
                dataSize:
                  type: integer
                  format: int64
                  description: The total size of the data in use (KiB)
                  example: 1572864
                entityCount:
                  type: integer
                  format: int64
                  description: The total number of entities in use
                  example: 40000
                indexSize:
                  type: integer
                  format: int64
                  description: The total size of all indexes in use (KiB)
                  example: 102400
                indexCount:
                  type: integer
                  format: int64
                  description: The total number of indexes in use
                  example: 240
                trashedModelCount:
                  type: integer
                  format: int64
                  description: The total number of custom models that were moved to the trash
                  example: 3
                trashedEntityTypeCount:
                  type: integer
                  format: int64
                  description: The total number of (custom) entity types that were moved to the trash
                  example: 20
                trashedEntitySetCount:
                  type: integer
                  format: int64
                  description: The total number of entity sets for which the related entity types were moved to the trash
                  example: 200
                trashedDataSize:
                  type: integer
                  format: int64
                  description: The total size of the data for which the related entity types were moved to the trash (KiB)
                  example: 262144
                trashedEntityCount:
                  type: integer
                  format: int64
                  description: The total number of entities for which the related entity types were moved to the trash
                  example: 8000
                trashedIndexSize:
                  type: integer
                  format: int64
                  description: The total size of all indexes for which the related entity types were moved to the trash (KiB)
                  example: 16384
                trashedIndexCount:
                  type: integer
                  format: int64
                  description: The total number of indexes for which the related entity types were moved to the trash
                  example: 40
                orphanedEntitySetCount:
                  type: integer
                  format: int64
                  description: The total number of entity sets that are orphaned
                  example: 100
                orphanedDataSize:
                  type: integer
                  format: int64
                  description: The total size of the orphaned data (KiB)
                  example: 262144
                orphanedEntityCount:
                  type: integer
                  format: int64
                  description: The total number of entities that are orphaned
                  example: 2000
                orphanedIndexSize:
                  type: integer
                  format: int64
                  description: The total size of all orphaned indexes (KiB)
                  example: 12288
                orphanedIndexCount:
                  type: integer
                  format: int64
                  description: The total number of indexes that are orphaned
                  example: 20
                referenceId:
                  type: string
                  description: Unique reference identifier of this event instance
                  example: "01JZAGPG76SXYC523XJAA7XNM7"
                comment:
                  type: string
                  description: Information that the event was backfilled
                  example: "backfilled"
    EntitySetStatisticsBuiltPayload:
      allOf:
        - $ref: '../../../base/base-event.yaml#/BaseEvent'
        - type: object
          title: The statistics of a tenant entity set
          properties:
            event:
              const: "EntitySetStatisticsBuilt"
            properties:
              type: object
              properties:
                tn:
                  type: string
                  description: Unique identifier of the tenant
                  example: "3b1"
                name:
                  type: string
                  description: The (logical) name of the entity set
                  example: "Products"
                typeName:
                  type: string
                  description: The type name of the entities in the entity set
                  example: "Product"
                physicalName:
                  type: string
                  description: The physical name of the entity set
                  example: "products_3b1_collection"
                dataSize:
                  type: integer
                  format: int64
                  description: The size of the data in the entity set (KiB)
                  example: 1024
                entityCount:
                  type: integer
                  format: int64
                  description: The number of entities in the entity set
                  example: 500
                averageEntitySize:
                  type: integer
                  format: int64
                  description: The average size of an entity in the entity set
                  example: 2
                indexSize:
                  type: integer
                  format: int64
                  description: The size of the indexes (KiB)
                  example: 128
                indexCount:
                  type: integer
                  format: int64
                  description: The number of indexes
                  example: 3
                kind:
                  type: string
                  description: The kind of the entity set (e.g., trashed, active)
                  example: "active"
                referenceId:
                  type: string
                  description: Unique reference identifier of this event instance
                  example: "01JZAGPG76SXYC523XJAA7XNM7"
                comment:
                  type: string
                  description: Information that the event was backfilled
                  example: "backfilled"
    TenantDatabaseStatisticsBuiltPayload:
      allOf:
        - $ref: '../../../base/base-event.yaml#/BaseEvent'
        - type: object
          title: The statistics of a tenant database
          properties:
            event:
              const: "TenantDatabaseStatisticsBuilt"
            properties:
              type: object
              properties:
                tn:
                  type: string
                  description: Unique identifier of the tenant
                  example: "3b1"
                referenceId:
                  type: string
                  description: Unique reference identifier of this event instance
                  example: "01JZAGPG76SXYC523XJAA7XNM7"
                id:
                  type: string
                  description: The unique identifier under which the statistics is stored
                  example: "01JZAGPG76SXYC523XJAA7XNM7"
                created:
                  type: string
                  format: date-time
                  description: The time the statistics were created
                  example: "2025-11-03T10:31:11.311Z"
                tenantDatabaseName:
                  type: string
                  description: The name of the tenant database
                  example: "t_10qg"
                totalEntitySetCount:
                  type: integer
                  format: int64
                  description: The total number of entity sets
                  example: 150
                totalDataSize:
                  type: integer
                  format: int64
                  description: The total size of the data held in the database (KiB)
                  example: 1048576
                totalEntityCount:
                  type: integer
                  format: int64
                  description: The total number of entities
                  example: 25000
                totalIndexSize:
                  type: integer
                  format: int64
                  description: The total size of all indexes (KiB)
                  example: 65536
                totalIndexCount:
                  type: integer
                  format: int64
                  description: The total number of indexes
                  example: 75
                modelCount:
                  type: integer
                  format: int64
                  description: The total number of custom models in use
                  example: 12
                entityTypeCount:
                  type: integer
                  format: int64
                  description: The total number of (custom) entity types in use
                  example: 45
                entitySetCount:
                  type: integer
                  format: int64
                  description: The total number of entity sets in use
                  example: 120
                dataSize:
                  type: integer
                  format: int64
                  description: The total size of the data in use (KiB)
                  example: 786432
                entityCount:
                  type: integer
                  format: int64
                  description: The total number of entities in use
                  example: 20000
                indexSize:
                  type: integer
                  format: int64
                  description: The total size of all indexes in use (KiB)
                  example: 51200
                indexCount:
                  type: integer
                  format: int64
                  description: The total number of indexes in use
                  example: 60
                trashedModelCount:
                  type: integer
                  format: int64
                  description: The total number of custom models that were moved to the trash
                  example: 2
                trashedEntityTypeCount:
                  type: integer
                  format: int64
                  description: The total number of (custom) entity types that were moved to the trash
                  example: 8
                trashedEntitySetCount:
                  type: integer
                  format: int64
                  description: The total number of entity sets for which the related entity types were moved to the trash
                  example: 20
                trashedDataSize:
                  type: integer
                  format: int64
                  description: The total size of the data for which the related entity types were moved to the trash (KiB)
                  example: 131072
                trashedEntityCount:
                  type: integer
                  format: int64
                  description: The total number of entities for which the related entity types were moved to the trash
                  example: 4000
                trashedIndexSize:
                  type: integer
                  format: int64
                  description: The total size of all indexes for which the related entity types were moved to the trash (KiB)
                  example: 8192
                trashedIndexCount:
                  type: integer
                  format: int64
                  description: The total number of indexes for which the related entity types were moved to the trash
                  example: 10
                orphanedEntitySetCount:
                  type: integer
                  format: int64
                  description: The total number of entity sets that are orphaned
                  example: 10
                orphanedDataSize:
                  type: integer
                  format: int64
                  description: The total size of the orphaned data (KiB)
                  example: 131072
                orphanedEntityCount:
                  type: integer
                  format: int64
                  description: The total number of entities that are orphaned
                  example: 1000
                orphanedIndexSize:
                  type: integer
                  format: int64
                  description: The total size of all orphaned indexes (KiB)
                  example: 6144
                orphanedIndexCount:
                  type: integer
                  format: int64
                  description: The total number of indexes that are orphaned
                  example: 5