Class: WhopSDK::Resources::Events

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/events.rb,
sig/whop_sdk/resources/events.rbs

Overview

An Event records conversion or engagement activity for an account, such as page views, purchases, or leads. Each event ties the action to the person who took it, so activity can be attributed to the ads and links that drove it.

Use the Events API to send new tracking events and list the events recorded for a person.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Events

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

Parameters:



116
117
118
# File 'lib/whop_sdk/resources/events.rb', line 116

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account_id:, event_name:, action_source: nil, context: nil, currency: nil, custom_name: nil, duration: nil, event_id: nil, event_time: nil, plan_id: nil, product_id: nil, referrer_url: nil, resumed: nil, source: nil, title: nil, url: nil, user: nil, value: nil, request_options: {}) ⇒ WhopSDK::Models::EventCreateResponse

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

Tracks a conversion or engagement event for an account.

Parameters:

  • account_id (String)

    The account to associate with this event.

  • event_name (Symbol, WhopSDK::Models::EventCreateParams::EventName)

    The type of conversion or engagement event

  • action_source (Symbol, WhopSDK::Models::EventCreateParams::ActionSource, nil)

    The channel where an event originated

  • context (WhopSDK::Models::EventCreateParams::Context, nil)

    Tracking and attribution context.

  • currency (Symbol, WhopSDK::Models::EventCreateParams::Currency, nil)

    The available currencies on the platform

  • custom_name (String, nil)

    Custom event name when event_name is 'custom'. Maximum 35 chars for this value.

  • duration (Integer, nil)

    For 'leave' events: milliseconds the visitor spent on the page.

  • event_id (String, nil)

    Client-provided identifier for deduplication. Generated if omitted.

  • event_time (Time, nil)

    When the event occurred. Defaults to now.

  • plan_id (String, nil)

    The plan associated with the event.

  • product_id (String, nil)

    The product associated with the event.

  • referrer_url (String, nil)

    The referring URL.

  • resumed (Boolean, nil)

    For 'page' events: true when the page was restored from the back/forward cache.

  • source (String, nil)

    For 'identify' events: where the identity was captured (url, form, manual, ifram

  • title (String, nil)

    For 'page' events: the document title.

  • url (String, nil)

    The URL where the event occurred.

  • user (WhopSDK::Models::EventCreateParams::User, nil)

    User identity and profile data.

  • value (Float, nil)

    Monetary value associated with the event.

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

Returns:

See Also:



61
62
63
64
65
66
67
68
69
70
# File 'lib/whop_sdk/resources/events.rb', line 61

def create(params)
  parsed, options = WhopSDK::EventCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "events",
    body: parsed,
    model: WhopSDK::Models::EventCreateResponse,
    options: options
  )
end

#list(person_id:, account_id: nil, after: nil, before: nil, first: nil, from: nil, to: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::EventListResponse>

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

Lists pixel events for a person, most recent first. Events are shaped like the POST /events intake: attribution in context, identity in user.

acco

Parameters:

  • person_id (String)

    The ID of the person.

  • account_id (String)

    The ID of the account, which will look like biz_*. Optional for

  • after (String)

    A cursor for fetching events after a previous page.

  • before (String)

    A cursor for fetching events before a later page.

  • first (Integer)

    The number of events to return.

  • from (Integer)

    Start of the time range as a Unix timestamp.

  • to (Integer)

    End of the time range as a Unix timestamp. Defaults to now.

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

Returns:

See Also:



100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/whop_sdk/resources/events.rb', line 100

def list(params)
  parsed, options = WhopSDK::EventListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "events",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::EventListResponse,
    options: options
  )
end