Skip to content

Commit 660eebc

Browse files
authored
fix: Add origin to track different integration usage for metrics (#62)
1 parent 01f34b7 commit 660eebc

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

lib/phraseapp-in-context-editor-ruby.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def enabled?
4848
def disabled?
4949
!config.enabled
5050
end
51+
52+
def origin
53+
config.origin
54+
end
5155
end
5256

5357
def self.configure

lib/phraseapp-in-context-editor-ruby/config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ class Config
88
enabled: false,
99
backend: PhraseApp::InContextEditor::BackendService.new,
1010
prefix: "{{__",
11-
suffix: "__}}"
11+
suffix: "__}}",
12+
origin: "in-context-editor-ruby"
1213
}.freeze
1314

1415
CONFIG_OPTIONS.each do |option, default_value|

lib/phraseapp-in-context-editor-ruby/view_helpers.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def load_in_context_editor(opts = {})
1717
"accountId" => PhraseApp::InContextEditor.account_id,
1818
"datacenter" => PhraseApp::InContextEditor.datacenter,
1919
"prefix" => PhraseApp::InContextEditor.prefix,
20-
"suffix" => PhraseApp::InContextEditor.suffix
20+
"suffix" => PhraseApp::InContextEditor.suffix,
21+
"origin" => PhraseApp::InContextEditor.origin
2122
}.merge(opts)
2223

2324
snippet = <<-EOS

spec/phraseapp-in-context-editor-ruby/view_helpers_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class Helpers
3737
it { is_expected.to include("\"suffix\":\"__]]\"") }
3838
end
3939

40+
describe "origin setting" do
41+
it { is_expected.to include("\"origin\":\"in-context-editor-ruby\"") }
42+
end
43+
4044
describe "overriding options" do
4145
let(:opts) { {prefix: "__%%"} }
4246
before(:each) { PhraseApp::InContextEditor.config.prefix = "__]]" }

0 commit comments

Comments
 (0)