Skip to content

Commit

Permalink
Add support for configuring a base endpoint URL (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospassos committed Dec 27, 2022
1 parent b544ded commit c142a44
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 275 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,21 +499,20 @@ a React component tree.

The component takes the followings properties:

| Option | Type | Required | Default Value | Description |
|-------------------------|--------------|----------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `appId` | string | Yes | None | The ID of the application you set up on Croct. |
| `debug` | boolean | No | `false` | If `true`, turns on debug mode, which logs helpful messages to the console. |
| `track` | boolean | No | `true` | If `true`, enables the automatic event tracking on initialization. |
| `clientId` | string | No | None | The ID of the client using the application. |
| `token` | string\|null | No | None | The JWT token issued by Croct. If `null`, clears any token specified on previous calls. |
| `userId` | string | No | None | The ID of the user logged into the application. Internally, the SDK will issue a token using the specified ID as the subject claim of the token. The `token` and `userId` options are mutually exclusive. |
| `tokenScope` | string | No | `global` | Defines how the SDK should synchronize the token across multiple tabs, see [token scopes](#token-scopes) for more details. |
| `eventMetadata` | JSON | No | None | Any additional information that may be useful to include as part of the event metadata. A common use case is to record the version of the application for future reference. |
| `logger` | object | No | None | A custom logger to handle log messages. By default, all logs are suppressed. |
| `urlSanitizer` | function | No | None | A function to sanitize URLs that allows removing sensitive information from URLs, such as tokens, that should not be sent to the platform. |
| `trackerEndpointUrl` | string | No | None | The URL of the tracker service, used by Croct's development team for testing purposes. |
| `evaluationEndpointUrl` | string | No | None | The URL of the evaluation service, used by Croct's development team for testing purposes. |
| `bootstrapEndpointUrl` | string | No | None | The URL of the bootstrap service, used by Croct's development team for testing purposes. |
| Option | Type | Required | Default Value | Description |
|--------------------------|--------------|----------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `appId` | string | Yes | None | The ID of the application you set up on Croct. |
| `debug` | boolean | No | `false` | If `true`, turns on debug mode, which logs helpful messages to the console. |
| `track` | boolean | No | `true` | If `true`, enables the automatic event tracking on initialization. |
| `clientId` | string | No | None | The ID of the client using the application. |
| `token` | string\|null | No | None | The JWT token issued by Croct. If `null`, clears any token specified on previous calls. |
| `userId` | string | No | None | The ID of the user logged into the application. Internally, the SDK will issue a token using the specified ID as the subject claim of the token. The `token` and `userId` options are mutually exclusive. |
| `tokenScope` | string | No | `global` | Defines how the SDK should synchronize the token across multiple tabs, see [token scopes](#token-scopes) for more details. |
| `eventMetadata` | JSON | No | None | Any additional information that may be useful to include as part of the event metadata. A common use case is to record the version of the application for future reference. |
| `logger` | object | No | None | A custom logger to handle log messages. By default, all logs are suppressed. |
| `urlSanitizer` | function | No | None | A function to sanitize URLs that allows removing sensitive information from URLs, such as tokens, that should not be sent to the platform. |
| `baseEndpointUrl` | string | No | None | The base URL to use for the API calls. By default, the SDK will use the production endpoint. |
| `cidAssignerEndpointUrl` | string | No | None | The URL to use for the client ID assignment. By default, the SDK will use the production endpoint. |

#### Code Sample

Expand Down Expand Up @@ -758,6 +757,7 @@ These are the currently supported options:
| Option | Type | Required | Description |
|----------------------------|--------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `apiKey` | string | Yes | The private API key of the application. This is a private key that should never be exposed to the client-side. |
| `baseEndpointUrl` | string | No | The base URL of the Evaluation API. Defaults to the production endpoint. |
| `fallback` | JSON | No | The value returned when the evaluation fails. If not specified, the function will throw an exception in case of failures. |
| `timeout` | number | No | The maximum evaluation time in milliseconds. Once reached, the evaluation will fail. |
| `clientId` | string | No | A UUID v4 that uniquely identifies the client across multiple evaluations. You should generate this identifier on your server-side using a random, cryptographically secure generator and ensure it doesn't change throughout the user journey (e.g. store in cookies). If not specified, the evaluation will run in an anonymous context. |
Expand Down Expand Up @@ -809,6 +809,7 @@ These are the currently supported options:
| Option | Type | Required | Description |
|----------------------------|---------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `apiKey` | string | Yes | The private API key of the application. This is a private key that should never be exposed to the client-side. |
| `baseEndpointUrl` | string | No | The base URL of the Content API. Defaults to the production endpoint. |
| `fallback` | JSON | No | The value returned when the fetch fails. If not specified, the function will throw an exception in case of failures. |
| `static` | boolean | No | Whether to fetch the static content. If not specified, the function will fetch the dynamic content. |
| `timeout` | number | No | The maximum fetch time in milliseconds. Once reached, the fetch will fail. |
Expand Down
Loading

0 comments on commit c142a44

Please sign in to comment.