-
Notifications
You must be signed in to change notification settings - Fork 2
Basic implementation #2
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
81efe90
base implementation, based on browser sdk
EmilianoSanchez 5fd58be
Merge branch 'setup_repo' into base_implementation
EmilianoSanchez 694f0c3
updated comment
EmilianoSanchez 4006f63
emi's feedback
EmilianoSanchez 5d85e78
emi's feedback
EmilianoSanchez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| export { InMemoryStorageCSFactory } from '@splitsoftware/splitio-commons'; | ||
| export { packageVersion } from './settings/defaults'; | ||
| export { SplitFactory } from './splitFactory'; | ||
| export { ErrorLogger } from '@splitsoftware/splitio-commons/src/logger/browser/ErrorLogger'; | ||
| export { WarnLogger } from '@splitsoftware/splitio-commons/src/logger/browser/WarnLogger'; | ||
| export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/InfoLogger'; | ||
| export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { splitApiFactory } from '@splitsoftware/splitio-commons/src/services/splitApi'; | ||
| import { syncManagerOnlineFactory } from '@splitsoftware/splitio-commons/src/sync/syncManagerOnline'; | ||
| import pushManagerFactory from '@splitsoftware/splitio-commons/src/sync/streaming/pushManager'; | ||
| import pollingManagerCSFactory from '@splitsoftware/splitio-commons/src/sync/polling/pollingManagerCS'; | ||
| import { sdkManagerFactory } from '@splitsoftware/splitio-commons/src/sdkManager/index'; | ||
| import { sdkClientMethodCSFactory } from '@splitsoftware/splitio-commons/src/sdkClient/sdkClientMethodCS'; | ||
| import { impressionObserverCSFactory } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/impressionObserverCS'; | ||
| import integrationsManagerFactory from '@splitsoftware/splitio-commons/src/integrations/pluggable'; | ||
| import EventEmitter from '@splitsoftware/splitio-commons/src/utils/MinEvents'; | ||
|
|
||
| import { shouldAddPt } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/utils'; | ||
| import type { ISettingsInternal } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/types'; | ||
| import type { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types'; | ||
|
|
||
| const rnPlatform = { | ||
| // No `getFetch` provided. RN provides global fetch. | ||
|
|
||
| // @TODO provide `getEventSource` implementation | ||
|
|
||
| EventEmitter, | ||
| }; | ||
|
|
||
| const syncManagerOnlineCSFactory = syncManagerOnlineFactory( | ||
| pollingManagerCSFactory, | ||
| pushManagerFactory | ||
| ); | ||
|
|
||
| /** | ||
| * Get minimal modules for RN client-side SDK in standalone mode and with online syncManager. | ||
| */ | ||
| export function getModules(settings: ISettingsInternal): ISdkFactoryParams { | ||
| return { | ||
| settings, | ||
|
|
||
| platform: rnPlatform, | ||
|
|
||
| storageFactory: settings.storage, | ||
|
|
||
| splitApiFactory, | ||
|
|
||
| syncManagerFactory: syncManagerOnlineCSFactory, | ||
|
|
||
| sdkManagerFactory, | ||
|
|
||
| sdkClientMethodFactory: sdkClientMethodCSFactory, | ||
| // @TODO provide RN signal listener | ||
| SignalListener: undefined, | ||
| // @ts-ignore | ||
| impressionListener: settings.impressionListener, | ||
|
|
||
| integrationsManagerFactory: | ||
| settings.integrations && settings.integrations.length > 0 | ||
| ? integrationsManagerFactory.bind(null, settings.integrations) | ||
| : undefined, | ||
|
|
||
| impressionsObserverFactory: shouldAddPt(settings) | ||
| ? impressionObserverCSFactory | ||
| : undefined, | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { packageVersion } from '../defaults'; | ||
| import { defaults } from '../defaults'; | ||
| import { version } from '../../../package.json'; | ||
|
|
||
| test('sdk version should be the package.json version', () => { | ||
| expect(packageVersion).toBe(version); | ||
| test('sdk version should contain the package.json version', () => { | ||
| expect(defaults.version).toBe(`reactnative-${version}`); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,20 @@ | ||
| export const packageVersion = '0.0.1-beta.0'; | ||
| const packageVersion = '0.0.1-beta.0'; | ||
|
|
||
| export const defaults = { | ||
| startup: { | ||
| // Stress the request time used while starting up the SDK. | ||
| requestTimeoutBeforeReady: 5, | ||
| // How many quick retries we will do while starting up the SDK. | ||
| retriesOnFailureBeforeReady: 1, | ||
| // Maximum amount of time used before notifies me a timeout. | ||
| readyTimeout: 10, | ||
| // Amount of time we will wait before the first push of events. | ||
| eventsFirstPushWindow: 10, | ||
| }, | ||
|
|
||
| // Instance version. | ||
| version: `reactnative-${packageVersion}`, | ||
|
|
||
| // @TODO check if we should provide some way to overwrite the default log level | ||
| debug: undefined, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { settingsValidation } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/index'; | ||
| import { defaults } from './defaults'; | ||
| import { validateStorageCS } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/storage/storageCS'; | ||
| import { validatePluggableIntegrations } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/integrations/pluggable'; | ||
| import { validateLogger } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/logger/pluggableLogger'; | ||
|
|
||
| const params = { | ||
| defaults, | ||
| storage: validateStorageCS, | ||
| integrations: validatePluggableIntegrations, | ||
| logger: validateLogger, | ||
| }; | ||
|
|
||
| export function settingsValidator(config: any) { | ||
| return settingsValidation(config, params); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { settingsValidator } from './settings'; | ||
| import { getModules } from './platform/getModules'; | ||
| import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index'; | ||
| import type { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types'; | ||
| import { merge } from '@splitsoftware/splitio-commons/src/utils/lang'; | ||
|
|
||
| /** | ||
| * SplitFactory for React Native. | ||
| * | ||
| * @param config Configuration object used to instantiates the SDK | ||
| * @param customModules Optional object of SDK modules to overwrite default ones. Use with caution since, unlike `config`, this param is not validated. | ||
| * @throws Will throw an error if the provided config is invalid. | ||
| */ | ||
| export function SplitFactory( | ||
| config: any, | ||
| customModules?: Partial<ISdkFactoryParams> | ||
| ) { | ||
| const settings = settingsValidator(config); | ||
| const modules = getModules(settings); | ||
| return sdkFactory( | ||
| customModules | ||
| ? (merge(modules, customModules) as ISdkFactoryParams) | ||
| : modules | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.