Skip to content

Release for LeanPlum & Generic Webhook - #94

Merged
SumanthPuram merged 29 commits into
masterfrom
develop
Mar 30, 2020
Merged

SumanthPuram merged 29 commits into
masterfrom
develop

Conversation

@arnabp92

@arnabp92 arnabp92 commented Mar 16, 2020 •

Copy link
Copy Markdown
Contributor

This change is Reviewable

sayan-rudder and others added 22 commits January 29, 2020 17:23
braze append traits with track events & also tests
* add collectContext

* remove unsupported methods

* field names refactor

* changes for intercom api v2

* Reverted to API version v1.4 and fixed user_id issue in for identify

Co-authored-by: dhawal-rudder <[email protected]>
Co-authored-by: Arnab <[email protected]>
* initial commit for leanplum transformation

* added code for advance API call

* added code for identify and track

* Prettier formatting changed
context.traits is passed to setUserAttributes

* sending anonymousId as userId for track and page

* Fixed prettier errors

* Changes for LeanPlum cloud mode

* split all config json files into required and optional fields

* added all fields supported by leanplum

* Added config file for start API call

* Updated Config JSON files for unified structure

* added code to set required and optional values

* Finalized Leanplum

* Fixed userId and time

Co-authored-by: arnab <[email protected]>
arnab-p and others added 2 commits March 17, 2020 00:05
* Minor optimizations for warehouse transformer

* custom fields in traits &  Todo -map all sg traits

* test file fix salesforce

* Add original timestamp to transformed events in warehouse

* salesforce full SEG identify fields mapping

* comment removal

* output format changed in case of exception

* changes for intercom api v2 (#81)

Co-authored-by: dhawal-rudder <[email protected]>

* Dest intercom (#82)

* add collectContext

* remove unsupported methods

* field names refactor

* changes for intercom api v2

* Reverted to API version v1.4 and fixed user_id issue in for identify

Co-authored-by: dhawal-rudder <[email protected]>
Co-authored-by: Arnab <[email protected]>

* Fixed conflict error

* Fixed user endpoint for intercom

* Add output field inside user transformation (#83)

* Add received_at to users table in warehouse

* transformer version changed to v0.1.4

* changes for webhook dest and testcases

* ip fix and test case update

* implement review comments

* making a release

* bump version

* Destination leanplum (#88)

* initial commit for leanplum transformation

* added code for advance API call

* added code for identify and track

* Prettier formatting changed
context.traits is passed to setUserAttributes

* sending anonymousId as userId for track and page

* Fixed prettier errors

* Changes for LeanPlum cloud mode

* split all config json files into required and optional fields

* added all fields supported by leanplum

* Added config file for start API call

* Updated Config JSON files for unified structure

* added code to set required and optional values

* Finalized Leanplum

* Fixed userId and time

Co-authored-by: arnab <[email protected]>

* changes for webhook dest and testcases

* Fixed lint, from let to const

* Added test cases and handled null headers and invalid webhook URL scenario

Co-authored-by: Srikanth <[email protected]>
Co-authored-by: Rajashekar Varkala <[email protected]>
Co-authored-by: lokey <[email protected]>
Co-authored-by: Rajashekar Varkala <[email protected]>
Co-authored-by: varkalablr <[email protected]>
Co-authored-by: Chandra shekar Varkala <[email protected]>
Co-authored-by: Arnab <[email protected]>
Co-authored-by: dhawal-rudder <[email protected]>
Co-authored-by: Sampath <[email protected]>
Co-authored-by: arnab <[email protected]>
@arnabp92 arnabp92 changed the title [WIP] Release for LeanPlum & AppsFlyer & Generic Webhook [WIP] Release for LeanPlum & Generic Webhook Mar 17, 2020
@arnabp92 arnabp92 changed the title [WIP] Release for LeanPlum & Generic Webhook Release for LeanPlum & Generic Webhook Mar 17, 2020
Comment thread v0/customerio/transform.js Outdated
);
//console.log(rawPayload);

if (userId) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this check to the beginning of the if block. As a practice, whenever we can return from a function those checks should be at the top.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread v0/customerio/transform.js Outdated
message.userId && message.userId != "" ? message.userId : undefined;

const response = defaultRequestConfig();
response.userId = message.userId ? message.userId : message.anonymousId;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response.userId = message.userId || message.anonymousId.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread v0/customerio/transform.js Resolved
Comment thread v0/customerio/transform.js Outdated
};

return response;
} else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Else can be skipped. Anyways, it's better to return error in the if.
I like this pattern.

https://medium.com/@matryer/line-of-sight-in-code-186dd7cdea88

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The post is really good. I'd try to enforce this pattern going forward

Comment thread v0/customerio/transform.js Outdated
case EventType.SCREEN:
evType = "event";
evName =
"Viewed " + message.name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put the part after Viewed in ().
Also since JS has no type, we could merge some ternary operator to || statements.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment thread v0/leanplum/transform.js Outdated
destination
);
// console.log(payload);
const url = ENDPOINT + "?action=start";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's send as array of two events back to router. We can remove the RETRY logic,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment thread v0/leanplum/transform.js Resolved
Comment thread v0/webhook/transform.js Outdated
function process(event) {
const { message, destination } = event;
const response = defaultRequestConfig();
if (destination.Config.webhookUrl && isURL(destination.Config.webhookUrl)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex checks are generally costly. Let's move this check to config-backend/webapp and assume this is a valid URL.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the regex check

Comment thread v0/webhook/transform.js Outdated

response.userId = message.userId ? message.userId : message.anonymousId;
response.body.JSON = { ...message };
if (!response.statusCode) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need if here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statusCode is not needed. Removed it

Comment thread v0/webhook/transform.js Outdated
"Content-Type": "application/json"
};

const configHeaders = destination.Config.header;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change the config-backend param to headers as well (instead of header)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated both control-plane and here

Comment thread v0/webhook/transform.js
const configHeaders = destination.Config.header;
if (configHeaders) {
configHeaders.forEach(header => {
response.headers[header.from] = header.to;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be header.name and header.value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't get you completely. But I think we are not adding extra keys name and value. Kept it as it is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally these fields should be named header.name and header.value.

For a header, from and to is not the right convention.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But from and to is coming from our config-backend response.

Comment thread v0/webhook/transform.js
response.endpoint = destination.Config.webhookUrl;
response.method = defaultPostRequestConfig.requestMethod;
// add content-type by default as our payload is json
response.headers = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our server's network.go support FORM body too. Do we want to restrict webhook only for JSON.
That is good infact, when someone asks we can enable support for FORM.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

@arnabp92

Copy link
Copy Markdown
Contributor Author

@SumanthPuram Review comments are taken care of. Please check.

Comment thread v0/customerio/transform.js Outdated
"Viewed " + message.name
? message.name
: message.properties.name + " Screen";
evName = "Viewed " + message.name || message.properties.name + " Screen";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Viewed " + (message.name || message.properties.name) + " Screen"
For better readability?

Comment thread v0/leanplum/transform.js Outdated
@@ -96,42 +92,7 @@ function responseBuilderSimple(message, category, destination) {
}

async function startSession(message, destination) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This not an async function anymore. We can remove async and the corresponding await.

Comment thread v0/leanplum/transform.js Outdated
// all event types except idetify requires startSession
if (messageType !== EventType.IDENTIFY) {
await startSession(message, destination);
respList = [await startSession(message, destination)];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need await now.

prabrisha-rudder and others added 2 commits March 27, 2020 18:13
* bug fix

* Few code cleanups

Co-authored-by: arnab <[email protected]>
@SumanthPuram
SumanthPuram merged commit 745b3e1 into master Mar 30, 2020
achettyiitr pushed a commit that referenced this pull request Nov 16, 2026
## What are the changes introduced in this PR?
Mixpanel /import emits GZIP without a capability handshake. Removed the
unused shared check and constant, batching-only metadata plumbing, and
obsolete test headers. Updated three headerless router expectations
without changing their JSON payloads.

## What is the related Linear task?
Resolves INT-6925

## Please explain the objectives of your changes below
This change follows the env-flag rollout work in INT-6924 and INT-6926.
Removing the header from rudder-server remains a coordinated follow-up.

### Any changes to existing capabilities/behaviour, mention the reason &
what are the changes ?
Headerless /import requests now receive GZIP. In production the server
already advertises gzip support unconditionally. /engage and /groups
retain their workspace env-flag gates.

### Any new dependencies introduced with this change?
None.

### Any new generic utility introduced or modified. Please explain the
changes.
Removed the unused IsGzipSupported utility and FEATURE_GZIP_SUPPORT
constant; no utility was added.

### Any technical or performance related pointers to consider with the
change?
Router request metadata remains available to single-event error
handling. The secret-path manifest passed byte comparison and was not
changed.

<hr>

### Developer checklist
- [x] My code follows the style guidelines of this project
- [x] No breaking changes are being introduced for the stated production
server baseline
- [x] All related docs linked with the PR? HLD §4.2 and §10 item 4,
rudder-specs #94
- [x] All changes manually tested? Validated with automated unit and
component tests
- [x] Any documentation changes needed with this change? No
- [x] Is the PR limited to 10 file changes? Yes, six
- [x] Is the PR limited to one linear task? Yes
- [x] Are relevant unit and component test-cases added in new
readability format? Updated existing coverage and fixtures

### Validation
- `npm run lint` — passed.
- `npm test -- --testPathPattern="src/v0/destinations/mp/util.test.js"
--no-coverage` — 57 passed.
- `npm run test:ts -- component --destination=mp` — 83 passed.
- `./node_modules/.bin/tsc --noEmit -p tsconfig.json` and `-p
tsconfig.test.json` — passed.
- Full `npm run check:secret-paths` with integrations-config definitions
— passed byte comparison.
- `git diff --check` — passed; obsolete-symbol search across `src` and
`test` — no matches.
- Simplify pass: combined duplicate constant imports; no other
worthwhile findings. An additional broad `mp` Jest-pattern run timed out
after five minutes; the focused Mixpanel unit suite passed.
- Local integration verification: skipped because rudder-transformer
uses a sha-pinned service image and its edited source cannot be run by
mini in this sandbox.

## ⚠️ Known Issues
- The broader `mp` Jest-pattern run timed out after five minutes; the
focused Mixpanel unit suite and 83 component cases passed.
- The `X-Feature-Gzip-Support` header remains in rudder-server pending
coordination with that team.
- The transformer source change was not exercised against a live mini
stack because this service cannot be source-built in this sandbox.

### Reviewer checklist
- [ ] Is the type of change in the PR title appropriate as per the
changes?
- [ ] Verified that there are no credentials or confidential data
exposed with the changes.

Co-authored-by: tech-infra-rudderstack <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants