Skip to content

Commit 736f9a4

Browse files
committed
Adding internal to post and topics
1 parent 26025eb commit 736f9a4

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

config/locales/server.en.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ en:
22
site_settings:
33
segment_io_enabled: "Is Segment IO enabled?"
44
segment_io_write_key: 'What is the segment io write key?'
5+
segment_io_internal_domain: 'What is the domain used to match internal users?'

config/settings.yml

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ plugins:
55
segment_io_write_key:
66
default: ''
77
client: false
8+
segment_io_internal_domain:
9+
default: ''
10+
client: false

plugin.rb

+12-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def emit_segment_user_identify
5151
username: username,
5252
email: email,
5353
created_at: created_at,
54-
internal: email.ends_with?('@pagerduty.com')
54+
internal: internal_user?
5555
},
5656
context: {
5757
ip: ip_address
@@ -65,6 +65,11 @@ def emit_segment_user_created
6565
event: 'Signed Up'
6666
)
6767
end
68+
69+
def internal_user?
70+
return false if SiteSetting.segment_io_internal_domain.blank?
71+
email.ends_with?(SiteSetting.segment_io_internal_domain)
72+
end
6873
end
6974

7075
require_dependency 'application_controller'
@@ -114,7 +119,8 @@ def emit_segment_post_created
114119
post_number: post_number,
115120
created_at: created_at,
116121
since_topic_created: (created_at - topic.created_at).to_i,
117-
reply_to_post_number: reply_to_post_number
122+
reply_to_post_number: reply_to_post_number,
123+
internal: user.internal_user?
118124
}
119125
)
120126
end
@@ -131,7 +137,8 @@ def emit_segment_topic_created
131137
properties: {
132138
slug: slug,
133139
title: title,
134-
url: url
140+
url: url,
141+
internal: user.internal_user?
135142
}
136143
)
137144
end
@@ -163,7 +170,8 @@ def emit_segment_post_liked
163170
event: 'Post Liked',
164171
properties: {
165172
post_id: target_post_id,
166-
topic_id: target_topic_id
173+
topic_id: target_topic_id,
174+
internal: user.internal_user?
167175
}
168176
)
169177
end

0 commit comments

Comments
 (0)