@@ -50,3 +50,78 @@ When publishing releases, the following rules apply:
50
50
** Note** : The release will not be published if:
51
51
- A pre-release is marked as "latest"
52
52
- A pre-release label is used without checking "Set as pre-release"
53
+
54
+ ## Tools
55
+
56
+ ### Bootstrap Configuration
57
+
58
+ You can generate a bootstrap configuration string from either the command line or programmatically via the
59
+ ConfigurationWireHelper class.
60
+
61
+ The tool allows you to specify the target SDK this configuration will be used on. It is important to correctly specify
62
+ the intended SDK, as this determines whether the configuration is obfuscated (for client SDKs) or not (for server SDKs).
63
+
64
+ #### Command Line Usage
65
+
66
+ ** Install as a project dependency:**
67
+ ``` bash
68
+ # Install as a dependency
69
+ npm install --save-dev @eppo/js-client-sdk-common
70
+
71
+ # or, with yarn
72
+ yarn add --dev @eppo/js-client-sdk-common
73
+ ```
74
+
75
+ Common usage examples:
76
+ ``` bash
77
+ # Basic usage
78
+ yarn bootstrap-config --key < sdkKey> --output bootstrap-config.json
79
+
80
+ # With custom SDK name (default is 'js-client-sdk')
81
+ yarn bootstrap-config --key < sdkKey> --sdk android
82
+
83
+ # With custom base URL
84
+ yarn bootstrap-config --key < sdkKey> --base-url https://api.custom-domain.com
85
+
86
+ # Output configuration to stdout
87
+ yarn bootstrap-config --key < sdkKey>
88
+
89
+ # Show help
90
+ yarn bootstrap-config --help
91
+ ```
92
+
93
+ The tool accepts the following arguments:
94
+ - ` --key, -k ` : SDK key (required, can also be set via EPPO_SDK_KEY environment variable)
95
+ - ` --sdk ` : Target SDK name (default: 'js-client-sdk')
96
+ - ` --base-url ` : Custom base URL for the API
97
+ - ` --output, -o ` : Output file path (if not specified, outputs to console)
98
+ - ` --help, -h ` : Show help
99
+
100
+ #### Programmatic Usage
101
+ ``` typescript
102
+ import { ConfigurationHelper } from ' @eppo/js-client-sdk-common' ;
103
+
104
+ async function getBootstrapConfig() {
105
+ // Initialize the helper
106
+ const helper = ConfigurationHelper .build (
107
+ ' your-sdk-key' ,
108
+ {
109
+ sdkName: ' android' , // optional: target SDK name (default: 'js-client-sdk')
110
+ baseUrl: ' https://api.custom-domain.com' , // optional: custom base URL
111
+ });
112
+
113
+ // Fetch the configuration
114
+ const config = await helper .fetchConfiguration ();
115
+ const configString = config .toString ();
116
+
117
+ // You are responsible to transport this string to the client
118
+ const clientInitialData = {eppoConfig: eppoConfigString };
119
+
120
+ // Client-side
121
+ const client = getInstance ();
122
+ const initialConfig = configurationFromString (clientInitialData .eppoConfig );
123
+ client .setInitialConfig (configurationFromString (configString ));
124
+ }
125
+ ```
126
+
127
+ The tool will output a JSON string containing the configuration wire format that can be used to bootstrap Eppo SDKs.
0 commit comments