Skip to content

Parse revenue value #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 27, 2018
Merged

Parse revenue value #91

merged 6 commits into from
Feb 27, 2018

Conversation

oakbani
Copy link
Contributor

@oakbani oakbani commented Feb 16, 2018

  • float/string values will now be accepted
  • Added logs to help debug

@optibot
Copy link

optibot commented Feb 16, 2018

Can one of the admins verify this patch?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 96.922% when pulling 48752e9 on oakbani/parse-revenue into eca6b6c on master.

@coveralls
Copy link

coveralls commented Feb 16, 2018

Coverage Status

Coverage increased (+0.09%) to 97.051% when pulling ef8df8e on oakbani/parse-revenue into 330e496 on master.

@mikeproeng37
Copy link
Contributor

build

{
if (!$logger) {
$logger = new NoOpLogger();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary because we already perform this logic here: https://github.com/optimizely/php-sdk/blob/master/src/Optimizely/Optimizely.php#L112

That should guarantee that the optimizely instance always has a valid logger

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This saves the effort to check $logger is not null before every log statement as in the method below

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it. However, my point is that we should assume here that we always pass in a valid logger because when we invoke getRevenue value, we will always have a valid logger and should just pass it in.

->method('log')
->with(Logger::DEBUG, "Revenue value couldn't be parsed as an integer.");

$this->assertNull(EventTagUtils::getRevenueValue(array('revenue' => 0.5), $this->loggerMock));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't these two parseable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The event api says that revenue has to be an integer. This PR accepts an int value even if it is passed as a float or string. Should we also entertain these values? If yes, do we pass it as a float or do we round off ro an int?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you are right. This is good.

@mikeproeng37
Copy link
Contributor

build

1 similar comment
@wangjoshuah
Copy link
Contributor

build

@oakbani
Copy link
Contributor Author

oakbani commented Feb 16, 2018

@mikeng13 Please review the updated PR. I realized that no logger was being passed to the method from EventBuilder, so basically no debug messaage logged from event tag utils when needed. Have added a logger to EventBuilder class and pass it on the function call.

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mikeproeng37
Copy link
Contributor

build

@mikeproeng37
Copy link
Contributor

build

Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mikeproeng37 mikeproeng37 merged commit 451dc1c into master Feb 27, 2018
@oakbani oakbani deleted the oakbani/parse-revenue branch March 5, 2018 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants