Skip to content

Commit 01af03a

Browse files
committed
Added analytics test
1 parent 837fac5 commit 01af03a

File tree

5 files changed

+103
-77
lines changed

5 files changed

+103
-77
lines changed

app/redux/navigationReducer.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

app/routes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Database from './views/Database';
1111
import Authentication from './views/Authentication';
1212
import Messaging, { Routes as MessagingRoutes } from './views/Messaging';
1313
import Presence, { Routes as PresenceRoutes } from './views/Presence'
14+
import Analytics, { Routes as AnalyticsRoutes } from './views/Analytics';
1415

1516
export type Route = {
1617
key: String,
@@ -19,6 +20,13 @@ export type Route = {
1920
};
2021

2122
export const exampleRoutes = {
23+
'analytics': {
24+
route: {
25+
title: 'Analytics',
26+
Component: Analytics
27+
},
28+
children: AnalyticsRoutes
29+
},
2230
'database': {
2331
route: {
2432
title: 'Database',
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react'
2+
3+
import {
4+
View,
5+
Text,
6+
TouchableHighlight
7+
} from 'react-native'
8+
9+
import appStyles from '../../../styles/app';
10+
11+
export class LogEvent extends React.Component {
12+
13+
_logEvent() {
14+
const {firestack} = this.props;
15+
firestack.analytics.logEventWithName('simpleEvent', {
16+
createdAt: new Date().getTime(),
17+
from: 'FirestackApp'
18+
})
19+
}
20+
21+
render() {
22+
return (
23+
<View>
24+
<TouchableHighlight onPress={this._logEvent.bind(this)} style={appStyles.row}>
25+
<Text>Log an event</Text>
26+
</TouchableHighlight>
27+
</View>
28+
)
29+
}
30+
31+
}
32+
33+
export default LogEvent;

app/views/Analytics/index.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import React from 'react';
2+
import {connect} from 'react-redux'
3+
import {
4+
View,
5+
Text
6+
} from 'react-native'
7+
8+
import appStyles from '../../styles/app';
9+
10+
import List from '../../components/List/List'
11+
12+
// Demos
13+
import LogEvent from './Demos/LogEvent';
14+
15+
export const Routes = {
16+
'logevent': {
17+
route: {
18+
title: 'Log event',
19+
Component: LogEvent
20+
}
21+
}
22+
}
23+
24+
export class Analytics extends React.Component {
25+
render() {
26+
const initialRows = Object.keys(Routes).map(key => {
27+
const routeCfg = Routes[key];
28+
return { title: routeCfg.route.title, key: `analytics.${key}` }
29+
})
30+
return (
31+
<View style={appStyles.container}>
32+
<List
33+
initialRows={initialRows}
34+
renderRow={this._renderRow.bind(this)}
35+
onRowPress={this._onRowPress.bind(this)}
36+
/>
37+
</View>
38+
)
39+
}
40+
41+
_renderRow(rowData, sectionID, rowID, highlightRow) {
42+
console.log(rowData)
43+
return (
44+
<View style={[appStyles.row]}>
45+
<Text>{rowData.title}</Text>
46+
</View>
47+
)
48+
}
49+
50+
_onRowPress(rowData) {
51+
const rowKey = rowData.key;
52+
const {actions} = this.props;
53+
const {navigation} = actions;
54+
navigation.push(rowKey, this.props);
55+
}
56+
}
57+
58+
const mapStateToProps = (state) => ({
59+
firestack: state.firestack
60+
})
61+
export default connect(mapStateToProps)(Analytics)

ios/FirestackApp/AppDelegate.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
#import "RCTBundleURLProvider.h"
1313
#import "RCTRootView.h"
14-
#import "Firestack.h"
15-
#import "FirestackCloudMessaging.h"
1614

1715
@implementation AppDelegate
1816

@@ -38,7 +36,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3836

3937
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
4038
{
41-
[FirestackCloudMessaging did]
39+
// [FirestackCloudMessaging did]
4240
}
4341

4442
@end

0 commit comments

Comments
 (0)