npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

moonshot-rails

v0.0.14

Published

A collection of Stimulus controllers for building SaaS applications with Rails

Downloads

202

Readme

npm version Gem Version

Moonshot Rails

A collection of Stimulus controllers and other helpers enabling faster building of SaaS applications using modern Rails and Stimulus. Most of these are heavily opinionated.

JavaScript Helpers

  1. Post Hog Analytics Stimulusjs wrapper
  2. Shepherdjs Stimulusjs wrapper
  3. Crisp Chat Stimulusjs wrapper

Content Helpers

  1. Jobs to be Done view component

Background Jobs

  1. Convertkit Subscribe / Unsubscribe

Installation

  bundle add moonshot-rails
  yarn add moonshot-rails

Generate an initializer

  bundle exec rails generate moonshot_rails

Include all the stimulus controllers

  # append this to `app/javascript/controllers/index.js`

  import { registerControllers } from 'moonshot-rails'
  registerControllers(application)

You can also pick and choose which controllers to include

  # append this to `app/javascript/controllers/index.js`

  import { PostHogController } from 'moonshot-rails'
  application.register('post-hog', PostHogController)

  # see the full list at https://github.com/cionescu/moonshot-rails/blob/main/app/assets/javascripts/moonshot/index.js

Contents

1. Post Hog Analytics Stimulusjs wrapper

I tend to use PostHog for session tracking and product usage analytics.

Usage:

In your layout file, add the following:

  = post_hog_tracker user: @user, enabled: Rails.env.production?, api_key: Settings.post_hog.api_key

Your User model needs to implement the following methods:

  • id - used to uniquely identify the user. I usually use the id column.
  • tracker_name - the display name for the user object. Could be User#full_name.
  • tracker_email - another way to identify the user.

2. Shepherdjs Stimulusjs wrapper

TODO

3. Crisp Chat Stimulusjs wrapper

Crisp is one of the options for a live chat/support widget. I tend to like to like it because it comes with an npm package, meaning I can wrap it in a Stimulus controller.

In the layout file, add the following:

  = crisp_chat user: current_user, enabled: Rails.env.production?, wrapper: :div, api_key: Settings.crisp.api_key

If you want to activate (open) the chat widget when clicking a link on the page, you can follow this pattern:

  You can reach out to us via the
  = crisp_chat(user: current_user, enabled: Rails.env.production?, wrapper: :span, api_key: Settings.crisp.api_key) do
    = link_to 'in-app chat', '#', data: { action: 'click->crisp#open' }, class: 'btn-link text-primary'

Similarly to the PostHog wrapper, the User model needs to implement the following methods:

  • tracker_name - the display name for the user object. Could be User#full_name.
  • tracker_email - another way to identify the user.

Release

Ruby Gem

  rake release

JavaScript Package

  npm run release