Skip to content

Commit

Permalink
📈 Add priceIndex in purchase flow events
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Oct 11, 2024
1 parent b4d0c2e commit acc6cdb
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/NFTBook/CrossSellDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ export default {
});
} else {
// NOTE: Only support single edition for now
const edition = this.getEditionByIndex(0);
const priceIndex = 0;
const edition = this.getEditionByIndex(priceIndex);
const hasStock = edition?.stock;
if (!hasStock || !this.nftIsCollectable || edition.price === 0) {
this.handleReject();
Expand All @@ -250,6 +251,7 @@ export default {
name: this.NFTName,
price: edition.price,
classId: this.classId,
priceIndex,
quantity: 1,
},
],
Expand Down
2 changes: 2 additions & 0 deletions src/mixins/nft.js
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,7 @@ export default {
items: [
{
classId: this.classId,
priceIndex: this.editionPriceIndex,
price: this.NFTPriceUSD,
name: this.NFTName,
},
Expand Down Expand Up @@ -1131,6 +1132,7 @@ export default {
{
name: this.NFTName,
price: this.NFTPriceUSD,
priceIndex: this.editionPriceIndex,
classId,
},
],
Expand Down
13 changes: 11 additions & 2 deletions src/pages/nft/claim/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -798,14 +798,15 @@ export default {
return;
}
let price;
let priceIndex;
if (this.cartId) {
const { data } = await this.$api.get(
getNFTBookCartStatusEndpoint({
cartId: this.cartId,
token: this.token,
})
);
({ price } = data);
({ price, priceIndex } = data);
const {
classIdsWithPrice = [],
collectionIdsWithPrice = [],
Expand Down Expand Up @@ -908,7 +909,13 @@ export default {
if (!free && !this.giftInfo && redirect && query.type === 'nft_book') {
const items = this.cartItems.length
? this.cartItems.map(item => {
const { classId, collectionId, price, quantity = 1 } = item;
const {
classId,
collectionId,
price,
priceIndex,
quantity = 1,
} = item;
const name = classId
? this.getNFTClassMetadataById(classId)?.name
: this.getNFTCollectionInfoByCollectionId(collectionId)?.name[
Expand All @@ -918,6 +925,7 @@ export default {
name,
classId,
collectionId,
priceIndex,
price,
quantity,
};
Expand All @@ -927,6 +935,7 @@ export default {
name: this.productName,
classId: this.classId,
collectionId: this.collectionId,
priceIndex,
price,
quantity: this.quantity,
},
Expand Down
1 change: 1 addition & 0 deletions src/pages/nft/class/_classId/_nftId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ export default {
{
name: this.NFTName,
price: this.NFTPriceUSD,
priceIndex: this.editionPriceIndex,
classId: this.classId,
},
],
Expand Down
14 changes: 14 additions & 0 deletions src/pages/nft/class/_classId/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ export default {
{
name: this.NFTName,
classId: this.classId,
priceIndex: this.editionPriceIndex,
price: this.NFTPriceUSD,
},
],
Expand Down Expand Up @@ -940,6 +941,7 @@ export default {
name: this.NFTName,
price: customPriceInDecimal || edition.price,
classId: this.classId,
priceIndex: edition.index,
quantity: this.quantity,
},
],
Expand Down Expand Up @@ -1357,6 +1359,18 @@ export default {
this.classId,
1
);
logPurchaseFlowEvent(this, 'view_item', {
items: [
{
name: this.NFTName,
classId: this.classId,
priceIndex: this.editionPriceIndex,
price: this.NFTPriceUSD,
},
],
price: this.NFTPriceUSD,
currency: 'USD',
});
},
handleInputCustomPrice(price) {
this.customPrice = Number(price);
Expand Down
1 change: 1 addition & 0 deletions src/pages/nft/fiat/stripe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export default {
name: this.NFTName,
price: this.result.fiatPrice,
classId: this.classId,
priceIndex: this.editionPriceIndex,
},
],
price: this.result.fiatPrice,
Expand Down
4 changes: 3 additions & 1 deletion src/pages/nft/gift/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default {
return;
}
let price;
let priceIndex;
if (this.cartId) {
const { data } = await this.$api.get(
Expand Down Expand Up @@ -147,7 +148,7 @@ export default {
paymentId: this.paymentId,
})
);
({ price } = data);
({ price, priceIndex } = data);
}
try {
if (this.cartItems.length) {
Expand Down Expand Up @@ -212,6 +213,7 @@ export default {
name: this.productName,
classId: this.classId,
collectionId: this.collectionId,
priceIndex,
price,
quantity: this.quantity,
},
Expand Down

0 comments on commit acc6cdb

Please sign in to comment.