PHP Class Segment_Client

Show file Open project: segmentio/analytics-php Class Usage Examples

Protected Properties

Property Type Description
$consumer

Public Methods

Method Description
__construct ( string $secret, array $options = [] ) Create a new analytics object with your app's secret key
__destruct ( )
alias ( array $message ) : boolean Aliases from one user id to another
flush ( ) : boolean Flush any async consumers
group ( array $message ) : [boolean] Tags traits about the group.
identify ( array $message ) : [boolean] Tags traits about the user.
page ( array $message ) : [boolean] Tracks a page view.
screen ( array $message ) : [boolean] Tracks a screen view.
track ( array $message ) : [boolean] Tracks a user action

Private Methods

Method Description
formatTime ( $ts ) Formats a timestamp by making sure it is set and converting it to iso8601.
getContext ( ) : array Add the segment.io context to the request
message ( array $msg, string $def = "" ) : array Add common fields to the gvien message
messageId ( ) : string Generate a random messageId.

Method Details

__construct() public method

Create a new analytics object with your app's secret key
public __construct ( string $secret, array $options = [] )
$secret string
$options array array of consumer options [optional]

__destruct() public method

public __destruct ( )

alias() public method

Aliases from one user id to another
public alias ( array $message ) : boolean
$message array
return boolean whether the alias call succeeded

flush() public method

Flush any async consumers
public flush ( ) : boolean
return boolean true if flushed successfully

group() public method

Tags traits about the group.
public group ( array $message ) : [boolean]
$message array
return [boolean]

identify() public method

Tags traits about the user.
public identify ( array $message ) : [boolean]
$message array
return [boolean]

page() public method

Tracks a page view.
public page ( array $message ) : [boolean]
$message array
return [boolean]

screen() public method

Tracks a screen view.
public screen ( array $message ) : [boolean]
$message array
return [boolean]

track() public method

Tracks a user action
public track ( array $message ) : [boolean]
$message array
return [boolean]

Property Details

$consumer protected property

protected $consumer