Adicionar dados extras de 'opts' ao evento "DiscourseEvent.on(:post_created)" via JavaScript?

Replace all of your code with this and it will work. I just tested it. Let me know if you have questions about specific parts.

Client

import Composer from 'discourse/models/composer';
import { withPluginApi } from 'discourse/lib/plugin-api';

export default {
  name: 'test-initializer',
  initialize() {
    Composer.serializeOnCreate('hide_devs', 'hideDevs');

    withPluginApi('0.8.12', api => {
      const user = api.getCurrentUser();

      user.findDetails().then(function() {
        const groups = user.get('groups');
        const inHideGroup = groups.find((g) => g.name == "hide_devs");

        if (inHideGroup) {
          api.modifyClass('model:composer', {
            hideDevs: false
          })

          api.onToolbarCreate(toolbar => {
            toolbar.addButton({
              id: "toggle-hide-devs-btn",
              group: "extras",
              icon: "user-secret",
              action: "toggleHideDevs"
            });
          });

          api.modifyClass('component:d-editor', {
            actions: {
              toggleHideDevs() {
                this.toggleProperty('outletArgs.composer.hideDevs');
              }
            }
          });
        }
      })
    })
  }
}

Server

# name: discourse-test
# about: test
# version: 1.0
# authors: Angus McLeod
# url: test.com

after_initialize do
   add_permitted_post_create_param('hide_devs')

   DiscourseEvent.on(:post_created) do |post, opts, user|
     puts "Hide devs: #{opts[:hide_devs]}"
   end
end