I’m considering using Cloudflare Stream for a live video streaming service. One critical requirement is that we be able to accurately track usage/minutes viewed by user.
Baseline:
- Long running livestreams. Don’t know in advance how long
- We will use signed URLs, and will be minting our own
- We can’t use the stream player’s analytics because those are client side and easily bypassed - and we may not even be using that player.
- We need granular usage data, hopefully down to about 5 minutes.
I was hoping someone might have some ideas. I’ve got two but there are issues with both.
Option 1: Server Side Analytics
There are bulk server-side analytics (${cloudflareDeveloperWebsite}/stream/getting-analytics/fetching-bulk-analytics/#server-side-analytics) via the GraphQL API available that almost are exactly what we need - but on the server side we have no way to filter or group by a user, token, etc. If there was a way to group by a token ID
Option 2: Expiring URLs
We could mint URLs that expire frequently and require the client to ask our service to issue them new ones periodically. Then we can track usage by user ourselves, and untrustworthy clients must check in with us to keep their stream going.
The problem with this one (and I haven’t tried this, but I’m guessing) is that I bet this will cause a noticeable hitch in playback - even if the Stream player lets us swap out the URL transparently.
Option 3: Revoke tokens
Similar to #2, we require clients to check in periodically to keep their stream going, but instead of giving a new token, we revoke tokens for clients that don’t check in with us frequently enough.
There is an API to revoke the signing key (${cloudflareApiWebsite}/#stream-signing-keys-delete-key] - and this could work if we could have a signing key per user. Alas - we are limited to 1000 keys total, and need to support more than 1000 users.
Does anyone have any other ideas of how we could make any of these work, or something else?