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 { ...@@ -37,29 +37,6 @@ class DiscoverPage extends React.PureComponent {
}; };
componentDidMount() { 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; const { sortByItem, fetchRewardedContent, fileList, followedTags } = this.props;
this.buildTagCollection(followedTags); this.buildTagCollection(followedTags);
......
...@@ -610,7 +610,7 @@ class FilePage extends React.PureComponent { ...@@ -610,7 +610,7 @@ class FilePage extends React.PureComponent {
let timeToStartMillis, timeToStart; let timeToStartMillis, timeToStart;
if (this.startTime) { if (this.startTime) {
timeToStartMillis = Date.now() - this.startTime; timeToStartMillis = Date.now() - this.startTime;
timeToStart = Math.ceil(timeToStartMillis / 1000); timeToStart = Math.ceil(timeToStartMillis / 1000.0);
this.startTime = null; this.startTime = null;
} }
...@@ -620,8 +620,8 @@ class FilePage extends React.PureComponent { ...@@ -620,8 +620,8 @@ class FilePage extends React.PureComponent {
let payload = { uri: uri }; let payload = { uri: uri };
if (!isNaN(timeToStart)) { if (!isNaN(timeToStart)) {
payload['time_to_start_seconds'] = timeToStart; payload['time_to_start_seconds'] = parseInt(timeToStart, 10);
payload['time_to_start_ms'] = timeToStartMillis; payload['time_to_start_ms'] = parseInt(timeToStartMillis, 10);
} }
NativeModules.Firebase.track('play', payload); NativeModules.Firebase.track('play', payload);
...@@ -702,19 +702,24 @@ class FilePage extends React.PureComponent { ...@@ -702,19 +702,24 @@ class FilePage extends React.PureComponent {
[ [
{ {
text: __('OK'), text: __('OK'),
onPress: () => purchaseUri(uri, costInfo, download), onPress: () => {
this.startTime = Date.now();
purchaseUri(uri, costInfo, download);
},
}, },
{ text: __('Cancel') }, { text: __('Cancel') },
], ],
); );
} else { } else {
// Free content. Just call purchaseUri directly. // Free content. Just call purchaseUri directly.
this.startTime = Date.now();
purchaseUri(uri, costInfo, download); purchaseUri(uri, costInfo, download);
} }
}; };
onFileDownloadButtonPressed = () => { 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 mediaType = Lbry.getMediaType(contentType);
const isPlayable = mediaType === 'video' || mediaType === 'audio'; const isPlayable = mediaType === 'video' || mediaType === 'audio';
const isViewable = mediaType === 'image' || mediaType === 'text'; const isViewable = mediaType === 'image' || mediaType === 'text';
...@@ -729,7 +734,6 @@ class FilePage extends React.PureComponent { ...@@ -729,7 +734,6 @@ class FilePage extends React.PureComponent {
} }
if (isPlayable) { if (isPlayable) {
this.startTime = Date.now();
this.setState({ downloadPressed: true, autoPlayMedia: true, stopDownloadConfirmed: false }); this.setState({ downloadPressed: true, autoPlayMedia: true, stopDownloadConfirmed: false });
} }
if (isViewable) { if (isViewable) {
......
...@@ -67,6 +67,9 @@ class SplashScreen extends React.PureComponent { ...@@ -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) { 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