action-destinations icon indicating copy to clipboard operation
action-destinations copied to clipboard

Mailing list support for Loops

Open danrowden opened this issue 1 year ago • 2 comments

Re-do of #2171

@joe-ayoub-segment This includes your suggestion for a better mailing list data format.

  • [x] Added unit tests for new functionality
  • [x] Tested end-to-end using the local server
  • [ ] [Segmenters] Tested in the staging environment

danrowden avatar Jul 25 '24 06:07 danrowden

hi @danrowden the change looks fine to me.

CI checks are failing though. Perhaps you could merge our main branch back in to your branch and see if that fixes the issue?

Kind regards, Joe

joe-ayoub-segment avatar Jul 25 '24 09:07 joe-ayoub-segment

@joe-ayoub-segment Done!

danrowden avatar Jul 30 '24 10:07 danrowden

@joe-ayoub-segment any update here?

askkaz avatar Aug 21 '24 13:08 askkaz

@joe-ayoub-segment any update here?

our bad, updating tests

askkaz avatar Aug 21 '24 15:08 askkaz

Ok @joe-ayoub-segment we're running into a problem with this approach. We've defined the mailingLists as an array of objects. However, when using the action tester, its creating an object and not an array (of objects): Screenshot 2024-08-22 at 11 22 13 AM This works, but it generates an object, not an array of objects: Screenshot 2024-08-22 at 11 22 53 AM We're not sure if this is an artifact of the builder or a limitation in Segment where we cannot actually create an array of objects.

If we "fake" it by passing in an array as part of the test event, this also works and passes through an array of objects: Screenshot 2024-08-22 at 11 25 57 AM

Is this a limitation of the tester or something with how Segment actually works? Will users be able to create an array of objects in the UI or not?

askkaz avatar Aug 22 '24 15:08 askkaz

hi @danrowden this is working correctly.

image

The customer needs to pass an array in the main payload.

We can make this more explicity by adding a default to the field, like this:

    mailingLists: {
      label: 'Mailing Lists',
      description:
        'An an array of objects containing key-value pairs of mailing list IDs and true/false determining if the contact should be added to or removed from each list.',
      type: 'object',
      multiple: true,
      required: false,
      properties: {
        list_id: {
          label: 'List ID',
          description: 'The ID of the mailing list.',
          type: 'string',
          required: true
        },
        value: {
          label: 'value',
          description:
            'true indicates that the user is to be added to the list, false will remove the user from the list.',
          type: 'boolean',
          required: true
        }
      },
      default: {
        '@arrayPath': [
          '$.properties.mailing_lists',
          {
            list_id: {
              '@path': '$.id'
            },
            value: {
              '@path': '$.value'
            }
          }
        ]
      }
    },

This will make the UI look something like this:

image

It makes the customer more aware that the item needs to be an array, and provides some defaults for how the items in the array should be named. The customer can change these mappings though, of course.

joe-ayoub-segment avatar Aug 26 '24 08:08 joe-ayoub-segment

hi @danrowden the change looks good - however CI is now failing.

joe-ayoub-segment avatar Aug 26 '24 16:08 joe-ayoub-segment

@joe-ayoub-segment I noticed today that we are modelling this on a "track" event but it should be for "identify" events, which don't have properties. I'll chat with @askkaz today about this

danrowden avatar Aug 26 '24 19:08 danrowden

This is ready for another look @joe-ayoub-segment

danrowden avatar Aug 28 '24 17:08 danrowden

hi @danrowden this PR has been deployed. Please confirm that the change works as expected.

joe-ayoub-segment avatar Sep 03 '24 14:09 joe-ayoub-segment