-
Notifications
You must be signed in to change notification settings - Fork 30
feat: Add init with sdk key #189
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
Changes from 1 commit
26dd1a0
4844558
f56015a
1b8d6ed
829a1d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
use Optimizely\Notification\NotificationCenter; | ||
use Optimizely\Notification\NotificationType; | ||
use Optimizely\OptimizelyConfig\OptimizelyConfigService; | ||
use Optimizely\ProjectConfigManager\HTTPProjectConfigManager; | ||
use Optimizely\ProjectConfigManager\ProjectConfigManagerInterface; | ||
use Optimizely\ProjectConfigManager\StaticProjectConfigManager; | ||
use Optimizely\UserProfile\UserProfileServiceInterface; | ||
|
@@ -96,7 +97,7 @@ class Optimizely | |
/** | ||
* @var ProjectConfigManagerInterface | ||
*/ | ||
private $_projectConfigManager; | ||
public $configManager; | ||
|
||
/** | ||
* @var NotificationCenter | ||
|
@@ -112,6 +113,7 @@ class Optimizely | |
* @param $errorHandler ErrorHandlerInterface | ||
* @param $skipJsonValidation boolean representing whether JSON schema validation needs to be performed. | ||
* @param $userProfileService UserProfileServiceInterface | ||
* @param $sdkKey string uniquely identifying the datafile corresponding to project and environment combination. Must provide at least one of datafile or sdkKey. | ||
* @param $configManager ProjectConfigManagerInterface provides ProjectConfig through getConfig method. | ||
* @param $notificationCenter NotificationCenter | ||
*/ | ||
|
@@ -122,6 +124,7 @@ public function __construct( | |
ErrorHandlerInterface $errorHandler = null, | ||
$skipJsonValidation = false, | ||
UserProfileServiceInterface $userProfileService = null, | ||
$sdkKey = null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this break previous versions since the order changed? Shouldn't this become the last parameter? Also ok if we file this as a breaking change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just tried to be consistent with python and ruby sdks. I would recommend to go for a breaking change and make sdkKey the first param of constructor. What do you suggest? |
||
ProjectConfigManagerInterface $configManager = null, | ||
NotificationCenter $notificationCenter = null | ||
) { | ||
|
@@ -132,7 +135,15 @@ public function __construct( | |
$this->_eventBuilder = new EventBuilder($this->_logger); | ||
$this->_decisionService = new DecisionService($this->_logger, $userProfileService); | ||
$this->notificationCenter = $notificationCenter ?: new NotificationCenter($this->_logger, $this->_errorHandler); | ||
$this->_projectConfigManager = $configManager ?: new StaticProjectConfigManager($datafile, $skipJsonValidation, $this->_logger, $this->_errorHandler); | ||
$this->configManager = $configManager; | ||
|
||
if ($this->configManager === null) { | ||
if ($sdkKey) { | ||
$this->configManager = new HTTPProjectConfigManager($sdkKey, null, null, true, $datafile, $skipJsonValidation, $this->_logger, $this->_errorHandler, $this->notificationCenter); | ||
} else { | ||
$this->configManager = new StaticProjectConfigManager($datafile, $skipJsonValidation, $this->_logger, $this->_errorHandler); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -141,7 +152,7 @@ public function __construct( | |
*/ | ||
protected function getConfig() | ||
{ | ||
$config = $this->_projectConfigManager->getConfig(); | ||
$config = $this->configManager->getConfig(); | ||
return $config instanceof DatafileProjectConfig ? $config : null; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this have to be public now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTPProjectConfigManager exposes a public method fetch, which the user can use to get the latest datafile from cdn. Previously, we were expecting the user to create it's own config manager and pass. Now, we will be creating httpconfigmanager given the sdk key so the user must be able to access it to fetch the latest datafile.