discourse/app/models/post_stat.rb
Martin Brennan 223b40de1c
FEATURE: Store composer version and device info on post stat (#31600)
We are developing our new composer, and it would be useful
if we could know how posts are being created by members.

To this end, we are going to start storing the following
on post_stats, which are created at the same time as a post
is created:

* writing_device - Based on `BrowserDetection.device`, which in
  turn is based on user agent. Will store .e.g iphone, android,
  mac, windows etc.
* writing_user_agent - Stores the full user agent (truncated at
  400 chars) of the device/browser the member used to write the post.
* composer_version - Either `1` for our old composer, or
  `2` if the new rich composer is enabled in site settings and
  the user has toggled it on
2025-03-05 12:48:32 +10:00

37 lines
1.1 KiB
Ruby

# frozen_string_literal: true
class PostStat < ActiveRecord::Base
# Version 1 is the original textarea composer for Discourse,
# which has been around since its inception and uses a split
# pane between markdown and preview.
#
# Version 2 is the new rich text composer, which is a single
# contendedibale using ProseMirror which is more of a WYSIWYG
# experience.
COMPOSER_VERSIONS = { 1 => "classic", 2 => "rich_text" }
belongs_to :post
end
# == Schema Information
#
# Table name: post_stats
#
# id :integer not null, primary key
# post_id :integer
# drafts_saved :integer
# typing_duration_msecs :integer
# composer_open_duration_msecs :integer
# created_at :datetime not null
# updated_at :datetime not null
# composer_version :integer
# writing_device :string
# writing_device_user_agent :string
#
# Indexes
#
# index_post_stats_on_composer_version (composer_version)
# index_post_stats_on_post_id (post_id)
# index_post_stats_on_writing_device (writing_device)
#