posthog-ruby 3.32.2 → 3.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3056f1b2b68fc770ad5d18e659f34d6d992baaee102184e0f4a6d8b7fae3758c
4
- data.tar.gz: 102c9721a7e7a99616948dbcd9486e4e6931d10eea192eff9c69f7cf7468416f
3
+ metadata.gz: 8da64dae9d5b02bfb1ad78f4557e4b9bfcba9c5e629dec50f71bb451968029e8
4
+ data.tar.gz: bcbd76ebc1e9f82e7cadd467be7793ab84255e0c67f8cbdfec1582fd1e9a1a48
5
5
  SHA512:
6
- metadata.gz: 04d40769af7139d68a82052011107f43467aab48472b2747b1bb770c6e83f77404cdea25c718ec0db518cbdabd17e40fca96af7ca7e39c750fd9fc2f6e150efa
7
- data.tar.gz: 2e9ef0c1931fda12ca37059632dd8d6e30eb889b9982c542e685b1846e1555daa26b638947daa0c7defb5ee1ebf0508d8d673b099ccbe37d5cba6c51a035d84f
6
+ metadata.gz: b8c19b770ee14ddc7b7dfabbce0fd50b1cfa421f544ab02ab0418a75673ded97a4f84b41eaf25be1b0dc31a0b1d8d6f87d49a9bb83d600dc1398cbdbe09c04ca
7
+ data.tar.gz: 070fad978093afa5ebbe163f2f56538f99812bfc90335e30f76c609ee521b9d521b34f0a387c70bad0ef51f8bdbe2ffc12ae38da96a08ffa827b0d28380e54ed
@@ -94,7 +94,7 @@ module PostHog
94
94
  "project's engagement setting."
95
95
  CODE_FORM_WHY = 'A send with template_key takes its content from your code.'
96
96
  TEMPLATE_FIELDS = %i[template_data].freeze
97
- CODE_FIELDS = %i[subject html text from reply_to capture_engagement].freeze
97
+ CODE_FIELDS = %i[subject html text from reply_to sensitive tracking capture_engagement].freeze
98
98
  NETWORK_ERRORS = [
99
99
  Timeout::Error, SocketError, SystemCallError, IOError, EOFError, OpenSSL::SSL::SSLError,
100
100
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, Zlib::Error
@@ -140,8 +140,22 @@ module PostHog
140
140
  # @param from [String] Code form: a verified sender, such as `Acme <hello@example.com>`. Without it, the
141
141
  # project's default sender.
142
142
  # @param reply_to [String, Array<String>] Code form: one address or a list of addresses.
143
- # @param capture_engagement [Boolean] Code form: whether PostHog captures the email's opens and clicks as events
144
- # of the recipient. Defaults to +true+. A project whose admin turned engagement capture off captures nothing.
143
+ # @param sensitive [Boolean] Code form: +true+ when the email carries login links, reset tokens or codes. A
144
+ # sensitive email keeps its links unchanged unless +tracking+ turns clicks on, leaves its subject off engagement
145
+ # events, and keeps its content out of logs. Left out, the email takes the setting of the template made in
146
+ # PostHog whose key matches +template_key+, and is sensitive when no template matches. Sent only when you set
147
+ # it, and needs a PostHog version that takes it.
148
+ # @param tracking [Boolean, Hash] Code form: what PostHog tracks for the email. Left out, PostHog counts opens and
149
+ # captures engagement events, and tracks clicks only when the email isn't sensitive. +true+ turns on opens,
150
+ # clicks and engagement events, even for a sensitive email. +false+ turns them all off: the email has no open
151
+ # pixel and no rewritten links, and PostHog captures no engagement events for it. A Hash such as
152
+ # +{ clicks: true }+ sets +:opens+ (default +true+), +:clicks+ (default: on unless the email is sensitive) and
153
+ # +:engagement+ (default +true+) one by one. Turn clicks on for a sensitive email only when its links are safe to
154
+ # rewrite. Click tracking needs open tracking. A project whose admin turned engagement capture off captures
155
+ # nothing, whatever the send says. Sent only when you set it, and needs a PostHog version that takes it.
156
+ # @param capture_engagement [Boolean] Deprecated: use +tracking: { engagement: false }+ instead. Code form:
157
+ # whether PostHog captures the email's engagement events. It still works, but a send can't set both. Sent
158
+ # only when you set it.
145
159
  # @param distinct_id [String] The recipient's distinct ID in your product. The email's events go to this
146
160
  # person. Without it, they go to a person whose distinct ID is the email address.
147
161
  # @param idempotency_key [String] 1 to 255 visible ASCII characters. A send with a key PostHog has already
@@ -155,11 +169,12 @@ module PostHog
155
169
  # @raise [ArgumentError] An argument has the wrong type or format, or the call mixes the two forms.
156
170
  def send(
157
171
  to:, template_id: nil, template_data: nil, template_key: nil, subject: nil, html: nil, text: nil, from: nil,
158
- reply_to: nil, capture_engagement: nil, distinct_id: nil, idempotency_key: nil, max_retries: nil
172
+ reply_to: nil, sensitive: nil, tracking: nil, capture_engagement: nil, distinct_id: nil, idempotency_key: nil,
173
+ max_retries: nil
159
174
  )
160
175
  fields = {
161
176
  template_data: template_data, subject: subject, html: html, text: text, from: from, reply_to: reply_to,
162
- capture_engagement: capture_engagement
177
+ sensitive: sensitive, tracking: tracking, capture_engagement: capture_engagement
163
178
  }.compact
164
179
  check_recipient(to, distinct_id, idempotency_key, max_retries)
165
180
  payload = content(template_id, template_key, fields).merge(to: to)
@@ -305,16 +320,29 @@ module PostHog
305
320
  %i[html text from].each do |name|
306
321
  raise ArgumentError, "#{name} must be a string." if fields.key?(name) && !fields[name].is_a?(String)
307
322
  end
308
- unless [nil, true, false].include?(fields[:capture_engagement])
309
- raise ArgumentError, 'capture_engagement must be true or false.'
323
+ %i[capture_engagement sensitive].each do |name|
324
+ raise ArgumentError, "#{name} must be true or false." unless [nil, true, false].include?(fields[name])
310
325
  end
311
326
 
312
327
  code = fields.slice(:subject, :html, :text, :from).merge(template_key: template_key)
313
328
  code[:reply_to] = addresses(fields[:reply_to]) if fields.key?(:reply_to)
314
- code[:capture_engagement] = fields.fetch(:capture_engagement, true)
329
+ code[:capture_engagement] = fields[:capture_engagement] if fields.key?(:capture_engagement)
330
+ code[:sensitive] = fields[:sensitive] if fields.key?(:sensitive)
331
+ code[:tracking] = tracking(fields[:tracking]) if fields.key?(:tracking)
315
332
  code
316
333
  end
317
334
 
335
+ def tracking(value)
336
+ return value if [true, false].include?(value)
337
+ raise ArgumentError, 'tracking must be true, false or a Hash such as { clicks: true }.' unless value.is_a?(Hash)
338
+
339
+ kinds = value.compact
340
+ kinds.each do |kind, on|
341
+ raise ArgumentError, "tracking[#{kind.inspect}] must be true or false." unless [true, false].include?(on)
342
+ end
343
+ kinds
344
+ end
345
+
318
346
  def refuse_fields(fields, allowed:, form:, other_form:, why:)
319
347
  field = fields.keys.find { |name| !allowed.include?(name) }
320
348
  return if field.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PostHog
4
- VERSION = '3.32.2'
4
+ VERSION = '3.33.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posthog-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.32.2
4
+ version: 3.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''