Module: Hackle

Defined in:
lib/hackle.rb,
lib/hackle/client.rb,
lib/hackle/config.rb,
lib/hackle/version.rb,
lib/hackle/http/http.rb,
lib/hackle/models/slot.rb,
lib/hackle/models/user.rb,
lib/hackle/models/event.rb,
lib/hackle/models/bucket.rb,
lib/hackle/decision/decider.rb,
lib/hackle/models/variation.rb,
lib/hackle/decision/bucketer.rb,
lib/hackle/events/user_event.rb,
lib/hackle/models/event_type.rb,
lib/hackle/models/experiment.rb,
lib/hackle/workspaces/workspace.rb,
lib/hackle/events/event_processor.rb,
lib/hackle/events/event_dispatcher.rb,
lib/hackle/workspaces/http_workspace_fetcher.rb,
lib/hackle/workspaces/polling_workspace_fetcher.rb

Defined Under Namespace

Classes: Bucket, Bucketer, Client, Config, Decider, Decision, Event, EventDispatcher, EventProcessor, EventType, Experiment, HTTP, HttpWorkspaceFetcher, PollingWorkspaceFetcher, SdkInfo, Slot, UnexpectedResponseError, User, UserEvent, Variation, Workspace

Constant Summary collapse

VERSION =
'1.0.0'
SDK_NAME =
'ruby-sdk'

Class Method Summary collapse

Class Method Details

.client(sdk_key:, **options) ⇒ Client

Instantiates a Hackle client.

Parameters:

  • sdk_key (String)

    The SDK key of your Hackle environment

  • options

    Optional parameters of configuration options

Returns:

  • (Client)

    The Hackle client instance.

See Also:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/hackle.rb', line 19

def self.client(sdk_key:, **options)
  config = Config.new(options)
  sdk_info = SdkInfo.new(key: sdk_key)

  http_workspace_fetcher = HttpWorkspaceFetcher.new(config: config, sdk_info: sdk_info)
  polling_workspace_fetcher = PollingWorkspaceFetcher.new(config: config, http_fetcher: http_workspace_fetcher)

  event_dispatcher = EventDispatcher.new(config: config, sdk_info: sdk_info)
  event_processor = EventProcessor.new(config: config, event_dispatcher: event_dispatcher)

  polling_workspace_fetcher.start!
  event_processor.start!

  Client.new(
    config: config,
    workspace_fetcher: polling_workspace_fetcher,
    event_processor: event_processor,
    decider: Decider.new
  )
end

.event(key:, value: nil, **properties) ⇒ Event

Instantiate an event to be used for the hackle sdk.

The only required parameter is ‘key`, which must uniquely identify each event.

Examples:

Hackle.event(key: 'purchase')
Hackle.event(key: 'purchase', value: 42000.0, app_version: '1.0.1', payment_method: 'CARD' )

Parameters:

  • key (String)

    The unique key of the events.

  • value (Float) (defaults to: nil)

    Optional numeric value of the events (e.g. purchase_amount, quantity, etc.)

  • properties

    Additional properties of the events (e.g. app_version, os_type, etc.)

Returns:

  • (Event)

    The configured event object.



73
74
75
# File 'lib/hackle.rb', line 73

def self.event(key:, value: nil, **properties)
  Event.new(key: key, value: value, properties: properties)
end

.user(id:, **properties) ⇒ User

Instantiate a user to be used for the hackle sdk.

The only required parameter is ‘id`, which must uniquely identify each user.

Examples:

Hackle.user(id: 'ae2182e0')
Hackle.user(id: 'ae2182e0', app_version: '1.0.1', paying_customer: false)

Parameters:

  • id (String)

    The identifier of the user. (e.g. device_id, account_id etc.)

  • properties

    Additional properties of the user. (e.g. app_version, membership_grade, etc.)

Returns:

  • (User)

    The configured user object.



54
55
56
# File 'lib/hackle.rb', line 54

def self.user(id:, **properties)
  User.new(id: id, properties: properties)
end