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

Added Inleads Action Destination #1989

Merged
merged 14 commits into from
Apr 23, 2024
Merged

Conversation

nagendra-d
Copy link
Contributor

@nagendra-d nagendra-d commented Apr 13, 2024

A new action destination for Inleads. It provides two actions:

Send Identify which maps Identify events by default
Send Track which maps TRACK events by default.

The destination introduces actions for Segment events.

Testing

  • Added unit tests for new functionality

  • Tested end-to-end using the local server

  • [Segmenters] Tested in the staging environment

@joe-ayoub-segment
Copy link
Contributor

Thanks for the PR @nagendra-d - I'll schedule for review.
Kind regards,
Joe

@joe-ayoub-segment
Copy link
Contributor

hi @nagendra-d there are some failing CI checks / tests. Could you take a look please?

image

@nagendra-d
Copy link
Contributor Author

hi @nagendra-d there are some failing CI checks / tests. Could you take a look please?

image

Thanks @joe-ayoub-segment, I have fixed the failing test case

first_name: {
type: 'string',
required: false,
allowNull: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowNull should allow the customer to null out the first_name. Is this what will happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, our API can handle even if this field is null

type: 'string',
required: false,
description: "The user's name",
allowNull: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowNull should allow the customer to null out the name. Is this what will happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, our API can handle even if this field is null

required: true,
description: 'The External ID of the user',
label: 'User ID',
default: { '@path': '$.userId' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you intend to allow anonymous user profile data to be collected? Or should all user data be for 'known' users?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do allow anonymous user data

last_name: {
type: 'string',
required: false,
allowNull: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowNull should allow the customer to null out the last_name. Is this what will happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, our API can handle even if this field is null

'@if': {
exists: { '@path': '$.context.group_id' },
then: { '@path': '$.context.group_id' },
else: { '@path': '$.groupId' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in a group() call, the groupId will always be at location $.groupId

},
created_at: {
type: 'string',
required: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add this if you like?

  format:'date-time'

}
},
created_at: {
type: 'string',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding this to ensure the value is an actual ISO8601 timestamp.
format:'date-time'

})

afterAll(() => {
nock.enableNetConnect()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no harm to remove this. nock should never be able to make real HTTPS requests.

required: true,
description: 'The user id, to uniquely identify the user associated with the event',
label: 'User id',
default: { '@path': '$.userId' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you intend to allow events for anonymous users to be collected?

required: false,
description: 'The Traits of the track call',
label: 'Event Traits',
default: { '@path': '$.traits' }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

traits in a track() call are usually located in $context.traits

Suggested change
default: { '@path': '$.traits' }
default: { '@path': '$.context.traits' }

timeZone: { '@path': '$.context.timezone' },
},
},
anonymous_id: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see you are allowing customer to collect anonymousId. You can ignore my comments about anonymous data then :)

default: { '@path': '$.context.locale' }
},
utc_time: {
type: 'string',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest adding:
format: 'date-time'

},
utc_time: {
type: 'string',
required: false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can make this required. It will always be there.

Comment on lines +5 to +8
userMeta: {
label: 'User Metadata',
type: 'object',
description: 'User metadata including IP, Location, etc.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why you didn't define properties for all of the sub fields such as latitude, country, etc?

Also, it may be worth adding this line to ensure the UI displays this field as a list of key:value pairs instead of an object.

  defaultObjectUI: 'keyvalue',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the suggestion to add defaultObjectUI, we require these fields as part of userMeta, so that it matches with our API

Copy link
Contributor

@joe-ayoub-segment joe-ayoub-segment Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @nagendra-d , regarding my first part of the comment:

Just wondering why you didn't define properties for all of the sub fields such as latitude, country, etc?

What I meant was, should you not be defining these sub fields with types?

properties: {
      ip: {
        label: 'IP Address',
        description: 'The user's IP address,
        type: 'string'
      },
      latitude: {
        label: 'Latitude',
        description: 'The latitude coordinates for the user. For example 123.455',
        type: 'string'
      }
      etc...
    },

You did this with the utm object field below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I got it now, The sub fields are from different context ip, location, os, etc... , I wasn't sure having the approach as utm would work here, and was having trouble with accessing values that way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added properties to userMeta object

@joe-ayoub-segment
Copy link
Contributor

hi @nagendra-d - nicely done with this PR! I provided some feedback.

I noticed that the CI checks are failing. I don't think it is because of your code. Could you rebase from main branch please? I think it should fix the issue.

@nagendra-d
Copy link
Contributor Author

Hi @joe-ayoub-segment ,

Thanks for the suggestions, I have updated the code as per your suggestions for date and triats

Regarding allowNull we intend to keep them that way and also we do allow anonymous user data

Thanks
Nagendra

Comment on lines 10 to 17
export interface Payload {
/**
* Segment Event Payload
*/
segmentEventData: {
[k: string]: unknown
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi again @nagendra-d ,

One thing I missed from my initial review.

Usually a separate generated-types.ts file is generated for each Action, as well as the main index.ts file.

How was this generated-types.ts file created? Did you run the ./bin/run generate:types command? Did you edit the file in any way manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @joe-ayoub-segment ,

I have manually created this file, is it mandatory to use the command to generate types, if so I will do and update,
when I checked some other destinations, I saw this type of implementation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK - yes please use the command to generate these files.

./bin/run generate:types

@joe-ayoub-segment
Copy link
Contributor

Hi @nagendra-d thanks for applying those changes. Just 2 more comments to respond to and we should be good.

@nagendra-d
Copy link
Contributor Author

nagendra-d commented Apr 19, 2024

Hi @nagendra-d thanks for applying those changes. Just 2 more comments to respond to and we should be good.

Hi @joe-ayoub-segment , Thanks,

  1. I updated types using command ./bin/run generate:types
  2. Regarding the values for userMeta, I have retried usng the suggested way, but our API is not receiving any data. Might be I'm missing somethings, If you can provide a sample example for retreiving IP, User City I will update them for all other fields, Fixed this

Thanks,
Nagendra

@joe-ayoub-segment joe-ayoub-segment merged commit 61aeb8b into segmentio:main Apr 23, 2024
10 of 11 checks passed
@nagendra-d
Copy link
Contributor Author

Hi @joe-ayoub-segment , Thanks for merging the changes, when can we access / start testing private beta url

https://github.com/segmentio/action-destinations/blob/main/CONTRIBUTING.md#release-to-private-beta-for-customer-testing

@joe-ayoub-segment
Copy link
Contributor

hi @nagendra-d this PR has been deployed. I'll email you next steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants