diff --git a/src/modules/ampli/index.ts b/src/modules/ampli/index.ts index 2eb4ac75..928074de 100644 --- a/src/modules/ampli/index.ts +++ b/src/modules/ampli/index.ts @@ -7,7 +7,7 @@ * To update run 'ampli pull scraper' * * Required dependencies: @amplitude/analytics-node@^0.5.0 - * Tracking Plan Version: 40 + * Tracking Plan Version: 43 * Build: 1.0.0 * Runtime: node.js:typescript-ampli-v2 * @@ -38,10 +38,10 @@ export const ApiKey: Record = { */ export const DefaultConfiguration: NodeOptions = { plan: { - version: "40", + version: "43", branch: "main", source: "scraper", - versionId: "cbc4a092-7d03-473a-bbba-f4fc79ef25b2", + versionId: "364c665a-00b3-4f3a-86b4-72245b71f5a0", }, ...{ ingestionMetadata: { @@ -118,7 +118,7 @@ export interface IdentifyProperties { walletType?: string; } -export interface TransferFillConfirmedProperties { +export interface TransferFillCompletedProperties { /** * Capital fee percent, in decimals */ @@ -135,7 +135,7 @@ export interface TransferFillConfirmedProperties { fillAmount: string; fillAmountUsd: string; fillCompleteTimestamp: string; - fillTime: string; + fillTimeInMs: string; /** * From amount in the bridge token, in decimals */ @@ -169,18 +169,9 @@ export interface TransferFillConfirmedProperties { * Lp fee in USD */ lpFeeTotalUsd: string; - /** - * Gas fee in network token - */ - NetworkFeeNative: string; - /** - * Network native token - */ - NetworkFeeNativeToken: string; - /** - * Gas fee in USD - */ - NetworkFeeUsd: string; + networkFeeNative: string; + networkFeeNativeToken: string; + networkFeeUsd: string; /** * Recipient wallet address */ @@ -281,10 +272,10 @@ export class Identify implements BaseEvent { } } -export class TransferFillConfirmed implements BaseEvent { - event_type = "TransferFillConfirmed"; +export class TransferFillCompleted implements BaseEvent { + event_type = "TransferFillCompleted"; - constructor(public event_properties: TransferFillConfirmedProperties) { + constructor(public event_properties: TransferFillCompletedProperties) { this.event_properties = event_properties; } } @@ -406,9 +397,9 @@ export class Ampli { } /** - * TransferFillConfirmed + * TransferFillCompleted * - * [View in Tracking Plan](https://data.amplitude.com/risklabs/Risk%20Labs/events/main/latest/TransferFillConfirmed) + * [View in Tracking Plan](https://data.amplitude.com/risklabs/Risk%20Labs/events/main/latest/TransferFillCompleted) * * Owner: Dong-Ha Kim * @@ -416,12 +407,12 @@ export class Ampli { * @param properties The event's properties (e.g. capitalFeePct) * @param options Amplitude event options. */ - transferFillConfirmed( + transferFillCompleted( userId: string | undefined, - properties: TransferFillConfirmedProperties, + properties: TransferFillCompletedProperties, options?: EventOptions, ) { - return this.track(userId, new TransferFillConfirmed(properties), options); + return this.track(userId, new TransferFillCompleted(properties), options); } } diff --git a/src/modules/deposit/service.ts b/src/modules/deposit/service.ts index b577c0ef..c71c8984 100644 --- a/src/modules/deposit/service.ts +++ b/src/modules/deposit/service.ts @@ -97,6 +97,7 @@ export class DepositService { [deposits, total] = await this.depositRepository .createQueryBuilder("d") .where("d.status = :status", { status }) + .andWhere("d.amount > 0") .andWhere("d.depositDate > NOW() - INTERVAL '1 days'") .andWhere(`d.depositRelayerFeePct * :multiplier >= d.suggestedRelayerFeePct`, { multiplier: this.appConfig.values.suggestedFees.deviationBufferMultiplier, diff --git a/src/modules/scraper/adapter/amplitude/track-service.ts b/src/modules/scraper/adapter/amplitude/track-service.ts index ad0bc024..f2f1058e 100644 --- a/src/modules/scraper/adapter/amplitude/track-service.ts +++ b/src/modules/scraper/adapter/amplitude/track-service.ts @@ -1,7 +1,7 @@ import { HttpService } from "@nestjs/axios"; import { Injectable } from "@nestjs/common"; -import { EventOptions, TransferFillConfirmedProperties, ampli } from "../../../ampli"; +import { EventOptions, TransferFillCompletedProperties, ampli } from "../../../ampli"; import { AppConfig } from "../../../configuration/configuration.service"; @Injectable() @@ -22,9 +22,9 @@ export class TrackService { public async trackDepositFilledEvent( userId: string, - eventProperties: TransferFillConfirmedProperties, + eventProperties: TransferFillCompletedProperties, eventOptions?: EventOptions, ) { - return ampli.transferFillConfirmed(userId, eventProperties, eventOptions); + return ampli.transferFillCompleted(userId, eventProperties, eventOptions); } } diff --git a/src/modules/scraper/adapter/messaging/TrackFillEventConsumer.ts b/src/modules/scraper/adapter/messaging/TrackFillEventConsumer.ts index 277dab14..4c6c3e6a 100644 --- a/src/modules/scraper/adapter/messaging/TrackFillEventConsumer.ts +++ b/src/modules/scraper/adapter/messaging/TrackFillEventConsumer.ts @@ -101,7 +101,9 @@ export class TrackFillEventConsumer { fillAmount: fillAmounts.formattedAmount, fillAmountUsd: fillAmounts.formattedAmountUsd, fillCompleteTimestamp: String(DateTime.fromISO(fillTx.date).toMillis()), - fillTime: String(DateTime.fromISO(fillTx.date).diff(DateTime.fromJSDate(deposit.depositDate)).as("milliseconds")), + fillTimeInMs: String( + DateTime.fromISO(fillTx.date).diff(DateTime.fromJSDate(deposit.depositDate)).as("milliseconds"), + ), fromAmount: fromAmounts.formattedAmount, fromAmountUsd: fromAmounts.formattedAmountUsd, fromChainId: String(deposit.sourceChainId), @@ -111,9 +113,9 @@ export class TrackFillEventConsumer { lpFeePct: formattedLpFeeValues.pct, lpFeeTotal: formattedLpFeeValues.total, lpFeeTotalUsd: formattedLpFeeValues.totalUsd, - NetworkFeeNative: fee, - NetworkFeeNativeToken: destinationChainInfo.nativeSymbol.toUpperCase(), - NetworkFeeUsd: feeUsd, + networkFeeNative: fee, + networkFeeNativeToken: destinationChainInfo.nativeSymbol.toUpperCase(), + networkFeeUsd: feeUsd, recipient: deposit.recipientAddr, referralProgramAddress: deposit.referralAddress || "-", relayFeePct: formattedRelayFeeValues.pct, diff --git a/test/deposit.e2e-spec.ts b/test/deposit.e2e-spec.ts index 8fd293a7..803eed7e 100644 --- a/test/deposit.e2e-spec.ts +++ b/test/deposit.e2e-spec.ts @@ -25,12 +25,12 @@ describe("GET /deposits", () => { // filled deposits with depositIds 10 - 19 and ascending depositDate const FILLED_DEPOSITS = mockManyDepositEntities(10, { depositIdStartIndex: 10, - overrides: { status: "filled", depositorAddr: depositorAddress }, + overrides: { status: "filled", depositorAddr: depositorAddress, amount: "10", filled: "10" }, }); // pending deposits with depositIds 20 - 29 and ascending depositDate const PENDING_DEPOSITS = mockManyDepositEntities(10, { depositIdStartIndex: 20, - overrides: { status: "pending", depositorAddr: depositorAddress }, + overrides: { status: "pending", depositorAddr: depositorAddress, amount: "10" }, }); beforeAll(async () => { diff --git a/yarn.lock b/yarn.lock index 25990b8a..11d5c4be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9794,9 +9794,9 @@ http-basic@^8.1.1: parse-cache-control "^1.0.1" http-cache-semantics@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390" - integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== + version "4.1.1" + resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" + integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== http-call@^5.2.2, http-call@^5.3.0: version "5.3.0"