Skip to content

Commit 0e2c778

Browse files
authored
Merge pull request #10 from trakerr-com/develop
v1.1.0 Expose the properties those use so people can populate them on their own.
2 parents e544caf + c65ca7a commit 0e2c778

6 files changed

Lines changed: 249 additions & 9 deletions

File tree

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ $contextDeploymentStage = "development")
101101
```
102102
The TrakerrClient class however has a lot of exposed properties. The benefit to setting these immediately after after you create the TrakerrClient is that AppEvent will default it's values against the TrakerClient that created it. This way if there is a value that all your AppEvents uses, and the constructor default value currently doesn't suit you; it may be easier to change it in TrakerrClient as it will become the default value for all AppEvents created after. A lot of these are populated by default value by the constructor, but you can populate them with whatever string data you want. The following table provides an in depth look at each of those.
103103

104+
If you're populating an app event directly, you'll want to take a look at the [AppEvent properties](generated/SwaggerClient-php/docs/Model/AppEvent.md) as they contain properties unique to each AppEvent which do not have defaults you may set in the client.
105+
104106
Name | Type | Description | Notes
105107
------------ | ------------- | ------------- | -------------
106108
**apiKey** | **string** | API Key for your application. |
@@ -112,10 +114,11 @@ Name | Type | Description | Notes
112114
**contextEnvHostname** | **string** | Provide the current hostname. | Defaults Value: `gethostname()`.
113115
**contextAppOS** | **string** | Provide an operating system name. | Defaults Value: `php_uname("s")`.
114116
**contextAppOSVersion** | **string** | Provide an operating system version. | Default Value: `php_uname("v")`.
115-
**contextAppOSBrowser** | **string** | An optional string browser name the application is running on. | Defaults to `Null`
116-
**contextAppOSBrowserVersion** | **string** | An optional string browser version the application is running on. | Defaults to `Null`
117-
**contextDataCenter** | **string** | Data center the application is running on or connected to. | Defaults to `Null`
118-
**contextDataCenterRegion** | **string** | Data center region. | Defaults to `Null`
117+
**contextAppOSBrowser** | **string** | An optional string browser name the application is running on. | Defaults to `NULL`
118+
**contextAppOSBrowserVersion** | **string** | An optional string browser version the application is running on. | Defaults to `NULL`
119+
**contextDataCenter** | **string** | Data center the application is running on or connected to. | Defaults to `NULL`
120+
**contextDataCenterRegion** | **string** | Data center region. | Defaults to `NULL`
121+
**context_tags** | **string[]** | Any tags that describe the the module that this handler is for. | Defaults to `NULL`
119122

120123

121124
## Documentation For Models

generated/SwaggerClient-php/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Get your application events and errors to Trakerr via the *Trakerr API*.
44
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
55

66
- API version: 1.0.0
7-
- Build date: 2017-03-13T16:52:09.648-07:00
7+
- Build date: 2017-05-05T15:16:45.124-07:00
88
- Build package: class io.swagger.codegen.languages.PhpClientCodegen
99

1010
## Requirements

generated/SwaggerClient-php/docs/Model/AppEvent.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**api_key** | **string** | API key generated for the application |
77
**log_level** | **string** | (optional) Logging level, one of 'debug','info','warning','error', 'fatal', defaults to 'error' | [optional]
8-
**classification** | **string** | (optional) one of 'error' or a custom string for non-errors, defaults to 'error' |
8+
**classification** | **string** | (optional) one of 'issue' or a custom string for non-issues, defaults to 'issue' |
99
**event_type** | **string** | type of the event or error (eg. NullPointerException) |
1010
**event_message** | **string** | message containing details of the event or error |
1111
**event_time** | **int** | (optional) event time in ms since epoch | [optional]
@@ -24,6 +24,14 @@ Name | Type | Description | Notes
2424
**context_app_os_version** | **string** | (optional) OS version the application is running on | [optional]
2525
**context_data_center** | **string** | (optional) Data center the application is running on or connected to | [optional]
2626
**context_data_center_region** | **string** | (optional) Data center region | [optional]
27+
**context_tags** | **string[]** | | [optional]
28+
**context_url** | **string** | (optional) The full URL when running in a browser when the event was generated. | [optional]
29+
**context_operation_time_millis** | **int** | (optional) duration that this event took to occur in millis. Example - database call time in millis. | [optional]
30+
**context_cpu_percentage** | **int** | (optional) CPU utilization as a percent when event occured | [optional]
31+
**context_memory_percentage** | **int** | (optional) Memory utilization as a percent when event occured | [optional]
32+
**context_cross_app_correlation_id** | **string** | (optional) Cross application correlation ID | [optional]
33+
**context_device** | **string** | (optional) Device information | [optional]
34+
**context_app_sku** | **string** | (optional) Application SKU | [optional]
2735
**custom_properties** | [**\trakerr\client\model\CustomData**](CustomData.md) | | [optional]
2836
**custom_segments** | [**\trakerr\client\model\CustomData**](CustomData.md) | | [optional]
2937

generated/SwaggerClient-php/lib/model/AppEvent.php

Lines changed: 209 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ class AppEvent implements ArrayAccess
8787
'context_app_os_version' => 'string',
8888
'context_data_center' => 'string',
8989
'context_data_center_region' => 'string',
90+
'context_tags' => 'string[]',
91+
'context_url' => 'string',
92+
'context_operation_time_millis' => 'int',
93+
'context_cpu_percentage' => 'int',
94+
'context_memory_percentage' => 'int',
95+
'context_cross_app_correlation_id' => 'string',
96+
'context_device' => 'string',
97+
'context_app_sku' => 'string',
9098
'custom_properties' => '\trakerr\client\model\CustomData',
9199
'custom_segments' => '\trakerr\client\model\CustomData'
92100
);
@@ -122,6 +130,14 @@ public static function swaggerTypes()
122130
'context_app_os_version' => 'contextAppOSVersion',
123131
'context_data_center' => 'contextDataCenter',
124132
'context_data_center_region' => 'contextDataCenterRegion',
133+
'context_tags' => 'contextTags',
134+
'context_url' => 'contextURL',
135+
'context_operation_time_millis' => 'contextOperationTimeMillis',
136+
'context_cpu_percentage' => 'contextCpuPercentage',
137+
'context_memory_percentage' => 'contextMemoryPercentage',
138+
'context_cross_app_correlation_id' => 'contextCrossAppCorrelationId',
139+
'context_device' => 'contextDevice',
140+
'context_app_sku' => 'contextAppSku',
125141
'custom_properties' => 'customProperties',
126142
'custom_segments' => 'customSegments'
127143
);
@@ -157,6 +173,14 @@ public static function attributeMap()
157173
'context_app_os_version' => 'setContextAppOsVersion',
158174
'context_data_center' => 'setContextDataCenter',
159175
'context_data_center_region' => 'setContextDataCenterRegion',
176+
'context_tags' => 'setContextTags',
177+
'context_url' => 'setContextUrl',
178+
'context_operation_time_millis' => 'setContextOperationTimeMillis',
179+
'context_cpu_percentage' => 'setContextCpuPercentage',
180+
'context_memory_percentage' => 'setContextMemoryPercentage',
181+
'context_cross_app_correlation_id' => 'setContextCrossAppCorrelationId',
182+
'context_device' => 'setContextDevice',
183+
'context_app_sku' => 'setContextAppSku',
160184
'custom_properties' => 'setCustomProperties',
161185
'custom_segments' => 'setCustomSegments'
162186
);
@@ -192,6 +216,14 @@ public static function setters()
192216
'context_app_os_version' => 'getContextAppOsVersion',
193217
'context_data_center' => 'getContextDataCenter',
194218
'context_data_center_region' => 'getContextDataCenterRegion',
219+
'context_tags' => 'getContextTags',
220+
'context_url' => 'getContextUrl',
221+
'context_operation_time_millis' => 'getContextOperationTimeMillis',
222+
'context_cpu_percentage' => 'getContextCpuPercentage',
223+
'context_memory_percentage' => 'getContextMemoryPercentage',
224+
'context_cross_app_correlation_id' => 'getContextCrossAppCorrelationId',
225+
'context_device' => 'getContextDevice',
226+
'context_app_sku' => 'getContextAppSku',
195227
'custom_properties' => 'getCustomProperties',
196228
'custom_segments' => 'getCustomSegments'
197229
);
@@ -258,6 +290,14 @@ public function __construct(array $data = null)
258290
$this->container['context_app_os_version'] = isset($data['context_app_os_version']) ? $data['context_app_os_version'] : null;
259291
$this->container['context_data_center'] = isset($data['context_data_center']) ? $data['context_data_center'] : null;
260292
$this->container['context_data_center_region'] = isset($data['context_data_center_region']) ? $data['context_data_center_region'] : null;
293+
$this->container['context_tags'] = isset($data['context_tags']) ? $data['context_tags'] : null;
294+
$this->container['context_url'] = isset($data['context_url']) ? $data['context_url'] : null;
295+
$this->container['context_operation_time_millis'] = isset($data['context_operation_time_millis']) ? $data['context_operation_time_millis'] : null;
296+
$this->container['context_cpu_percentage'] = isset($data['context_cpu_percentage']) ? $data['context_cpu_percentage'] : null;
297+
$this->container['context_memory_percentage'] = isset($data['context_memory_percentage']) ? $data['context_memory_percentage'] : null;
298+
$this->container['context_cross_app_correlation_id'] = isset($data['context_cross_app_correlation_id']) ? $data['context_cross_app_correlation_id'] : null;
299+
$this->container['context_device'] = isset($data['context_device']) ? $data['context_device'] : null;
300+
$this->container['context_app_sku'] = isset($data['context_app_sku']) ? $data['context_app_sku'] : null;
261301
$this->container['custom_properties'] = isset($data['custom_properties']) ? $data['custom_properties'] : null;
262302
$this->container['custom_segments'] = isset($data['custom_segments']) ? $data['custom_segments'] : null;
263303
}
@@ -375,7 +415,7 @@ public function getClassification()
375415

376416
/**
377417
* Sets classification
378-
* @param string $classification (optional) one of 'error' or a custom string for non-errors, defaults to 'error'
418+
* @param string $classification (optional) one of 'issue' or a custom string for non-issues, defaults to 'issue'
379419
* @return $this
380420
*/
381421
public function setClassification($classification)
@@ -763,6 +803,174 @@ public function setContextDataCenterRegion($context_data_center_region)
763803
return $this;
764804
}
765805

806+
/**
807+
* Gets context_tags
808+
* @return string[]
809+
*/
810+
public function getContextTags()
811+
{
812+
return $this->container['context_tags'];
813+
}
814+
815+
/**
816+
* Sets context_tags
817+
* @param string[] $context_tags
818+
* @return $this
819+
*/
820+
public function setContextTags($context_tags)
821+
{
822+
$this->container['context_tags'] = $context_tags;
823+
824+
return $this;
825+
}
826+
827+
/**
828+
* Gets context_url
829+
* @return string
830+
*/
831+
public function getContextUrl()
832+
{
833+
return $this->container['context_url'];
834+
}
835+
836+
/**
837+
* Sets context_url
838+
* @param string $context_url (optional) The full URL when running in a browser when the event was generated.
839+
* @return $this
840+
*/
841+
public function setContextUrl($context_url)
842+
{
843+
$this->container['context_url'] = $context_url;
844+
845+
return $this;
846+
}
847+
848+
/**
849+
* Gets context_operation_time_millis
850+
* @return int
851+
*/
852+
public function getContextOperationTimeMillis()
853+
{
854+
return $this->container['context_operation_time_millis'];
855+
}
856+
857+
/**
858+
* Sets context_operation_time_millis
859+
* @param int $context_operation_time_millis (optional) duration that this event took to occur in millis. Example - database call time in millis.
860+
* @return $this
861+
*/
862+
public function setContextOperationTimeMillis($context_operation_time_millis)
863+
{
864+
$this->container['context_operation_time_millis'] = $context_operation_time_millis;
865+
866+
return $this;
867+
}
868+
869+
/**
870+
* Gets context_cpu_percentage
871+
* @return int
872+
*/
873+
public function getContextCpuPercentage()
874+
{
875+
return $this->container['context_cpu_percentage'];
876+
}
877+
878+
/**
879+
* Sets context_cpu_percentage
880+
* @param int $context_cpu_percentage (optional) CPU utilization as a percent when event occured
881+
* @return $this
882+
*/
883+
public function setContextCpuPercentage($context_cpu_percentage)
884+
{
885+
$this->container['context_cpu_percentage'] = $context_cpu_percentage;
886+
887+
return $this;
888+
}
889+
890+
/**
891+
* Gets context_memory_percentage
892+
* @return int
893+
*/
894+
public function getContextMemoryPercentage()
895+
{
896+
return $this->container['context_memory_percentage'];
897+
}
898+
899+
/**
900+
* Sets context_memory_percentage
901+
* @param int $context_memory_percentage (optional) Memory utilization as a percent when event occured
902+
* @return $this
903+
*/
904+
public function setContextMemoryPercentage($context_memory_percentage)
905+
{
906+
$this->container['context_memory_percentage'] = $context_memory_percentage;
907+
908+
return $this;
909+
}
910+
911+
/**
912+
* Gets context_cross_app_correlation_id
913+
* @return string
914+
*/
915+
public function getContextCrossAppCorrelationId()
916+
{
917+
return $this->container['context_cross_app_correlation_id'];
918+
}
919+
920+
/**
921+
* Sets context_cross_app_correlation_id
922+
* @param string $context_cross_app_correlation_id (optional) Cross application correlation ID
923+
* @return $this
924+
*/
925+
public function setContextCrossAppCorrelationId($context_cross_app_correlation_id)
926+
{
927+
$this->container['context_cross_app_correlation_id'] = $context_cross_app_correlation_id;
928+
929+
return $this;
930+
}
931+
932+
/**
933+
* Gets context_device
934+
* @return string
935+
*/
936+
public function getContextDevice()
937+
{
938+
return $this->container['context_device'];
939+
}
940+
941+
/**
942+
* Sets context_device
943+
* @param string $context_device (optional) Device information
944+
* @return $this
945+
*/
946+
public function setContextDevice($context_device)
947+
{
948+
$this->container['context_device'] = $context_device;
949+
950+
return $this;
951+
}
952+
953+
/**
954+
* Gets context_app_sku
955+
* @return string
956+
*/
957+
public function getContextAppSku()
958+
{
959+
return $this->container['context_app_sku'];
960+
}
961+
962+
/**
963+
* Sets context_app_sku
964+
* @param string $context_app_sku (optional) Application SKU
965+
* @return $this
966+
*/
967+
public function setContextAppSku($context_app_sku)
968+
{
969+
$this->container['context_app_sku'] = $context_app_sku;
970+
971+
return $this;
972+
}
973+
766974
/**
767975
* Gets custom_properties
768976
* @return \trakerr\client\model\CustomData

lib/TrakerrClient.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class TrakerrClient
6363
private $contextDataCenter;
6464
private $contextDataCenterRegion;
6565
private $errorHelper;
66+
private $contextTags;
6667

6768
/**
6869
* TrakerrClient constructor.
@@ -71,7 +72,7 @@ class TrakerrClient
7172
* @param string $contextAppVersion (optional) application version, defaults to 1.0
7273
* @param string $contextEnvName (optional) environment name like "development", "staging", "production" or a custom string
7374
*/
74-
public function __construct($apiKey, $contextAppVersion = "1.0", $contextDeploymentStage = "development")
75+
public function __construct($apiKey, $contextAppVersion = "1.0", $contextDeploymentStage = "development", $contextTags = NULL)
7576
{
7677
$this->apiKey = $apiKey;
7778
$this->contextAppVersion = is_null($contextAppVersion) ? "1.0" : $contextAppVersion;
@@ -86,6 +87,7 @@ public function __construct($apiKey, $contextAppVersion = "1.0", $contextDeploym
8687
$this->contextAppBrowserVersion = NULL;
8788
$this->contextDataCenter = NULL;
8889
$this->contextDataCenterRegion = NULL;
90+
$this->contextTags = $contextTags;
8991

9092
$apiClient = new ApiClient();
9193
$this->eventsApi = new EventsApi($apiClient);
@@ -201,7 +203,7 @@ private function fillDefaults(AppEvent $appEvent)
201203
}
202204

203205
if (is_null($appEvent->getEventTime())) {
204-
$appEvent->setEventTime($this->millitime());
206+
$appEvent->setEventTime(intval($this->millitime()));
205207
}
206208
return $appEvent;
207209
}
@@ -386,4 +388,17 @@ public function getContextDataCenterRegion()
386388
{
387389
return $this->contextDataCenterRegion;
388390
}
391+
392+
public function setContextTags($contexttags)
393+
{
394+
if (!is_array($contextdatacenterregion)) {
395+
throw new \InvalidArgumentException('Function only accepts an array of strings');
396+
}
397+
$this->contextTags = $contexttags;
398+
}
399+
400+
public function getContextTags()
401+
{
402+
return $this->contextTags;
403+
}
389404
}

testapp.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
$customStringData->setCustomData1("Some custom data");
3939
$customProperties->setStringData($customStringData);
4040
$appEvent2->setCustomProperties($customProperties);
41+
$appEvent2->setContextOperationTimeMillis(1000);
42+
$appEvent2->setContextCpuPercentage(60);
43+
$appEvent2->setContextMemoryPercentage(80);
44+
$appEvent2->setContextDevice("pc");
45+
$appEvent2->setContextAppSku("mobile");
46+
$appEvent2->setContextTags(["client, frontend"]);
4147

4248
$trakerrClient->sendEvent($appEvent2);
4349
}

0 commit comments

Comments
 (0)