Skip to content

Commit

Permalink
Add origin to track different integration usage for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Varpuspaavi authored Dec 1, 2023
1 parent 01f34b7 commit b44abb2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/phraseapp-in-context-editor-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def enabled?
def disabled?
!config.enabled
end

def origin
config.origin
end
end

def self.configure
Expand Down
1 change: 1 addition & 0 deletions lib/phraseapp-in-context-editor-ruby/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Config
backend: PhraseApp::InContextEditor::BackendService.new,
prefix: "{{__",
suffix: "__}}"
origin: "in-context-editor-ruby"
}.freeze

CONFIG_OPTIONS.each do |option, default_value|
Expand Down
1 change: 1 addition & 0 deletions lib/phraseapp-in-context-editor-ruby/view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def load_in_context_editor(opts = {})
"datacenter" => PhraseApp::InContextEditor.datacenter,
"prefix" => PhraseApp::InContextEditor.prefix,
"suffix" => PhraseApp::InContextEditor.suffix
"origin" => PhraseApp::InContextEditor.origin
}.merge(opts)

snippet = <<-EOS
Expand Down
6 changes: 6 additions & 0 deletions spec/phraseapp-in-context-editor-ruby/view_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class Helpers
it { is_expected.to include("\"suffix\":\"__]]\"") }
end

describe "origin setting" do
before(:each) { PhraseApp::InContextEditor.config.origin = "__]]" }

it { is_expected.to include("\"origin\":\"in-context-editor-ruby\"") }
end

describe "overriding options" do
let(:opts) { {prefix: "__%%"} }
before(:each) { PhraseApp::InContextEditor.config.prefix = "__]]" }
Expand Down

0 comments on commit b44abb2

Please sign in to comment.