async function createSegment()

in integrations/amplitude-sam/src/handlers/s3-trigger-processor/index.js [73:112]


async function createSegment(applicationId, cohort) {
    var userAttributes = {}
    userAttributes[`AMP_Cohort_${cohort}`] = {
        "AttributeType": "INCLUSIVE",
        "Values": [
            'Active'
        ]
    };

    var params = {
        ApplicationId: applicationId,
        WriteSegmentRequest: {
            "Name": `AMP_Cohort_${cohort}`,
            "SegmentGroups": {
                "Groups": [
                    {
                        "Dimensions": [
                            {
                                "UserAttributes": userAttributes
                            }
                        ],
                        "SourceSegments": [],
                        "SourceType": "ANY",
                        "Type": "ANY"
                    }
                ],
                "Include": "ALL"
            }
        }
    };

    try {
        var data = await pinpoint.createSegment(params).promise();
        log.trace(data)
        return data
    }
    catch (err){
        log.error(err, err.stack);
    }
}