-
Notifications
You must be signed in to change notification settings - Fork 0
feat: ENG-1123: setup() + command queue foundation #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
7 commits
Select commit
Hold shift + click to select a range
7af3c53
sets up the repo as a monorepo
pandeymangg 2b85f05
setup function
pandeymangg 0a20572
chore: merge with main
pandeymangg ff89dfc
fixes coderabbit feedback
pandeymangg a8a495d
addresses PR feedback
pandeymangg 5d71359
merge conflicts
pandeymangg bd7e609
fixes lint
pandeymangg 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
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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copy to `.env` and fill in your workspace credentials. | ||
| # `.env` is git-ignored; `tool/run.sh` passes it via --dart-define-from-file. | ||
| APP_URL=https://app.formbricks.com | ||
| WORKSPACE_ID=wsp_your_workspace_id |
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
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
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,11 +1,62 @@ | ||
| /// Formbricks Flutter SDK. | ||
| /// | ||
| /// Skeleton entry point. The real public API — `Formbricks.setup`, `track`, | ||
| /// `setUserId`, `setAttributes`, `setLanguage`, `logout`, and the `Formbricks` | ||
| /// host widget — lands in follow-up work. For now this only proves the package | ||
| /// wires into the workspace and the demo app. | ||
| /// Public entry point. This ticket lands initialization only — `Formbricks.setup` | ||
| /// plus the foundations behind it (config, API client, command queue, expiry | ||
| /// ticker). `track` / identify / survey rendering arrive in follow-up work. | ||
| library; | ||
|
|
||
| /// Placeholder greeting used to verify the package is linked correctly from | ||
| /// the demo app and from tests. Replaced by the real SDK surface later. | ||
| String welcome() => 'Welcome to Formbricks'; | ||
| import 'package:shared_preferences/shared_preferences.dart'; | ||
|
|
||
| import 'src/common/command_queue.dart'; | ||
| import 'src/common/config.dart'; | ||
| import 'src/common/logger.dart'; | ||
| import 'src/common/result.dart'; | ||
| import 'src/common/setup.dart' as setup_internal; | ||
| import 'src/types/errors.dart'; | ||
|
|
||
| export 'src/common/logger.dart' show LogLevel; | ||
| export 'src/common/result.dart'; | ||
| export 'src/types/errors.dart'; | ||
|
|
||
| /// The Formbricks SDK facade. | ||
| /// | ||
| /// Static methods delegate to a hidden command queue so calls execute in strict | ||
| /// submission order. `setup()` itself runs with `checkSetup: false` because it | ||
| /// is what flips the SDK into the set-up state. | ||
| class Formbricks { | ||
| Formbricks._(); | ||
|
|
||
| static final CommandQueue _queue = CommandQueue( | ||
| isSetup: () => setup_internal.isSetup, | ||
| ); | ||
|
|
||
| /// Initializes the SDK against [appUrl] / [workspaceId]. | ||
| /// | ||
| /// Completes with `Ok` on success or `Err(MissingFieldError)` for invalid | ||
| /// input. Throws [FormbricksSetupError] if the *first* setup attempt fails on | ||
| /// the network (the SDK then enters a 10-minute error cooldown). | ||
| static Future<Result<void, FormbricksError>> setup({ | ||
| required String appUrl, | ||
| required String workspaceId, | ||
| LogLevel? logLevel, | ||
| }) { | ||
| return _queue.add<Result<void, FormbricksError>>( | ||
| () => setup_internal.setup( | ||
| appUrl: appUrl, | ||
| workspaceId: workspaceId, | ||
| logLevel: logLevel, | ||
| ), | ||
| checkSetup: false, | ||
| ); | ||
| } | ||
|
|
||
| /// Returns the raw JSON the SDK has persisted in `SharedPreferences` (under | ||
| /// the `formbricks-flutter` key), or `null` if nothing is stored yet. | ||
| /// | ||
| /// A debugging/inspection aid — handy for seeing exactly what `setup()` and | ||
| /// future state changes write to disk. Not part of the stable API. | ||
| static Future<String?> debugStoredConfig() async { | ||
| final prefs = await SharedPreferences.getInstance(); | ||
| return prefs.getString(FormbricksConfig.storageKey); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.