field_test 0.5.4 → 0.5.5
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 +4 -4
 - data/CHANGELOG.md +4 -0
 - data/README.md +0 -70
 - data/lib/field_test/experiment.rb +5 -0
 - data/lib/field_test/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f9182763b694b61f732e994e50f0b18f86d60fed181d302f885cd850f19831ae
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b5c0e167d8f0e942dad04fd19f565ec54f38593b6cb4501c5a8631670046dc39
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: cde68d5e3a16b45e2d29e25c2bbf7fc74190bc69a7ef11477b808619d54764f1107f254ac9eea893468c48678bb64545cf99ca2d57ee3f570335210f12c4e08a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9e82ce617955680184e3a79c01d1028e50a0a07ff26a6751cfffb47a68345223762742f41f40741ff52bd75e85c9706c845d438b4302544f5c923cdc211d6070
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -332,76 +332,6 @@ Now you can do: 
     | 
|
| 
       332 
332 
     | 
    
         
             
            user.field_test_memberships
         
     | 
| 
       333 
333 
     | 
    
         
             
            ```
         
     | 
| 
       334 
334 
     | 
    
         | 
| 
       335 
     | 
    
         
            -
            ## Upgrading
         
     | 
| 
       336 
     | 
    
         
            -
             
     | 
| 
       337 
     | 
    
         
            -
            ### 0.3.0
         
     | 
| 
       338 
     | 
    
         
            -
             
     | 
| 
       339 
     | 
    
         
            -
            Upgrade the gem and add to `config/field_test.yml`:
         
     | 
| 
       340 
     | 
    
         
            -
             
     | 
| 
       341 
     | 
    
         
            -
            ```yml
         
     | 
| 
       342 
     | 
    
         
            -
            legacy_participants: true
         
     | 
| 
       343 
     | 
    
         
            -
            ```
         
     | 
| 
       344 
     | 
    
         
            -
             
     | 
| 
       345 
     | 
    
         
            -
            Also, if you use Field Test in emails, know that the default way participants are determined has changed. Restore the previous way with:
         
     | 
| 
       346 
     | 
    
         
            -
             
     | 
| 
       347 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       348 
     | 
    
         
            -
            class ApplicationMailer < ActionMailer::Base
         
     | 
| 
       349 
     | 
    
         
            -
              def field_test_participant
         
     | 
| 
       350 
     | 
    
         
            -
                message.to.first
         
     | 
| 
       351 
     | 
    
         
            -
              end
         
     | 
| 
       352 
     | 
    
         
            -
            end
         
     | 
| 
       353 
     | 
    
         
            -
            ```
         
     | 
| 
       354 
     | 
    
         
            -
             
     | 
| 
       355 
     | 
    
         
            -
            We also recommend upgrading participants when you have time.
         
     | 
| 
       356 
     | 
    
         
            -
             
     | 
| 
       357 
     | 
    
         
            -
            #### Upgrading Participants
         
     | 
| 
       358 
     | 
    
         
            -
             
     | 
| 
       359 
     | 
    
         
            -
            Field Test 0.3.0 splits the `field_test_memberships.participant` column into `participant_type` and `participant_id`.
         
     | 
| 
       360 
     | 
    
         
            -
             
     | 
| 
       361 
     | 
    
         
            -
            To upgrade without downtime, create a migration:
         
     | 
| 
       362 
     | 
    
         
            -
             
     | 
| 
       363 
     | 
    
         
            -
            ```sh
         
     | 
| 
       364 
     | 
    
         
            -
            rails generate migration upgrade_field_test_participants
         
     | 
| 
       365 
     | 
    
         
            -
            ```
         
     | 
| 
       366 
     | 
    
         
            -
             
     | 
| 
       367 
     | 
    
         
            -
            with:
         
     | 
| 
       368 
     | 
    
         
            -
             
     | 
| 
       369 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       370 
     | 
    
         
            -
            class UpgradeFieldTestParticipants < ActiveRecord::Migration[6.0]
         
     | 
| 
       371 
     | 
    
         
            -
              def change
         
     | 
| 
       372 
     | 
    
         
            -
                add_column :field_test_memberships, :participant_type, :string
         
     | 
| 
       373 
     | 
    
         
            -
                add_column :field_test_memberships, :participant_id, :string
         
     | 
| 
       374 
     | 
    
         
            -
             
     | 
| 
       375 
     | 
    
         
            -
                add_index :field_test_memberships, [:participant_type, :participant_id, :experiment],
         
     | 
| 
       376 
     | 
    
         
            -
                  unique: true, name: "index_field_test_memberships_on_participant_and_experiment"
         
     | 
| 
       377 
     | 
    
         
            -
              end
         
     | 
| 
       378 
     | 
    
         
            -
            end
         
     | 
| 
       379 
     | 
    
         
            -
            ```
         
     | 
| 
       380 
     | 
    
         
            -
             
     | 
| 
       381 
     | 
    
         
            -
            After you run it, writes will go to both the old and new sets of columns.
         
     | 
| 
       382 
     | 
    
         
            -
             
     | 
| 
       383 
     | 
    
         
            -
            Next, backfill data:
         
     | 
| 
       384 
     | 
    
         
            -
             
     | 
| 
       385 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       386 
     | 
    
         
            -
            FieldTest::Membership.where(participant_id: nil).find_each do |membership|
         
     | 
| 
       387 
     | 
    
         
            -
              participant = membership.participant
         
     | 
| 
       388 
     | 
    
         
            -
             
     | 
| 
       389 
     | 
    
         
            -
              if participant.include?(":")
         
     | 
| 
       390 
     | 
    
         
            -
                participant_type, _, participant_id = participant.rpartition(":")
         
     | 
| 
       391 
     | 
    
         
            -
                participant_type = nil if participant_type == "cookie" # legacy
         
     | 
| 
       392 
     | 
    
         
            -
              else
         
     | 
| 
       393 
     | 
    
         
            -
                participant_id = participant
         
     | 
| 
       394 
     | 
    
         
            -
              end
         
     | 
| 
       395 
     | 
    
         
            -
             
     | 
| 
       396 
     | 
    
         
            -
              membership.update!(
         
     | 
| 
       397 
     | 
    
         
            -
                participant_type: participant_type,
         
     | 
| 
       398 
     | 
    
         
            -
                participant_id: participant_id
         
     | 
| 
       399 
     | 
    
         
            -
              )
         
     | 
| 
       400 
     | 
    
         
            -
            end
         
     | 
| 
       401 
     | 
    
         
            -
            ```
         
     | 
| 
       402 
     | 
    
         
            -
             
     | 
| 
       403 
     | 
    
         
            -
            Finally, remove `legacy_participants: true` from the config file. Once you confirm it’s working, you can drop the `participant` column (you can rename it first just to be extra safe).
         
     | 
| 
       404 
     | 
    
         
            -
             
     | 
| 
       405 
335 
     | 
    
         
             
            ## Credits
         
     | 
| 
       406 
336 
     | 
    
         | 
| 
       407 
337 
     | 
    
         
             
            A huge thanks to [Evan Miller](https://www.evanmiller.org/) for deriving the Bayesian formulas.
         
     | 
| 
         @@ -8,6 +8,11 @@ module FieldTest 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  @name = attributes[:name] || @id.to_s.titleize
         
     | 
| 
       9 
9 
     | 
    
         
             
                  @description = attributes[:description]
         
     | 
| 
       10 
10 
     | 
    
         
             
                  @variants = attributes[:variants]
         
     | 
| 
      
 11 
     | 
    
         
            +
                  if @variants.any? { |v| !v.is_a?(String) }
         
     | 
| 
      
 12 
     | 
    
         
            +
                    # TODO add support for more types (including query parameters)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    # or raise error in 0.6
         
     | 
| 
      
 14 
     | 
    
         
            +
                    warn "[field_test] Only string variants are supported (#{id})"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
       11 
16 
     | 
    
         
             
                  @weights = @variants.size.times.map { |i| attributes[:weights].to_a[i] || 1 }
         
     | 
| 
       12 
17 
     | 
    
         
             
                  @winner = attributes[:winner]
         
     | 
| 
       13 
18 
     | 
    
         
             
                  @closed = attributes[:closed]
         
     | 
    
        data/lib/field_test/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: field_test
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.5. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.5.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Andrew Kane
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-01-30 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: railties
         
     | 
| 
         @@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       124 
124 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       125 
125 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       126 
126 
     | 
    
         
             
            requirements: []
         
     | 
| 
       127 
     | 
    
         
            -
            rubygems_version: 3. 
     | 
| 
      
 127 
     | 
    
         
            +
            rubygems_version: 3.4.1
         
     | 
| 
       128 
128 
     | 
    
         
             
            signing_key:
         
     | 
| 
       129 
129 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       130 
130 
     | 
    
         
             
            summary: A/B testing for Rails
         
     |