Class: OursprivacyIngest::Resources::Visitor

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Visitor

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 Visitor.

Parameters:



56
57
58
# File 'lib/oursprivacy_ingest/resources/visitor.rb', line 56

def initialize(client:)
  @client = client
end

Instance Method Details

#upsert(token:, user_properties:, default_properties: nil, email: nil, external_id: nil, identity_context: nil, user_id: nil, request_options: {}) ⇒ OursprivacyIngest::Models::VisitorUpsertResponse

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

Set or update properties on an existing visitor, or create a new visitor if no match is found. This fires a $identify event, making the call visible in the event stream. Identity resolution runs in priority order: userId (direct, no lookup) → externalId (lookup by your ID) → email (fallback lookup). When a visitor is found, their Ours Visitor ID is used going forward so all future events are attached to the same profile. For top-level visitor properties: null clears the existing value, while undefined, omitted fields, and empty strings are ignored. For entries inside custom_properties: null, undefined, and empty strings are all ignored (custom_properties use merge semantics). See docs.oursprivacy.com/docs/data-types for details and common pitfalls.

Parameters:

Returns:

See Also:



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/oursprivacy_ingest/resources/visitor.rb', line 41

def upsert(params)
  parsed, options = OursprivacyIngest::VisitorUpsertParams.dump_request(params)
  path = @client.base_url_overridden? ? "identify" : "https://api.oursprivacy.com/api/v1/identify"
  @client.request(
    method: :post,
    path: path,
    body: parsed,
    model: OursprivacyIngest::Models::VisitorUpsertResponse,
    options: options
  )
end