'booking_id', 'fxlc_customer_created' => 'customer_id', 'fxlc_payment_completed' => 'payment_id', 'fxlc_review_received' => 'review_id', ]; public function register(): void { add_action( 'fxlc_form_submitted', [ $this, 'on_form_submitted' ], 10, 2 ); add_action( 'fxlc_lead_created', [ $this, 'on_lead_created' ], 10, 2 ); add_action( 'fxlc_service_created', [ $this, 'on_service_event' ], 10, 2 ); add_action( 'fxlc_service_updated', [ $this, 'on_service_event' ], 10, 2 ); foreach ( array_keys( self::ADDON_EVENTS ) as $event ) { add_action( $event, [ $this, 'on_addon_event' ], 10, 1 ); } } public function on_form_submitted( int $entry_id, mixed $entry ): void { $payload = [ 'entry_id' => $entry_id ]; if ( $entry instanceof FormEntry ) { $payload['form_id'] = $entry->form_id; } $this->repo()->record( 'fxlc_form_submitted', $payload ); } public function on_lead_created( int $lead_id, mixed $lead ): void { $payload = [ 'lead_id' => $lead_id ]; if ( $lead instanceof Lead ) { $payload['source'] = $lead->source; } $this->repo()->record( 'fxlc_lead_created', $payload ); } public function on_service_event( int $service_id, mixed $service ): void { unset( $service ); $this->repo()->record( (string) current_action(), [ 'service_id' => $service_id ] ); } public function on_addon_event( mixed $id ): void { $event = (string) current_action(); if ( ! isset( self::ADDON_EVENTS[ $event ] ) ) { return; } $this->repo()->record( $event, [ self::ADDON_EVENTS[ $event ] => absint( $id ) ] ); } private function repo(): EventRepository { return new EventRepository(); } }