SDK Types
SDKCredentials
- Description: An object containing the necessary credentials to connect to the API.
- Properties:
url: String, the URL of the API.key: String, the API Key.trackingId: String, the tracking ID.
Example:
typescript
const credentials: SDKCredentials = {
url: "https://api.example.com",
key: "your-api-key",
trackingId: "your-tracking-id",
};SDKOptions
- Description: An object containing the general SDK configuration options.
- Properties:
guiOptions: Configuration options for the user interface (seeSDKGuiOptions).language: The language of the SDK, either"vi"or"en".forceConsent: Boolean, requires the user to consent before proceeding.darkMode: Boolean, configures the user interface to use dark mode.
Example:
typescript
const options: SDKOptions = {
guiOptions: {
consentModal: {
layout: "box",
position: "top center",
},
},
language: "vi",
forceConsent: true,
darkMode: false,
};SDKGuiOptions
- Description: Configuration options for the user interface of the SDK, including options for consent and preferences modals.
- Properties:
consentModal: Options for the user consent modal.layout: The layout of the consent modal (seeConsentModalLayout).position: The position of the consent modal (seeConsentModalPosition).
preferencesModal: Options for the user preferences modal.layout: The layout of the preferences modal (seePreferencesModalLayout).position: The position of the preferences modal (seePreferencesModalPosition).
Example:
typescript
const guiOptions: SDKGuiOptions = {
consentModal: {
layout: "box",
position: "top center",
},
preferencesModal: {
layout: "bar",
position: "right",
},
};ConsentModalLayout
- Description: The layout types for the user consent modal.
- Valid values:
"box""box wide""box inline""cloud""cloud inline""bar""bar inline"
Example:
typescript
const layout: ConsentModalLayout = "box";ConsentModalPosition
- Description: The position options for the user consent modal.
- Valid values:
"top""bottom""middle""top left""top center""top right""middle left""middle center""middle right""bottom left""bottom center""bottom right"
Example:
typescript
const position: ConsentModalPosition = "top center";PreferencesModalLayout
- Description: The layout types for the user preferences modal.
- Valid values:
"box""bar""bar wide"
Example:
typescript
const layout: PreferencesModalLayout = "bar";PreferencesModalPosition
- Description: The position options for the user preferences modal.
- Valid values:
"left""right"
Example:
typescript
const position: PreferencesModalPosition = "left";SDKError
- Description: SDK error, including error code, name, and detailed description.
- Properties:
code: Error code (integer).name: Error name (string).description: Detailed error description.
Example:
typescript
const error: SDKError = new SDKError(
1001,
"INVALID_CREDENTIALS",
"API Key is missing."
);