Class: OursprivacyIngest::Resources::Experiments

Inherits:
Object
  • Object
show all
Defined in:
lib/oursprivacy_ingest/resources/experiments.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Experiments

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Experiments.

Parameters:



86
87
88
# File 'lib/oursprivacy_ingest/resources/experiments.rb', line 86

def initialize(client:)
  @client = client
end

Instance Method Details

#assignment(experiment_key, token:, visitor_id:, context: nil, track_impression: nil, request_options: {}) ⇒ OursprivacyIngest::Models::ExperimentAssignmentResponse::UnionMember0, OursprivacyIngest::Models::ExperimentAssignmentResponse::UnionMember1

Some parameter documentations has been truncated, see Models::ExperimentAssignmentParams for more details.

Return the server-side variant assignment for a visitor in a single A/B or multivariate experiment, identified by its experiment key. Bucketing is deterministic on ‘visitor_id` and is sticky across calls. Tracking an impression is the default — pass `track_impression: false` to read without recording. The browser SDK and this endpoint converge on the same variant for the same visitor.

Parameters:

  • experiment_key (String)

    The experiment’s stable key. Surfaced in the dashboard under each experiment’s s

  • token (String)

    The experiment token (‘exp_*`) for the experiment settings holding this experime

  • visitor_id (String)

    Stable identifier for the visitor — typically the Ours visitor id from your brow

  • context (OursprivacyIngest::Models::ExperimentAssignmentParams::Context, nil)

    Optional page context for URL + query-param eligibility. Variant bucketing is de

  • track_impression (Boolean, nil)

    When true (default), an ‘$experiment_impression` event is enqueued and the visit

  • request_options (OursprivacyIngest::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/oursprivacy_ingest/resources/experiments.rb', line 32

def assignment(experiment_key, params)
  parsed, options = OursprivacyIngest::ExperimentAssignmentParams.dump_request(params)
  path =
    if @client.base_url_overridden?
      [
        "experiments/assignments/%1$s",
        experiment_key
      ]
    else
      [
        "https://api.oursprivacy.com/api/v1/experiments/assignments/%1$s", experiment_key
      ]
    end
  @client.request(
    method: :post,
    path: path,
    body: parsed,
    model: OursprivacyIngest::Models::ExperimentAssignmentResponse,
    options: options
  )
end

#personalization(token:, visitor_id:, request_options: {}) ⇒ OursprivacyIngest::Models::ExperimentPersonalizationResponse

Return the active personalization assignments for a visitor. Read-only and never records an impression. Personalizations are populated by the event-driven rule engine — until that ships, this endpoint returns an empty list for every visitor, which is the correct fail-closed behavior (no false positives).

Parameters:

Returns:

See Also:



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/oursprivacy_ingest/resources/experiments.rb', line 70

def personalization(params)
  parsed, options = OursprivacyIngest::ExperimentPersonalizationParams.dump_request(params)
  path =
    @client.base_url_overridden? ? "experiments/personalization" : "https://api.oursprivacy.com/api/v1/experiments/personalization"
  @client.request(
    method: :post,
    path: path,
    body: parsed,
    model: OursprivacyIngest::Models::ExperimentPersonalizationResponse,
    options: options
  )
end