public function testSummary() { $waka = Client::getInstance(); $waka->getStats('2015-11-02'); //$waka->getStats('2015-10-27'); foreach ($waka->dayStats as $dayStat) { try { $dayStat->findOrSave(); } catch (\Exception $e) { echo $e->getMessage(), PHP_EOL; } } foreach ($waka->durations as $duration) { try { $duration->findOrSave(); } catch (\Exception $e) { echo $e->getMessage(), PHP_EOL; } } //print_r($waka->dayStats); //print_r($waka->durations); /* foreach ($waka->dayStats as $dayStat) { var_dump(json_encode($dayStat)); break; } */ $client = KeenIOClient::factory(['projectId' => '558d2fff96773d40f566e8db', 'writeKey' => '37c06b3669e8b5dcfff4ba4a749a4d1dc68515d46a49b6ee5ed5fba40be7ef178a20f98556080ec32165d88467a0012e560708d59e7d72282bfe9847f2d722db062a9a0c6e2abce30c280b9e071f64bbea8e0f0934df3bcfa637567c6e698e56ea2ba0e1ad835751f2f9e98bf81ffa78', 'readKey' => '1026bfdc118a30dd49df97362e9dd3b38c8cb9c5f30d85257ddce11871f2416424d5f5d2445ebe6e7ac0107baf91a0f1b1f80cf96b19751c04745734f9d431043c044cab48a2016eb04cd83686b10f825622a80f0986c0794cd03288a6a2c814b7d1a0469c2c37f9cd10d2faa221651c']); //$client->addEvent('day_stat', $data); $events = array('daily' => $waka->dayStats, 'durations' => $waka->durations); //$client->addEvents($events); }
/** * Tests the creation of a Scoped Key */ public function testCreateScopedKey() { $client = KeenIOClient::factory(array('masterKey' => 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')); $filter = array('property_name' => 'id', 'operator' => 'eq', 'property_value' => '123'); $filters = array($filter); $allowed_operations = array('read'); $scopedKey = $client->createScopedKey($filters, $allowed_operations); $result = $client->decryptScopedKey($scopedKey); $expected = array('filters' => $filters, 'allowed_operations' => $allowed_operations); $this->assertEquals($expected, $result); }
/** * @param null $project * @return KeenIOClient * @throws ConfigurationException */ public function client($project = null) { $moduleOptions = $this->moduleOptions; if (is_null($project)) { $project = $moduleOptions->get('default'); } $projects = $this->getProjects(); if (!isset($projects[$project])) { throw new ConfigurationException(sprintf('No configuration found for \'%s\'', $project)); } $config = $projects[$project]; // Version if (is_null($config->get('version'))) { $config->set('version', self::DEFAULT_VERSION); } return KeenIOClient::factory(['projectId' => $config->get('projectId'), 'masterKey' => $config->get('masterKey'), 'writeKey' => $config->get('writeKey'), 'readKey' => $config->get('readKey'), 'version' => $config->get('version')]); }
public function init() { parent::init(); if (!$this->_projectId) { throw new InvalidConfigException('ProjectId cannot be empty!'); } if (!$this->_writeKey) { throw new InvalidConfigException('WriteKey cannot be empty!'); } if (!$this->_readKey) { throw new InvalidConfigException('Readkey cannot be empty!'); } //Create a new Keen object if it hasn't already been created if ($this->_keenio === null) { $configArray = ['projectId' => $this->_projectId, 'masterKey' => $this->_masterKey, 'writeKey' => $this->_writeKey, 'readKey' => $this->_readKey]; //Only add the version if it is properly set, if not use the version the //PHP SDK choses if ($this->_version !== null) { $configArray['version'] = $this->_version; } $this->_keenio = KeenIOClient::factory($configArray); } }
/** * Register the service provider. * * @return void */ public function register() { $this->app->singleton(KeenIOClient::class, function ($app) { return KeenIOClient::factory($app['config']['services.keen-io']); }); }
public function __construct(array $params, $dataFolder) { $this->client = KeenIOClient::factory(['projectId' => $params['keenio']['projectId'], 'writeKey' => $params['keenio']['writeKey'], 'readKey' => $params['keenio']['readKey']]); $this->processorConfig = $params['processors']; $this->dataFolder = $dataFolder; }
/** * Get things started. * * @param string $plugin_prefix Prefix of the plugin using this library. * @param string $plugin_name Name of the plugin, this will be sent to keen.io so you can identify the data easily. * @param string $installation_date Installation date of the plugin using this library. * @param string $days_passed How many days we should wait to show the tracking message. * @param string $project_id Keen.io project id. * @param [type] $write_key Keen.io write key. */ public function __construct($plugin_prefix, $plugin_name, $installation_date, $days_passed, $project_id, $write_key) { $this->plugin_prefix = sanitize_title($plugin_prefix); $this->plugin_name = strip_tags($plugin_name); $this->installation_date = strtotime($installation_date); $this->days_passed = $days_passed; $this->project_id = $project_id; $this->write_key = $write_key; require __DIR__ . '/vendor/autoload.php'; $this->helper = new TDP\Codeless(); $this->client = KeenIOClient::factory(array('projectId' => $this->project_id, 'writeKey' => $this->write_key)); }