Skip to content

Commit

Permalink
chore: restore intercom js code
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-4116 committed Feb 6, 2024
1 parent 2a94bd8 commit 165e973
Show file tree
Hide file tree
Showing 9 changed files with 1,441 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/v0/destinations/intercom/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const { getMappingConfig } = require('../../util');

const BASE_ENDPOINT = 'https://api.intercom.io';

// track events | Track
const TRACK_ENDPOINT = `${BASE_ENDPOINT}/events`;
// Create, Update a user with a company | Identify
const IDENTIFY_ENDPOINT = `${BASE_ENDPOINT}/users`;
// create, update, delete a company | Group
const GROUP_ENDPOINT = `${BASE_ENDPOINT}/companies`;

const ConfigCategory = {
TRACK: {
endpoint: TRACK_ENDPOINT,
name: 'INTERCOMTrackConfig',
},
IDENTIFY: {
endpoint: IDENTIFY_ENDPOINT,
name: 'INTERCOMIdentifyConfig',
},
GROUP: {
endpoint: GROUP_ENDPOINT,
name: 'INTERCOMGroupConfig',
},
};

const MappingConfig = getMappingConfig(ConfigCategory, __dirname);

const ReservedTraitsProperties = [
'userId',
'email',
'phone',
'name',
'createdAt',
'firstName',
'lastName',
'firstname',
'lastname',
'company',
];

const ReservedCompanyProperties = ['id', 'name', 'industry'];

// ref:- https://developers.intercom.com/intercom-api-reference/v1.4/reference/event-metadata-types
const MetadataTypes = { richLink: ['url', 'value'], monetaryAmount: ['amount', 'currency'] };

module.exports = {
ConfigCategory,
MappingConfig,
ReservedCompanyProperties,
ReservedTraitsProperties,
MetadataTypes,
};
53 changes: 53 additions & 0 deletions src/v0/destinations/intercom/data/INTERCOMGroupConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[
{
"destKey": "company_id",
"sourceKeys": "groupId",
"required": true
},
{
"destKey": "name",
"sourceKeys": "name",
"sourceFromGenericMap": true,
"required": false
},
{
"destKey": "plan",
"sourceKeys": ["traits.plan", "context.traits.plan"],
"required": false
},
{
"destKey": "size",
"sourceKeys": ["traits.size", "context.traits.size"],
"metadata": {
"type": "toNumber"
},
"required": false
},
{
"destKey": "website",
"sourceKeys": "website",
"sourceFromGenericMap": true,
"required": false
},
{
"destKey": "industry",
"sourceKeys": ["traits.industry", "context.traits.industry"],
"required": false
},
{
"destKey": "monthly_spend",
"sourceKeys": ["traits.monthlySpend", "context.traits.monthlySpend"],
"metadata": {
"type": "toNumber"
},
"required": false
},
{
"destKey": "remote_created_at",
"sourceKeys": ["traits.remoteCreatedAt", "context.traits.remoteCreatedAt"],
"metadata": {
"type": "toNumber"
},
"required": false
}
]
46 changes: 46 additions & 0 deletions src/v0/destinations/intercom/data/INTERCOMIdentifyConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"destKey": "user_id",
"sourceKeys": [
"userId",
"traits.userId",
"traits.id",
"context.traits.userId",
"context.traits.id"
],
"required": false
},
{
"destKey": "email",
"sourceKeys": ["traits.email", "context.traits.email"],
"required": false
},
{
"destKey": "phone",
"sourceKeys": ["traits.phone", "context.traits.phone"],
"required": false
},
{
"destKey": "name",
"sourceKeys": ["traits.name", "context.traits.name"],
"required": false
},
{
"destKey": "signed_up_at",
"sourceKeys": ["traits.createdAt", "context.traits.createdAt"],
"required": false,
"metadata": {
"type": "secondTimestamp"
}
},
{
"destKey": "last_seen_user_agent",
"sourceKeys": "context.userAgent",
"required": false
},
{
"destKey": "custom_attributes",
"sourceKeys": ["traits", "context.traits"],
"required": false
}
]
36 changes: 36 additions & 0 deletions src/v0/destinations/intercom/data/INTERCOMTrackConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[
{
"destKey": "user_id",
"sourceKeys": [
"userId",
"traits.userId",
"traits.id",
"context.traits.userId",
"context.traits.id"
],
"required": false
},
{
"destKey": "email",
"sourceKeys": ["traits.email", "context.traits.email"],
"required": false
},
{
"destKey": "event_name",
"sourceKeys": "event",
"required": true
},
{
"destKey": "created",
"sourceKeys": "timestamp",
"sourceFromGenericMap": true,
"required": true,
"metadata": {
"type": "secondTimestamp"
}
},
{
"destKey": "metadata",
"sourceKeys": "properties"
}
]
Loading

0 comments on commit 165e973

Please sign in to comment.