-
Notifications
You must be signed in to change notification settings - Fork 267
Added Functionaility for Custom Attributes and Subscribers API from Attentive #2873
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @duynguyen100 thanks for the PR.
I think I understand what you are intending to do here.
One Action is to append attributes to a user. Another Action is to subscribe a user.
Both of these Actions are invoked with an identify() call.
Are 2 different Actions really needed for this? I'm wondering if a single Action could collect all the user attributes, and would also have a field where the customer can indicate if the user should be subscribed. You could then make 2 calls to your API to update the attributes and to subscribe the user?
Also do these API calls upsert a user?
For example if a user doesn't already exist, will the customAttributes Action create the user before adding the custom attributes to the user? Same question for the subscribers API call.
I'd be happy to discuss these design questions on a call if you can't make the decision yourself.
Please also have a look at the other comments I left inline.
Best regards,
Joe
@@ -73,7 +73,7 @@ | |||
"timers-browserify": "^2.0.12", | |||
"ts-jest": "^27.0.7", | |||
"ts-node": "^9.1.1", | |||
"typescript": "4.9.5", | |||
"typescript": "^5.8.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @duynguyen100 - can you undo this change please? This affects the entire solution and it's a file that should be changed.
@@ -15,7 +15,7 @@ | |||
}, | |||
"typings": "./dist/esm", | |||
"dependencies": { | |||
"@segment/analytics-browser-actions-braze": "^1.85.0", | |||
"@segment/analytics-browser-actions-braze": "^1.86.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @duynguyen100 . Did you mean to change this file? If not can you revert the change to this file please?
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "@segment/analytics-browser-actions-braze", | |||
"version": "1.85.0", | |||
"version": "1.86.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @duynguyen100 . Did you mean to change this file? If not can you revert the change to this file please?
@@ -36,7 +36,7 @@ | |||
"@types/google-libphonenumber": "^7.4.23", | |||
"@types/jest": "^27.0.0", | |||
"@types/ssh2-sftp-client": "^9.0.0", | |||
"jest": "^27.3.1", | |||
"jest": "^27.5.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @duynguyen100 . Did you mean to change this file? If not can you revert the change to this file please?
"@segment/analytics-browser-actions-braze": "^1.85.0", | ||
"@segment/analytics-browser-actions-braze-cloud-plugins": "^1.85.0", | ||
"@segment/analytics-browser-actions-braze": "^1.86.0", | ||
"@segment/analytics-browser-actions-braze-cloud-plugins": "^1.86.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @duynguyen100 . Did you mean to change this file? If not can you revert the change to this file please?
userIdentifiers: { | ||
label: 'User Identifiers', | ||
description: 'At least one identifier (phone or email) is required.', | ||
type: 'object', | ||
required: true, | ||
additionalProperties: true, | ||
properties: { | ||
phone: { | ||
label: 'Phone', | ||
description: "The user's phone number in E.164 format.", | ||
type: 'string', | ||
required: false | ||
}, | ||
email: { | ||
label: 'Email', | ||
description: "The user's email address.", | ||
type: 'string', | ||
format: 'email', | ||
required: false | ||
} | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could add some default mappings to look for email and phone. In an identify call these would be as follows:
default: {
phone: { '@path': '$.traits.phone'},
email: { '@path': '$.traits.email'}
}
} | ||
} | ||
}, | ||
subscriptionType: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this field is limited to 2 different types of inputs, please update it as below. It will only allow payloads through which contain one of these values:
subscriptionType: {
label: 'Subscription Type',
description: 'Type of subscription',
type: 'string',
required: true,
choices: [
{value: "MARKETING", value: "MARKETING"},
{value: "TRANSACTIONAL", value: "TRANSACTIONAL"}
],
default: 'MARKETING'
}
locale: { | ||
label: 'Locale', | ||
description: 'User locale (language and country)', | ||
type: 'object', | ||
required: false, | ||
properties: { | ||
language: { | ||
label: 'Language', | ||
type: 'string', | ||
required: true | ||
}, | ||
country: { | ||
label: 'Country', | ||
type: 'string', | ||
required: true | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Segment actually provides the locale of a client side device in most cases. It doesn't do this for server side SKDs though.
The locale data is usually located here in a Segment payload:
$.context.locale
The value usually looks like this: 'en-US', where the first 2 characters are the language and the last 2 characters are the country.
See https://segment.com/docs/connections/spec/common/#context
You could go with a single locale field that collects this value. You could then parse it and use it as you like in the perform() function.
For example:
locale: {
label: 'Locale',
description: 'User locale (language and country)',
type: 'string',
required:false,
default: {'@path': '$.context.locale'}
}
|
||
const action: ActionDefinition<Settings, Payload> = { | ||
title: 'Custom Attributes', | ||
description: 'Send custom attributes to Attentive.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: 'Send custom attributes to Attentive.', | |
description: 'Send Custom Attributes to Attentive.', |
}, | ||
{ | ||
name: 'Subscribe User', | ||
subscribe: 'type = "identify" and traits.phone != null', // Trigger on identify with `subscribed: true` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @duynguyen100 is the logic here correct?
hi again @duynguyen100 tried to yarn build the branch and got this error:
error Command failed with exit code 1. Can you address this also please? |
Added functionaility for action destinations to support mappings of Custom Attribute and Subscribers API, Unit tested all passed!
Testing
Include any additional information about the testing you have completed to
ensure your changes behave as expected. For a speedy review, please check
any of the tasks you completed below during your testing.
@brennan