Repository navigation
fix: discard duplicate cart event - #2091
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## fix.redis-connector #2091 +/- ##
=======================================================
+ Coverage 87.87% 87.95% +0.07%
=======================================================
Files 509 509
Lines 25742 25746 +4
Branches 6368 6352 -16
=======================================================
+ Hits 22622 22646 +24
+ Misses 2787 2767 -20
Partials 333 333
☔ View full report in Codecov by Sentry. |
| "token": "shopify_test3", | ||
| "updated_at": "2023-02-10T12:16:07.251Z" | ||
| } | ||
| "error": "event type carts_create not supported" |
There was a problem hiding this comment.
Can we absorb the changes made here in this PR ?
CC @krishna2020
There was a problem hiding this comment.
I am adding some more cases here and there first it is confirm.Then we can see depending on number conflicts
Will that be right approach?
There was a problem hiding this comment.
Changes are simple:
Move redisConnector.js to src/util/redis &
Move redisConnector.test.js to src/util/redis & redis test cases files to src/util/testdata
Co-authored-by: Sudip Paul <[email protected]>
| errorType: "Redis", | ||
| timestamp: Date.now() |
There was a problem hiding this comment.
This is wrong labels, we shouldn't add timestamp as label. Also having a constant value for errorType as label as well doesn't make sense
There was a problem hiding this comment.
Let me gather info and see what would be the best param
| * | ||
| */ | ||
| async getVal(key, isJsonExpected = true) { | ||
| async getVal(key, isObjExpected = true) { |
There was a problem hiding this comment.
Please update the JS docs its still showing description for isJsonExpected
| return isJsonExpected ? JSON.parse(value) : value; | ||
| const bytes = Buffer.byteLength(JSON.stringify(value), "utf-8"); | ||
| stats.gauge('redis_get_val_size', bytes, { | ||
| timestamp: Date.now() |
There was a problem hiding this comment.
Please remove timestamp as label from here
| } catch (e) { | ||
| stats.increment('redis_get_val_error', { | ||
| error: e, | ||
| errorType: "Redis", |
There was a problem hiding this comment.
Same please remove timestamp as label from here
|
|
||
| async setVal(key, value, isValJson = true) { | ||
| const dataExpiry = 60 * 60; // 1 hour | ||
| async setVal(key, value, expiryTime = 60 * 60) { |
There was a problem hiding this comment.
| async setVal(key, value, expiryTime = 60 * 60) { | |
| async setVal(key, value, expiryTimeInSec = 60 * 60) { |
| } else { | ||
| bytes = Buffer.byteLength(value, "utf-8"); | ||
| await this.client.setex(key, expiryTime, value); | ||
| } |
There was a problem hiding this comment.
Remove timestamp as a stats label for all occurrences
| .exec(); | ||
| } else { | ||
| bytes = Buffer.byteLength(value, "utf-8"); | ||
| await this.client.setex(key, expiryTimeInSec, value); |
There was a problem hiding this comment.
| if (isObjExpected === true) { | ||
| value = await this.client.hmget(key); | ||
| if (isDefinedAndNotNull(value)) { | ||
| Object.keys(value).forEach(Key => { |
There was a problem hiding this comment.
Key -> keep key (lower case)
There was a problem hiding this comment.
we already have key as parameter . will change this to objKey
| @@ -122,7 +151,7 @@ const RedisDB = { | |||
| }); | |||
| this.client.quit(); | |||
There was a problem hiding this comment.
| } | ||
| return element; | ||
| }) | ||
| bytes = Buffer.byteLength(JSON.stringify(value), "utf-8"); |
There was a problem hiding this comment.
this is not required, aws provides this already
There was a problem hiding this comment.
okay will remove this
| .expire(key, expiryTimeInSec) | ||
| .exec(); | ||
| } else { | ||
| bytes = Buffer.byteLength(value, "utf-8"); |
There was a problem hiding this comment.
this is not required, aws provides this already
| } | ||
| if (!isDefinedAndNotNull(cartToken)) { | ||
| stats.increment('shopify_no_cartToken', { | ||
| stats.increment('No_cartToken_in_payload', { |
There was a problem hiding this comment.
keep all small no_cart_token_in_payload
what are we planning to do with this metric?
There was a problem hiding this comment.
we want to know in how many cases will we wont get any cartToken in payload
| redisVal = await RedisDB.getVal(cartToken); | ||
| } catch (e) { | ||
| // so if redis is down we will send the event to downstream destinations | ||
| console.log("Error: ", e); |
There was a problem hiding this comment.
console.log("Shopify events not stitched:", e);
|
Kudos, SonarCloud Quality Gate passed! |
* fix: redis connect with promise race timeoutPromise should be a function so that it returns a new promise everytime. * fix: redis connect with promise race timeoutPromise should be a function so that it returns a new promise everytime. Also we should use reject so that it will error if timed out. * added extra padding for redis failure and passing events if redis error comes up * refactor: checkAndConnectConnection method * feat: tested redis * refactor redis for incorporating end signal * comments addressed * test coverage increased * test coverage increased * introducing redis_error stat * introducing redis_latency stat * comments addressed+1 * stat fix * chore: comments addressed+2 * fix: discard duplicate cart event (#2091) * fix: discard duplicate cart event * Removed cart_create event * Removed cart_create event * chore: utils test cases added * fix: updated design flow for cart duplication * chore: test cases added * fix: directory path * fix: directory path * feat: added some more redis metric * Update src/util/redisConnector.js Co-authored-by: Sudip Paul <[email protected]> * comments addressed * chore: conflicts resolved * chore: comments addressed * chore: ideas incorporated * chore: comments addressed * chore: comments addressed * fix: redis mock * fix: redis --------- Co-authored-by: Sudip Paul <[email protected]> * chore: update import statement * chore: comments addressed * feat: redis return type changes * chore: add metrics in prometheus.js * replaced hmget with hget * added padding * removed use of isObject * console removes * added error logs * chore: addressed comments * chore: addressed comments * solve build issue * chore: addressed comments --------- Co-authored-by: Anant Jain <[email protected]> Co-authored-by: Anant Jain <[email protected]> Co-authored-by: Sudip Paul <[email protected]>








Description of the change
Type of change
Related issues
Checklists
Development
Code review