Skip to content

Commit

Permalink
Merge branch 'develop' into reddit.refactor-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-4116 authored Feb 29, 2024
2 parents 7a96454 + 7532c90 commit b6c364e
Show file tree
Hide file tree
Showing 71 changed files with 4,756 additions and 315 deletions.
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ See the project's [README](README.md) for further information about working in t
- Include instructions on how to test your changes.
3. Your branch may be merged once all configured checks pass, including:
- A review from appropriate maintainers
4. Along with the PR in transformer raise a PR against [config-generator][config-generator] with the configurations.

## Committing

Expand Down
70 changes: 70 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@pyroscope/nodejs": "^0.2.6",
"@rudderstack/integrations-lib": "^0.2.4",
"@rudderstack/workflow-engine": "^0.7.2",
"@shopify/jest-koa-mocks": "^5.1.1",
"ajv": "^8.12.0",
"ajv-draft-04": "^1.0.0",
"ajv-formats": "^2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/algolia/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ steps:
const filters = $.context.payload.filters;
const objectIDs = $.context.payload.objectIDs;
$.assert(!(filters && objectIDs), "event can't have both objectIds and filters at the same time.");
$.assert(filters || objectIDs, "Either filters or objectIds is required.");
$.assert(filters.length || objectIDs.length, "Either filters or objectIds is required and must be non empty.");
- name: validatePayloadForClickEvent
condition: $.context.payload.eventType === "click"
Expand Down
31 changes: 31 additions & 0 deletions src/cdk/v2/destinations/ninetailed/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { getMappingConfig } = require('../../../../v0/util');

const ConfigCategories = {
GENERAL: {
type: 'general',
name: 'generalPayloadMapping',
},
CONTEXT: {
type: 'context',
name: 'contextMapping',
},
TRACK: {
type: 'track',
name: 'trackMapping',
},
IDENTIFY: {
type: 'identify',
name: 'identifyMapping',
},
PAGE: {
type: 'page',
name: 'pageMapping',
},
};

// MAX_BATCH_SIZE : // Maximum number of events to send in a single batch
const mappingConfig = getMappingConfig(ConfigCategories, __dirname);
const batchEndpoint =
'https://experience.ninetailed.co/v2/organizations/{{organisationId}}/environments/{{environment}}/events';

module.exports = { ConfigCategories, mappingConfig, batchEndpoint, MAX_BATCH_SIZE: 200 };
43 changes: 43 additions & 0 deletions src/cdk/v2/destinations/ninetailed/data/contextMapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[
{
"sourceKeys": "app.name",
"required": true,
"destKey": "app.name"
},
{
"sourceKeys": "app.version",
"required": true,
"destKey": "app.version"
},
{
"sourceKeys": "campaign",
"destKey": "campaign"
},
{
"sourceKeys": "library.name",
"required": true,
"destKey": "library.name"
},
{
"sourceKeys": "library.version",
"required": true,
"destKey": "library.version"
},
{
"sourceKeys": "locale",
"destKey": "locale"
},
{
"sourceKeys": "page",
"destKey": "page"
},
{
"sourceKeys": "userAgent",
"destKey": "userAgent"
},
{
"sourceKeys": "location",
"required": true,
"destKey": "location"
}
]
25 changes: 25 additions & 0 deletions src/cdk/v2/destinations/ninetailed/data/generalPayloadMapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"sourceKeys": "anonymousId",
"required": true,
"destKey": "anonymousId"
},
{
"sourceKeys": "messageId",
"required": true,
"destKey": "messageId"
},
{
"sourceKeys": "channel",
"required": true,
"destKey": "channel"
},
{
"sourceKeys": "type",
"destKey": "type"
},
{
"sourceKeys": "originalTimestamp",
"destKey": "originalTimestamp"
}
]
14 changes: 14 additions & 0 deletions src/cdk/v2/destinations/ninetailed/data/identifyMapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"sourceKeys": "traits",
"sourceFromGenericMap": true,
"required": true,
"destKey": "traits"
},
{
"sourceKeys": "userIdOnly",
"sourceFromGenericMap": true,
"required": true,
"destKey": "userId"
}
]
7 changes: 7 additions & 0 deletions src/cdk/v2/destinations/ninetailed/data/pageMapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
{
"sourceKeys": "properties",
"required": true,
"destKey": "properties"
}
]
12 changes: 12 additions & 0 deletions src/cdk/v2/destinations/ninetailed/data/trackMapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"sourceKeys": "properties",
"required": true,
"destKey": "properties"
},
{
"sourceKeys": "event",
"required": true,
"destKey": "event"
}
]
33 changes: 33 additions & 0 deletions src/cdk/v2/destinations/ninetailed/procWorkflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
bindings:
- name: EventType
path: ../../../../constants
- path: ../../bindings/jsontemplate
- name: defaultRequestConfig
path: ../../../../v0/util
- name: removeUndefinedAndNullValues
path: ../../../../v0/util
- path: ./utils

steps:
- name: messageType
template: |
.message.type.toLowerCase();
- name: validateInput
template: |
let messageType = $.outputs.messageType;
$.assert(messageType, "message Type is not present. Aborting");
$.assert(messageType in {{$.EventType.([.TRACK,.IDENTIFY,.PAGE])}}, "message type " + messageType + " is not supported");
$.assertConfig(.destination.Config.organisationId, "Organisation ID is not present. Aborting");
$.assertConfig(.destination.Config.environment, "Environment is not present. Aborting");
- name: preparePayload
template: |
const payload = $.constructFullPayload(.message);
$.context.payload = $.removeUndefinedAndNullValues(payload);
- name: buildResponse
template: |
const response = $.defaultRequestConfig();
response.body.JSON.events = [$.context.payload];
response.endpoint = $.getEndpoint(.destination.Config);
response.method = "POST";
response
35 changes: 35 additions & 0 deletions src/cdk/v2/destinations/ninetailed/rtWorkflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
bindings:
- path: ./config
- name: handleRtTfSingleEventError
path: ../../../../v0/util/index
- path: ./utils
steps:
- name: validateInput
template: |
$.assert(Array.isArray(^) && ^.length > 0, "Invalid event array")
- name: transform
externalWorkflow:
path: ./procWorkflow.yaml
loopOverInput: true

- name: successfulEvents
template: |
$.outputs.transform#idx.output.({
"output": .body.JSON.events[0],
"destination": ^[idx].destination,
"metadata": ^[idx].metadata
})[]
- name: failedEvents
template: |
$.outputs.transform#idx.error.(
$.handleRtTfSingleEventError(^[idx], .originalError ?? ., {})
)[]
- name: batchSuccessfulEvents
description: Batches the successfulEvents
template: |
$.batchResponseBuilder($.outputs.successfulEvents);
- name: finalPayload
template: |
[...$.outputs.failedEvents, ...$.outputs.batchSuccessfulEvents]
Loading

0 comments on commit b6c364e

Please sign in to comment.