Skip to content

Commit

Permalink
Merge branch 'develop' into intercom.refactor-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-4116 authored Mar 12, 2024
2 parents f0c4b1a + 1ef20d6 commit c29300a
Show file tree
Hide file tree
Showing 30 changed files with 3,304 additions and 230 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/prepare-for-prod-dt-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,39 @@ jobs:
git push -u origin hosted-transformer-$TAG_NAME
gh pr create --fill
- name: Update helm charts and raise pull request for enterprise customers on dedicated transformers
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
cd rudder-devops
git checkout -b dedicated-transformer-$TAG_NAME
cd customer-objects
declare -a enabled_ut_customers=()
declare -a sub_directories=('enterprise-us' 'enterprise-eu')
# identify the customers enabled in sub-directories
for directory in "${sub_directories[@]}"; do
for f in "./$directory"/*; do
[[ -f $f ]] || continue
enabled="$(yq e '.spec.user_transformer.enabled' $f)"
if [ $enabled == "true" ]; then
enabled_ut_customers+=( $f )
fi
done
done
# bump up the customers version and repository information
for customer in "${enabled_ut_customers[@]}"; do
yq eval -i ".spec.user_transformer.image.version=\"$TAG_NAME\"" $customer
yq eval -i ".spec.user_transformer.image.repository=\"$TF_IMAGE_REPOSITORY\"" $customer
git add $customer
done
git commit -m "chore: upgrade dedicated transformers to $TAG_NAME"
git push -u origin dedicated-transformer-$TAG_NAME
gh pr create --fill
40 changes: 39 additions & 1 deletion .github/workflows/prepare-for-prod-rollback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ jobs:
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Clone Devops Repo
run: |
git clone https://${{secrets.PAT}}@github.com/rudderlabs/rudder-devops.git
- name: Update Helm Charts and Raise Pull Request
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
git clone https://${{secrets.PAT}}@github.com/rudderlabs/rudder-devops.git
cd rudder-devops
git checkout -b shared-transformer-rollback-${{ steps.target-version.outputs.tag_name }}
Expand All @@ -57,3 +60,38 @@ jobs:
git push -u origin shared-transformer-rollback-${{ steps.target-version.outputs.tag_name }}
gh pr create --fill
- name: Update helm charts and raise pull request for enterprise customers on dedicated transformers
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
cd rudder-devops
git checkout -b dedicated-transformer-rollback-${{ steps.target-version.outputs.tag_name }}
cd customer-objects
declare -a enabled_ut_customers=()
declare -a sub_directories=('enterprise-us' 'enterprise-eu')
# identify the customers enabled in sub-directories
for directory in "${sub_directories[@]}"; do
for f in "./$directory"/*; do
[[ -f $f ]] || continue
enabled="$(yq e '.spec.user_transformer.enabled' $f)"
if [ $enabled == "true" ]; then
enabled_ut_customers+=( $f )
fi
done
done
# bump up the customers version and repository information
for customer in "${enabled_ut_customers[@]}"; do
yq eval -i ".spec.user_transformer.image.version=\"${{ steps.target-version.outputs.tag_name }}\"" $customer
git add $customer
done
git commit -m "chore: rollback dedicated transformers to ${{ steps.target-version.outputs.tag_name }}"
git push -u origin dedicated-transformer-rollback-${{ steps.target-version.outputs.tag_name }}
gh pr create --fill
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.19.0
18.19.1
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1.4
FROM node:18.19.0-alpine3.18 AS base
FROM node:18.19.1-alpine3.18 AS base
ENV HUSKY 0

RUN apk update
Expand Down
65 changes: 65 additions & 0 deletions src/cdk/v2/destinations/koala/procWorkflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
bindings:
- name: EventType
path: ../../../../constants
- path: ../../bindings/jsontemplate
- name: defaultRequestConfig
path: ../../../../v0/util

steps:
- name: validateInput
template: |
$.assert(.message.type, "message Type is not present. Aborting message");
$.assert(.message.type in {{$.EventType.([.IDENTIFY, .TRACK])}},
"message type " + .message.type + " is not supported");
$.assertConfig(.destination.Config.publicKey, "publicKey is not present. Aborting message");
$.context.email = .message.().({{{{$.getGenericPaths("emailOnly")}}}});
$.context.ko_profile_id = .message.traits.ko_profile_id ?? .message.context.traits.ko_profile_id ?? .message.properties.ko_profile_id;
$.assert($.context.email || $.context.ko_profile_id, "Neither email or ko_profile_id are present on traits. Aborting message");
- name: setMessageType
template: |
$.context.messageType = .message.type.toLowerCase();
- name: preparePayloadForIdentify
condition: $.context.messageType === {{$.EventType.IDENTIFY}}
template: |
const traits = .message.traits ?? .message.context.traits ?? {};
const koTraits = traits{~['ko_profile_id']}
const basePayload = {
email: $.context.email,
profile_id: $.context.ko_profile_id,
identifies: [{
type: $.context.messageType,
sent_at: .message.().({{{{$.getGenericPaths("timestamp")}}}}),
traits: koTraits
}]
};
$.context.payload = basePayload
- name: preparePayloadForTrack
condition: $.context.messageType === {{$.EventType.TRACK}}
template: |
const properties = .message.properties ?? {};
const koProperties = properties{~['ko_profile_id']}
const basePayload = {
ip: .message.context.ip ?? .message.request_ip,
email: $.context.email,
profile_id: $.context.ko_profile_id,
events: [{
type: $.context.messageType,
event: .message.event,
message_id: .message.messageId,
sent_at: .message.().({{{{$.getGenericPaths("timestamp")}}}}),
properties: koProperties,
context: .message.context
}]
};
$.context.payload = basePayload
- name: buildResponseForProcessTransformation
template: |
const response = $.defaultRequestConfig();
response.body.JSON = $.context.payload;
response.endpoint = "https://api2.getkoala.com/web/projects/" + .destination.Config.publicKey + "/batch";
response.headers = {
"content-type": "application/json"
};
response
31 changes: 31 additions & 0 deletions src/cdk/v2/destinations/koala/rtWorkflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
bindings:
- name: handleRtTfSingleEventError
path: ../../../../v0/util/index

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.({
"batchedRequest": .,
"batched": false,
"destination": ^[idx].destination,
"metadata": ^[idx].metadata[],
"statusCode": 200
})[]
- name: failedEvents
template: |
$.outputs.transform#idx.error.(
$.handleRtTfSingleEventError(^[idx], .originalError ?? ., {})
)[]
- name: finalPayload
template: |
[...$.outputs.failedEvents, ...$.outputs.successfulEvents]
1 change: 1 addition & 0 deletions src/constants/destinationCanonicalNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const DestCanonicalNames = {
'the trade desk',
],
INTERCOM: ['INTERCOM', 'intercom', 'Intercom'],
koala: ['Koala', 'koala', 'KOALA'],
};

module.exports = { DestHandlerMap, DestCanonicalNames };
3 changes: 2 additions & 1 deletion src/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"REDDIT": true,
"THE_TRADE_DESK": true,
"INTERCOM": true,
"NINETAILED": true
"NINETAILED": true,
"KOALA": true
},
"regulations": [
"BRAZE",
Expand Down
2 changes: 1 addition & 1 deletion src/util/prometheus.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ class Prometheus {
name: 'get_libraries_code_time',
help: 'get_libraries_code_time',
type: 'histogram',
labelNames: ['libraryVersionId', 'versionId', 'type'],
labelNames: ['libraryVersionId', 'versionId', 'type', 'version'],
},
{
name: 'isolate_cpu_time',
Expand Down
2 changes: 1 addition & 1 deletion src/util/redis/redisConnector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe(`Redis Class Get Tests`, () => {
data.forEach((dataPoint, index) => {
it(`${index}. Redis Get- ${dataPoint.description}`, async () => {
try {
const output = await RedisDB.getVal(dataPoint.input.value, (isObjExpected = false));
const output = await RedisDB.getVal(dataPoint.input.value, false);
expect(output).toEqual(dataPoint.output);
} catch (error) {
expect(error.message).toEqual(dataPoint.output.error);
Expand Down
15 changes: 10 additions & 5 deletions src/util/redis/testData/shopify_source.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"user_id": "rudder01",
"id": "shopify_test_get_items_fail",
"query_parameters": {
"topic": ["carts_update"]
"topic": ["carts_update"],
"writeKey": ["wr"]
},
"token": "shopify_test_get_items_fail",
"email": "[email protected]",
Expand Down Expand Up @@ -115,7 +116,8 @@
"input": {
"cart_token": "shopifyGetAnonymousId",
"query_parameters": {
"topic": ["checkouts_delete"]
"topic": ["checkouts_delete"],
"writeKey": ["wr"]
},
"line_items": [],
"note": null,
Expand Down Expand Up @@ -154,7 +156,8 @@
"input": {
"id": "shopify_test3",
"query_parameters": {
"topic": ["carts_update"]
"topic": ["carts_update"],
"writeKey": ["wr"]
},
"token": "shopify_test3",
"line_items": [],
Expand Down Expand Up @@ -252,7 +255,8 @@
"user_id": "rudder01",
"id": "shopify_test_cart",
"query_parameters": {
"topic": ["carts_update"]
"topic": ["carts_update"],
"writeKey": ["wr"]
},
"token": "shopify_test_cart",
"email": "[email protected]",
Expand Down Expand Up @@ -1256,7 +1260,8 @@
"input": {
"id": "shopify_test4",
"query_parameters": {
"topic": ["carts_update"]
"topic": ["carts_update"],
"writeKey": ["wr"]
},
"token": "shopify_test4",
"line_items": [],
Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/clevertap/data/CleverTapIdentify.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"destKey": "Email",
"sourceKeys": "email",
"sourceKeys": "emailOnly",
"required": false,
"sourceFromGenericMap": true
},
Expand Down
14 changes: 9 additions & 5 deletions src/v0/sources/shopify/shopify_redis.util.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const { getAnonymousIdAndSessionId, checkAndUpdateCartItems } = require('./util');
jest.mock('ioredis', () => require('../../../../test/__mocks__/redis'));
const metricMetadata = {
writeKey: 'dummyKey',
source: 'src',
};
describe('Shopify Utils Test', () => {
describe('Check for valid cart update event test cases', () => {
it('Event containing token and nothing is retreived from redis and less than req. time difference between created_at and uadated_at', async () => {
Expand All @@ -14,7 +18,7 @@ describe('Shopify Utils Test', () => {
created_at: '2023-02-10T12:05:04.402Z',
};
const expectedOutput = false;
const output = await checkAndUpdateCartItems(input);
const output = await checkAndUpdateCartItems(input, null, metricMetadata);
expect(output).toEqual(expectedOutput);
});
it('Event containing token and nothing is retreived from redis', async () => {
Expand All @@ -28,7 +32,7 @@ describe('Shopify Utils Test', () => {
],
};
const expectedOutput = true;
const output = await checkAndUpdateCartItems(input);
const output = await checkAndUpdateCartItems(input, null, metricMetadata);
expect(output).toEqual(expectedOutput);
});

Expand All @@ -44,7 +48,7 @@ describe('Shopify Utils Test', () => {
};

const expectedOutput = true;
const output = await checkAndUpdateCartItems(input);
const output = await checkAndUpdateCartItems(input, null, metricMetadata);
expect(output).toEqual(expectedOutput);
});

Expand All @@ -60,7 +64,7 @@ describe('Shopify Utils Test', () => {
};

const expectedOutput = false;
const output = await checkAndUpdateCartItems(input);
const output = await checkAndUpdateCartItems(input, null, metricMetadata);
expect(output).toEqual(expectedOutput);
});

Expand All @@ -76,7 +80,7 @@ describe('Shopify Utils Test', () => {
};

const expectedOutput = true;
const output = await checkAndUpdateCartItems(input);
const output = await checkAndUpdateCartItems(input, null, metricMetadata);
expect(output).toEqual(expectedOutput);
});
});
Expand Down
Loading

0 comments on commit c29300a

Please sign in to comment.