daily-co / daily-js

https://docs.daily.co/reference/daily-js
BSD 2-Clause "Simplified" License
103 stars 33 forks source link

BUG userData coming through mangled #223

Closed aphillipo closed 1 year ago

aphillipo commented 1 year ago

Expected behavior

I want to be able to broadcast from the computer as well as the device so I was playing about as follows:

window?.callFrame?.join({
  url: `https://veloa.daily.co/${roomName}`,
  token,
  dailyConfig: {
    userMediaVideoConstraints: { width: 1920, height: 1080 },
  },
  userData: {
    broadcastFrom: "COMPUTER",
  },
});

However when I look in the participants list I see the following for the "COMPUTER" participant on the device:

{
   ...participantStuff...
   "userData": {"c": {"broadcastFrom": "COMPUTER"}}
}

Where is the "c" coming from! Daily JS in react-native is not adding this.

Describe the bug (unexpected behavior)

Data should be:

{
   ...participantStuff...
   "userData": {"broadcastFrom": "COMPUTER"}
}

Steps to reproduce

I am not sure, maybe it is elixir Live View breaking things somehow but I think it should be fine.

System information

* Device: 16 Inch Apple Silicon Macbook * OS, version: Ventura * Browser, version: Safari 16.2 # Additional context I am using Elixir Live View, maybe I should include the javascript differently but adding wrapping the javascript in a {c: } seems weird!
mattieruth commented 1 year ago

Thank you for the post. When you are accessing the participant list, are you doing so from the outer frame or from within the prebuilt frame? When using prebuilt, under the hood, we bucket customer userData under c so as not to confict with prebuilt's own use of userData (which gets bucketed under p). Below shows what the local participant userData looks like from the outer frame vs. the inner frame.

image

So is it possible you are calling participants() from the wrong window frame?

aphillipo commented 1 year ago

Okay so maybe this is me misunderstanding things then - I will probably at some point move away from prebuilt and use custom so this issue will go away. I do not believe this is a bug given your explanation - personally I would use a couple more bytes and go for custom: {} and prebuilt: {} but it's your library! Thanks!