init() public static méthode

Initializes the default client to use. Uses the socket consumer by default.
public static init ( string $secret, array $options = [] )
$secret string your project's secret key
$options array passed straight to the client
Exemple #1
0
 public function __construct($cfg, $webhost)
 {
     $this->cfg = $cfg;
     $weburl = parse_url($webhost);
     $this->spaceHost = preg_replace('/\\.$/', '', $weburl['host']);
     // init Analytics lib
     \Segment::init($this->cfg['api_secret'], $this->cfg['api_options']);
 }
 function setUp()
 {
     date_default_timezone_set("UTC");
     Segment::init("oq0vdlg7yi", array("debug" => true));
 }
Exemple #3
0
    exit(0);
}
if (!rename($old, $file)) {
    print "error renaming from {$old} to {$new}\n";
    exit(1);
}
/**
 * File contents.
 */
$contents = file_get_contents($file);
$lines = explode("\n", $contents);
/**
 * Initialize the client.
 */
Segment::init($args["secret"], array("debug" => true, "error_handler" => function ($code, $msg) {
    print "{$code}: {$msg}\n";
    exit(1);
}));
/**
 * Payloads
 */
$total = 0;
$successful = 0;
foreach ($lines as $line) {
    if (!trim($line)) {
        continue;
    }
    $payload = json_decode($line, true);
    $dt = new DateTime($payload["timestamp"]);
    $ts = floatval($dt->getTimestamp() . "." . $dt->format("u"));
    $payload["timestamp"] = $ts;
    $type = $payload["type"];