Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add generic consent management fields in initially onboarded destinations config #1058

Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d2c682d
chore: partial poc
bardisg Nov 7, 2023
db610e5
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Nov 7, 2023
b95dc53
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Nov 7, 2023
f2a550e
feat: add GCM destination configurations
bardisg Nov 7, 2023
85673ab
fix: revert configuration that was done for local testing only
bardisg Nov 7, 2023
3c02b93
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Nov 10, 2023
d7b3ffa
feat: add GCM fields in Mixpanel destination configs
bardisg Nov 13, 2023
b78b881
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Nov 13, 2023
6c72f16
chore: revert formatting changes
bardisg Nov 13, 2023
0550122
chore: revert formatting changes
bardisg Nov 13, 2023
6cc67da
chore: revert auto generated changes in MixPanel schema
bardisg Nov 13, 2023
2be42d6
chore: revert formatting changes
bardisg Nov 13, 2023
9ae16c7
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Nov 21, 2023
5062969
feat: new generic consent management fields in GA4
bardisg Nov 21, 2023
d9a2db5
fix: make consentManagement field to be source specific
bardisg Nov 21, 2023
c60f8c1
fix: make consentManagement field to be source specific in db-config
bardisg Nov 21, 2023
a7002f8
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Nov 23, 2023
6de4548
chore: revert formatting changes
bardisg Nov 23, 2023
f0c8f1e
fix: add dynamic custom form field preRequisites in validator and sch…
bardisg Nov 27, 2023
9ffa453
fix: add labels
bardisg Nov 27, 2023
df5a41e
fix: correct level in schema.json for nested prerequsites
bardisg Nov 27, 2023
7f020de
fix: generated pattern value for schema.json and add tests
bardisg Nov 28, 2023
67d0ec1
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Jan 11, 2024
f98c6e3
feat: new designs for consent management fields
bardisg Jan 17, 2024
d3e57c4
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Jan 17, 2024
41e5fb8
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Jan 19, 2024
89c5ce4
fix: resolve PR comments
bardisg Jan 19, 2024
427c25e
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Jan 19, 2024
3e65af9
Merge branch 'feature/sdk-660-update-consent-settings-in-destination-…
bardisg Jan 19, 2024
472e23d
fix: add support for consentSettingsTemplate in schemaGenerator script
bardisg Jan 19, 2024
796629a
fix: revert snowflake schema definitions ref
bardisg Jan 19, 2024
3e975e2
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Jan 23, 2024
33127d7
fix: remove default resolution strategy values from GCM fields
bardisg Jan 26, 2024
b082045
fix: set as default GCM provider OneTrust
bardisg Jan 26, 2024
70d58c8
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Jan 26, 2024
4a04292
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Jan 30, 2024
140ef01
Merge branch 'develop' into feature/sdk-660-update-consent-settings-i…
bardisg Jan 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"update:schema:source": "python3 scripts/schemaGenerator.py source -update -name ",
"check:schema:destination:all": "python3 scripts/schemaGenerator.py destination -all",
"check:schema:destination": "python3 scripts/schemaGenerator.py destination -name ",
"update:schema:destination": "python3 scripts/schemaGenerator.py destination -update -name "
"update:schema:destination": "python3 scripts/schemaGenerator.py destination -update -name ",
"deploy:db:local": "python3 scripts/deployToDB.py http://localhost:5050"
},
"devDependencies": {
"@babel/core": "^7.21.3",
Expand Down
Empty file modified scripts/run-schema-validation.sh
100644 → 100755
Empty file.
152 changes: 119 additions & 33 deletions scripts/schemaGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def is_field_present_in_default_config(field, dbConfig, schema_field_name):
return False

def generate_schema_for_default_checkbox(field, dbConfig, schema_field_name):
"""Creates an schema object of defaultCheckbox.
"""Creates a schema object of defaultCheckbox.

Args:
field (object): Individual field in ui-config.
Expand All @@ -144,7 +144,7 @@ def generate_schema_for_default_checkbox(field, dbConfig, schema_field_name):


def generate_schema_for_checkbox(field, dbConfig, schema_field_name):
"""Creates an schema object of checkbox.
"""Creates a schema object of checkbox.

Args:
field (object): Individual field in ui-config.
Expand Down Expand Up @@ -173,7 +173,7 @@ def generate_schema_for_checkbox(field, dbConfig, schema_field_name):


def generate_schema_for_textinput(field, dbConfig, schema_field_name):
"""Creates an schema object of textinput.
"""Creates a schema object of textinput.

Args:
field (object): Individual field in ui-config.
Expand Down Expand Up @@ -204,7 +204,7 @@ def generate_schema_for_textinput(field, dbConfig, schema_field_name):


def generate_schema_for_textarea_input(field, dbConfig, schema_field_name):
"""Creates an schema object of textareaInput.
"""Creates a schema object of textareaInput.

Args:
field (object): Individual field in ui-config.
Expand All @@ -222,7 +222,7 @@ def generate_schema_for_textarea_input(field, dbConfig, schema_field_name):


def generate_schema_for_single_select(field, dbConfig, schema_field_name):
"""Creates an schema object of singleSelect.
"""Creates a schema object of singleSelect.

Args:
field (object): Individual field in ui-config.
Expand Down Expand Up @@ -269,7 +269,7 @@ def generate_schema_for_single_select(field, dbConfig, schema_field_name):


def generate_schema_for_dynamic_custom_form(field, dbConfig, schema_field_name):
"""Creates an schema object of dynamicCustomForm.
"""Creates a schema object of dynamicCustomForm.

Args:
field (object): Individual field in ui-config.
Expand All @@ -285,21 +285,39 @@ def generate_schema_for_dynamic_custom_form(field, dbConfig, schema_field_name):
dynamicCustomFormItemObj = {}
dynamicCustomFormItemObj["type"] = FieldTypeEnum.OBJECT.value
dynamicCustomFormItemObj["properties"] = {}
for customField in field["customFields"]:
customeFieldSchemaObj = uiTypetoSchemaFn.get(customField["type"])(customField, dbConfig, schema_field_name)
allOfSchemaObj = {}

# For old schema types customFields contains the children, for v2 its is rowFields
customFieldsKey = "customFields"
if "rowFields" in field:
customFieldsKey = "rowFields"

allOfSchemaObj = generate_schema_for_dynamic_custom_form_allOf(field[customFieldsKey], dbConfig, schema_field_name)

for customField in field[customFieldsKey]:
customFieldSchemaObj = uiTypetoSchemaFn.get(customField["type"])(customField, dbConfig, schema_field_name)
isCustomFieldDependentOnSource = is_dest_field_dependent_on_source(customField, dbConfig, schema_field_name)
if 'pattern' not in customeFieldSchemaObj and not isCustomFieldDependentOnSource and customeFieldSchemaObj["type"]==FieldTypeEnum.STRING.value:
customeFieldSchemaObj["pattern"] = generalize_regex_pattern(customField)

if "preRequisites" in customField:
continue

if 'pattern' not in customFieldSchemaObj and not isCustomFieldDependentOnSource and customFieldSchemaObj["type"] == FieldTypeEnum.STRING.value:
customFieldSchemaObj["pattern"] = generalize_regex_pattern(customField)

# If the custom field is source dependent, we remove the source keys as it's not required inside custom fields, rather they need to be moved to top.
if isCustomFieldDependentOnSource:
for sourceType in dbConfig["supportedSourceTypes"]:
if sourceType in dbConfig["destConfig"] and field[schema_field_name] in dbConfig["destConfig"][sourceType]:
customeFieldSchemaObj = customeFieldSchemaObj["properties"][sourceType]
customFieldSchemaObj = customFieldSchemaObj["properties"][sourceType]
break
dynamicCustomFormItemObj["properties"][customField[schema_field_name]] = customeFieldSchemaObj
dynamicCustomFormItemObj["properties"][customField[schema_field_name]] = customFieldSchemaObj

if allOfSchemaObj:
dynamicCustomFormItemObj['allOf'] = allOfSchemaObj

dynamicCustomFormObj["items"] = dynamicCustomFormItemObj
isSourceDependent = is_dest_field_dependent_on_source(field, dbConfig, schema_field_name)

# If the field is source dependent, new schema object is created by setting the fields inside the source.
if isSourceDependent:
newDynamicCustomFormObj = {"type": FieldTypeEnum.OBJECT.value}
Expand All @@ -308,11 +326,62 @@ def generate_schema_for_dynamic_custom_form(field, dbConfig, schema_field_name):
if sourceType in dbConfig["destConfig"] and field[schema_field_name] in dbConfig["destConfig"][sourceType]:
newDynamicCustomFormObj["properties"][sourceType] = dynamicCustomFormObj
dynamicCustomFormObj = newDynamicCustomFormObj

return dynamicCustomFormObj



def generate_schema_for_dynamic_custom_form_allOf(customFields, dbConfig, schema_field_name):
"""Creates the allOf structure of schema, empty if not required.
- Finds the list of unique preRequisites.
- For each unique preRequisites, the properties are found by matching the current preRequisites.
- preRequisites becomes if block and corresponding properties become then block.

Args:
customFields (collection): child fields from file content of ui-config.json.
dbConfig (object): Configurations of db-config.json.
schema_field_name (string): Specifies which key has the field's name in schema.
For old schema types, it is 'value' else 'configKey'.

Returns:
object: allOf object of schema
"""
allOfItemList = []
preRequisitesList = []

for field in customFields:
if "preRequisites" not in field:
continue
isPresent = False
for preRequisites in preRequisitesList:
if compare_pre_requisite_fields(preRequisites, field["preRequisites"]["fields"], True):
isPresent = True
break
if not isPresent:
preRequisitesList.append(field["preRequisites"]["fields"])

for preRequisites in preRequisitesList:
ifObj = generate_if_object(preRequisites, True)
thenObj = {"properties": {}, "required": []}
allOfItemObj = {"if": ifObj}

for field in customFields:
if "preRequisites" not in field:
continue
if compare_pre_requisite_fields(field["preRequisites"]["fields"], preRequisites, True):
thenObj["properties"][field[schema_field_name]] = uiTypetoSchemaFn.get(field["type"])(field, dbConfig, schema_field_name)
if "required" in field and field["required"] == True:
thenObj["required"].append(field[schema_field_name])
allOfItemObj["then"] = thenObj
allOfItemList.append(allOfItemObj)

# Calling anyOf to check if two conditions can be grouped as anyOf.
allOfItemList = generate_schema_for_anyOf(allOfItemList, schema_field_name)
return allOfItemList


def generate_schema_for_dynamic_form(field, dbConfig, schema_field_name):
"""Creates an schema object of dynamicForm.
"""Creates a schema object of dynamicForm.

Args:
field (object): Individual field in ui-config.
Expand Down Expand Up @@ -363,7 +432,7 @@ def generate_key(forFieldWithTo):


def generate_schema_for_dynamic_select_form(field, dbConfig, schema_field_name):
"""Creates an schema object of dynamicSelectForm.
"""Creates a schema object of dynamicSelectForm.

Args:
field (object): Individual field in ui-config.
Expand All @@ -377,7 +446,7 @@ def generate_schema_for_dynamic_select_form(field, dbConfig, schema_field_name):
return generate_schema_for_dynamic_form(field, dbConfig, schema_field_name)

def generate_schema_for_mapping(field, dbConfig, schema_field_name):
"""Creates an schema object of mapping.
"""Creates a schema object of mapping.

Args:
field (object): Individual field in ui-config.
Expand All @@ -392,7 +461,7 @@ def generate_schema_for_mapping(field, dbConfig, schema_field_name):


def generate_schema_for_tag_input(field, dbConfig, schema_field_name):
"""Creates an schema object of tagInput.
"""Creates a schema object of tagInput.

Args:
field (object): Individual field in ui-config.
Expand Down Expand Up @@ -428,7 +497,7 @@ def generate_schema_for_tag_input(field, dbConfig, schema_field_name):


def generate_schema_for_time_range_picker(field, dbConfig, schema_field_name):
"""Creates an schema object of timeRangePicker.
"""Creates a schema object of timeRangePicker.

Args:
field (object): Individual field in ui-config.
Expand All @@ -451,7 +520,7 @@ def generate_schema_for_time_range_picker(field, dbConfig, schema_field_name):


def generate_schema_for_time_picker(field, dbConfig, schema_field_name):
"""Creates an schema object of timePicker.
"""Creates a schema object of timePicker.

Args:
field (object): Individual field in ui-config.
Expand All @@ -466,26 +535,35 @@ def generate_schema_for_time_picker(field, dbConfig, schema_field_name):
"type": FieldTypeEnum.STRING.value
}

def compare_pre_requisite_fields(fieldA, fieldB):
"""Compares two preRequisiteFields fieldA and fieldB for each property and checks if there "selectedValue" match.

def compare_pre_requisite_fields(fieldA, fieldB, isV2 = False):
"""Compares two preRequisiteFields fieldA and fieldB for each property and checks if their value matches.

Args:
fieldA (list or object): contains two properties, 'name' and 'selectedValue'.
fieldB (list or object):
fieldA (list or object): contains two properties representing 'name' and 'selectedValue'.
fieldB (list or object): contains two properties representing 'name' and 'selectedValue'.
isV2 (bool): determines if new property names should be used

Returns:
boolean: If all the properties have the same 'name' and 'selectedValue', then it returns True else False.
"""
"""
valueKey = 'selectedValue'
nameKey = 'name'

if isV2:
valueKey = 'value'
nameKey = 'configKey'

if type(fieldA) != type(fieldB):
return False
elif type(fieldA) == list:
if len(fieldA) != len(fieldB):
return False
for i in range(0, len(fieldA)):
if fieldA[i]['name'] != fieldB[i]['name'] or fieldA[i]['selectedValue'] != fieldB[i]['selectedValue']:
if fieldA[i][nameKey] != fieldB[i][nameKey] or fieldA[i][valueKey] != fieldB[i][valueKey]:
return False
else:
if fieldA['name'] != fieldB['name'] or fieldA['selectedValue'] != fieldB['selectedValue']:
if fieldA[nameKey] != fieldB[nameKey] or fieldA[valueKey] != fieldB[valueKey]:
return False
return True

Expand Down Expand Up @@ -514,27 +592,35 @@ def get_unique_pre_requisite_fields(uiConfig):
return preRequisiteFieldsList


def generate_if_object(preRequisiteField):
def generate_if_object(preRequisiteField, isV2 = False):
"""Creates an if object for the given preRequisiteField. The preRequisiteField becomes an if condition in the schema.

Args:
preRequisiteField (list or object): contains two properties, 'name' and 'selectedValue'.
isV2 (bool): if it should use the v2 or the legacy property key names

Returns:
object: if block for given preRequisiteField.
"""
"""
ifObj = {"properties": {}, "required": []}
valueKey = 'selectedValue'
nameKey = 'name'

if isV2:
valueKey = 'value'
nameKey = 'configKey'

if type(preRequisiteField) == list:
for field in preRequisiteField:
ifObj["properties"][field["name"]] = {
"const": field["selectedValue"]
ifObj["properties"][field[nameKey]] = {
"const": field[valueKey]
}
ifObj["required"].append(field["name"])
ifObj["required"].append(field[nameKey])
else:
ifObj["properties"][preRequisiteField["name"]] = {
"const": preRequisiteField["selectedValue"]
ifObj["properties"][preRequisiteField[nameKey]] = {
"const": preRequisiteField[valueKey]
}
ifObj["required"].append(preRequisiteField["name"])
ifObj["required"].append(preRequisiteField[nameKey])
return ifObj


Expand Down
7 changes: 6 additions & 1 deletion src/configurations/destinations/customerio/db-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"whitelistedEvents",
"oneTrustCookieCategories",
"ketchConsentPurposes",
"consentManagement",
"eventFilteringOption",
"sendPageNameInSDK",
"dataUseInApp"
Expand Down Expand Up @@ -46,7 +47,11 @@
"oneTrustCookieCategories",
"ketchConsentPurposes"
],
"web": ["dataUseInApp", "useNativeSDK", "sendPageNameInSDK"]
"web": ["dataUseInApp", "useNativeSDK", "sendPageNameInSDK", "consentManagement"],
"android": ["consentManagement"],
"ios": ["consentManagement"],
"flutter": ["consentManagement"],
"reactnative": ["consentManagement"]
},
"secretKeys": []
}
Expand Down
Loading