Automattic\WooCommerce\Internal\Abilities

AbilitiesTracking::open_frame │ private │ WC 1.0

Start tracking an invocation.

Method of the class: AbilitiesTracking{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->open_frame( $ability_name, $executing ): void;
$ability_name(string) (required)
The ability name.
$executing(true|false) (required)
Whether execution already started (WordPress 7.0 path).

AbilitiesTracking::open_frame() code WC 11.3.0

private function open_frame( string $ability_name, bool $executing ): void {
	// Consent is per site, and the site can change mid-request with switch_to_blog().
	if ( ! self::is_tracking_allowed() ) {
		return;
	}

	// Only agent entry points. Direct PHP and cron calls are plugin internals and could add a pixel to every page view.
	if ( ! in_array( $this->get_channel(), self::TRACKED_CHANNELS, true ) ) {
		return;
	}

	// Calls that fail without a closing hook keep their frame until shutdown. Recording the oldest one as an
	// unknown failure keeps the stack bounded and lets later closing hooks still find their own frame.
	if ( count( $this->frames ) >= self::MAX_EVENTS_PER_REQUEST ) {
		$oldest = $this->frames[0];
		array_shift( $this->frames );
		$this->add_event( $oldest, null, false );
	}

	$this->frames[] = $this->create_frame( $ability_name, $executing );
	++$this->frames_opened;
}