Skip to main content

benecaster_download_app_patterns

Filter Free

Filters the podcast app detection pattern table used to classify download requests into named apps for analytics display. Keys are lowercased substring needles matched against the lowercased raw user-agent; values are display labels. The detection engine iterates keys in array order and uses the first matching key, so order matters.

This filter runs at analytics query time, not at download-request time. The raw user-agent string is never stored — only the resolved app label is written to the log row. Adding a new pattern reclassifies only future log rows at query time; it does not backfill historical rows.

Examples

Prepend custom corporate player patterns

add_filter(
    'benecaster_download_app_patterns',
    function ( array $patterns ): array {
        return [
            'acmeplayer'   => 'Acme Corporate Player',
            'internalcast' => 'InternalCast',
        ] + $patterns; // Prepend so these are evaluated first.
    }
);

Remove curl and wget from named apps

add_filter(
    'benecaster_download_app_patterns',
    function ( array $patterns ): array {
        unset( $patterns['curl'], $patterns['wget'] );
        return $patterns;
    }
);

Replace pattern table with a custom set

add_filter(
    'benecaster_download_app_patterns',
    function ( array $patterns ): array {
        return [
            'apple podcasts' => 'Apple Podcasts',
            'overcast'       => 'Overcast',
            'spotify'        => 'Spotify',
            'pocket casts'   => 'Pocket Casts',
            'mozilla'        => 'Browser',
        ];
    }
);

Notes

Pattern matching is performed against the lowercased raw user-agent. All needles must be lowercase. If no key matches, the download is bucketed as Other. To give a custom pattern priority over a built-in one, prepend it using return [ 'myneedle' => 'My App' ] + $patterns;. This filter is called once per analytics request, not once per log row — avoid expensive operations inside the callback.