Skip to content

Commit 20a9a57

Browse files
panteleymonchukmsarcevbegonaalvarezd
authored
feat(dapp): add expirationTime to Purchase, Renew, and RenewSubname amplitude events (#1029)
* feat(dapp): add expirationTime to Purchase, Renew, and RenewSubname dialogs * chore: remove expiration property for renew --------- Co-authored-by: msarcev <mario.sarcevic@iota.org> Co-authored-by: Begoña Álvarez de la Cruz <balvarez@boxfish.studio>
1 parent 1987557 commit 20a9a57

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

dapp/src/components/dialogs/PurchaseNameDialog.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,14 @@ export function PurchaseNameDialog({ name, open, setOpen, onCompleted }: Purchas
161161
queryKey: queryKey.publicName(account?.address || ''),
162162
});
163163

164+
const expirationDate = new Date();
165+
expirationDate.setFullYear(expirationDate.getFullYear() + purchaseYears);
166+
const expirationTime = expirationDate.getTime();
167+
164168
ampli.purchasedName({
165169
name,
166170
amount: parseNanosToIota(price ?? 0),
167-
expiration: purchaseYears, // tbd replace expiration with more meaningful name purchaseYears
171+
expirationTime,
168172
purchaseYears: purchaseYears,
169173
discountName: couponCodes.join(','),
170174
discountPercentage: applyDiscount ? (price - (discountedPrice ?? 0)) / price : 0,

dapp/src/components/dialogs/RenewNameDialog.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,15 @@ export function RenewNameDialog({ setOpen, name, onRenew }: RenewDialogProps) {
142142
queryClient.invalidateQueries({
143143
queryKey: queryKey.getObject(name),
144144
});
145+
const currentExpiration = nameRecord?.nameRecord?.expirationDate
146+
? new Date(nameRecord.nameRecord.expirationDate)
147+
: new Date();
148+
currentExpiration.setFullYear(currentExpiration.getFullYear() + (renewYears || 0));
149+
const expirationTime = currentExpiration.getTime();
150+
145151
ampli.renewedName({
146152
name,
147-
expiration: renewYears || 0, // tbd replace with more meaningful name renewYears
153+
expirationTime,
148154
renewYears: renewYears || 0,
149155
});
150156
toast.success('Name renewed successfully');

dapp/src/components/dialogs/RenewSubameDialog.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,13 @@ export function RenewSubnameDialog({ setOpen, name, onRenew }: RenewDialogProps)
132132
queryClient.invalidateQueries({
133133
queryKey: queryKey.getObject(name),
134134
});
135+
const expirationTime = expirationDate ? expirationDate.getTime() : Date.now();
136+
135137
ampli.renewedSubname({
136138
name,
137139
// TODO expirationType `custom` will be added after implement https://github.com/iotaledger/iota-names/issues/915
138140
expirationType: 'parent',
139-
expirationTime: expirationDate?.getTime().toString() || '',
141+
expirationTime,
140142
});
141143
toast.success('Subname renewed successfully');
142144
},

dapp/src/lib/utils/analytics/ampli/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export interface PurchasedNameProperties {
162162
* |---|---|
163163
* | Type | number |
164164
*/
165-
expiration: number;
165+
expirationTime: number;
166166
name: string;
167167
/**
168168
* Property created as alternative of `expiration` with more readable name.
@@ -180,7 +180,7 @@ export interface RenewedNameProperties {
180180
* |---|---|
181181
* | Type | number |
182182
*/
183-
expiration: number;
183+
expirationTime: number;
184184
name: string;
185185
/**
186186
* | Rule | Value |
@@ -191,7 +191,12 @@ export interface RenewedNameProperties {
191191
}
192192

193193
export interface RenewedSubnameProperties {
194-
expirationTime: string;
194+
/**
195+
* | Rule | Value |
196+
* |---|---|
197+
* | Type | number |
198+
*/
199+
expirationTime: number;
195200
expirationType: string;
196201
name: string;
197202
}
@@ -583,7 +588,7 @@ export class Ampli {
583588
*
584589
* Event has no description in tracking plan.
585590
*
586-
* @param properties The event's properties (e.g. expiration)
591+
* @param properties The event's properties (e.g. expirationTime)
587592
* @param options Amplitude event options.
588593
*/
589594
renewedName(

0 commit comments

Comments
 (0)