Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit cc293e1

Browse files
authored
Merge pull request #1345 from OpenBazaar/addInventoryAnalytics
Add inventory analytics
2 parents 4c43b9b + 0aec2dd commit cc293e1

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

js/views/ListingCard.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,14 @@ export default class extends baseVw {
246246
app.router.navigateUser(`${this.options.listingBaseUrl}${this.model.get('slug')}`,
247247
this.ownerGuid);
248248

249-
startEvent('LoadListingFromCard');
249+
startEvent('Listing_LoadFromCard');
250250

251251
const listingFetch = this.fetchFullListing();
252252
const loadListing = () => {
253253
app.loadingModal.open();
254254
listingFetch.done(jqXhr => {
255-
endEvent('LoadListingFromCard', {
256-
ownListing: this.ownListing,
255+
endEvent('Listing_LoadFromCard', {
256+
ownListing: !!this.ownListing,
257257
errors: 'none',
258258
});
259259
if (jqXhr.statusText === 'abort' || this.isRemoved()) return;
@@ -280,9 +280,9 @@ export default class extends baseVw {
280280
app.loadingModal.close();
281281
})
282282
.fail(xhr => {
283-
endEvent('LoadListingFromCard', {
284-
ownListing: this.ownListing,
285-
errors: xhr.statusText,
283+
endEvent('Listing_LoadFromCard', {
284+
ownListing: !!this.ownListing,
285+
errors: xhr.responseJSON.reason || xhr.statusText || 'unknown error',
286286
});
287287
if (xhr.statusText === 'abort') return;
288288
app.router.listingError(xhr, this.model.get('slug'), `#${this.ownerGuid}/store`);

js/views/modals/listingDetail/Listing.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
getInventory,
1717
events as inventoryEvents,
1818
} from '../../../utils/inventory';
19-
import { recordEvent } from '../../../utils/metrics';
19+
import { endEvent, recordEvent, startEvent } from '../../../utils/metrics';
2020
import { getTranslatedCountries } from '../../../data/countries';
2121
import BaseModal from '../BaseModal';
2222
import Purchase from '../purchase/Purchase';
@@ -138,12 +138,25 @@ export default class extends BaseModal {
138138
});
139139

140140
if (this.model.isCrypto) {
141+
startEvent('Listing_InventoryFetch');
141142
this.inventoryFetch = getInventory(this.vendor.peerID, {
142143
slug: this.model.get('slug'),
143144
coinDivisibility: this.model.get('metadata')
144145
.get('coinDivisibility'),
145146
})
146-
.done(e => (this._inventory = e.inventory));
147+
.done(e => {
148+
this._inventory = e.inventory;
149+
endEvent('Listing_InventoryFetch', {
150+
ownListing: !!this.ownListing,
151+
errors: 'none',
152+
});
153+
})
154+
.fail(e => {
155+
endEvent('Listing_InventoryFetch', {
156+
ownListing: !!this.ownListing,
157+
errors: e.error || e.errCode || 'unknown error',
158+
});
159+
});
147160
this.listenTo(inventoryEvents, 'inventory-change',
148161
e => (this._inventory = e.inventory));
149162
}

0 commit comments

Comments
 (0)