Module: ConvertSdk::GoalDataKey

Defined in:
lib/convert_sdk/enums/goal_data_key.rb

Overview

Recognized keys for conversion goal data (consumed by conversion tracking, Story 4.3). Wire strings byte-identical to the JS SDK (javascript-sdk/packages/enums/src/goal-data-key.ts).

Constant Summary collapse

AMOUNT =

Revenue amount. Wire: +amount+.

"amount"
PRODUCTS_COUNT =

Number of products. Wire: +productsCount+.

"productsCount"
TRANSACTION_ID =

Transaction identifier. Wire: +transactionId+.

"transactionId"
CUSTOM_DIMENSION_1 =

Custom dimension 1. Wire: +customDimension1+.

"customDimension1"
CUSTOM_DIMENSION_2 =

Custom dimension 2. Wire: +customDimension2+.

"customDimension2"
CUSTOM_DIMENSION_3 =

Custom dimension 3. Wire: +customDimension3+.

"customDimension3"
CUSTOM_DIMENSION_4 =

Custom dimension 4. Wire: +customDimension4+.

"customDimension4"
CUSTOM_DIMENSION_5 =

Custom dimension 5. Wire: +customDimension5+.

"customDimension5"
ALL =

All recognized goal-data keys, in declaration order. Frozen array for validation use (Story 4.3).

[
  AMOUNT, PRODUCTS_COUNT, TRANSACTION_ID,
  CUSTOM_DIMENSION_1, CUSTOM_DIMENSION_2, CUSTOM_DIMENSION_3,
  CUSTOM_DIMENSION_4, CUSTOM_DIMENSION_5
].freeze
RUBY_KEY_MAP =

The two-worlds mapping (Story 4.3): the PUBLIC Ruby +track_conversion+ +goal_data:+ surface accepts snake_case symbol keys; this is the SINGLE place the snake_case input is translated to the camelCase WIRE identifier. The conversion build site (DataManager#convert) consults this map to validate caller keys and emit the wire-correct +[value]+ pairs; any key absent here is unknown and rejected. Frozen so it cannot drift.

{
  amount: AMOUNT,
  products_count: PRODUCTS_COUNT,
  transaction_id: TRANSACTION_ID,
  custom_dimension_1: CUSTOM_DIMENSION_1,
  custom_dimension_2: CUSTOM_DIMENSION_2,
  custom_dimension_3: CUSTOM_DIMENSION_3,
  custom_dimension_4: CUSTOM_DIMENSION_4,
  custom_dimension_5: CUSTOM_DIMENSION_5
}.freeze

Class Method Summary collapse

Class Method Details

.wire_key_for(key) ⇒ String?

Translate a single caller-supplied +goal_data+ key (symbol or string, snake_case OR the camelCase wire form) to its wire identifier, or +nil+ when the key is not one of the eight platform keys (caller rejects it). Accepting the wire form too keeps the surface forgiving for integrators who already know the platform identifiers.

Parameters:

  • key (Symbol, String)

    the caller key.

Returns:

  • (String, nil)

    the wire identifier, or nil when unrecognized.



58
59
60
# File 'lib/convert_sdk/enums/goal_data_key.rb', line 58

def self.wire_key_for(key)
  RUBY_KEY_MAP[key.to_sym] || (ALL.include?(key.to_s) ? key.to_s : nil)
end