Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
Adding internal to post and topics
Browse files Browse the repository at this point in the history
  • Loading branch information
smasry committed May 28, 2017
1 parent 26025eb commit 736f9a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ en:
site_settings:
segment_io_enabled: "Is Segment IO enabled?"
segment_io_write_key: 'What is the segment io write key?'
segment_io_internal_domain: 'What is the domain used to match internal users?'
3 changes: 3 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ plugins:
segment_io_write_key:
default: ''
client: false
segment_io_internal_domain:
default: ''
client: false
16 changes: 12 additions & 4 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def emit_segment_user_identify
username: username,
email: email,
created_at: created_at,
internal: email.ends_with?('@pagerduty.com')
internal: internal_user?
},
context: {
ip: ip_address
Expand All @@ -65,6 +65,11 @@ def emit_segment_user_created
event: 'Signed Up'
)
end

def internal_user?
return false if SiteSetting.segment_io_internal_domain.blank?
email.ends_with?(SiteSetting.segment_io_internal_domain)
end
end

require_dependency 'application_controller'
Expand Down Expand Up @@ -114,7 +119,8 @@ def emit_segment_post_created
post_number: post_number,
created_at: created_at,
since_topic_created: (created_at - topic.created_at).to_i,
reply_to_post_number: reply_to_post_number
reply_to_post_number: reply_to_post_number,
internal: user.internal_user?
}
)
end
Expand All @@ -131,7 +137,8 @@ def emit_segment_topic_created
properties: {
slug: slug,
title: title,
url: url
url: url,
internal: user.internal_user?
}
)
end
Expand Down Expand Up @@ -163,7 +170,8 @@ def emit_segment_post_liked
event: 'Post Liked',
properties: {
post_id: target_post_id,
topic_id: target_topic_id
topic_id: target_topic_id,
internal: user.internal_user?
}
)
end
Expand Down

0 comments on commit 736f9a4

Please sign in to comment.