pusher / pusher-http-ruby

Ruby library for Pusher Channels HTTP API
https://pusher.com/channels
MIT License
664 stars 123 forks source link

Pusher event namespaces? #142

Closed jaydorsey closed 5 years ago

jaydorsey commented 5 years ago

Good afternoon, I ran into this error today:

Pusher::Error (Bad request: The 'pusher' namespace is reserved for internal usage)

We had a snippet of code that looked like this:

Pusher.trigger(
  "private-channel-#{user_id}",
  'pusher-notification',
  key: 'ThingCreate',
  thingId: thing_id
)

Swapping out pusher-notification for new-notification resolved the issue, but I didn't see this namespace reserved either in this library, or in the API docs. It took me far longer to debug than I would have liked, so if it is part of the API rules it might be nice to add a check on the library side to prevent this kind of event naming.

I'm using the latest published gem (1.3.2)

annzenkina commented 5 years ago

Thanks for the feedback. We’re sorry that you’ve spent that much time debugging the issue. The check is implemented in Pusher server, not on the library side. We will make sure to update the documentation to mention this!

WillSewell commented 5 years ago

Would the problem have been clearer with a better error message? i.e.:

Pusher::Error (Bad request: Event names cannot be prefixed with 'pusher')
jaydorsey commented 5 years ago

I do think that message is clear.

With the namespace nomenclature in the error we were looking at things like gem version, an API change, deprecated syntax, etc.

WillSewell commented 5 years ago

That makes sense. Thanks for the feedback!

We will fix this by updating the error message. I'll close this issue since this is a change that will be made to the Channels API; not this library.