Skip to content

Commit 8aa23ea

Browse files
committed
Merge branch 'master' into experiment
# Conflicts: # src/LaunchDarkly/LDClient.php
2 parents 1dc3408 + 4199948 commit 8aa23ea

File tree

13 files changed

+197
-38
lines changed

13 files changed

+197
-38
lines changed

.circleci/config.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
sudo apt-get -q update &&
8585
sudo apt-cache policy docker-ce &&
8686
sudo apt-get -qy install docker-ce
87-
- run: sudo apt-get -qy install redis-server
87+
- run: sudo apt-get -qy install redis-server curl
8888
- checkout
8989
- run:
9090
name: validate composer.json
@@ -109,6 +109,13 @@ jobs:
109109
name: start Consul
110110
command: ./consul agent -dev
111111
background: true
112+
- run:
113+
name: wait on Consul
114+
command: |
115+
until $(curl --output /dev/null --silent --fail --request PUT --data 'test' http://localhost:8500/v1/kv/initchecker); do
116+
echo 'still waiting on Consul...'; sleep 2;
117+
done
118+
timeout: 50
112119
- run:
113120
name: run tests
114121
command: vendor/bin/phpunit --log-junit ~/phpunit/junit.xml --coverage-text tests
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is this a support request?**
11+
This issue tracker is maintained by LaunchDarkly SDK developers and is intended for feedback on the SDK code. If you're not sure whether the problem you are having is specifically related to the SDK, or to the LaunchDarkly service overall, it may be more appropriate to contact the LaunchDarkly support team; they can help to investigate the problem and will consult the SDK team if necessary. You can submit a support request by going [here](https://support.launchdarkly.com/) and clicking "submit a request", or by emailing [email protected].
12+
13+
Note that issues filed on this issue tracker are publicly accessible. Do not provide any private account information on your issues. If your problem is specific to your account, you should submit a support request as described above.
14+
15+
**Describe the bug**
16+
A clear and concise description of what the bug is.
17+
18+
**To reproduce**
19+
Steps to reproduce the behavior.
20+
21+
**Expected behavior**
22+
A clear and concise description of what you expected to happen.
23+
24+
**Logs**
25+
If applicable, add any log output related to your problem.
26+
27+
**SDK version**
28+
The version of this SDK that you are using.
29+
30+
**Language version, developer tools**
31+
For instance, Go 1.11 or Ruby 2.5.3. If you are using a language that requires a separate compiler, such as C, please include the name and version of the compiler too.
32+
33+
**OS/platform**
34+
For instance, Ubuntu 16.04, Windows 10, or Android 4.0.3. If your code is running in a browser, please also include the browser type and version.
35+
36+
**Additional context**
37+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I would love to see the SDK [...does something new...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context about the feature request here.

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to the LaunchDarkly PHP SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [3.5.2] - 2019-04-11
6+
### Fixed:
7+
- In the 3.5.1 release, the `VERSION` constant was incorrectly still reporting the version as "3.5.0". The constant is now correct. There are no other changes in this release.
8+
9+
10+
## [3.5.1] - 2019-04-03
11+
### Fixed:
12+
- Setting user attributes to non-string values when a string was expected would cause analytics events not to be processed. The SDK will now convert attribute values to strings as needed.
13+
- If `track` or `identify` is called without a user, the SDK now logs a warning, and does not send an analytics event to LaunchDarkly (since it would not be processed without a user).
14+
515
## [3.5.0] - 2019-01-30
616
### Added:
717
- It is now possible to use Consul or DynamoDB as a data store with `ld-relay`, similar to the existing Redis integration. See `LaunchDarkly\Integrations\Consul` and `LaunchDarkly\Integrations\DynamoDb`, and the reference guide [Using a persistent feature store](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).

README.md

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,10 @@ About LaunchDarkly
152152
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
153153
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
154154
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
155-
* LaunchDarkly provides feature flag SDKs for
156-
* [Java](http://docs.launchdarkly.com/docs/java-sdk-reference "Java SDK")
157-
* [JavaScript](http://docs.launchdarkly.com/docs/js-sdk-reference "LaunchDarkly JavaScript SDK")
158-
* [PHP](http://docs.launchdarkly.com/docs/php-sdk-reference "LaunchDarkly PHP SDK")
159-
* [Python](http://docs.launchdarkly.com/docs/python-sdk-reference "LaunchDarkly Python SDK")
160-
* [Go](http://docs.launchdarkly.com/docs/go-sdk-reference "LaunchDarkly Go SDK")
161-
* [Node.JS](http://docs.launchdarkly.com/docs/node-sdk-reference "LaunchDarkly Node SDK")
162-
* [Electron](http://docs.launchdarkly.com/docs/electron-sdk-reference "LaunchDarkly Electron SDK")
163-
* [.NET](http://docs.launchdarkly.com/docs/dotnet-sdk-reference "LaunchDarkly .Net SDK")
164-
* [Ruby](http://docs.launchdarkly.com/docs/ruby-sdk-reference "LaunchDarkly Ruby SDK")
165-
* [iOS](http://docs.launchdarkly.com/docs/ios-sdk-reference "LaunchDarkly iOS SDK")
166-
* [Android](http://docs.launchdarkly.com/docs/android-sdk-reference "LaunchDarkly Android SDK")
155+
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list.
167156
* Explore LaunchDarkly
168-
* [launchdarkly.com](http://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
169-
* [docs.launchdarkly.com](http://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDKs
170-
* [apidocs.launchdarkly.com](http://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
171-
* [blog.launchdarkly.com](http://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
157+
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
158+
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
159+
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
160+
* [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates
172161
* [Feature Flagging Guide](https://github.com/launchdarkly/featureflags/ "Feature Flagging Guide") for best practices and strategies

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.5.0
1+
3.5.2

scripts/release.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
# This script updates the version in the client code. It does not need to do anything else to release
3+
# a new version, because Packagist will pick up the new version automatically by watching our public
4+
# repository.
5+
6+
# It takes exactly one argument: the new version.
7+
# It should be run from the root of this git repo like this:
8+
# ./scripts/release.sh 4.0.9
9+
10+
# When done you should commit and push the changes made.
11+
12+
set -uxe
13+
echo "Starting php-client release (version update only)"
14+
15+
VERSION=$1
16+
17+
echo $VERSION >./VERSION
18+
19+
# Update version in LDClient class
20+
LDCLIENT_PHP=src/LaunchDarkly/LDClient.php
21+
LDCLIENT_PHP_TEMP=./LDClient.php.tmp
22+
sed "s/const VERSION = '.*'/const VERSION = '${VERSION}'/g" $LDCLIENT_PHP > $LDCLIENT_PHP_TEMP
23+
mv $LDCLIENT_PHP_TEMP $LDCLIENT_PHP
24+
25+
echo "Done with php-client release (version update only)"

src/LaunchDarkly/EventSerializer.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private function filterEvent($e)
3737
return $ret;
3838
}
3939

40-
private function filterAttrs($attrs, &$json, $userPrivateAttrs, &$allPrivateAttrs)
40+
private function filterAttrs($attrs, &$json, $userPrivateAttrs, &$allPrivateAttrs, $stringify)
4141
{
4242
foreach ($attrs as $key => $value) {
4343
if ($value != null) {
@@ -46,15 +46,15 @@ private function filterAttrs($attrs, &$json, $userPrivateAttrs, &$allPrivateAttr
4646
array_search($key, $this->_privateAttrNames) !== false) {
4747
$allPrivateAttrs[$key] = true;
4848
} else {
49-
$json[$key] = $value;
49+
$json[$key] = $stringify ? strval($value) : $value;
5050
}
5151
}
5252
}
5353
}
5454

5555
private function serializeUser($user)
5656
{
57-
$json = array("key" => $user->getKey());
57+
$json = array("key" => strval($user->getKey()));
5858
$userPrivateAttrs = $user->getPrivateAttributeNames();
5959
$allPrivateAttrs = array();
6060

@@ -66,13 +66,15 @@ private function serializeUser($user)
6666
'name' => $user->getName(),
6767
'avatar' => $user->getAvatar(),
6868
'firstName' => $user->getFirstName(),
69-
'lastName' => $user->getLastName(),
70-
'anonymous' => $user->getAnonymous()
69+
'lastName' => $user->getLastName()
7170
);
72-
$this->filterAttrs($attrs, $json, $userPrivateAttrs, $allPrivateAttrs);
71+
$this->filterAttrs($attrs, $json, $userPrivateAttrs, $allPrivateAttrs, true);
72+
if ($user->getAnonymous()) {
73+
$json['anonymous'] = true;
74+
}
7375
if (!empty($user->getCustom())) {
7476
$customs = array();
75-
$this->filterAttrs($user->getCustom(), $customs, $userPrivateAttrs, $allPrivateAttrs);
77+
$this->filterAttrs($user->getCustom(), $customs, $userPrivateAttrs, $allPrivateAttrs, false);
7678
if ($customs) { // if this is empty, we will return a json array for 'custom' instead of an object
7779
$json['custom'] = $customs;
7880
}

src/LaunchDarkly/Impl/EventFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function newIdentifyEvent($user)
8888
return array(
8989
'kind' => 'identify',
9090
'creationDate' => Util::currentTimeUnixMillis(),
91-
'key' => $user->getKey(),
91+
'key' => strval($user->getKey()),
9292
'user' => $user
9393
);
9494
}

src/LaunchDarkly/LDClient.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class LDClient
1414
{
1515
const DEFAULT_BASE_URI = 'https://app.launchdarkly.com';
1616
const DEFAULT_EVENTS_URI = 'https://events.launchdarkly.com';
17-
const VERSION = '3.5.0';
17+
const VERSION = '3.5.2';
1818

1919
/** @var string */
2020
protected $_sdkKey;
@@ -280,6 +280,7 @@ public function track($eventName, $user, $data)
280280
}
281281
if (is_null($user) || $user->isKeyBlank()) {
282282
$this->_logger->warning("Track called with null user or null/empty user key!");
283+
return;
283284
}
284285
$this->_eventProcessor->enqueue($this->_eventFactoryDefault->newCustomEvent($eventName, $user, $data));
285286
}
@@ -294,6 +295,7 @@ public function identify($user)
294295
}
295296
if (is_null($user) || $user->isKeyBlank()) {
296297
$this->_logger->warning("Track called with null user or null/empty user key!");
298+
return;
297299
}
298300
$this->_eventProcessor->enqueue($this->_eventFactoryDefault->newIdentifyEvent($user));
299301
}

0 commit comments

Comments
 (0)