Skip to content

Commit

Permalink
Merge pull request #29 from databox/bugfix/attributes
Browse files Browse the repository at this point in the history
Fix attributes usage
  • Loading branch information
ocvirksimon authored Sep 14, 2024
2 parents 88c4d6c + 77a4027 commit a2f0719
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ use Databox\Api\DefaultApi;
use Databox\ApiException;
use Databox\Configuration;
use Databox\Model\PushData as DataboxPushData;
use Databox\Model\PushDataAttribute;
use GuzzleHttp\Client;

execute();
Expand Down Expand Up @@ -79,8 +80,19 @@ function execute()
->setKey('<METRIC_KEY_NAME>') // for e.g. sessions
->setValue(125)
->setDate('2017-01-01T00:00:00Z') // Date in ISO8601 format
->setUnit('<UNIT>') // for e.g. $
->setAttributes(['<DIMENSION_VALUE>']); // for e.g. ['US']
->setUnit('<UNIT>'); // for e.g. $

// Optional
if (true) { // If you want to push data to a specific dimension
$pushDataAttribute = new PushDataAttribute(
[
'key' => '<DIMENSION_KEY>', // for e.g. country
'value' => '<DIMENSION_VALUE>' // for e.g. US
]
);

$pushData->setAttributes([$pushDataAttribute]);
}

try {
$apiInstance->dataPost([$pushData]);
Expand Down
16 changes: 14 additions & 2 deletions src/examples/pushData/PushData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Databox\ApiException;
use Databox\Configuration;
use Databox\Model\PushData as DataboxPushData;
use Databox\Model\PushDataAttribute;
use GuzzleHttp\Client;

execute();
Expand Down Expand Up @@ -33,8 +34,19 @@ function execute()
->setKey('<METRIC_KEY_NAME>') // for e.g. sessions
->setValue(125)
->setDate('2017-01-01T00:00:00Z') // Date in ISO8601 format
->setUnit('<UNIT>') // for e.g. $
->setAttributes(['<DIMENSION_VALUE>']); // for e.g. ['US']
->setUnit('<UNIT>'); // for e.g. $

// Optional
if (true) { // If you want to push data to a specific dimension
$pushDataAttribute = new PushDataAttribute(
[
'key' => '<DIMENSION_KEY>', // for e.g. country
'value' => '<DIMENSION_VALUE>' // for e.g. US
]
);

$pushData->setAttributes([$pushDataAttribute]);
}

try {
$apiInstance->dataPost([$pushData]);
Expand Down

0 comments on commit a2f0719

Please sign in to comment.