function setUp()
 {
     date_default_timezone_set("UTC");
     Segment::init("oq0vdlg7yi", array("debug" => true));
 }
Exemple #2
0
    exit(0);
}
if (!rename($old, $file)) {
    print "error renaming from {$old} to {$file}\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"];