Socket Token can be fetched using /socket/token endpoint
Sample Code:

<script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js' type='text/javascript'></script>
<script type = 'text/javascript'>
  const socketToken = ''; //Socket token from /socket/token end point
	
	//Connect to socket
	const streamlabs = io(`https://sockets.streamlabs.com?token=${socketToken}`);
	
	//Perform Action on event
	streamlabs.on('event', (eventData) => {
    if (!eventData.for || eventData.for === 'streamlabs' && eventData.type === 'donation') {
    	//code to handle donation events
      console.log(eventData.message);
    }
    if (eventData.for === 'twitch_account') {
      switch(eventData.type) {
        case 'follow':
          //code to handle follow events
          console.log(eventData.message);
          break;
        case 'subscription':
          //code to handle subscription events
          console.log(eventData.message);
          break;
        default:
          //default case
          console.log(eventData.message);
      }
    }
  });
</script>

❗️

eventData.message

This will always be an array

type and for values for different events are described below

typeforEvent
donation'' || streamlabsDonations
followtwitch_accountTwitch Follow
subscriptiontwitch_accountTwitch Subscription
hosttwitch_accountTwitch Host
bitstwitch_accountTwitch Bits/Cheers
followyoutube_accountYoutube Subscriber
subscriptionyoutube_accountYoutube Sponsor
superchatyoutube_accountYoutube Superchats
followmixer_accountMixer Follow
subscriptionmixer_accountMixer Subscription
hostmixer_accountMixer Host

Sample Responses:

Donations

{
  "type": "donation",
  "message": [
    {
      "id": 96164121,
      "name": "test",
      "amount": "13.37",
      "formatted_amount": "$13.37",
      "formattedAmount": "$13.37",
      "message": "test donation",
      "currency": "USD",
      "emotes": null,
      "iconClassName": "user",
      "to": {
        "name": "Sai Harsha Maddela"
      },
      "from": "test",
      "from_user_id": null,
      "_id": "0820c9d5bafd768c9843f5e35c885e71"
    }
  ],
  "event_id": "evt_17e5f4dc6888767ed9799f78dfa2cabc"
}

Twitch Subscription

{
  "type": "subscription",
  "message": [
    {
      "name": "kevin",
      "months": 7,
      "message": "sub message",
      "emotes": null,
      "sub_plan": 1000,
      "sub_plan_name": "Sample Plan name",
      "sub_type": "resub",
      "_id": "a226a8c223634afdc368439c1da7aaba"
    }
  ],
  "for": "twitch_account"
}

Twitch Follow

{
  "type": "follow",
  "message": [
    {
      "created_at": "2017-08-22 00:14:35",
      "id": "170884026",
      "name": "h4r5h48002",
      "_id": "74a0b93e736f1f14762111f8ae34bf42"
    }
  ],
  "for": "twitch_account"
}

Twitch Host

{
  "type": "host",
  "message": [
    {
      "name": "h4r5h48002",
      "viewers": "1",
      "type": "manual",
      "_id": "74a0b93e736f1f14762111f8ae34bf42"
    }
  ],
  "for": "twitch_account"
}

Twitch Bits

{
  "type": "bits",
  "message": [
    {
      "id": "fc546f7d-aab8-42b2-9933-8681e9fb5eb0",
      "name": "h4r5h48002",
      "amount": "1",
			"emotes": null,
			"message": "streamlabs1",
      "_id": "74a0b93e736f1f14762111f8ae34bf42"
    }
  ],
  "for": "twitch_account"
}

Youtube Subscriber

{
  "type": "follow",
  "message": [
    {
      "publishedAt": "2017-08-22 00:25:57",
      "id": "UCec4hVEu3ZXE8qlRtUeK0DA",
      "name": "Kappa Lord",
      "_id": "6af0964e548a6d93c192c9e31e0959cc"
    }
  ],
  "for": "youtube_account"
}

Youtube Sponsor

{
  "type": "subscription",
  "message": [
    {
      "sponsorSince": "2017-08-22 00:45:48",
      "id": "UCec4hVEu3ZXE8qlRtUeK0DA",
      "name": "Kappa Lord",
      "channelUrl": "http://www.youtube.com/channel/UCec4hVEu3ZXE8qlRtUeK0DA",
      "months": 3,
      "_id": "33d396edab6e2e2e8b37a7b6f1b60b82"
    }
  ],
  "for": "youtube_account"
}

Youtube Superchat

{
  "type": "superchat",
  "message": [
    {
      "id": "LCC.Cg8KDQoLWmpUemdzdU1vM2sSHAoaQ05PcW01UzJ3dElDRll2WkhBb2RLd0lBOWc0.028141892513880107",
      "channelId": "UCec4hVEu3ZXE8qlRtUeK0DA",
      "channelUrl": "http://www.youtube.com/channel/UCec4hVEu3ZXE8qlRtUeK0DA",
      "name": "Kappa Lord",
      "comment": "love the stream",
      "amount": "2000000",
      "currency": "USD",
      "displayString": "$2.00",
      "messageType": 2,
      "createdAt": "2017-08-22 00:51:57",
      "_id": "ad46c7e468331c5e39373e05876fa17e"
    }
  ],
  "for": "youtube_account"
}

Mixer Follow

{
  "type": "follow",
  "message": [
    {
      "id": 1816,
      "name": "Jamacanbacn",
      "created_at": "2017-08-22 00:30:25",
      "_id": "4fbcdd82bc9fd39467572b24ee20a766"
    }
  ],
  "for": "mixer_account"
}

Mixer Subscription

{
  "type": "subscription",
  "message": [
    {
      "id": "123456",
      "name": "h4r5h4",
      "months": 2,
      "message": null,
      "emotes": null,
      "since": "2017-08-22 00:36:59",
      "_id": "68f034214d68dce22431801b940d2b90"
    }
  ],
  "for": "mixer_account"
}

Mixer Host

{
  "type": "host",
  "message": [
    {
      "name": "h4r5h47",
      "viewers": "5",
      "type": "manual",
      "_id": "4ee5fcf7e34128f4f07bb978c9e35fd4"
    }
  ],
  "for": "mixer_account"
}