Skip to content

Commit

Permalink
refactor: rename deposit fill event and props amplitude (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki authored Jan 16, 2023
1 parent c57e44b commit 683d72d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 32 deletions.
41 changes: 16 additions & 25 deletions src/modules/ampli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -38,10 +38,10 @@ export const ApiKey: Record<Environment, string> = {
*/
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: {
Expand Down Expand Up @@ -118,7 +118,7 @@ export interface IdentifyProperties {
walletType?: string;
}

export interface TransferFillConfirmedProperties {
export interface TransferFillCompletedProperties {
/**
* Capital fee percent, in decimals
*/
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -406,22 +397,22 @@ 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
*
* @param userId The user's ID.
* @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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/modules/scraper/adapter/amplitude/track-service.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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);
}
}
10 changes: 6 additions & 4 deletions src/modules/scraper/adapter/messaging/TrackFillEventConsumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down

0 comments on commit 683d72d

Please sign in to comment.