Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose provider name #45

Open
sebastien-p opened this issue Aug 15, 2023 · 8 comments
Open

Expose provider name #45

sebastien-p opened this issue Aug 15, 2023 · 8 comments

Comments

@sebastien-p
Copy link

Hello

I would like to access the provider name (twitch, youtube, …) and found out that this information is stored in the AngularJS code of the parent frame but don’t seem to be exposed to the custom code one. Or maybe it is somehow? Only the provider ID seems to be available but I sadly can’t do much with it.

Thanks 😊

@c4ldas
Copy link

c4ldas commented Aug 15, 2023

You cannot get it directly, but you can obtain the account ID and then fetch an endpoint that will show with platform that user is from:

window.addEventListener('onWidgetLoad', async (obj) => {
  const accountId = obj.detail.channel.id
  
  const accountFetch = await fetch(`https://api.streamelements.com/kappa/v2/channels/${accountId}`)
  const account = await accountFetch.json()

  console.log(account.provider) // twitch / youtube / trovo / etc
})

@sebastien-p
Copy link
Author

You cannot get it directly, but you can obtain the account ID and then fetch an endpoint that will show with platform that user is from:

window.addEventListener('onWidgetLoad', async (obj) => {
  const accountId = obj.detail.channel.id
  
  const accountFetch = await fetch(`https://api.streamelements.com/kappa/v2/channels/${accountId}`)
  const account = await accountFetch.json()

  console.log(account.provider) // twitch / youtube / trovo / etc
})

Ok but I feel like sending an HTTP request to fetch an information that already is present in memory is a bad idea and this would introduce potential errors and latency for no reason.

@c4ldas
Copy link

c4ldas commented Aug 15, 2023

Other than that, only on onEventReceived, like a chat message, for example.
It will show in obj.detail.event.service

@sebastien-p
Copy link
Author

Other than that, only on onEventReceived, like a chat message, for example.
It will show in obj.detail.event.service

Yes but I am implementing a solution for multi streaming so I need to know the source/provider for every event being onWidgetLoad, onEventReceived or onSessionUpdate.

@c4ldas
Copy link

c4ldas commented Aug 15, 2023

Unfortunately, there is no way. The only place you will have that information is either from onEventReceived or fetching the endpoint.

@sebastien-p
Copy link
Author

Unfortunately, there is no way. The only place you will have that information is either from onEventReceived or fetching the endpoint.

Well the provider won’t change so we can assume having this info once in onWidgetLoad would be enough. But what we have instead is an ID forcing us to send an HTTP request to exchange it for the provider name, I’m not sure how that would be useful. Why not just also expose the provider name alongside the ID since the parent frame already has it?

@c4ldas
Copy link

c4ldas commented Aug 15, 2023

Why not just also expose the provider name alongside the ID since the parent frame already has it?

That's an excellent question that we will never know the answer. I also wouldn't expect that will be changed soon, given how hard is to reach SE devs or have good suggestions rolled out.

@sebastien-p
Copy link
Author

Why not just also expose the provider name alongside the ID since the parent frame already has it?

That's an excellent question that we will never know the answer. I also wouldn't expect that will be changed soon, given how hard is to reach SE devs or have good suggestions rolled out.

Fingers crossed 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants