Audience Segment External Feed Methods
Those are the routes to implement for an Audience Segment External Feed plugin.
Generic
Those are the mandatory methods to implement.
instanceContextBuilder
This method
validates feed properties and selected identifying resources.
simplifies the instance handling by managing in one place properties, credentials, configurations, api clients...
It is called once at the beginning of the feed instantiation.
It may be called again in the 3 other generic methods: onExternalSegmentCreation, onExternalSegmentConnection and onUserSegmentUpdate if we want to refresh the instance context.
We have to define a custom interface for this extended context, so we can return whatever we want in it.
instanceContextBuilder(feedId: string): Promise<InstanceContext>Input parameters
There is only one input parameter feedId.
Return
This method returns a context of type AudienceFeedConnectorBaseInstanceContext or an extended context of type InstanceContext.
We recommend you to use the extended context in order to simplify the reuse of objects and variables in the plugin code.
The original context format contains the feed metadata and its properties.
ctx (AudienceFeedConnectorBaseInstanceContext)
The original format of the AudienceFeedConnectorBaseInstanceContext type is
feed
AudienceSegmentExternalFeedResource
Represents the external feed resource for the audience segment.
feedProperties
PropertiesWrapper
Wrapper for properties associated with the feed, containing metadata and configurations.
With the object feed (AudienceSegmentExternalFeedResource) that represents the external feed resource for the audience segment:
id
string
Unique identifier for the audience segment external feed.
plugin_id
string
Identifier for the plugin associated with the feed.
organisation_id
string
Identifier for the organization that owns the feed.
group_id
string
Identifier for the group to which the feed belongs.
artifact_id
string
Identifier for the specific plugin artifact related to the feed.
version_id
string
Version identifier for the feed, indicating its versioning.
selected_identifying_resources
IdentifyingResourceShape optional
Optional array of identifying resources used for segment identification.
created_by
string
Optional identifier for the user that created the feed.
The extended context contains the feed metadata, the feed properties, plus a bunch of useful variables and objects.
instanceContext (InstanceContext)
Those are the variables and objects that extend the original context (AudienceFeedConnectorBaseInstanceContext).
technicalConfig
TechnicalConfiguration
Configuration details for technical aspects.
loggerPrefix
string
A prefix for logging to identify the source of log messages.
segment
AudienceSegmentResource
The audience segment resource being processed.
properties
Properties
Plugin properties of the created feed.
credentials
Credentials
Credentials for external systems.
datamartConfig
DatamartConfiguration
Configuration specific to the datamart.
micsApiClient
MicsApiClient
Client for interacting with the MICS API.
partnerClient
PartnerClient
Client for interacting with the partner solution.
Code
There is only one input parameter feedId, but you must retrieve the context ctx at the beginning of the method code to extend it, like this:
onExternalSegmentCreation
This method checks wether the audience already exist on the partner platform, or if it must create it. In this last case, we create the audience.
Also, through the instance context method, this onExternalSegmentCreation method validates again the feed properties and selected identifying resources.
This method is called synchronously.
Input parameters
request (ExternalSegmentCreationRequest, required): An object containing the details necessary for creating the segment. It is sent by the platform at the feed creation.
request object format:
feed_id
string
The unique identifier of the feed
segment_id
string
The unique identifier of the segment related to the feed
datamart_id
string
The identifier for the datamart of the segment
context (InstanceContext, required): The context in which the feed creation is executed, containing various configuration and resource objects.
Check the instance context section to understand the format of the feed instance context. You can find the extended context interface in the returns tab.
Return
Resolves to an object containing the status of the segment creation process, along with an optional message and visibility.
Promise<ExternalSegmentCreationPluginResponse>
ExternalSegmentCreationPluginResponse object format:
status
enum['ok' | 'error' | 'retry' | 'no_eligible_identifier']
message
string
visibility
enum['PRIVATE' | 'PUBLIC']
Code
onExternalSegmentConnection
Establishing connection with segment on destination platform.
This method check the availability of the segment on the destination platform.
Also, through the instance context method, this onExternalSegmentConnection method may validate feed properties and selected identifying resources. It is not mandatory at this step as it was supposed to be done beforehand.
Input parameters
request (ExternalSegmentConnectionRequest, required): An object containing the details necessary for creating the segment. It is sent by the platform at the feed creation.
request object format:
feed_id
string
The unique identifier of the feed
segment_id
string
The unique identifier of the segment related to the feed
datamart_id
string
The identifier for the datamart of the segment
context (InstanceContext, required): The context in which the feed creation is executed, containing various configuration and resource objects.
Check the instance context section to understand the format of the feed instance context. You can find the extended context interface in the returns tab.
Return
Resolves to an object containing the status of the segment creation process, along with an optional message and visibility.
Promise<ExternalSegmentCreationPluginResponse>
ExternalSegmentCreationPluginResponse object format:
status
enum['ok' | 'error' | 'retry' | 'no_eligible_identifier']
message
string
visibility
enum['PRIVATE' | 'PUBLIC'] optional
Code
onUserSegmentUpdate
This method sends the user identifiers (insertion or deletion) or prepares the payload to be sent to the partner platform.
Depending on the plugin output type, this method will have different roles and return different objects.
Single API calls (classic plugin)
This method sends the user identifiers (insertion or deletion) to the partner platform.
Batch API calls
This method inserts the user identifiers in the batch through the returned object - it can be for both insertion or deletion.
The batch will be sent to the partner platform through the onBatchUpdate method.
File delivery
This method inserts the user identifiers in the file through the returned object - it can be for both insertion or deletion.
Also, through the instance context method, this onUserSegmentUpdate method may again validate feed properties and selected identifying resources. It is not mandatory at this step again as it was supposed to be done beforehand.
Input parameters
request (UserSegmentUpdateRequest, required): An object containing the details necessary for creating the segment. It is sent by the platform at the feed creation.
request object format:
feed_id
string
unique identifier for the feed associated with the user segment update
session_id
string
identifier for the session during which the update is being made
datamart_id
string
identifier for the datamart where the user segment resides
segment_id
string
unique identifier for the segment being updated
user_identifiers
UserIdentifierInfo[]
array of user identifiers from the segment to send to the partner platform
user_profiles
UserProfileInfo[]
array of user profiles from the segment to send to the partner platform
ts
number
timestamp indicating when the update request was created
operation
UpdateType
type of update operation being performed, indicating whether it is an add, remove, or modify operation
context (InstanceContext, required): The context in which the feed creation is executed, containing various configuration and resource objects.
Check the instance context section to understand the format of the feed instance context. You can find the extended context interface in the returns tab.
Return (batch case)
Resolves to an object containing the batch of users identifiers to update on the segment destination platform.
Promise<BatchedUserSegmentUpdatePluginResponse<Payload>>
BatchedUserSegmentUpdatePluginResponse<Payload> object format:
status
enum['ok' | 'error' | 'retry' | 'no_eligible_identifier']
data
UserSegmentUpdatePluginBatchDeliveryResponseData<Payload>[], optional
stats
UserSegmentUpdatePluginResponseStats[], optional
message
string, optional
next_msg_delay_in_ms
number, optional
Code
onTroubleshoot
This method is utilized to troubleshoot the feed using audience data from the partner platform.
Input parameters
request (TroubleshootActionFetchDestinationAudience, required): An object containing the details necessary for handling the troubleshoot.
feed_id
string
The unique identifier of the feed
segment_id
string
The unique identifier of the segment related to the feed
datamart_id
string
The identifier for the datamart of the segment
action
enum['FETCH_DESTINATION_AUDIENCE']
context (InstanceContext, required): The context in which the feed creation is executed, containing various configuration and resource objects.
Check the instance context section to understand the format of the feed instance context. You can find the extended context interface in the returns tab.
Return
Resolves to an object containing the status of the segment creation process, along with an optional message and visibility.
Promise<ExternalSegmentCreationPluginResponse>
ExternalSegmentCreationPluginResponse object format:
status
enum['ok' | 'error' | 'retry' | 'no_eligible_identifier']
message
string
data
any, optional
Data to be displayed in the troubleshooting section of the feed card. It must provide as much data as possible to compare identifiers received, stored and used by the partner platform
Code
Batching
This method is required if we batch the calls to the partner API or to send a flat file.
onBatchUpdate
Send the batched payload of user identifiers to the partner platform.
This payload is prepared by our platform thanks to the unitary calls to the onUserSegmentUpdate method.
Input parameters
request (BatchUpdateRequest<AudienceFeedBatchContext, Payload>)
batch_content
T[]
Array of items (insertion/deletion) to be sent to the partner platform
ts
number
Timestamp indicating when the batch update request was created
context
AudienceFeedBatchContext
Context information relevant to the batch update process We do not use this variable from this parameter.
context (InstanceContext, required): The context in which the feed creation is executed, containing various configuration and resource objects.
Check the instance context section to understand the format of the feed instance context. You can find the extended context interface in the returns tab.
Return
Resolves to an object containing the status of the users identifiers sent to the destination platform, along with an optional message.
Promise<BatchUpdatePluginResponse>
BatchUpdatePluginResponse object format:
status
enum['OK' | 'ERROR' | 'RETRY']
message
string, optional
next_msg_delay_in_ms
number, optional
sent_items_in_success
number
sent_items_in_error
number
Code
Authentication
onAuthenticationStatusQuery
Check the authentication status of the connector. If the connector has no valid authentication, it must respond with a url to let the user authenticate through the desired method.
Input parameters
request (ExternalSegmentAuthenticationStatusQueryRequest): Request sent at authentication checking.
segment_id
string, optional
Optional identifier for the segment being queried
datamart_id
string
Identifier for the datamart associated with the authentication status query
plugin_version_id
string
Identifier for the version of the plugin being used
user_id
string
Unique identifier for the user making the authentication status query
properties
PluginProperty[], optional
Optional array of properties related to the plugin for additional context
Return
Resolves to an object containing the status of the authentication, and the login url if not authenticated.
Promise<ExternalSegmentAuthenticationStatusQueryResponse>
ExternalSegmentAuthenticationStatusQueryResponse object format:
status
enum['authenticated' | 'not_authenticated' | 'error' | 'not_implemented']
Status of the authentication process indicating success or
message
string, optional
Message providing additional information about the authentication
data
object, optional
Optional object containing additional data related to the authentication status
data object format:
login_url
string, optional
Optional URL for the login page if authentication is
any key
string, optional
Additional properties can be included in this object as needed
Code
onAuthentication
Handle the redirection from the partner authentication flow and authenticate the connection within mediarithmics.
Input parameters
request (ExternalSegmentAuthenticationRequest): Request forwarded from the partner response after authentication on their
user_id
string
unique identifier for the user making the authentication request
plugin_version_id
string
identifier for the version of the plugin being used for authentication
params
object, optional
[key: string]
Optional object containing additional parameters received in the redirection from the partner authentication. Concerning the Oauth2.0 protocol, the code is present within this array
Return
Resolves to an object containing the response status along the optional message.
Promise<ExternalSegmentAuthenticationResponse>
status
enum['ok' | 'error' | 'not_implemented']
Status of the authentication process indicating success or failure
message
string, optional
optional message providing additional information about the authentication status
Code
onLogout
Handle the connector logout for either a user, or a datamart.
Input parameters
request (ExternalSegmentLogoutRequest): Request sent when logging out
user_id
string
Unique identifier for the user making the logout request
plugin_version_id
string
Identifier for the plugin version being used for the logout
datamart_id
string
Identifier for the datamart associated with the logout request
Return
Resolves to an object containing the response status along the optional message.
Promise<ExternalSegmentLogoutResponse>
status
enum['ok' | 'error' | 'not_implemented']
Status of the authentication process indicating success or failure
message
string, optional
Optional message providing additional information about the authentication status
Code
Dynamic properties
onDynamicPropertyValuesQuery
Enable the feed creation form to dynamically suggest values from the partner solution, allowing users to select from these options. Additionally, one dynamic property may depend on another.
Input parameters
request (ExternalSegmentDynamicPropertyValuesQueryRequest): Request coming from the feed creation form.
segment_id
string, optional
Optional identifier for the segment related to the feed being created
datamart_id
string
Identifier for the datamart associated with the feed being created
user_id
string
Unique identifier for the user making the query
properties
PluginProperty[], optional
Optional array of properties already set in the feed creation form
To better understand the properties array, here is an example type that can be found within it:
property_type
enum['STRING', 'URL', ...]
value
object[]
value(string, optional)id(string, optional)... depending on the property type
Return
Resolves to an object containing the array of the dynamic properties and their values to be displayed in the feed creation form.
Promise<ExternalSegmentDynamicPropertyValuesQueryResponse>
status
enum['ok' | 'error' | 'not_implemented']
status of the dynamic property values query indicating whether the operation was successful, encountered an error, or is not implemented
message
string, optional
Optional message providing additional information about the query status
data
object[], optional
Optional array of objects containing the dynamic property values
Object format for each dynamic property present in the data array:
property_technical_name
string
enum
object[]
Array of objects representing the possible values for the property
Object format for each value present in the enum array:
label
string
Human-readable label for the property value displayed in the dropdown
value
string
Actual value associated with the property (technical most of the time)
Code
Last updated
Was this helpful?