Reading sub status not working


#1

Hi guys,

I use this bit of code which I found on this board:

let tier = false;
try {
    let { subscriptionStatus } = window.Twitch.ext.viewer;
    tier = subscriptionStatus.tier;
    twitch.rig.log('Status is', tier);
} catch (e) {
    tier = false;
    twitch.rig.log('No Sub');
}

My channel has the affiliate status, I did the onboarding and had activated the read sub status option in the developer console. I built a view with logged in user granting access to the user data and made the checkmark on the sub status.

But still my response is “No Sub”.
Where else could be the problem?
Thank you!


#2

So to confirm:

On

Dev Console -> Extensions -> Manage Extension -> Manage a Version -> Monetization

You have this option enabled:

And on

Dashboard -> Extensions -> My Extensions -> Manage Permissions

You have the second toggle enable? (It’s disabled in my screenshot)

Finally you are testing on the Twitch front end (the actual website) as a user whom has a subscription? The above quote suggests you are testing it in the Rig and the behaviour may vary. Certain parts of the Rig don’t work as expected in the rig.

You can and should add a test:

window.Twitch.ext.features.isSubscriptionStatusAvailable

To check if sub status is actually available, documented at https://dev.twitch.tv/docs/extensions/reference#helper-feature-flags

Before running the code you used which doesn’t do the “enablement” check.

I predict the issue is, that you are testing in the Developer Rig where subscriber status just isn’t available/not working as expected, or could be a bug. And the checkbox you refer to:

Just turns on the feature flag doesn’t set the “user” as having a sub

The feature flag being: window.Twitch.ext.features.isSubscriptionStatusAvailable as mentioned earlier.

For best results install the extension to a “real” Twitch Channel and test there.


#3

Hi Barry,

I just wanted to reply to your detailed post:
I had toggled all said settings and did the check you suggested which returned a positive result. I ended up with using the sub list form the API (which is not that reliable) and checking it for that twitch id which works quite good enough. You were probably right about the twitch rig giving inconsistent results in that case since I could not find another potential source for that error.

Thanks though I’m using a workaround now!

Merry Christmas!


#4

You should do this check if you are sending an interaction from your Frontend to your EBS anyway. In case the sub started (or lapsed) before the onAuthorised JWT is refreshed updating the client side flags (never trust user submitted data!).

But for the client side stuff, it’s best tested on the actual Twitch website (the developer rig is completely optional, it just saves a need to faff with Self Signed SSL certs, so all my Extension local development is behind a real SSL cert again)