From 683d72d6d9d18c4e5f7f201523ddac4c2c25cf04 Mon Sep 17 00:00:00 2001 From: Dong-Ha Kim Date: Mon, 16 Jan 2023 18:09:33 +0100 Subject: [PATCH] refactor: rename deposit fill event and props amplitude (#209) --- src/modules/ampli/index.ts | 41 ++++++++----------- .../adapter/amplitude/track-service.ts | 6 +-- .../messaging/TrackFillEventConsumer.ts | 10 +++-- 3 files changed, 25 insertions(+), 32 deletions(-) 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/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,