Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit cceff54

Browse files
committed
Update example project
1 parent 1f43315 commit cceff54

File tree

16 files changed

+1932
-1333
lines changed

16 files changed

+1932
-1333
lines changed

example/.flowconfig

+18-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212
; For RN Apps installed via npm, "Libraries" folder is inside
1313
; "node_modules/react-native" but in the source repo it is in the root
1414
.*/Libraries/react-native/React.js
15-
.*/Libraries/react-native/ReactNative.js
15+
16+
; Ignore polyfills
17+
.*/Libraries/polyfills/.*
18+
19+
; Ignore metro
20+
.*/node_modules/metro/.*
1621

1722
[include]
1823

1924
[libs]
2025
node_modules/react-native/Libraries/react-native/react-native-interface.js
21-
node_modules/react-native/flow
22-
flow/
26+
node_modules/react-native/flow/
27+
node_modules/react-native/flow-github/
2328

2429
[options]
2530
emoji=true
@@ -30,16 +35,22 @@ munge_underscores=true
3035

3136
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
3237

38+
module.file_ext=.js
39+
module.file_ext=.jsx
40+
module.file_ext=.json
41+
module.file_ext=.native.js
42+
3343
suppress_type=$FlowIssue
3444
suppress_type=$FlowFixMe
35-
suppress_type=$FixMe
45+
suppress_type=$FlowFixMeProps
46+
suppress_type=$FlowFixMeState
3647

37-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-7]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
38-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-7]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
3950
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
4051
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
4152

4253
unsafe.enable_getters_and_setters=true
4354

4455
[version]
45-
^0.47.0
56+
^0.61.0

example/.gitignore

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ buck-out/
4646
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
4747
# screenshots whenever they are needed.
4848
# For more information about the recommended setup visit:
49-
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
49+
# https://docs.fastlane.tools/best-practices/source-control/
5050

51-
fastlane/report.xml
52-
fastlane/Preview.html
53-
fastlane/screenshots
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots

example/App.js

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import React, { Component } from "react";
2+
import { AppRegistry, StyleSheet, Text, View } from "react-native";
3+
4+
import {
5+
GoogleAnalyticsTracker,
6+
GoogleAnalyticsSettings,
7+
GoogleTagManager
8+
} from "react-native-google-analytics-bridge";
9+
export default class App extends Component {
10+
render() {
11+
// Recommend you set this much higher in real app! 30 seconds+
12+
// GoogleAnalyticsSettings has static methods and is applied
13+
// for all trackers
14+
GoogleAnalyticsSettings.setDispatchInterval(2);
15+
//GoogleAnalyticsSettings.setDryRun(true);
16+
//GoogleAnalyticsSettings.setOptOut(true);
17+
18+
// The tracker is constructed
19+
let tracker = new GoogleAnalyticsTracker("UA-12345-3");
20+
// You can have multiple trackers
21+
//let tracker2 = new GoogleAnalyticsTracker("UA-12345-3", { demo: 1 });
22+
23+
//tracker2.trackScreenViewWithCustomDimensionValues("Home", { demo: "Yes" });
24+
25+
tracker.trackEvent("testcategory", "Hello iOS");
26+
27+
tracker.trackScreenView("Home");
28+
29+
tracker.trackEvent("testcategory", "Hello iOS", {
30+
label: "notdry",
31+
value: 1
32+
});
33+
34+
tracker.trackTiming("testcategory", 13000, {
35+
label: "notdry",
36+
name: "testduration"
37+
});
38+
39+
tracker.setTrackUncaughtExceptions(true);
40+
tracker.trackPurchaseEvent(
41+
{
42+
id: "P12345",
43+
name: "Android Warhol T-Shirt",
44+
category: "Apparel/T-Shirts",
45+
brand: "Apple",
46+
variant: "Black",
47+
price: 29.2,
48+
quantity: 1,
49+
couponCode: "APPARELSALE"
50+
},
51+
{
52+
id: "T12345",
53+
affiliation: "Apple Store - Online",
54+
revenue: 37.39,
55+
tax: 2.85,
56+
shipping: 5.34,
57+
couponCode: "SUMMER2013"
58+
}
59+
);
60+
61+
tracker.trackMultiProductsPurchaseEvent(
62+
[
63+
{
64+
id: "2224711",
65+
name: "Top Ilem",
66+
category: "Women/Kleidung/Tops/Spitzentops",
67+
brand: "THE label",
68+
variant: "rot",
69+
price: 39.9,
70+
quantity: 1
71+
},
72+
{
73+
id: "2224706",
74+
name: "Shorts Isto",
75+
category: "Women/Kleidung/Hosen/Shirts",
76+
brand: "THE label",
77+
variant: "grau",
78+
price: 59.9,
79+
quantity: 1
80+
}
81+
],
82+
{
83+
id: "T12345",
84+
affiliation: "THE label Shop",
85+
revenue: 83.87,
86+
tax: 15.93,
87+
shipping: 0.0,
88+
couponCode: "SUMMER2016"
89+
}
90+
);
91+
92+
tracker.trackException("This is an error message", false);
93+
94+
tracker.trackSocialInteraction("Twitter", "Post");
95+
96+
tracker.setUser("12345678");
97+
98+
tracker.allowIDFA(true);
99+
100+
tracker.setAnonymizeIp(true);
101+
102+
tracker.trackScreenView("Hello");
103+
104+
/*GoogleTagManager.openContainerWithId("GT-NZT48")
105+
.then(() => {
106+
return GoogleTagManager.stringForKey("pack");
107+
})
108+
.then(str => {
109+
console.log("Str: ", str);
110+
return GoogleTagManager.boolForKey("wat");
111+
})
112+
.then(wat => {
113+
console.log("Wat: ", wat);
114+
return GoogleTagManager.doubleForKey("orly");
115+
})
116+
.then(orly => {
117+
console.log("Orly: ", orly);
118+
})
119+
.catch(err => {
120+
console.log(err);
121+
});*/
122+
123+
return (
124+
<View style={styles.container}>
125+
<Text style={styles.welcome}>
126+
Welcome to React Native Google Analytics Bridge!
127+
</Text>
128+
</View>
129+
);
130+
}
131+
}
132+
133+
const styles = StyleSheet.create({
134+
container: {
135+
flex: 1,
136+
justifyContent: "center",
137+
alignItems: "center",
138+
backgroundColor: "#F5FCFF"
139+
},
140+
welcome: {
141+
fontSize: 20,
142+
textAlign: "center",
143+
margin: 10
144+
}
145+
});
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import 'react-native';
22
import React from 'react';
3-
import Index from '../index.ios.js';
3+
import App from '../App';
44

55
// Note: test renderer must be required after react-native.
66
import renderer from 'react-test-renderer';
77

88
it('renders correctly', () => {
99
const tree = renderer.create(
10-
<Index />
10+
<App />
1111
);
1212
});

example/__tests__/index.android.js

-12
This file was deleted.

example/android/app/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ import com.android.build.OutputFile
7272
* ]
7373
*/
7474

75+
project.ext.react = [
76+
entryFile: "index.js"
77+
]
78+
7579
apply from: "../../node_modules/react-native/react.gradle"
7680

7781
/**

example/android/app/src/main/java/com/example/MainApplication.java

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ protected List<ReactPackage> getPackages() {
2727
new GoogleAnalyticsBridgePackage()
2828
);
2929
}
30+
31+
@Override
32+
protected String getJSMainModuleName() {
33+
return "index";
34+
}
3035
};
3136

3237
@Override

0 commit comments

Comments
 (0)