diff --git a/Makefile b/Makefile index 09d99a8..002961c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ HOSTNAME=rudderstack.com NAMESPACE=rudderlabs NAME=rudderstack BINARY=terraform-provider-${NAME} -VERSION=0.8.2 +VERSION=1.0.0 OS_ARCH=$(shell go env GOOS)_$(shell go env GOARCH) default: install diff --git a/cmd/generatetf/generator/generator_test.go b/cmd/generatetf/generator/generator_test.go index d6608bd..71878f2 100644 --- a/cmd/generatetf/generator/generator_test.go +++ b/cmd/generatetf/generator/generator_test.go @@ -72,13 +72,11 @@ func TestGeneratorTerraform(t *testing.T) { "categoryToContent": [{ "from": "from", "to": "to" }], "legacyConversionPixelId": { "from": "from", "to": "to" }, "useNativeSDK": { "web": true }, - "oneTrustCookieCategories": { - "web": [ + "oneTrustCookieCategories": [ { "oneTrustCookieCategory": "one" }, { "oneTrustCookieCategory": "two" }, { "oneTrustCookieCategory": "three" } - ] - }, + ], "blacklistedEvents": [ { "eventName": "one" }, { "eventName": "two" }, @@ -146,13 +144,11 @@ resource "rudderstack_destination_facebook_pixel" "dst_id-facebook-pixel" { from = "from" to = "to" } - onetrust_cookie_categories { - web = ["one", "two", "three"] - } - pixel_id = "facebook pixel id" - standard_page_call = true - test_destination = true - test_event_code = "..." + onetrust_cookie_categories = ["one", "two", "three"] + pixel_id = "facebook pixel id" + standard_page_call = true + test_destination = true + test_event_code = "..." use_native_sdk { web = true } diff --git a/docs/guides/import.md b/docs/guides/import.md index c47da96..ddf4ee1 100644 --- a/docs/guides/import.md +++ b/docs/guides/import.md @@ -46,7 +46,7 @@ terraform { required_providers { rudderstack = { source = "rudderlabs/rudderstack" - version = "~> 0.8.1" + version = "~> 1.0.0" } } required_version = "~> 1.1.0" diff --git a/docs/index.md b/docs/index.md index d9b582b..48f979a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,7 +16,7 @@ terraform { required_providers { rudderstack = { source = "rudderlabs/rudderstack" - version = "~> 0.8.1" + version = "~> 1.0.0" } } required_version = "~> 1.1.0" @@ -34,4 +34,4 @@ provider "rudderstack" { ### Optional - `access_token` (String) The Rudderstack API access token used to authenticate you Rudderstack account. If not set, the provider will look for that value in the `RUDDERSTACK_ACCESS_TOKEN` environmental value, and fail with an error if that is missing. -- `api_url` (String) The base URL of Rudderstack API. If not set, the provider will first look for a value in the `RUDDERSTACK_API_URL` environmental value, and finally default to `https://api.rudderstack.com/v2` if that is missing. \ No newline at end of file +- `api_url` (String) The base URL of Rudderstack API. If not set, the provider will first look for a value in the `RUDDERSTACK_API_URL` environmental value, and finally default to `https://api.rudderstack.com/v2` if that is missing. diff --git a/docs/resources/destination_amplitude.md b/docs/resources/destination_amplitude.md index 8c2e4f5..aea33a1 100644 --- a/docs/resources/destination_amplitude.md +++ b/docs/resources/destination_amplitude.md @@ -121,7 +121,19 @@ resource "rudderstack_destination_amplitude" "example" { # blacklist = ["one", "two", "three"] # } - # onetrust_cookie_categories = ["one", "two", "three"] + # onetrust_cookie_categories { + # web = ["one", "two", "three"] + # android = ["one", "two", "three"] + # ios = ["one", "two", "three"] + # unity = ["one", "two", "three"] + # reactnative = ["one", "two", "three"] + # flutter = ["one", "two", "three"] + # cordova = ["one", "two", "three"] + # amp = ["one", "two", "three"] + # cloud = ["one", "two", "three"] + # warehouse = ["one", "two", "three"] + # shopify = ["one", "two", "three"] + # } # residency_server = "EU" } diff --git a/docs/resources/destination_google_analytics4.md b/docs/resources/destination_google_analytics4.md index 549812b..85bc795 100644 --- a/docs/resources/destination_google_analytics4.md +++ b/docs/resources/destination_google_analytics4.md @@ -38,7 +38,19 @@ resource "rudderstack_destination_google_analytics4" "example" { # blacklist = ["one", "two", "three"] # } - # onetrust_cookie_categories = ["one", "two", "three"] + # onetrust_cookie_categories { + # web = ["one", "two", "three"] + # android = ["one", "two", "three"] + # ios = ["one", "two", "three"] + # unity = ["one", "two", "three"] + # reactnative = ["one", "two", "three"] + # flutter = ["one", "two", "three"] + # cordova = ["one", "two", "three"] + # amp = ["one", "two", "three"] + # cloud = ["one", "two", "three"] + # warehouse = ["one", "two", "three"] + # shopify = ["one", "two", "three"] + # } } } ``` diff --git a/docs/resources/destination_google_tag_manager.md b/docs/resources/destination_google_tag_manager.md index 66f5cec..715592e 100644 --- a/docs/resources/destination_google_tag_manager.md +++ b/docs/resources/destination_google_tag_manager.md @@ -30,7 +30,9 @@ resource "rudderstack_destination_google_tag_manager" "example" { blacklist = ["one", "two", "three"] } - # onetrust_cookie_categories = ["one", "two", "three"] + # onetrust_cookie_categories { + # web = ["one", "two", "three"] + # } } } ``` diff --git a/docs/resources/destination_mixpanel.md b/docs/resources/destination_mixpanel.md index 3caa208..527bc4b 100644 --- a/docs/resources/destination_mixpanel.md +++ b/docs/resources/destination_mixpanel.md @@ -44,7 +44,19 @@ resource "rudderstack_destination_mixpanel" example{ # blacklist = ["one","two","three"] # } - # onetrust_cookie_categories = ["one", "two", "three"] + # onetrust_cookie_categories { + # web = ["one", "two", "three"] + # android = ["one", "two", "three"] + # ios = ["one", "two", "three"] + # unity = ["one", "two", "three"] + # reactnative = ["one", "two", "three"] + # flutter = ["one", "two", "three"] + # cordova = ["one", "two", "three"] + # amp = ["one", "two", "three"] + # cloud = ["one", "two", "three"] + # warehouse = ["one", "two", "three"] + # shopify = ["one", "two", "three"] + # } # use_new_mapping = true } } diff --git a/examples/destination_amplitude.tf b/examples/destination_amplitude.tf index 9be7635..4a036f6 100644 --- a/examples/destination_amplitude.tf +++ b/examples/destination_amplitude.tf @@ -106,7 +106,19 @@ resource "rudderstack_destination_amplitude" "example" { # blacklist = ["one", "two", "three"] # } - # onetrust_cookie_categories = ["one", "two", "three"] + # onetrust_cookie_categories { + # web = ["one", "two", "three"] + # android = ["one", "two", "three"] + # ios = ["one", "two", "three"] + # unity = ["one", "two", "three"] + # reactnative = ["one", "two", "three"] + # flutter = ["one", "two", "three"] + # cordova = ["one", "two", "three"] + # amp = ["one", "two", "three"] + # cloud = ["one", "two", "three"] + # warehouse = ["one", "two", "three"] + # shopify = ["one", "two", "three"] + # } # residency_server = "EU" } diff --git a/examples/destination_google_analytics4.tf b/examples/destination_google_analytics4.tf index 67def18..e308f59 100644 --- a/examples/destination_google_analytics4.tf +++ b/examples/destination_google_analytics4.tf @@ -23,6 +23,18 @@ resource "rudderstack_destination_google_analytics4" "example" { # blacklist = ["one", "two", "three"] # } - # onetrust_cookie_categories = ["one", "two", "three"] + # onetrust_cookie_categories { + # web = ["one", "two", "three"] + # android = ["one", "two", "three"] + # ios = ["one", "two", "three"] + # unity = ["one", "two", "three"] + # reactnative = ["one", "two", "three"] + # flutter = ["one", "two", "three"] + # cordova = ["one", "two", "three"] + # amp = ["one", "two", "three"] + # cloud = ["one", "two", "three"] + # warehouse = ["one", "two", "three"] + # shopify = ["one", "two", "three"] + # } } } diff --git a/examples/destination_google_tag_manager.tf b/examples/destination_google_tag_manager.tf index ac10063..69b726a 100644 --- a/examples/destination_google_tag_manager.tf +++ b/examples/destination_google_tag_manager.tf @@ -15,6 +15,8 @@ resource "rudderstack_destination_google_tag_manager" "example" { blacklist = ["one", "two", "three"] } - # onetrust_cookie_categories = ["one", "two", "three"] + # onetrust_cookie_categories { + # web = ["one", "two", "three"] + # } } } diff --git a/examples/destination_mixpanel.tf b/examples/destination_mixpanel.tf index 38dd842..668c938 100644 --- a/examples/destination_mixpanel.tf +++ b/examples/destination_mixpanel.tf @@ -29,7 +29,19 @@ resource "rudderstack_destination_mixpanel" example{ # blacklist = ["one","two","three"] # } - # onetrust_cookie_categories = ["one", "two", "three"] + # onetrust_cookie_categories { + # web = ["one", "two", "three"] + # android = ["one", "two", "three"] + # ios = ["one", "two", "three"] + # unity = ["one", "two", "three"] + # reactnative = ["one", "two", "three"] + # flutter = ["one", "two", "three"] + # cordova = ["one", "two", "three"] + # amp = ["one", "two", "three"] + # cloud = ["one", "two", "three"] + # warehouse = ["one", "two", "three"] + # shopify = ["one", "two", "three"] + # } # use_new_mapping = true } -} \ No newline at end of file +} diff --git a/examples/main.tf b/examples/main.tf index cc5a07d..69fcd3b 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { rudderstack = { source = "rudderlabs/rudderstack" - version = "~> 0.8.2" + version = "~> 1.0.0" } } required_version = "~> 1.1.0" diff --git a/rudderstack/integrations/destinations/common_config_meta.go b/rudderstack/integrations/destinations/common_config_meta.go new file mode 100644 index 0000000..4f4d326 --- /dev/null +++ b/rudderstack/integrations/destinations/common_config_meta.go @@ -0,0 +1,58 @@ +package destinations + +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + c "github.com/rudderlabs/terraform-provider-rudderstack/rudderstack/configs" +) + +func GetConfigMetaForOneTrustConsents(supportedSourceTypes []string) ([]c.ConfigProperty, map[string]*schema.Schema) { + oneTrustConsentsProperties := []c.ConfigProperty{} + oneTrustConsentsSchema := map[string]*schema.Schema{} + + if len(supportedSourceTypes) != 0 && supportedSourceTypes != nil { + onetrust_terraform_key := "onetrust_cookie_categories" + onetrust_elements_schema := make(map[string]*schema.Schema) + + // Create property and schema for each source type + for _, sourceType := range supportedSourceTypes { + oneTrustConsentsProperties = append(oneTrustConsentsProperties, c.ArrayWithStrings(fmt.Sprintf("oneTrustCookieCategories.%s", sourceType), "oneTrustCookieCategory", fmt.Sprintf("%s.0.%s", onetrust_terraform_key, sourceType))) + + onetrust_elements_schema[sourceType] = &schema.Schema{ + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + } + } + + oneTrustConsentsSchema[onetrust_terraform_key] = &schema.Schema{ + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Specify OneTrust category IDs.", + Elem: &schema.Resource{ + Schema: onetrust_elements_schema, + }, + }; + } + + return oneTrustConsentsProperties, oneTrustConsentsSchema +} + +func GetCommonConfigMeta(supportedSourceTypes []string) ([]c.ConfigProperty, map[string]*schema.Schema) { + commonProperties := []c.ConfigProperty{} + commonSchema := map[string]*schema.Schema{} + + oneTrustConsentFieldProperties, oneTrustConsentFieldSchema := GetConfigMetaForOneTrustConsents(supportedSourceTypes) + + commonProperties = append(commonProperties, oneTrustConsentFieldProperties...) + + for key, value := range oneTrustConsentFieldSchema { + commonSchema[key] = value + } + + return commonProperties, commonSchema +} diff --git a/rudderstack/integrations/destinations/common_config_meta_test.go b/rudderstack/integrations/destinations/common_config_meta_test.go new file mode 100644 index 0000000..6a91fa7 --- /dev/null +++ b/rudderstack/integrations/destinations/common_config_meta_test.go @@ -0,0 +1,101 @@ +// write unit tests for the common_config_meta.go file + +package destinations + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + c "github.com/rudderlabs/terraform-provider-rudderstack/rudderstack/configs" + "github.com/stretchr/testify/require" +) + +func TestGetCommonConfigMeta(t *testing.T) { + testCases := []struct { + description string + supportedSourceTypes []string + expectedProperties []c.ConfigProperty + expectedSchema map[string]*schema.Schema + }{ + { + description: "Valid list of supported source types", + supportedSourceTypes: []string{"web", "android", "ios"}, + expectedProperties: []c.ConfigProperty{ + c.ArrayWithStrings("oneTrustCookieCategories.web", "oneTrustCookieCategory", "onetrust_cookie_categories.0.web"), + c.ArrayWithStrings("oneTrustCookieCategories.android", "oneTrustCookieCategory", "onetrust_cookie_categories.0.android"), + c.ArrayWithStrings("oneTrustCookieCategories.ios", "oneTrustCookieCategory", "onetrust_cookie_categories.0.ios"), + }, + expectedSchema: map[string]*schema.Schema{ + "onetrust_cookie_categories": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Specify OneTrust category IDs.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "android": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "ios": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + { + description: "Empty list of supported source types", + supportedSourceTypes: []string{}, + expectedProperties: []c.ConfigProperty{}, + expectedSchema: map[string]*schema.Schema{}, + }, + { + description: "Nil supported source types", + supportedSourceTypes: nil, + expectedProperties: []c.ConfigProperty{}, + expectedSchema: map[string]*schema.Schema{}, + }, + { + description: "A single supported source type", + supportedSourceTypes: []string{"web"}, + expectedProperties: []c.ConfigProperty{ + c.ArrayWithStrings("oneTrustCookieCategories.web", "oneTrustCookieCategory", "onetrust_cookie_categories.0.web"), + }, + expectedSchema: map[string]*schema.Schema{ + "onetrust_cookie_categories": { + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: "Specify OneTrust category IDs.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, + }, + }, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.description, func(t *testing.T) { + actualProperties, actualSchema := GetCommonConfigMeta(tc.supportedSourceTypes) + require.EqualValues(t, tc.expectedSchema, actualSchema) + require.True(t, len(actualProperties) == len(tc.expectedProperties)) + }) + } +} diff --git a/rudderstack/integrations/destinations/destination_amplitude.go b/rudderstack/integrations/destinations/destination_amplitude.go index 775f809..e4f34a1 100644 --- a/rudderstack/integrations/destinations/destination_amplitude.go +++ b/rudderstack/integrations/destinations/destination_amplitude.go @@ -6,478 +6,482 @@ import ( ) func init() { - c.Destinations.Register("amplitude", c.ConfigMeta{ - APIType: "AM", - Properties: []c.ConfigProperty{ - c.Simple("apiKey", "api_key"), - c.Simple("apiSecret", "api_secret"), - c.Simple("groupTypeTrait", "group_type_trait", c.SkipZeroValue), - c.Simple("groupValueTrait", "group_value_trait", c.SkipZeroValue), - c.Simple("trackAllPages", "track_all_pages", c.SkipZeroValue), - c.Simple("trackCategorizedPages", "track_categorized_pages", c.SkipZeroValue), - c.Simple("trackNamedPages", "track_named_pages", c.SkipZeroValue), - c.Simple("trackProductsOnce", "track_products_once", c.SkipZeroValue), - c.Simple("trackRevenuePerProduct", "track_revenue_per_product", c.SkipZeroValue), - c.Simple("versionName", "version_name", c.SkipZeroValue), - c.ArrayWithStrings("traitsToIncrement", "traits", "traits_to_increment"), - c.ArrayWithStrings("traitsToSetOnce", "traits", "traits_to_set_once"), - c.ArrayWithStrings("traitsToAppend", "traits", "traits_to_append"), - c.ArrayWithStrings("traitsToPrepend", "traits", "traits_to_prepend"), - c.Simple("useNativeSDK.web", "use_native_sdk.0.web"), - c.Simple("useNativeSDK.ios", "use_native_sdk.0.ios"), - c.Simple("useNativeSDK.android", "use_native_sdk.0.android"), - c.Simple("useNativeSDK.reactnative", "use_native_sdk.0.react_native"), - c.Simple("preferAnonymousIdForDeviceId.web", "prefer_anonymous_id_for_device_id.0.web"), - c.Simple("deviceIdFromUrlParam.web", "device_id_from_url_param.0.web"), - c.Simple("forceHttps.web", "force_https.0.web"), - c.Simple("trackGclid.web", "track_gclid.0.web"), - c.Simple("trackReferrer.web", "track_referrer.0.web"), - c.Simple("saveParamsReferrerOncePerSession.web", "save_params_referrer_once_per_session.0.web"), - c.Simple("trackUtmProperties.web", "track_utm_properties.0.web"), - c.Simple("unsetParamsReferrerOnNewSession.web", "unset_params_referrer_on_new_session.0.web"), - c.Simple("batchEvents.web", "batch_events.0.web"), - c.ArrayWithStrings("whitelistedEvents", "eventName", "event_filtering.0.whitelist"), - c.ArrayWithStrings("blacklistedEvents", "eventName", "event_filtering.0.blacklist"), - c.Discriminator("eventFilteringOption", c.DiscriminatorValues{ - "event_filtering.0.whitelist": "whitelistedEvents", - "event_filtering.0.blacklist": "blacklistedEvents", - }), - c.Simple("eventUploadPeriodMillis.web", "event_upload_period_millis.0.web"), - c.Simple("eventUploadPeriodMillis.android", "event_upload_period_millis.0.android"), - c.Simple("eventUploadPeriodMillis.ios", "event_upload_period_millis.0.ios"), - c.Simple("eventUploadPeriodMillis.reactnative", "event_upload_period_millis.0.react_native"), - c.Simple("eventUploadThreshold.web", "event_upload_threshold.0.web"), - c.Simple("eventUploadThreshold.android", "event_upload_threshold.0.android"), - c.Simple("eventUploadThreshold.ios", "event_upload_threshold.0.ios"), - c.Simple("eventUploadThreshold.reactnative", "event_upload_threshold.0.react_native"), - c.Simple("mapDeviceBrand", "map_device_brand", c.SkipZeroValue), - c.Simple("enableLocationListening.android", "enable_location_listening.0.android"), - c.Simple("enableLocationListening.reactnative", "enable_location_listening.0.react_native"), - c.Simple("trackSessionEvents.android", "track_session_events.0.android"), - c.Simple("trackSessionEvents.ios", "track_session_events.0.ios"), - c.Simple("trackSessionEvents.reactnative", "track_session_events.0.react_native"), - c.Simple("useAdvertisingIdForDeviceId.android", "use_advertising_id_for_device_id.0.android"), - c.Simple("useAdvertisingIdForDeviceId.reactnative", "use_advertising_id_for_device_id.0.react_native"), - c.Simple("useIdfaAsDeviceId.ios", "use_idfa_as_device_id.0.ios"), - c.Simple("useIdfaAsDeviceId.reactnative", "use_idfa_as_device_id.0.react_native"), - c.ArrayWithStrings("oneTrustCookieCategories", "oneTrustCookieCategory", "onetrust_cookie_categories"), - c.Simple("residencyServer", "residency_server", c.SkipZeroValue), - }, - ConfigSchema: map[string]*schema.Schema{ - "api_key": { - Type: schema.TypeString, - Required: true, - Description: "Enter your Amplitude API key.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), - }, - "api_secret": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "Enter the Amplitude API Secret key required for user deletion.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), - }, - "group_type_trait": { - Type: schema.TypeString, - Optional: true, - Description: "RudderStack will use this value as `groupType` in the `group` calls.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), - }, - "group_value_trait": { - Type: schema.TypeString, - Optional: true, - Description: "RudderStack will use this value as `groupValue` in the `group` calls.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), - }, - "residency_server": { - Type: schema.TypeString, - Optional: true, - ValidateDiagFunc: c.StringMatchesRegexp("(^env[.].*)|^(standard|EU)$"), - }, - "track_all_pages": { - Type: schema.TypeBool, - Optional: true, - Description: "If this setting is enabled, RudderStack sends an event named `Loaded a page` / `Loaded a Screen` to Amplitude.", - }, - "track_categorized_pages": { - Type: schema.TypeBool, - Optional: true, - Description: "If this setting is enabled and if `category` is present in a `page` / `screen` call, then an event named `Viewed {category} page` / `Viewed {category} Screen` will be sent to Amplitude.", - }, - "track_named_pages": { - Type: schema.TypeBool, - Optional: true, - Description: "If this setting is enabled and `name` is present in a `page` call, then an event named `Viewed {name} page` will be sent to Amplitude.", - }, - "track_products_once": { - Type: schema.TypeBool, - Optional: true, - Description: "If this setting is enabled and if the event payload contains an array of products, then the event is tracked with the original event name and all the products as its property. Otherwise, each product is tracked with event as `Product purchased`.", - }, - "track_revenue_per_product": { - Type: schema.TypeBool, - Optional: true, - Description: "If this setting is enabled and if the event payload contains multiple products, each product's revenue is tracked individually.", - }, - "version_name": { - Type: schema.TypeString, - Optional: true, - Description: "The value of this field is set as the `versionName` of the Amplitude SDK.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), - }, - "traits_to_increment": { - Type: schema.TypeList, - Optional: true, - Description: "If this setting is enabled, the value of the corresponding trait will be incremented at Amplitude, with the value provided against the trait in an `identify` call.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + supportedSourceTypes := []string{"web", "android", "ios", "unity", "reactnative", "flutter", "cordova", "amp", "cloud", "warehouse", "shopify"} + commonProperties, commonSchema := GetCommonConfigMeta(supportedSourceTypes) + + properties := []c.ConfigProperty{ + c.Simple("apiKey", "api_key"), + c.Simple("apiSecret", "api_secret"), + c.Simple("groupTypeTrait", "group_type_trait", c.SkipZeroValue), + c.Simple("groupValueTrait", "group_value_trait", c.SkipZeroValue), + c.Simple("trackAllPages", "track_all_pages", c.SkipZeroValue), + c.Simple("trackCategorizedPages", "track_categorized_pages", c.SkipZeroValue), + c.Simple("trackNamedPages", "track_named_pages", c.SkipZeroValue), + c.Simple("trackProductsOnce", "track_products_once", c.SkipZeroValue), + c.Simple("trackRevenuePerProduct", "track_revenue_per_product", c.SkipZeroValue), + c.Simple("versionName", "version_name", c.SkipZeroValue), + c.ArrayWithStrings("traitsToIncrement", "traits", "traits_to_increment"), + c.ArrayWithStrings("traitsToSetOnce", "traits", "traits_to_set_once"), + c.ArrayWithStrings("traitsToAppend", "traits", "traits_to_append"), + c.ArrayWithStrings("traitsToPrepend", "traits", "traits_to_prepend"), + c.Simple("useNativeSDK.web", "use_native_sdk.0.web"), + c.Simple("useNativeSDK.ios", "use_native_sdk.0.ios"), + c.Simple("useNativeSDK.android", "use_native_sdk.0.android"), + c.Simple("useNativeSDK.reactnative", "use_native_sdk.0.react_native"), + c.Simple("preferAnonymousIdForDeviceId.web", "prefer_anonymous_id_for_device_id.0.web"), + c.Simple("deviceIdFromUrlParam.web", "device_id_from_url_param.0.web"), + c.Simple("forceHttps.web", "force_https.0.web"), + c.Simple("trackGclid.web", "track_gclid.0.web"), + c.Simple("trackReferrer.web", "track_referrer.0.web"), + c.Simple("saveParamsReferrerOncePerSession.web", "save_params_referrer_once_per_session.0.web"), + c.Simple("trackUtmProperties.web", "track_utm_properties.0.web"), + c.Simple("unsetParamsReferrerOnNewSession.web", "unset_params_referrer_on_new_session.0.web"), + c.Simple("batchEvents.web", "batch_events.0.web"), + c.ArrayWithStrings("whitelistedEvents", "eventName", "event_filtering.0.whitelist"), + c.ArrayWithStrings("blacklistedEvents", "eventName", "event_filtering.0.blacklist"), + c.Discriminator("eventFilteringOption", c.DiscriminatorValues{ + "event_filtering.0.whitelist": "whitelistedEvents", + "event_filtering.0.blacklist": "blacklistedEvents", + }), + c.Simple("eventUploadPeriodMillis.web", "event_upload_period_millis.0.web"), + c.Simple("eventUploadPeriodMillis.android", "event_upload_period_millis.0.android"), + c.Simple("eventUploadPeriodMillis.ios", "event_upload_period_millis.0.ios"), + c.Simple("eventUploadPeriodMillis.reactnative", "event_upload_period_millis.0.react_native"), + c.Simple("eventUploadThreshold.web", "event_upload_threshold.0.web"), + c.Simple("eventUploadThreshold.android", "event_upload_threshold.0.android"), + c.Simple("eventUploadThreshold.ios", "event_upload_threshold.0.ios"), + c.Simple("eventUploadThreshold.reactnative", "event_upload_threshold.0.react_native"), + c.Simple("mapDeviceBrand", "map_device_brand", c.SkipZeroValue), + c.Simple("enableLocationListening.android", "enable_location_listening.0.android"), + c.Simple("enableLocationListening.reactnative", "enable_location_listening.0.react_native"), + c.Simple("trackSessionEvents.android", "track_session_events.0.android"), + c.Simple("trackSessionEvents.ios", "track_session_events.0.ios"), + c.Simple("trackSessionEvents.reactnative", "track_session_events.0.react_native"), + c.Simple("useAdvertisingIdForDeviceId.android", "use_advertising_id_for_device_id.0.android"), + c.Simple("useAdvertisingIdForDeviceId.reactnative", "use_advertising_id_for_device_id.0.react_native"), + c.Simple("useIdfaAsDeviceId.ios", "use_idfa_as_device_id.0.ios"), + c.Simple("useIdfaAsDeviceId.reactnative", "use_idfa_as_device_id.0.react_native"), + c.Simple("residencyServer", "residency_server", c.SkipZeroValue), + }; + + properties = append(properties, commonProperties...) + + schema := map[string]*schema.Schema{ + "api_key": { + Type: schema.TypeString, + Required: true, + Description: "Enter your Amplitude API key.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), + }, + "api_secret": { + Type: schema.TypeString, + Optional: true, + Sensitive: true, + Description: "Enter the Amplitude API Secret key required for user deletion.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), + }, + "group_type_trait": { + Type: schema.TypeString, + Optional: true, + Description: "RudderStack will use this value as `groupType` in the `group` calls.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), + }, + "group_value_trait": { + Type: schema.TypeString, + Optional: true, + Description: "RudderStack will use this value as `groupValue` in the `group` calls.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), + }, + "residency_server": { + Type: schema.TypeString, + Optional: true, + ValidateDiagFunc: c.StringMatchesRegexp("(^env[.].*)|^(standard|EU)$"), + }, + "track_all_pages": { + Type: schema.TypeBool, + Optional: true, + Description: "If this setting is enabled, RudderStack sends an event named `Loaded a page` / `Loaded a Screen` to Amplitude.", + }, + "track_categorized_pages": { + Type: schema.TypeBool, + Optional: true, + Description: "If this setting is enabled and if `category` is present in a `page` / `screen` call, then an event named `Viewed {category} page` / `Viewed {category} Screen` will be sent to Amplitude.", + }, + "track_named_pages": { + Type: schema.TypeBool, + Optional: true, + Description: "If this setting is enabled and `name` is present in a `page` call, then an event named `Viewed {name} page` will be sent to Amplitude.", + }, + "track_products_once": { + Type: schema.TypeBool, + Optional: true, + Description: "If this setting is enabled and if the event payload contains an array of products, then the event is tracked with the original event name and all the products as its property. Otherwise, each product is tracked with event as `Product purchased`.", + }, + "track_revenue_per_product": { + Type: schema.TypeBool, + Optional: true, + Description: "If this setting is enabled and if the event payload contains multiple products, each product's revenue is tracked individually.", + }, + "version_name": { + Type: schema.TypeString, + Optional: true, + Description: "The value of this field is set as the `versionName` of the Amplitude SDK.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), + }, + "traits_to_increment": { + Type: schema.TypeList, + Optional: true, + Description: "If this setting is enabled, the value of the corresponding trait will be incremented at Amplitude, with the value provided against the trait in an `identify` call.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "traits_to_set_once": { - Type: schema.TypeList, - Optional: true, - Description: "If this setting is enabled, the value of the corresponding trait will be set once at Amplitude with the value provided against the trait in an `identify` call.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + }, + "traits_to_set_once": { + Type: schema.TypeList, + Optional: true, + Description: "If this setting is enabled, the value of the corresponding trait will be set once at Amplitude with the value provided against the trait in an `identify` call.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "traits_to_append": { - Type: schema.TypeList, - Optional: true, - Description: "If this setting is enabled, the value of the corresponding trait will be appended to the corresponding trait array at Amplitude.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + }, + "traits_to_append": { + Type: schema.TypeList, + Optional: true, + Description: "If this setting is enabled, the value of the corresponding trait will be appended to the corresponding trait array at Amplitude.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "traits_to_prepend": { - Type: schema.TypeList, - Optional: true, - Description: "If this setting is enabled, the value of the corresponding trait will be prepended to the corresponding trait array at Amplitude.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + }, + "traits_to_prepend": { + Type: schema.TypeList, + Optional: true, + Description: "If this setting is enabled, the value of the corresponding trait will be prepended to the corresponding trait array at Amplitude.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "use_native_sdk": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Enable this setting to send events to Amplitude via the device mode.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, - "ios": { - Type: schema.TypeBool, - Optional: true, - }, - "android": { - Type: schema.TypeBool, - Optional: true, - }, - "react_native": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "use_native_sdk": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Enable this setting to send events to Amplitude via the device mode.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, + }, + "ios": { + Type: schema.TypeBool, + Optional: true, + }, + "android": { + Type: schema.TypeBool, + Optional: true, + }, + "react_native": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "prefer_anonymous_id_for_device_id": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If this setting is enabled, the device ID will be set as the `anonymousId` generated by RudderStack SDK or by the `anonymousId` set via RudderStack's `setAnonymousId()` method.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "prefer_anonymous_id_for_device_id": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If this setting is enabled, the device ID will be set as the `anonymousId` generated by RudderStack SDK or by the `anonymousId` set via RudderStack's `setAnonymousId()` method.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "device_id_from_url_param": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If this setting is enabled, the Amplitude SDK will parse the URL parameter and set the device ID from `amp_device_id`.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "device_id_from_url_param": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If this setting is enabled, the Amplitude SDK will parse the URL parameter and set the device ID from `amp_device_id`.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "force_https": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If this setting is enabled, the events will always be uploaded by the Amplitude SDK to the HTTPS endpoint, otherwise it will use the embedding site's protocol.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "force_https": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If this setting is enabled, the events will always be uploaded by the Amplitude SDK to the HTTPS endpoint, otherwise it will use the embedding site's protocol.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "track_gclid": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If this setting is enabled, the Amplitude SDK will capture the `gclid` URL parameters along with the user's `initial_gclid` parameters.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "track_gclid": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If this setting is enabled, the Amplitude SDK will capture the `gclid` URL parameters along with the user's `initial_gclid` parameters.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "track_referrer": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If this setting is enabled, the Amplitude SDK will capture the `referrer` and `referring_domain` for each session along with the user's `initial_referrer` and `initial_referring_domain`.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "track_referrer": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If this setting is enabled, the Amplitude SDK will capture the `referrer` and `referring_domain` for each session along with the user's `initial_referrer` and `initial_referring_domain`.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "save_params_referrer_once_per_session": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If this setting is enabled, the corresponding tracking of `gclid`, referrer, UTM parameters will be done once per session.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "save_params_referrer_once_per_session": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If this setting is enabled, the corresponding tracking of `gclid`, referrer, UTM parameters will be done once per session.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "track_utm_properties": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If this setting is enabled, the Amplitude SDK parses the UTM parameters in the query string or `_utmz` cookie and includes them as user properties in all uploaded events.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "track_utm_properties": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If this setting is enabled, the Amplitude SDK parses the UTM parameters in the query string or `_utmz` cookie and includes them as user properties in all uploaded events.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "unset_params_referrer_on_new_session": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If this setting is disabled, the existing `referrer` and `utm_parameter` values will be passed to each new session. If enabled, `referrer` and `utm_parameter` properties will be set to `null` upon instantiating a new session.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "unset_params_referrer_on_new_session": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If this setting is disabled, the existing `referrer` and `utm_parameter` values will be passed to each new session. If enabled, `referrer` and `utm_parameter` properties will be set to `null` upon instantiating a new session.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "batch_events": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If this setting is enabled, the events are batched together and uploaded by the Amplitude SDK.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "batch_events": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If this setting is enabled, the events are batched together and uploaded by the Amplitude SDK.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "event_filtering": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "This option allows you filter the events you want to send to Amplitude.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "whitelist": { - Type: schema.TypeList, - Optional: true, + }, + "event_filtering": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "This option allows you filter the events you want to send to Amplitude.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "whitelist": { + Type: schema.TypeList, + Optional: true, Description: "Enter the event names to be allowlisted.", - ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "blacklist": { - Type: schema.TypeList, - Optional: true, + }, + "blacklist": { + Type: schema.TypeList, + Optional: true, Description: "Enter the event names to be denylisted.", - ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, }, }, - "event_upload_period_millis": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If the batch events settings is enabled, this is the amount of time that the SDK waits to upload the events.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeString, - Optional: true, - }, - "ios": { - Type: schema.TypeString, - Optional: true, - }, - "android": { - Type: schema.TypeString, - Optional: true, - }, - "react_native": { - Type: schema.TypeString, - Optional: true, - }, + }, + "event_upload_period_millis": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If the batch events settings is enabled, this is the amount of time that the SDK waits to upload the events.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeString, + Optional: true, }, - }, - }, - "event_upload_threshold": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "If the batch events settings is enabled, this is the minimum number of events to batch together by the Amplitude SDK.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeString, - Optional: true, - }, - "ios": { - Type: schema.TypeString, - Optional: true, - }, - "android": { - Type: schema.TypeString, - Optional: true, - }, - "react_native": { - Type: schema.TypeString, - Optional: true, - }, + "ios": { + Type: schema.TypeString, + Optional: true, + }, + "android": { + Type: schema.TypeString, + Optional: true, + }, + "react_native": { + Type: schema.TypeString, + Optional: true, }, }, }, - "map_device_brand": { - Type: schema.TypeBool, - Optional: true, - Description: "Enable this setting for RudderStack to send the device brand information (`context.device.brand`) to Amplitude.", - }, - "enable_location_listening": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Enable this setting to activate location listening.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "android": { - Type: schema.TypeBool, - Optional: true, - }, - "react_native": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "event_upload_threshold": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "If the batch events settings is enabled, this is the minimum number of events to batch together by the Amplitude SDK.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeString, + Optional: true, + }, + "ios": { + Type: schema.TypeString, + Optional: true, + }, + "android": { + Type: schema.TypeString, + Optional: true, + }, + "react_native": { + Type: schema.TypeString, + Optional: true, }, }, }, - "track_session_events": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Enable this setting to track the session events.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ios": { - Type: schema.TypeBool, - Optional: true, - }, - "android": { - Type: schema.TypeBool, - Optional: true, - }, - "react_native": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "map_device_brand": { + Type: schema.TypeBool, + Optional: true, + Description: "Enable this setting for RudderStack to send the device brand information (`context.device.brand`) to Amplitude.", + }, + "enable_location_listening": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Enable this setting to activate location listening.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "android": { + Type: schema.TypeBool, + Optional: true, + }, + "react_native": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "use_advertising_id_for_device_id": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Enable this setting to set the advertising ID as the device ID.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "android": { - Type: schema.TypeBool, - Optional: true, - }, - "react_native": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "track_session_events": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Enable this setting to track the session events.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ios": { + Type: schema.TypeBool, + Optional: true, + }, + "android": { + Type: schema.TypeBool, + Optional: true, + }, + "react_native": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "use_idfa_as_device_id": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Enable this setting to set the IDFA as the device ID.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ios": { - Type: schema.TypeBool, - Optional: true, - }, - "react_native": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "use_advertising_id_for_device_id": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Enable this setting to set the advertising ID as the device ID.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "android": { + Type: schema.TypeBool, + Optional: true, + }, + "react_native": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "onetrust_cookie_categories": { - Type: schema.TypeList, - Optional: true, - Description: "Specify the OneTrust category name for mapping the OneTrust consent settings to RudderStack's consent purposes.", - Elem: &schema.Schema{ - Type: schema.TypeString, + }, + "use_idfa_as_device_id": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Enable this setting to set the IDFA as the device ID.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ios": { + Type: schema.TypeBool, + Optional: true, + }, + "react_native": { + Type: schema.TypeBool, + Optional: true, + }, }, }, }, + }; + + for key, value := range commonSchema { + schema[key] = value + } + + c.Destinations.Register("amplitude", c.ConfigMeta{ + APIType: "AM", + Properties: properties, + ConfigSchema: schema, }) } diff --git a/rudderstack/integrations/destinations/destination_amplitude_test.go b/rudderstack/integrations/destinations/destination_amplitude_test.go index f13ecc1..f73427c 100644 --- a/rudderstack/integrations/destinations/destination_amplitude_test.go +++ b/rudderstack/integrations/destinations/destination_amplitude_test.go @@ -122,7 +122,19 @@ func TestDestinationResourceAmplitude(t *testing.T) { blacklist = ["one", "two", "three"] } - onetrust_cookie_categories = ["one", "two", "three"] + onetrust_cookie_categories { + web = ["one", "two", "three"] + android = ["one", "two", "three"] + ios = ["one", "two", "three"] + unity = ["one", "two", "three"] + reactnative = ["one", "two", "three"] + flutter = ["one", "two", "three"] + cordova = ["one", "two", "three"] + amp = ["one", "two", "three"] + cloud = ["one", "two", "three"] + warehouse = ["one", "two", "three"] + shopify = ["one", "two", "three"] + } residency_server = "EU" `, @@ -195,11 +207,63 @@ func TestDestinationResourceAmplitude(t *testing.T) { "trackSessionEvents": { "android": true, "ios": true, "reactnative": true }, "useAdvertisingIdForDeviceId": { "android": true, "reactnative": true }, "useIdfaAsDeviceId": { "ios": true, "reactnative": true }, - "oneTrustCookieCategories": [ - { "oneTrustCookieCategory": "one" }, - { "oneTrustCookieCategory": "two" }, - { "oneTrustCookieCategory": "three" } - ], + "oneTrustCookieCategories": { + "web": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "android": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "ios": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "unity": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "reactnative": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "flutter": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "cordova": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "amp": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "cloud": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "warehouse": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "shopify": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ] + }, "residencyServer": "EU" }`, }, diff --git a/rudderstack/integrations/destinations/destination_braze.go b/rudderstack/integrations/destinations/destination_braze.go index ec3a7e9..2b79a54 100644 --- a/rudderstack/integrations/destinations/destination_braze.go +++ b/rudderstack/integrations/destinations/destination_braze.go @@ -9,8 +9,8 @@ func init() { c.Destinations.Register("braze", c.ConfigMeta{ APIType: "BRAZE", Properties: []c.ConfigProperty{ - c.Simple("restApiKey", "rest_api_key"), - c.Simple("appKey", "app_key"), + c.Simple("restApiKey", "rest_api_key", c.SkipZeroValue), + c.Simple("appKey", "app_key", c.SkipZeroValue), c.Simple("dataCenter", "data_center"), c.Simple("enableSubscriptionGroupInGroupCall", "enable_subscription_group_in_group_call", c.SkipZeroValue), c.Simple("enableNestedArrayOperations", "enable_nested_array_operations", c.SkipZeroValue), diff --git a/rudderstack/integrations/destinations/destination_braze_test.go b/rudderstack/integrations/destinations/destination_braze_test.go index d155afb..1530308 100644 --- a/rudderstack/integrations/destinations/destination_braze_test.go +++ b/rudderstack/integrations/destinations/destination_braze_test.go @@ -11,27 +11,37 @@ func TestDestinationResourceBraze(t *testing.T) { cmt.AssertDestination(t, "braze", []c.TestConfig{ { TerraformCreate: ` - connection_mode = "cloud", - data_center = "US-01", + connection_mode { + web = "cloud" + ios = "cloud" + } + data_center = "US-03" rest_api_key = "rest_api_pass" `, APICreate: `{ - connection_mode = "cloud", - data_center = "US-01", - rest_api_key = "rest_api_pass", - enable_subscription_group_in_group_call = true, - track_anonymous_user = true + "connectionMode": { + "web": "cloud", + "ios": "cloud" + }, + "dataCenter": "US-03", + "restApiKey": "rest_api_pass" }`, TerraformUpdate: ` - connection_mode = "cloud", - data_center = "US-03", - rest_api_key = "updated_rest_api_pass" - onetrust_cookie_categories = ["one", "two", "three"] + connection_mode { + web = "cloud" + ios = "cloud" + } + data_center = "US-03" + rest_api_key = "updated_rest_api_pass" + onetrust_cookie_categories = ["one", "two", "three"] `, APIUpdate: `{ - "connection_mode = "cloud", - data_center = "US-03", - rest_api_key = "updated_rest_api_pass" + "connectionMode": { + "web": "cloud", + "ios": "cloud" + }, + "dataCenter": "US-03", + "restApiKey": "updated_rest_api_pass", "oneTrustCookieCategories": [ { "oneTrustCookieCategory": "one" }, { "oneTrustCookieCategory": "two" }, diff --git a/rudderstack/integrations/destinations/destination_google_analytics4.go b/rudderstack/integrations/destinations/destination_google_analytics4.go index 2ed060d..2cd60b9 100644 --- a/rudderstack/integrations/destinations/destination_google_analytics4.go +++ b/rudderstack/integrations/destinations/destination_google_analytics4.go @@ -6,116 +6,120 @@ import ( ) func init() { - c.Destinations.Register("google_analytics4", c.ConfigMeta{ - APIType: "GA4", - Properties: []c.ConfigProperty{ - c.Simple("apiSecret", "api_secret", c.SkipZeroValue), - c.Simple("typesOfClient", "types_of_client", c.SkipZeroValue), - c.Simple("measurementId", "measurement_id", c.SkipZeroValue), - c.Simple("firebaseAppId", "firebase_app_id", c.SkipZeroValue), - c.Simple("blockPageViewEvent", "block_page_view_event", c.SkipZeroValue), - c.Simple("extendPageViewParams", "extend_page_view_params", c.SkipZeroValue), - c.Simple("sendUserId", "send_user_id", c.SkipZeroValue), - c.ArrayWithStrings("whitelistedEvents", "eventName", "event_filtering.0.whitelist"), - c.ArrayWithStrings("blacklistedEvents", "eventName", "event_filtering.0.blacklist"), - c.Discriminator("eventFilteringOption", c.DiscriminatorValues{ - "event_filtering.0.whitelist": "whitelistedEvents", - "event_filtering.0.blacklist": "blacklistedEvents", - }), - c.Simple("useNativeSDK.web", "use_native_sdk.0.web"), - c.ArrayWithStrings("oneTrustCookieCategories", "oneTrustCookieCategory", "onetrust_cookie_categories"), + supportedSourceTypes := []string{"web", "android", "ios", "unity", "reactnative", "flutter", "cordova", "amp", "cloud", "warehouse", "shopify"} + commonProperties, commonSchema := GetCommonConfigMeta(supportedSourceTypes) + + properties := []c.ConfigProperty{ + c.Simple("apiSecret", "api_secret", c.SkipZeroValue), + c.Simple("typesOfClient", "types_of_client", c.SkipZeroValue), + c.Simple("measurementId", "measurement_id", c.SkipZeroValue), + c.Simple("firebaseAppId", "firebase_app_id", c.SkipZeroValue), + c.Simple("blockPageViewEvent", "block_page_view_event", c.SkipZeroValue), + c.Simple("extendPageViewParams", "extend_page_view_params", c.SkipZeroValue), + c.Simple("sendUserId", "send_user_id", c.SkipZeroValue), + c.ArrayWithStrings("whitelistedEvents", "eventName", "event_filtering.0.whitelist"), + c.ArrayWithStrings("blacklistedEvents", "eventName", "event_filtering.0.blacklist"), + c.Discriminator("eventFilteringOption", c.DiscriminatorValues{ + "event_filtering.0.whitelist": "whitelistedEvents", + "event_filtering.0.blacklist": "blacklistedEvents", + }), + c.Simple("useNativeSDK.web", "use_native_sdk.0.web"), + } + + properties = append(properties, commonProperties...) + + schema := map[string]*schema.Schema{ + "api_secret": { + Type: schema.TypeString, + Optional: true, + Sensitive: true, + Description: "This field is required only for the cloud mode setup where you can enter the API Secret generated through the Google Analytics dashboard.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"), }, - ConfigSchema: map[string]*schema.Schema{ - "api_secret": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "This field is required only for the cloud mode setup where you can enter the API Secret generated through the Google Analytics dashboard.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"), - }, - "types_of_client": { - Type: schema.TypeString, - Optional: true, - Description: "Select the client type as gtag or Firebase.", - ValidateDiagFunc: c.StringMatchesRegexp("(^env[.].+)|^(gtag|firebase)$"), - }, - "measurement_id": { - Type: schema.TypeString, - Required: true, - Description: "Enter the Measurement Id which is the identifier for a data stream.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(G-.{1,100})$|^$"), - }, - "firebase_app_id": { - Type: schema.TypeString, - Optional: true, - Description: "Enter the Firebase App ID which is the identifier for Firebase app.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"), - }, - "block_page_view_event": { - Type: schema.TypeBool, - Optional: true, - Description: "Enable this setting to disable sending `page_view` events on load. This setting is applicable only for device mode.", - }, - "extend_page_view_params": { - Type: schema.TypeBool, - Optional: true, - Description: "Enable this setting to send `url` and `search` along with any other custom property to the `page` call of the RudderStack SDK. This setting is applicable only for device mode.", - }, - "send_user_id": { - Type: schema.TypeBool, - Optional: true, - Description: "If enabled, the user ID is set to the identified visitors and sent to Google Analytics 4.", - }, - "event_filtering": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "With this option, you can determine which events are blocked or allowed to flow through to Google Analytics 4.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "whitelist": { - Type: schema.TypeList, - Optional: true, + "types_of_client": { + Type: schema.TypeString, + Optional: true, + Description: "Select the client type as gtag or Firebase.", + ValidateDiagFunc: c.StringMatchesRegexp("(^env[.].+)|^(gtag|firebase)$"), + }, + "measurement_id": { + Type: schema.TypeString, + Required: true, + Description: "Enter the Measurement Id which is the identifier for a data stream.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(G-.{1,100})$|^$"), + }, + "firebase_app_id": { + Type: schema.TypeString, + Optional: true, + Description: "Enter the Firebase App ID which is the identifier for Firebase app.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"), + }, + "block_page_view_event": { + Type: schema.TypeBool, + Optional: true, + Description: "Enable this setting to disable sending `page_view` events on load. This setting is applicable only for device mode.", + }, + "extend_page_view_params": { + Type: schema.TypeBool, + Optional: true, + Description: "Enable this setting to send `url` and `search` along with any other custom property to the `page` call of the RudderStack SDK. This setting is applicable only for device mode.", + }, + "send_user_id": { + Type: schema.TypeBool, + Optional: true, + Description: "If enabled, the user ID is set to the identified visitors and sent to Google Analytics 4.", + }, + "event_filtering": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "With this option, you can determine which events are blocked or allowed to flow through to Google Analytics 4.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "whitelist": { + Type: schema.TypeList, + Optional: true, Description: "Enter the event names to be allowlisted.", - ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "blacklist": { - Type: schema.TypeList, - Optional: true, + }, + "blacklist": { + Type: schema.TypeList, + Optional: true, Description: "Enter the event names to be denylisted.", - ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, }, }, - "use_native_sdk": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Enable this setting to send the events via the device mode.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "use_native_sdk": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Enable this setting to send the events via the device mode.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "onetrust_cookie_categories": { - Type: schema.TypeList, - Optional: true, - Description: "Specify the OneTrust category name for mapping the OneTrust consent settings to RudderStack's consent purposes.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, }, + } + + for key, value := range commonSchema { + schema[key] = value + } + + c.Destinations.Register("google_analytics4", c.ConfigMeta{ + APIType: "GA4", + Properties: properties, + ConfigSchema: schema, }) } diff --git a/rudderstack/integrations/destinations/destination_google_analytics4_test.go b/rudderstack/integrations/destinations/destination_google_analytics4_test.go index 18e6592..fc89b04 100644 --- a/rudderstack/integrations/destinations/destination_google_analytics4_test.go +++ b/rudderstack/integrations/destinations/destination_google_analytics4_test.go @@ -37,7 +37,19 @@ func TestDestinationResourceGoogleAnalytics4(t *testing.T) { blacklist = ["one", "two", "three"] } - onetrust_cookie_categories = ["one", "two", "three"] + onetrust_cookie_categories { + web = ["one", "two", "three"] + android = ["one", "two", "three"] + ios = ["one", "two", "three"] + unity = ["one", "two", "three"] + reactnative = ["one", "two", "three"] + flutter = ["one", "two", "three"] + cordova = ["one", "two", "three"] + amp = ["one", "two", "three"] + cloud = ["one", "two", "three"] + warehouse = ["one", "two", "three"] + shopify = ["one", "two", "three"] + } `, APIUpdate: `{ "apiSecret": "...", @@ -62,11 +74,63 @@ func TestDestinationResourceGoogleAnalytics4(t *testing.T) { "useNativeSDK": { "web": true }, - "oneTrustCookieCategories": [ - { "oneTrustCookieCategory": "one" }, - { "oneTrustCookieCategory": "two" }, - { "oneTrustCookieCategory": "three" } - ] + "oneTrustCookieCategories": { + "web": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "android": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "ios": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "unity": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "reactnative": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "flutter": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "cordova": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "amp": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "cloud": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "warehouse": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "shopify": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ] + } }`, }, }) diff --git a/rudderstack/integrations/destinations/destination_google_tag_manager.go b/rudderstack/integrations/destinations/destination_google_tag_manager.go index e0c26e9..fab54f5 100644 --- a/rudderstack/integrations/destinations/destination_google_tag_manager.go +++ b/rudderstack/integrations/destinations/destination_google_tag_manager.go @@ -6,83 +6,87 @@ import ( ) func init() { - c.Destinations.Register("google_tag_manager", c.ConfigMeta{ - APIType: "GTM", - Properties: []c.ConfigProperty{ - c.Simple("containerID", "container_id"), - c.Simple("serverUrl", "server_url", c.SkipZeroValue), - c.ArrayWithStrings("whitelistedEvents", "eventName", "event_filtering.0.whitelist"), - c.ArrayWithStrings("blacklistedEvents", "eventName", "event_filtering.0.blacklist"), - c.Discriminator("eventFilteringOption", c.DiscriminatorValues{ - "event_filtering.0.whitelist": "whitelistedEvents", - "event_filtering.0.blacklist": "blacklistedEvents", - }), - c.Simple("useNativeSDK.web", "use_native_sdk.0.web"), - c.ArrayWithStrings("oneTrustCookieCategories", "oneTrustCookieCategory", "onetrust_cookie_categories"), + supportedSourceTypes := []string{"web"} + commonProperties, commonSchema := GetCommonConfigMeta(supportedSourceTypes) + + properties := []c.ConfigProperty{ + c.Simple("containerID", "container_id"), + c.Simple("serverUrl", "server_url", c.SkipZeroValue), + c.ArrayWithStrings("whitelistedEvents", "eventName", "event_filtering.0.whitelist"), + c.ArrayWithStrings("blacklistedEvents", "eventName", "event_filtering.0.blacklist"), + c.Discriminator("eventFilteringOption", c.DiscriminatorValues{ + "event_filtering.0.whitelist": "whitelistedEvents", + "event_filtering.0.blacklist": "blacklistedEvents", + }), + c.Simple("useNativeSDK.web", "use_native_sdk.0.web"), + } + + properties = append(properties, commonProperties...) + + schema := map[string]*schema.Schema{ + "container_id": { + Type: schema.TypeString, + Required: true, + Description: "Enter your Google Tag Manager container ID.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), }, - ConfigSchema: map[string]*schema.Schema{ - "container_id": { - Type: schema.TypeString, - Required: true, - Description: "Enter your Google Tag Manager container ID.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), - }, - "server_url": { - Type: schema.TypeString, - Optional: true, - Description: "Specify Tag Manager server container URL.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$"), - }, - "event_filtering": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "With this option, you can determine which events are blocked or allowed to flow through to GTM.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "whitelist": { - Type: schema.TypeList, - Optional: true, + "server_url": { + Type: schema.TypeString, + Optional: true, + Description: "Specify Tag Manager server container URL.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$"), + }, + "event_filtering": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "With this option, you can determine which events are blocked or allowed to flow through to GTM.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "whitelist": { + Type: schema.TypeList, + Optional: true, Description: "Enter the event names to be allowlisted.", - ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "blacklist": { - Type: schema.TypeList, - Optional: true, + }, + "blacklist": { + Type: schema.TypeList, + Optional: true, Description: "Enter the event names to be denylisted.", - ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, }, }, - "use_native_sdk": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Enable this setting to send the events via the device mode.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "use_native_sdk": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Enable this setting to send the events via the device mode.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "onetrust_cookie_categories": { - Type: schema.TypeList, - Optional: true, - Description: "Specify the OneTrust category name for mapping the OneTrust consent settings to RudderStack's consent purposes.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, }, + } + + for key, value := range commonSchema { + schema[key] = value + } + + c.Destinations.Register("google_tag_manager", c.ConfigMeta{ + APIType: "GTM", + Properties: properties, + ConfigSchema: schema, }) } diff --git a/rudderstack/integrations/destinations/destination_google_tag_manager_test.go b/rudderstack/integrations/destinations/destination_google_tag_manager_test.go index 465a285..ec369aa 100644 --- a/rudderstack/integrations/destinations/destination_google_tag_manager_test.go +++ b/rudderstack/integrations/destinations/destination_google_tag_manager_test.go @@ -29,7 +29,9 @@ func TestDestinationResourceGoogleTagManager(t *testing.T) { blacklist = ["one", "two", "three"] } - onetrust_cookie_categories = ["one", "two", "three"] + onetrust_cookie_categories { + web = ["one", "two", "three"] + } `, APIUpdate: `{ "containerID": "GTM-000000", @@ -49,11 +51,13 @@ func TestDestinationResourceGoogleTagManager(t *testing.T) { "useNativeSDK": { "web": true }, - "oneTrustCookieCategories": [ - { "oneTrustCookieCategory": "one" }, - { "oneTrustCookieCategory": "two" }, - { "oneTrustCookieCategory": "three" } - ] + "oneTrustCookieCategories": { + "web": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ] + } }`, }, }) diff --git a/rudderstack/integrations/destinations/destination_kafka.go b/rudderstack/integrations/destinations/destination_kafka.go index 39397fe..cd59f9f 100644 --- a/rudderstack/integrations/destinations/destination_kafka.go +++ b/rudderstack/integrations/destinations/destination_kafka.go @@ -7,17 +7,17 @@ import ( func init() { c.Destinations.Register("kafka", c.ConfigMeta{ - APIType: "RS", + APIType: "KAFKA", Properties: []c.ConfigProperty{ c.Simple("hostName", "host_name"), c.Simple("port", "port"), c.Simple("topic", "topic"), c.Simple("sslEnabled", "ssl_enabled", c.SkipZeroValue), - c.Simple("caCertificate", "ca_certificate"), + c.Simple("caCertificate", "ca_certificate", c.SkipZeroValue), c.Simple("useSASL", "use_sasl", c.SkipZeroValue), - c.Simple("saslType", "sasl_type"), - c.Simple("username", "username"), - c.Simple("password", "password"), + c.Simple("saslType", "sasl_type", c.SkipZeroValue), + c.Simple("username", "username", c.SkipZeroValue), + c.Simple("password", "password", c.SkipZeroValue), c.Simple("convertToAvro", "convert_to_avro", c.SkipZeroValue), c.ArrayWithObjects("avroSchema", "avro_schema", map[string]string{ "schemaId": "schema_id", @@ -175,4 +175,4 @@ func init() { }, }, }) -} \ No newline at end of file +} diff --git a/rudderstack/integrations/destinations/destination_kafka_test.go b/rudderstack/integrations/destinations/destination_kafka_test.go index 548f2aa..675a454 100644 --- a/rudderstack/integrations/destinations/destination_kafka_test.go +++ b/rudderstack/integrations/destinations/destination_kafka_test.go @@ -16,9 +16,10 @@ func TestDestinationResourceKafka(t *testing.T) { topic = "example-topic" `, APICreate: `{ - hostName = "example.com" - port = "9092" - topic = "example-topic" + "hostName": "example.com", + "port": "9092", + "topic": "example-topic", + "sslEnabled": true }`, TerraformUpdate: ` host_name = "example-updated.com" @@ -26,13 +27,13 @@ func TestDestinationResourceKafka(t *testing.T) { topic = "example-topic" ssl_enabled = true ca_certificate = "example-ca-certificate" - `, + `, APIUpdate: `{ - hostName = "example-updated.com" - port = "9092" - topic = "example-topic" - sslEnabled = true - caCertificate = "example-ca-certificate" + "hostName": "example-updated.com", + "port": "9092", + "topic": "example-topic", + "sslEnabled": true, + "caCertificate": "example-ca-certificate" }`, }, }) diff --git a/rudderstack/integrations/destinations/destination_marketo_test.go b/rudderstack/integrations/destinations/destination_marketo_test.go index ce2dace..3c30ced 100644 --- a/rudderstack/integrations/destinations/destination_marketo_test.go +++ b/rudderstack/integrations/destinations/destination_marketo_test.go @@ -8,7 +8,7 @@ import ( ) func TestDestinationResourceMarketo(t *testing.T) { - cmt.AssertDestination(t, "merketo", []c.TestConfig{ + cmt.AssertDestination(t, "marketo", []c.TestConfig{ { TerraformCreate: ` account_id = "..." @@ -16,14 +16,21 @@ func TestDestinationResourceMarketo(t *testing.T) { client_secret = "cs" track_anonymous_events = true create_if_not_exist = true - + connection_mode { + web = "cloud" + ios = "cloud" + } `, APICreate: `{ "accountId": "...", "clientId": "cid", "clientSecret": "cs", "trackAnonymousEvents": true, - "createIfNotExist": true + "createIfNotExist": true, + "connectionMode": { + "web": "cloud", + "ios": "cloud" + } }`, TerraformUpdate: ` account_id = "..." @@ -50,10 +57,14 @@ func TestDestinationResourceMarketo(t *testing.T) { to = "value1" } ] + connection_mode { + web = "cloud" + ios = "cloud" + } onetrust_cookie_categories = ["one", "two", "three"] `, APIUpdate: `{ - accountId": "...", + "accountId": "...", "clientId": "cid2", "clientSecret": "cs", "trackAnonymousEvents": true, @@ -77,7 +88,15 @@ func TestDestinationResourceMarketo(t *testing.T) { "to": "value1" } ], - "oneTrustCookieCategories": ["one", "two", "three"] + "connectionMode": { + "web": "cloud", + "ios": "cloud" + }, + "oneTrustCookieCategories": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ] }`, }, }) diff --git a/rudderstack/integrations/destinations/destination_mixpanel.go b/rudderstack/integrations/destinations/destination_mixpanel.go index e3b3cb2..f7c3c19 100644 --- a/rudderstack/integrations/destinations/destination_mixpanel.go +++ b/rudderstack/integrations/destinations/destination_mixpanel.go @@ -6,201 +6,205 @@ import ( ) func init() { - c.Destinations.Register("mixpanel", c.ConfigMeta{ - APIType: "MP", - Properties: []c.ConfigProperty{ - c.Simple("token", "token"), - c.Simple("apiSecret", "api_secret", c.SkipZeroValue), - c.Simple("dataResidency", "data_residency"), - c.Simple("people", "people", c.SkipZeroValue), - c.Simple("setAllTraitsByDefault", "set_all_traits_by_default", c.SkipZeroValue), - c.Simple("consolidatedPageCalls", "consolidated_page_calls"), - c.Simple("trackCategorizedPages", "track_categorized_pages", c.SkipZeroValue), - c.Simple("trackNamedPages", "track_named_pages", c.SkipZeroValue), - c.Simple("sourceName", "source_name", c.SkipZeroValue), - c.Simple("crossSubdomainCookie", "cross_subdomain_cookie", c.SkipZeroValue), - c.Simple("persistence", "persistence"), - c.Simple("secureCookie", "secure_cookie", c.SkipZeroValue), - c.ArrayWithStrings("superProperties", "property", "super_properties"), - c.ArrayWithStrings("peopleProperties", "property", "people_properties"), - c.ArrayWithStrings("eventIncrements", "property", "event_increments"), - c.ArrayWithStrings("propIncrements", "property", "prop_increments"), - c.ArrayWithStrings("groupKeySettings", "groupKey", "group_key_settings"), - c.Simple("useNativeSDK.web", "use_native_sdk.0.web"), - c.Discriminator("eventFilteringOption", c.DiscriminatorValues{ - "event_filtering.0.whitelist": "whitelistedEvents", - "event_filtering.0.blacklist": "blacklistedEvents", - }), - c.ArrayWithStrings("whitelistedEvents", "eventName", "event_filtering.0.whitelist"), - c.ArrayWithStrings("blacklistedEvents", "eventName", "event_filtering.0.blacklist"), - c.ArrayWithStrings("oneTrustCookieCategories", "oneTrustCookieCategory", "onetrust_cookie_categories"), - c.Simple("useNewMapping", "use_new_mapping", c.SkipZeroValue), - }, - ConfigSchema: map[string]*schema.Schema{ - "token": { - Type: schema.TypeString, - Required: true, - Description: "Mixpanel API Token", - Sensitive: true, - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), - }, - "api_secret": { - Type: schema.TypeString, - Optional: true, - Sensitive: true, - Description: "Mixpanel API secret", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"), - }, - "data_residency": { - Type: schema.TypeString, - Required: true, - Description: "Mixpanel Server region either us/eu", - ValidateDiagFunc: c.StringMatchesRegexp("^(us|eu)$"), - }, - "people": { - Type: schema.TypeBool, - Optional: true, - Description: "Boolean flag to send all of your identify calls to Mixpanel's People feature ", - }, - "set_all_traits_by_default": { - Type: schema.TypeBool, - Optional: true, - Description: "While this is checked, our integration automatically sets all traits on identify calls as super properties and people properties if Mixpanel People is checked as well.", - }, - "consolidated_page_calls": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "This will track Loaded a Page events to Mixpanel for all page method calls. We enable this by default as it's how Mixpanel suggests sending these calls.", - }, - "track_categorized_pages": { - Type: schema.TypeBool, - Optional: true, - Description: "This will track events to Mixpanel for page method calls that have a category associated with them. For example page('Docs', 'Index') would translate to Viewed Docs Index Page.", - }, - "track_named_pages": { - Type: schema.TypeBool, - Optional: true, - Description: "This will track events to Mixpanel for page method calls that have a name associated with them. For example page('Signup') would translate to Viewed Signup Page.", - }, - "source_name": { - Type: schema.TypeString, - Optional: true, - Description: "This value, if it's not blank, will be sent as rudderstack_source_name to Mixpanel for every event/page/screen call.", - ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"), - }, - "cross_subdomain_cookie": { - Type: schema.TypeBool, - Optional: true, - Description: "This will allow the Mixpanel cookie to persist between different pages of your application.", - }, - "persistence": { - Type: schema.TypeString, - Required: true, - Description: "Choose persistence for Mixpanel SDK. One of none|cookie|localStorage", - ValidateDiagFunc: c.StringMatchesRegexp("^(none|cookie|localStorage)$"), - }, - "secure_cookie": { - Type: schema.TypeBool, - Optional: true, - Description: "This will mark the Mixpanel cookie as secure, meaning it will only be transmitted over https.", - }, - "super_properties": { - Type: schema.TypeList, - Optional: true, - Description: "Property to send as super Properties.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + supportedSourceTypes := []string{"web", "android", "ios", "unity", "reactnative", "flutter", "cordova", "amp", "cloud", "warehouse", "shopify"} + commonProperties, commonSchema := GetCommonConfigMeta(supportedSourceTypes) + + properties := []c.ConfigProperty{ + c.Simple("token", "token"), + c.Simple("apiSecret", "api_secret", c.SkipZeroValue), + c.Simple("dataResidency", "data_residency"), + c.Simple("people", "people", c.SkipZeroValue), + c.Simple("setAllTraitsByDefault", "set_all_traits_by_default", c.SkipZeroValue), + c.Simple("consolidatedPageCalls", "consolidated_page_calls"), + c.Simple("trackCategorizedPages", "track_categorized_pages", c.SkipZeroValue), + c.Simple("trackNamedPages", "track_named_pages", c.SkipZeroValue), + c.Simple("sourceName", "source_name", c.SkipZeroValue), + c.Simple("crossSubdomainCookie", "cross_subdomain_cookie", c.SkipZeroValue), + c.Simple("persistence", "persistence"), + c.Simple("secureCookie", "secure_cookie", c.SkipZeroValue), + c.ArrayWithStrings("superProperties", "property", "super_properties"), + c.ArrayWithStrings("peopleProperties", "property", "people_properties"), + c.ArrayWithStrings("eventIncrements", "property", "event_increments"), + c.ArrayWithStrings("propIncrements", "property", "prop_increments"), + c.ArrayWithStrings("groupKeySettings", "groupKey", "group_key_settings"), + c.Simple("useNativeSDK.web", "use_native_sdk.0.web"), + c.Discriminator("eventFilteringOption", c.DiscriminatorValues{ + "event_filtering.0.whitelist": "whitelistedEvents", + "event_filtering.0.blacklist": "blacklistedEvents", + }), + c.ArrayWithStrings("whitelistedEvents", "eventName", "event_filtering.0.whitelist"), + c.ArrayWithStrings("blacklistedEvents", "eventName", "event_filtering.0.blacklist"), + c.Simple("useNewMapping", "use_new_mapping", c.SkipZeroValue), + } + + properties = append(properties, commonProperties...) + + schema := map[string]*schema.Schema{ + "token": { + Type: schema.TypeString, + Required: true, + Description: "Mixpanel API Token", + Sensitive: true, + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$"), + }, + "api_secret": { + Type: schema.TypeString, + Optional: true, + Sensitive: true, + Description: "Mixpanel API secret", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"), + }, + "data_residency": { + Type: schema.TypeString, + Required: true, + Description: "Mixpanel Server region either us/eu", + ValidateDiagFunc: c.StringMatchesRegexp("^(us|eu)$"), + }, + "people": { + Type: schema.TypeBool, + Optional: true, + Description: "Boolean flag to send all of your identify calls to Mixpanel's People feature ", + }, + "set_all_traits_by_default": { + Type: schema.TypeBool, + Optional: true, + Description: "While this is checked, our integration automatically sets all traits on identify calls as super properties and people properties if Mixpanel People is checked as well.", + }, + "consolidated_page_calls": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "This will track Loaded a Page events to Mixpanel for all page method calls. We enable this by default as it's how Mixpanel suggests sending these calls.", + }, + "track_categorized_pages": { + Type: schema.TypeBool, + Optional: true, + Description: "This will track events to Mixpanel for page method calls that have a category associated with them. For example page('Docs', 'Index') would translate to Viewed Docs Index Page.", + }, + "track_named_pages": { + Type: schema.TypeBool, + Optional: true, + Description: "This will track events to Mixpanel for page method calls that have a name associated with them. For example page('Signup') would translate to Viewed Signup Page.", + }, + "source_name": { + Type: schema.TypeString, + Optional: true, + Description: "This value, if it's not blank, will be sent as rudderstack_source_name to Mixpanel for every event/page/screen call.", + ValidateDiagFunc: c.StringMatchesRegexp("(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"), + }, + "cross_subdomain_cookie": { + Type: schema.TypeBool, + Optional: true, + Description: "This will allow the Mixpanel cookie to persist between different pages of your application.", + }, + "persistence": { + Type: schema.TypeString, + Required: true, + Description: "Choose persistence for Mixpanel SDK. One of none|cookie|localStorage", + ValidateDiagFunc: c.StringMatchesRegexp("^(none|cookie|localStorage)$"), + }, + "secure_cookie": { + Type: schema.TypeBool, + Optional: true, + Description: "This will mark the Mixpanel cookie as secure, meaning it will only be transmitted over https.", + }, + "super_properties": { + Type: schema.TypeList, + Optional: true, + Description: "Property to send as super Properties.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "people_properties": { - Type: schema.TypeList, - Optional: true, - Description: "Traits to set as People Properties.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + }, + "people_properties": { + Type: schema.TypeList, + Optional: true, + Description: "Traits to set as People Properties.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "event_increments": { - Type: schema.TypeList, - Optional: true, - Description: "Events to increment in People.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + }, + "event_increments": { + Type: schema.TypeList, + Optional: true, + Description: "Events to increment in People.", + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "prop_increments": { - Type: schema.TypeList, - Optional: true, - Description: "Properties to increment in People", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + }, + "prop_increments": { + Type: schema.TypeList, + Optional: true, + Description: "Properties to increment in People", + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "group_key_settings": { - Type: schema.TypeList, - Optional: true, - Description: "Group Key", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + }, + "group_key_settings": { + Type: schema.TypeList, + Optional: true, + Description: "Group Key", + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "use_native_sdk": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "Enable this setting to send the events via the device mode.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "web": { - Type: schema.TypeBool, - Optional: true, - }, + }, + "use_native_sdk": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "Enable this setting to send the events via the device mode.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "web": { + Type: schema.TypeBool, + Optional: true, }, }, }, - "event_filtering": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Description: "With this option, you can determine which events are blocked or allowed to flow through to Mixpanel.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "whitelist": { - Type: schema.TypeList, - Optional: true, + }, + "event_filtering": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Description: "With this option, you can determine which events are blocked or allowed to flow through to Mixpanel.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "whitelist": { + Type: schema.TypeList, + Optional: true, Description: "Enter the event names to be allowlisted.", - ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, - "blacklist": { - Type: schema.TypeList, - Optional: true, + }, + "blacklist": { + Type: schema.TypeList, + Optional: true, Description: "Enter the event names to be denylisted.", - ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + ExactlyOneOf: []string{"config.0.event_filtering.0.whitelist", "config.0.event_filtering.0.blacklist"}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, }, }, - "onetrust_cookie_categories": { - Type: schema.TypeList, - Optional: true, - Description: "Specify the OneTrust category name for mapping the OneTrust consent settings to RudderStack's consent purposes.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "use_new_mapping": { - Type: schema.TypeBool, - Optional: true, - Default: true, - Description: "This value is true by default and when this flag is enabled, camel case fields are mapped to snake case fields while sending to Mixpanel. Please refer to https://www.rudderstack.com/docs/destinations/streaming-destinations/mixpanel/#connection-settings for more details.", - }, }, + "use_new_mapping": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "This value is true by default and when this flag is enabled, camel case fields are mapped to snake case fields while sending to Mixpanel. Please refer to https://www.rudderstack.com/docs/destinations/streaming-destinations/mixpanel/#connection-settings for more details.", + }, + } + + for key, value := range commonSchema { + schema[key] = value + } + + c.Destinations.Register("mixpanel", c.ConfigMeta{ + APIType: "MP", + Properties: properties, + ConfigSchema: schema, }) } diff --git a/rudderstack/integrations/destinations/destination_mixpanel_test.go b/rudderstack/integrations/destinations/destination_mixpanel_test.go index a8e6331..dbb4c64 100644 --- a/rudderstack/integrations/destinations/destination_mixpanel_test.go +++ b/rudderstack/integrations/destinations/destination_mixpanel_test.go @@ -50,7 +50,19 @@ func TestDestinationResourceMixpanel(t *testing.T) { whitelist = ["one", "two", "three"] } - onetrust_cookie_categories = ["one", "two", "three"] + onetrust_cookie_categories { + web = ["one", "two", "three"] + android = ["one", "two", "three"] + ios = ["one", "two", "three"] + unity = ["one", "two", "three"] + reactnative = ["one", "two", "three"] + flutter = ["one", "two", "three"] + cordova = ["one", "two", "three"] + amp = ["one", "two", "three"] + cloud = ["one", "two", "three"] + warehouse = ["one", "two", "three"] + shopify = ["one", "two", "three"] + } use_new_mapping = true `, APIUpdate: ` @@ -131,11 +143,63 @@ func TestDestinationResourceMixpanel(t *testing.T) { "eventName": "three" } ], - "oneTrustCookieCategories": [ - { "oneTrustCookieCategory": "one" }, - { "oneTrustCookieCategory": "two" }, - { "oneTrustCookieCategory": "three" } - ], + "oneTrustCookieCategories": { + "web": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "android": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "ios": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "unity": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "reactnative": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "flutter": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "cordova": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "amp": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "cloud": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "warehouse": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ], + "shopify": [ + { "oneTrustCookieCategory": "one" }, + { "oneTrustCookieCategory": "two" }, + { "oneTrustCookieCategory": "three" } + ] + }, "useNewMapping": true } `, diff --git a/rudderstack/integrations/destinations/destination_postgres.go b/rudderstack/integrations/destinations/destination_postgres.go index 5e68b2e..7ad010a 100644 --- a/rudderstack/integrations/destinations/destination_postgres.go +++ b/rudderstack/integrations/destinations/destination_postgres.go @@ -14,7 +14,7 @@ func init() { c.Simple("user", "user"), c.Simple("password", "password"), c.Simple("port", "port"), - c.Simple("namespace", "namespace"), + c.Simple("namespace", "namespace", c.SkipZeroValue), c.Simple("sslMode", "ssl_mode"), c.Simple("syncFrequency", "sync_frequency"), c.Simple("syncStartAt", "sync_start_at"), @@ -25,9 +25,9 @@ func init() { c.Simple("bucketProvider", "bucket_provider"), c.ArrayWithStrings("oneTrustCookieCategories", "oneTrustCookieCategory", "onetrust_cookie_categories"), c.Simple("bucketName", "bucket_name"), - c.Simple("clientKey", "client_key"), - c.Simple("clientCert", "client_cert"), - c.Simple("serverCA", "server_ca"), + c.Simple("clientKey", "client_key", c.SkipZeroValue), + c.Simple("clientCert", "client_cert", c.SkipZeroValue), + c.Simple("serverCA", "server_ca", c.SkipZeroValue), c.Simple("roleBasedAuth", "role_based_auth", c.SkipZeroValue), // boolean c.Simple("iamRoleARN", "iam_role_arn", c.SkipZeroValue), c.Simple("accessKeyID", "access_key_id", c.SkipZeroValue), diff --git a/rudderstack/integrations/destinations/destination_postgres_test.go b/rudderstack/integrations/destinations/destination_postgres_test.go index 19e4a77..b2614de 100644 --- a/rudderstack/integrations/destinations/destination_postgres_test.go +++ b/rudderstack/integrations/destinations/destination_postgres_test.go @@ -36,14 +36,9 @@ func TestDestinationResourcePostgres(t *testing.T) { user = "test-user" password = "test-password" port = "test-port" - ssl_mode = "test-ssl_mode" - sync_frequency = "test-sync_frequency" + ssl_mode = "verify-ca" + sync_frequency = "60" use_rudder_storage = true - exclude_window { - exclude_window_start_time = "test-exclude_window_start_time" - exclude_window_end_time = "test-exclude_window_end_time" - } - onetrust_cookie_categories = ["c001"] `, APIUpdate: `{ "host": "test-host", @@ -51,14 +46,9 @@ func TestDestinationResourcePostgres(t *testing.T) { "user": "test-user", "password": "test-password", "port": "test-port", - "sslMode": "test-ssl_mode", - "syncFrequency": "test-sync_frequency", - "useRudderStorage": true, - "excludeWindow": { - "excludeWindowStartTime": "test-exclude_window_start_time", - "excludeWindowEndTime": "test-exclude_window_end_time" - }, - "oneTrustCookieCategories": ["c001"] + "sslMode": "verify-ca", + "syncFrequency": "60", + "useRudderStorage": true }`, }, }) diff --git a/rudderstack/integrations/destinations/destination_zendesk_test.go b/rudderstack/integrations/destinations/destination_zendesk_test.go index 06312ba..7a4c3ee 100644 --- a/rudderstack/integrations/destinations/destination_zendesk_test.go +++ b/rudderstack/integrations/destinations/destination_zendesk_test.go @@ -28,7 +28,7 @@ func TestDestinationResourceZendesk(t *testing.T) { create_users_as_verified = true send_group_calls_without_user_id = true remove_users_from_organization = true - search_by_external_id = false + search_by_external_id = true onetrust_cookie_categories = ["one", "two", "three"] `, APIUpdate: `{ @@ -38,7 +38,7 @@ func TestDestinationResourceZendesk(t *testing.T) { "createUsersAsVerified": true, "sendGroupCallsWithoutUserId": true, "removeUsersFromOrganization": true, - "searchByExternalId": false, + "searchByExternalId": true, "oneTrustCookieCategories": [ { "oneTrustCookieCategory": "one" }, { "oneTrustCookieCategory": "two" }, diff --git a/rudderstack/provider.go b/rudderstack/provider.go index cd0e032..7f0678e 100644 --- a/rudderstack/provider.go +++ b/rudderstack/provider.go @@ -73,7 +73,7 @@ func configureClient(ctx context.Context, d *schema.ResourceData) (*Client, diag accessToken := d.Get("access_token").(string) client, err := NewAPIClient(accessToken, client.WithBaseURL(apiUrl), - client.WithUserAgent("terraform-provider-rudderstack/0.8.2")) + client.WithUserAgent("terraform-provider-rudderstack/1.0.0")) if err != nil { return nil, diag.FromErr(err) }