lib/SiftClient.php
public function track($event, $properties, $opts = array()) {
        $this->mergeArguments($opts, array(
            'return_score' => false,
            'return_action' => false,
            'return_workflow_status' => false,
            'force_workflow_run' => false,
            'abuse_types' => array(),
            'path' => null,
            'timeout' => $this->timeout,
            'version' => $this->version
        ));
        $this->validateArgument($event, 'event', 'string');
        $this->validateArgument($properties, 'properties', 'array');

        $path = $opts['path'];
        if (!$path) {
            $path = self::restApiUrl($opts['version']);
        }

        $properties['$api_key'] = $this->api_key;
        $properties['$type'] = $event;

        $params = array();
        if ($opts['return_score']) $params['return_score'] = 'true';
        if ($opts['return_action']) $params['return_action'] = 'true';
        if ($opts['return_workflow_status']) $params['return_workflow_status'] = 'true';
        if ($opts['force_workflow_run']) $params['force_workflow_run'] = 'true';
        if ($opts['abuse_types']) $params['abuse_types'] = implode(',', $opts['abuse_types']);

        try {
            $request = new SiftRequest(
                $path, SiftRequest::POST, $opts['timeout'], $opts['version'], array(
                    'body' => $properties,
                    'params' => $params
                ),
                $this->curl_opts
            );
            return $request->send();
        } catch (Exception $e) {
            $this->logError($e->getMessage());
            return null;
        }
    }
public function track($event, $properties, $opts = array()) {
        $this->mergeArguments($opts, array(
            'return_score' => false,
            'return_action' => false,
            'return_workflow_status' => false,
            'force_workflow_run' => false,
            'abuse_types' => array(),
            'path' => null,
            'timeout' => $this->timeout,
            'version' => $this->version
        ));
        $this->validateArgument($event, 'event', 'string');
        $this->validateArgument($properties, 'properties', 'array');

        $path = $opts['path'];
        if (!$path) {
            $path = self::restApiUrl($opts['version']);
        }

        $properties['$api_key'] = $this->api_key;
        $properties['$type'] = $event;

        $params = array();
        if ($opts['return_score']) $params['return_score'] = 'true';
        if ($opts['return_action']) $params['return_action'] = 'true';
        if ($opts['return_workflow_status']) $params['return_workflow_status'] = 'true';
        if ($opts['force_workflow_run']) $params['force_workflow_run'] = 'true';
        if ($opts['abuse_types']) $params['abuse_types'] = implode(',', $opts['abuse_types']);

        try {
            $request = new SiftRequest(
                $path, SiftRequest::POST, $opts['timeout'], $opts['version'], array(
                    'body' => $properties,
                    'params' => $params
                ),
                $this->curl_opts
            );
            return $request->send();
        } catch (Exception $e) {
            $this->logError($e->getMessage());
            return null;
        }
    }
public function track ( $ event , $ properties , $ opts = array ( ) ) { $ this -> mergeArguments ( $ opts , array ( 'return_score' => false , 'return_action' => false , 'return_workflow_status' => false , 'force_workflow_run' => false , 'abuse_types' => array ( ) , 'path' => null , 'timeout' => $ this -> timeout , 'version' => $ this -> version ) ) ; $ this -> validateArgument ( $ event , 'event' , 'string' ) ; $ this -> validateArgument ( $ properties , 'properties' , 'array' ) ; $ path = $ opts [ 'path' ] ; if ( ! $ path ) { $ path = self :: restApiUrl ( $ opts [ 'version' ] ) ; } $ properties [ '$api_key' ] = $ this -> api_key ; $ properties [ '$type' ] = $ event ; $ params = array ( ) ; if ( $ opts [ 'return_score' ] ) $ params [ 'return_score' ] = 'true' ; if ( $ opts [ 'return_action' ] ) $ params [ 'return_action' ] = 'true' ; if ( $ opts [ 'return_workflow_status' ] ) $ params [ 'return_workflow_status' ] = 'true' ; if ( $ opts [ 'force_workflow_run' ] ) $ params [ 'force_workflow_run' ] = 'true' ; if ( $ opts [ 'abuse_types' ] ) $ params [ 'abuse_types' ] = implode ( ',' , $ opts [ 'abuse_types' ] ) ; try { $ request = new SiftRequest ( $ path , SiftRequest :: POST , $ opts [ 'timeout' ] , $ opts [ 'version' ] , array ( 'body' => $ properties , 'params' => $ params ) , $ this -> curl_opts ) ; return $ request -> send ( ) ; } catch ( Exception $ e ) { $ this -> logError ( $ e -> getMessage ( ) ) ; return null ; } }
Tracks an event and associated properties through the Sift Science API.

See https://siftscience.com/resources/references/events_api.html for valid $event values
and $properties fields.

@param string $event  The type of the event to send. This can be either a reserved event name,
like $transaction or $label or a custom event name (that does not start with a $). This
parameter is required.

@param array $properties An array of name-value pairs that specify the event-specific
attributes to track.  This parameter is required.

@param array $opts  Array of optional parameters for this request:
- bool 'return_score': Whether to return the user's score as part of the API response.  The
score will include the posted event.
- bool 'return_action': Whether to return any actions triggered by this event as part of the
API response.
- bool 'return_workflow_status': Whether to return the status of any workflow run as a
result of the posted event in the API response.
- bool 'force_workflow_run': Whether to request an asynchronous workflow run if the
workflow is configured to only run with API request.
- array 'abuse_types': List of abuse types, specifying for which abuse types a score
should be returned (if scores were requested).  If not specified, a score will
be returned for every abuse_type to which you are subscribed.
- int 'timeout': By default, this client's timeout is used.
- string 'version': By default, this client's version is used.
- string 'path': The URL path to use for this call.  By default, the path for the requested
version of the Events API is used.

@return null|SiftResponse
Tracks an event and associated properties through the Sift Science API .