{"_id":"56ad24afd21f1b0d00fd2f86","user":"56acd6caa040860d00ac94a2","githubsync":"","parentDoc":null,"project":"56acd71213ac890d001c3c7a","category":{"_id":"56ad20660ab3c00d00ce3347","__v":11,"pages":["56ad21651c09150d00a183a0","56ad235c693f0a0d0085f0c3","56ad24afd21f1b0d00fd2f86","56ad2e5b1c09150d00a183a6","56ad305879011b0d00c32aaa","56ad30c81a7ee417009ced18","56ad31432a7860170013f711","56ad33b21a7ee417009ced1a","56ad34a0b9ac5517006b6962","56ad35503fc1020d009776e1","56e7266bdbc36117006a41ff"],"project":"56acd71213ac890d001c3c7a","version":"56acd71213ac890d001c3c7d","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-30T20:43:18.400Z","from_sync":false,"order":9,"slug":"singularity-real-time-events","title":"Singularity: Real-Time Events"},"__v":22,"version":{"_id":"56acd71213ac890d001c3c7d","project":"56acd71213ac890d001c3c7a","__v":15,"createdAt":"2016-01-30T15:30:26.928Z","releaseDate":"2016-01-30T15:30:26.928Z","categories":["56acd71313ac890d001c3c7e","56acd8f113ac890d001c3c81","56acd8f95ac4060d0027865e","56acd93a13ac890d001c3c82","56ad20660ab3c00d00ce3347","56ad356a2a7860170013f714","56ad47eb0ab3c00d00ce334f","56afd523bc304a0d00ace1df","56b29a019621f20d00efb37e","56b657e11bc6970d009feee7","5845cc3c39950c1b002afe77","5845cde163c11b250037967e","5846efd45d064323007b17b4","588604da4674e32300efd160","588627882393d50f00f1322c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-30T21:01:35.473Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"This Event is Part of an Event Chain\",\n  \"body\": \"Note, this event may fire independently, but it will at least ***always*** fire after a **subscriber-new** event.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Robust, Automated, Benefit Delivery is Complicated\",\n  \"body\": \"This is easily the most important event in the entirety of the Singularity. It relies heavily on benefit-fulfillment pairs. Be sure to [read about how they work](https://gamewisp.readme.io/docs/working-with-benefits-and-fulfillment) if you haven't!\"\n}\n[/block]\nUsing Socket.IO this event can be listened to as follows:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"socket.on('subscriber-benefits-change', function(data){\\n    //Do something\\n});\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThis event fires whenever a subscriber’s benefits change. A benefit change can be triggered by a user:\n\n* Subscribing to a new channel \n* Upgrading their subscription to a channel\n* Downgrading their subscription to a channel. \n\nThis event can also fire if the channel makes changes to a tier that contains active subscribers. In this case, a** subscriber-benefits-change **event will fire for each subscriber currently in the modified tier.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n   event: \\\"subscriber-benefits-change\\\",\\n   channel_id: \\\"channel identifier\\\",\\n   channel: {\\n      names: {\\n         gamewisp: \\\"GameWisp channel name\\\",\\n         twitch: \\\"twitch channel name\\\",\\n         youtube: \\\"youtube channel name\\\"\\n      },\\n      ids: {\\n         gamewisp: \\\"channel identifier\\\",\\n         twitch: \\\"12312312q\\\",\\n         youtube: \\\"UCiqp4J8asdkssssssssdfae\\\"\\n        }\\n    }\\n   data: {\\n      benefits: [\\n         {\\n            benefit: {\\n               id: \\\"3\\\",\\n               delivery: \\\"delivery-messaging\\\",\\n               title: \\\"Subscriber Messaging\\\",\\n               description: \\\"Receive Subscriber-only messages from me.\\\",\\n               channel_data: null,\\n               type: \\\"unknown-type\\\",\\n               month_delay: null,\\n               recurring: false,\\n               recurring_input: false,\\n               receieve_immediately: false,\\n               removed_at: null,\\n               subscriber_limit: null,\\n               tier_bonus: false,\\n               quantity: 1,\\n               multiplier: 1\\n            },\\n            fulfillment: {\\n               id: \\\"54350\\\",\\n               benefit_id: \\\"3\\\",\\n               tier_id: \\\"8781\\\",\\n               channel_fulfillment_response: null,\\n               fulfilled_at: \\\"2015-12-30 21:29:07\\\",\\n               previously_fulfilled_at: null,\\n               disabled_at: null,\\n               user_input_provided_at: null,\\n               recurring: true,\\n               granted_at: {\\n                  date: \\\"2015-12-30 21:29:07.000000\\\",\\n                  timezone_type: 3,\\n                  timezone: \\\"UTC\\\"\\n               },\\n               channel_cancelled_at: null,\\n               status: \\\"active\\\"\\n            }\\n         },\\n         //...\\n      ],\\n      ids: {\\n         gamewisp: \\\"111111\\\",\\n         twitch: \\\"121212121212\\\"\\n      },\\n      usernames: {\\n         gamewisp: \\\"gamewisp_username\\\",\\n         twitch: \\\"twitch_username\\\"\\n      },\\n      status: \\\"active\\\",\\n      amount: \\\"3.99\\\",\\n      subscribed_at: \\\"2015-12-30 00:00:00\\\",\\n      end_of_access: \\\"2016-01-30 23:59:00\\\",\\n      tier: {\\n         id: \\\"11112\\\",\\n         title: \\\"Tier Title\\\",\\n         level: \\\"1\\\",\\n         cost: \\\"3.99\\\",\\n         description: \\\"Tier description\\\",\\n         published: true\\n      }\\n   }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe benefits array contains an array of[ benefit-fulfillment pairs](https://gamewisp.readme.io/docs/working-with-benefits-and-fulfillment). The benefit object in the pair describes a single benefit for the subscriber. The fulfillment object in the pair provides information about whether or not the benefit has been fulfilled.\n\nAdditionally, this event contains information pertaining to the subscriber, their payment amount, etc. that can also be found in the **subscriber-new** event documentation.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Benefit-Fulfillment Pairs are Important\",\n  \"body\": \"It is highly advised to read about [benefit-fulfillment pairs](https://gamewisp.readme.io/docs/working-with-benefits-and-fulfillment) and how benefits work on GameWisp if you haven't already.\"\n}\n[/block]","excerpt":"This event fires whenever a subscriber's benefits are changed on GameWisp.","slug":"subscriber-benefits-change","type":"fn","title":"subscriber-benefits-change"}

subscriber-benefits-change

This event fires whenever a subscriber's benefits are changed on GameWisp.

[block:callout] { "type": "warning", "title": "This Event is Part of an Event Chain", "body": "Note, this event may fire independently, but it will at least ***always*** fire after a **subscriber-new** event." } [/block] [block:callout] { "type": "info", "title": "Robust, Automated, Benefit Delivery is Complicated", "body": "This is easily the most important event in the entirety of the Singularity. It relies heavily on benefit-fulfillment pairs. Be sure to [read about how they work](https://gamewisp.readme.io/docs/working-with-benefits-and-fulfillment) if you haven't!" } [/block] Using Socket.IO this event can be listened to as follows: [block:code] { "codes": [ { "code": "socket.on('subscriber-benefits-change', function(data){\n //Do something\n});", "language": "javascript" } ] } [/block] This event fires whenever a subscriber’s benefits change. A benefit change can be triggered by a user: * Subscribing to a new channel * Upgrading their subscription to a channel * Downgrading their subscription to a channel. This event can also fire if the channel makes changes to a tier that contains active subscribers. In this case, a** subscriber-benefits-change **event will fire for each subscriber currently in the modified tier. [block:code] { "codes": [ { "code": "{\n event: \"subscriber-benefits-change\",\n channel_id: \"channel identifier\",\n channel: {\n names: {\n gamewisp: \"GameWisp channel name\",\n twitch: \"twitch channel name\",\n youtube: \"youtube channel name\"\n },\n ids: {\n gamewisp: \"channel identifier\",\n twitch: \"12312312q\",\n youtube: \"UCiqp4J8asdkssssssssdfae\"\n }\n }\n data: {\n benefits: [\n {\n benefit: {\n id: \"3\",\n delivery: \"delivery-messaging\",\n title: \"Subscriber Messaging\",\n description: \"Receive Subscriber-only messages from me.\",\n channel_data: null,\n type: \"unknown-type\",\n month_delay: null,\n recurring: false,\n recurring_input: false,\n receieve_immediately: false,\n removed_at: null,\n subscriber_limit: null,\n tier_bonus: false,\n quantity: 1,\n multiplier: 1\n },\n fulfillment: {\n id: \"54350\",\n benefit_id: \"3\",\n tier_id: \"8781\",\n channel_fulfillment_response: null,\n fulfilled_at: \"2015-12-30 21:29:07\",\n previously_fulfilled_at: null,\n disabled_at: null,\n user_input_provided_at: null,\n recurring: true,\n granted_at: {\n date: \"2015-12-30 21:29:07.000000\",\n timezone_type: 3,\n timezone: \"UTC\"\n },\n channel_cancelled_at: null,\n status: \"active\"\n }\n },\n //...\n ],\n ids: {\n gamewisp: \"111111\",\n twitch: \"121212121212\"\n },\n usernames: {\n gamewisp: \"gamewisp_username\",\n twitch: \"twitch_username\"\n },\n status: \"active\",\n amount: \"3.99\",\n subscribed_at: \"2015-12-30 00:00:00\",\n end_of_access: \"2016-01-30 23:59:00\",\n tier: {\n id: \"11112\",\n title: \"Tier Title\",\n level: \"1\",\n cost: \"3.99\",\n description: \"Tier description\",\n published: true\n }\n }\n}", "language": "json" } ] } [/block] The benefits array contains an array of[ benefit-fulfillment pairs](https://gamewisp.readme.io/docs/working-with-benefits-and-fulfillment). The benefit object in the pair describes a single benefit for the subscriber. The fulfillment object in the pair provides information about whether or not the benefit has been fulfilled. Additionally, this event contains information pertaining to the subscriber, their payment amount, etc. that can also be found in the **subscriber-new** event documentation. [block:callout] { "type": "warning", "title": "Benefit-Fulfillment Pairs are Important", "body": "It is highly advised to read about [benefit-fulfillment pairs](https://gamewisp.readme.io/docs/working-with-benefits-and-fulfillment) and how benefits work on GameWisp if you haven't already." } [/block]