Category Archives: Viget

You Should Use Snowplow

What is Snowplow?

Snowplow is a flexible and dynamic data collection platform that gives you complete ownership of your event data pipeline. It runs on the cloud of your choice, Amazon Web Services (AWS) or Google Cloud Platform (GCP).

Snowplow events, entities–users, products, transactions, and their associated behavior across your multiple platforms—and fully custom events are tracked to scalable data warehouses like Amazon Redshift, Google Cloud BigQuery, or Snowflake. You can consume data in real-time from Amazon Kinesis streams, Google Cloud Pub/Sub topics, and Elasticsearch clusters. From there, analyze the data using business intelligence tools like Mode and Looker, aggregate the data for holistic reporting, or use the hit-level data to power machine learning applications.

read more

Four Uses for ActiveInteraction

On a recent project we made extensive use of the ActiveInteraction gem.
Its a Ruby implementation of the command pattern that works well with Rails for validating inputs, performing isolated pieces of work, and cleanly returning results or errors.
The project was a JSON API which interacted with a number of external services.
We were tasked with getting the project started, establishing some conventions and patterns, and then handing it back to an internal team to finish development.
At the end of the engagement, our team was happy with the code and the client team was able to hit the ground running.

ActiveInteraction

ActiveInteraction is “an implementation of the command pattern in Ruby”. This post which announced the gem does a nice job of explaining the motivation behind the gem. It came from a rails project which was running into a fairly common problem: bloated controllers. The developers wanted to leave their models concerned with persistence and keep their controllers concerned with request logic. But where to put the business logic that the application was actually supposed to implement? Enter the interactor pattern, which houses application specific business rules in interactor objects, and isolates details like which database the application uses, or whether it renders the data as html views or json payloads. The interactor is responsible for validating what input the application accepts, performing some work, and returning whether the work was successful or not.

ActiveInteraction takes this concept and implements it for use in a Rails environment. ActiveInteraction objects respond to the same validations and errors API that ActiveModel does, so they can be seamlessly integrated into Rails forms. One of our favorite features was composition, which lets you call an interactor from within another interactor. If the called interactor fails, it will terminate and add its errors to the caller. This lets you nest interactors several layers deep without the top level needing to handle lower level failures or know anything about the interactor that caused it.

Our uses

We found the command pattern really handy, and used it in several different ways: for controller actions, to handle state transitions, to wrap external services, and for use as miscellaneous service objects. I’ll give examples of each, in a fictional domain, and provide some assessment as to whether it ended up being a good use case for the pattern or not.

1) Controller Actions:

Every public controller method was backed by a corresponding interaction defined in app/controllers/controller_actions/MODEL_NAME/ACTION_NAME. A controller action takes inputs from the controller and returns a serialized object.

Our controllers actions looked like:

def create
  inputs = create_params
  outcome = ControllerActions::Animals::Create.run(inputs)
  render_outcome(outcome, success_status: 201)
end

Which was backed by an interaction like:

module ControllerActions
  module Animals
    # Interaction for AnimalsController#create
    class Create < ::ControllerActions::Base
      date_time :birthday, default: nil
      string :name
      string :favorite_food

      def execute
        serialize(animal, with: AnimalSerializer)
      end

      private

      def animal 
        @animal ||= compose(
          ::Animals::Create,
          name: name,
          favorite_food: favorite_food,
          birthday: birthday
        )
      end
    end
  end
end

read more

Four Uses for ActiveInteraction

On a recent project we made extensive use of the ActiveInteraction gem.
Its a Ruby implementation of the command pattern that works well with Rails for validating inputs, performing isolated pieces of work, and cleanly returning results or errors.
The project was a JSON API which interacted with a number of external services.
We were tasked with getting the project started, establishing some conventions and patterns, and then handing it back to an internal team to finish development.
At the end of the engagement, our team was happy with the code and the client team was able to hit the ground running.

ActiveInteraction

ActiveInteraction is “an implementation of the command pattern in Ruby”. This post which announced the gem does a nice job of explaining the motivation behind the gem. It came from a rails project which was running into a fairly common problem: bloated controllers. The developers wanted to leave their models concerned with persistence and keep their controllers concerned with request logic. But where to put the business logic that the application was actually supposed to implement? Enter the interactor pattern, which houses application specific business rules in interactor objects, and isolates details like which database the application uses, or whether it renders the data as html views or json payloads. The interactor is responsible for validating what input the application accepts, performing some work, and returning whether the work was successful or not.

ActiveInteraction takes this concept and implements it for use in a Rails environment. ActiveInteraction objects respond to the same validations and errors API that ActiveModel does, so they can be seamlessly integrated into Rails forms. One of our favorite features was composition, which lets you call an interactor from within another interactor. If the called interactor fails, it will terminate and add its errors to the caller. This lets you nest interactors several layers deep without the top level needing to handle lower level failures or know anything about the interactor that caused it.

Our uses

We found the command pattern really handy, and used it in several different ways: for controller actions, to handle state transitions, to wrap external services, and for use as miscellaneous service objects. I’ll give examples of each, in a fictional domain, and provide some assessment as to whether it ended up being a good use case for the pattern or not.

1) Controller Actions:

Every public controller method was backed by a corresponding interaction defined in app/controllers/controller_actions/MODEL_NAME/ACTION_NAME. A controller action takes inputs from the controller and returns a serialized object.

Our controllers actions looked like:

def create
  inputs = create_params
  outcome = ControllerActions::Animals::Create.run(inputs)
  render_outcome(outcome, success_status: 201)
end

Which was backed by an interaction like:

module ControllerActions
  module Animals
    # Interaction for AnimalsController#create
    class Create < ::ControllerActions::Base
      date_time :birthday, default: nil
      string :name
      string :favorite_food

      def execute
        serialize(animal, with: AnimalSerializer)
      end

      private

      def animal 
        @animal ||= compose(
          ::Animals::Create,
          name: name,
          favorite_food: favorite_food,
          birthday: birthday
        )
      end
    end
  end
end

read more

Value Over Invention: Breaking Down the Promise of IoT (Part 2)

In Part 1 of this article series, we outlined a high-level overview of the Internet of Things and established a philosophy for identifying the value of potential use-cases of connected devices. Using this mindset, we will now dive into the realm of consumer products, currently the most visible and glamorous application of IoT, to scope out the best way to deliver value to customers instead of simply new tech.

The value of a consumer product is determined, naturally, by the consumer, the most fickle of stakeholders. Unlike a business, the consumer’s accounting of value is nuanced and complex, transcending the simple math of revenue and cost. IoT consumer products are graded against the same rubric that non-connected consumer products are subject to—measures of their functional, emotional and social impact (check out this excellent breakdown of those factors in Harvard Business Review). However, regardless of the problem they are trying to solve for consumers, smart products must focus their design considerations in two areas more so than their non-connected counterparts to not dilute their value proposition: usability and integration.

read more

Celebrating 19 Years of Talent

Quarterly retreats are a longstanding tradition at Viget. Since our founding, we’ve taken a day each quarter to step away and focus on us. We come together, reflect on progress, share new ideas, realign, and do something fun as a team. In the last year, we’ve curled, shot pool, and cheered on our local baseball teams.

For the summer and winter retreats, our three offices meet locally and follow the same format: thoughtful meeting, followed by fun. But in the fall and spring we come together as one big team, getting the whole company together in one place. I know we say it every year, but this year was better than ever.

read more