Unverified Commit 1f649b9d authored by Akinwale Ariwodola's avatar Akinwale Ariwodola Committed by GitHub
Browse files

App timing (#123)

* log launch timing. recalculate play time to start timing.
* remove decimal points from time to start values
parent 55b292ab
......@@ -37,29 +37,6 @@ class DiscoverPage extends React.PureComponent {
};
componentDidMount() {
// Track the total time taken if this is the first launch
AsyncStorage.getItem('firstLaunchTime').then(startTime => {
if (startTime !== null && !isNaN(parseInt(startTime, 10))) {
// We don't need this value anymore once we've retrieved it
AsyncStorage.removeItem('firstLaunchTime');
// We know this is the first app launch because firstLaunchTime is set and it"s a valid number
const start = parseInt(startTime, 10);
const now = moment().unix();
const delta = now - start;
AsyncStorage.getItem('firstLaunchSuspended').then(suspended => {
AsyncStorage.removeItem('firstLaunchSuspended');
const appSuspended = suspended === 'true';
if (NativeModules.Firebase) {
NativeModules.Firebase.track('first_run_time', {
total_seconds: delta,
app_suspended: appSuspended,
});
}
});
}
});
const { sortByItem, fetchRewardedContent, fileList, followedTags } = this.props;
this.buildTagCollection(followedTags);
......
......@@ -610,7 +610,7 @@ class FilePage extends React.PureComponent {
let timeToStartMillis, timeToStart;
if (this.startTime) {
timeToStartMillis = Date.now() - this.startTime;
timeToStart = Math.ceil(timeToStartMillis / 1000);
timeToStart = Math.ceil(timeToStartMillis / 1000.0);
this.startTime = null;
}
......@@ -620,8 +620,8 @@ class FilePage extends React.PureComponent {
let payload = { uri: uri };
if (!isNaN(timeToStart)) {
payload['time_to_start_seconds'] = timeToStart;
payload['time_to_start_ms'] = timeToStartMillis;
payload['time_to_start_seconds'] = parseInt(timeToStart, 10);
payload['time_to_start_ms'] = parseInt(timeToStartMillis, 10);
}
NativeModules.Firebase.track('play', payload);
......@@ -702,19 +702,24 @@ class FilePage extends React.PureComponent {
[
{
text: __('OK'),
onPress: () => purchaseUri(uri, costInfo, download),
onPress: () => {
this.startTime = Date.now();
purchaseUri(uri, costInfo, download);
},
},
{ text: __('Cancel') },
],
);
} else {
// Free content. Just call purchaseUri directly.
this.startTime = Date.now();
purchaseUri(uri, costInfo, download);
}
};
onFileDownloadButtonPressed = () => {
const { claim, costInfo, contentType, purchaseUri, setPlayerVisible } = this.props;
this.startTime = Date.now();
const { claim, costInfo, contentType, setPlayerVisible } = this.props;
const mediaType = Lbry.getMediaType(contentType);
const isPlayable = mediaType === 'video' || mediaType === 'audio';
const isViewable = mediaType === 'image' || mediaType === 'text';
......@@ -729,7 +734,6 @@ class FilePage extends React.PureComponent {
}
if (isPlayable) {
this.startTime = Date.now();
this.setState({ downloadPressed: true, autoPlayMedia: true, stopDownloadConfirmed: false });
}
if (isViewable) {
......
......@@ -67,6 +67,9 @@ class SplashScreen extends React.PureComponent {
}
}
}
// splash screen is done at this point, next page to be displayed will be user-interactable
NativeModules.Firebase.logLaunchTiming();
};
componentWillReceiveProps(nextProps) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment