Skip to content

Commit 8cfb759

Browse files
committed
chore(refactor-release): release v2.0.0 🚀
1 parent e13303d commit 8cfb759

File tree

83 files changed

+10891
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+10891
-348
lines changed

README.md

Lines changed: 71 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,90 @@
1+
# SatisMeter React Native (react-native-satismeter)
12

2-
# react-native-satismeter
33

4+
<p align="center">
5+
<!-- START social-badges -->
6+
<a href="https://github.com/React-Native-Nation/react-native-satismeter/watchers"><img src="https://img.shields.io/github/watchers/React-Native-Nation/react-native-satismeter.svg?style=social" alt="Watch on GitHub" /></a>
7+
<a href="https://github.com/React-Native-Nation/react-native-satismeter/stargazers"><img src="https://img.shields.io/github/stars/React-Native-Nation/react-native-satismeter.svg?style=social" alt="Star on GitHub" /></a>
8+
<a href="https://twitter.com/intent/tweet?text=Satismeter React Native Support! https://github.com/React-Native-Nation/react-native-satismeter"><img src="https://img.shields.io/twitter/url/https/github.com/React-Native-Nation/react-native-satismeter.svg?style=social" alt="Tweet!" /></a>
9+
<!-- END social-badges -->
10+
</p>
411

5-
## Getting started
12+
<p align="center">
13+
<!-- START description -->
14+
From ReactNativeNation.com Community
15+
<!-- END description -->
16+
</p>
617

7-
`$ npm install react-native-satismeter --save`
18+
<p align="center">
19+
<!-- START status-badges -->
20+
<a href="http://makeapullrequest.com"><img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs Welcome" /></a>
21+
<a href="#contributors"><img src="https://img.shields.io/badge/all_contributors-7-blue.svg?style=flat-square" alt="All Contributors" /></a>
22+
<a href="https://travis-ci.org/React-Native-Nation/react-native-satismeter"><img src="https://img.shields.io/travis/React-Native-Nation/react-native-satismeter.svg?style=flat-square" alt="Build Status" /></a>
23+
<a href="https://codecov.io/github/React-Native-Nation/react-native-satismeter"><img src="https://img.shields.io/codecov/c/github/React-Native-Nation/react-native-satismeter.svg?style=flat-square" alt="Code Coverage" /></a>
24+
<a href="https://greenkeeper.io"><img src="https://badges.greenkeeper.io/React-Native-Nation/react-native-satismeter.svg?style=flat-square" alt="Greenkeeper" /></a>
25+
<!-- END status-badges -->
26+
</p>
827

9-
### Mostly automatic installation
28+
<p align="center">
29+
<!-- START npm-badges -->
30+
<a href="https://npmjs.com/package/react-native-satismeter"><img src="https://img.shields.io/npm/v/react-native-satismeter.svg?label=react-native-satismeter&style=flat-square" alt="react-native-satismeter"></a>
31+
<!-- END npm-badges -->
32+
</p>
1033

11-
`$ react-native link react-native-satismeter`
1234

13-
### Remember to link iOS bundle
14-
Link the bundle iOS file by adding it in the copy bundle section, search
15-
node_modules/react-native-satismeter/ios/*.bundle and add it.
35+
SatisMeter is mobile and web platform for collecting customer feedback, based on Net Promoter Score.
1636

17-
### Manual installation
37+
This package contains a survey widget that can be easily integrated into any **React Native** application.
1838

39+
## Installation, It's Mostly automatic installation
1940

20-
#### iOS
41+
`$ yarn add react-native-satismeter`
2142

22-
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
23-
2. Go to `node_modules``react-native-satismeter` and add `RNSatismeter.xcodeproj`
24-
3. In XCode, in the project navigator, select your project. Add `libRNSatismeter.a` to your project's `Build Phases``Link Binary With Libraries`
25-
4. Run your project (`Cmd+R`)<
43+
## Usage
2644

27-
#### Android
45+
### Registration
2846

29-
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
30-
- Add `import com.jamesjara.rnsatismeter.RNSatismeterPackage;` to the imports at the top of the file
31-
- Add `new RNSatismeterPackage()` to the list returned by the `getPackages()` method
32-
2. Append the following lines to `android/settings.gradle`:
33-
```
34-
include ':react-native-satismeter'
35-
project(':react-native-satismeter').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-satismeter/android')
36-
```
37-
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
38-
```
39-
compile project(':react-native-satismeter')
40-
```
47+
First of all you should create your account in https://satismeter.com
48+
49+
### Identify user
50+
51+
Add the following code to your RN application.
4152

4253

43-
## Usage
4454
```javascript
45-
import RNSatismeter from 'react-native-satismeter';
55+
import Satismeter from 'react-native-satismeter';
56+
57+
Satismeter.hook('<USER_ID>', '<WRITE_KEY>', '', (message) => {
58+
this.setState({
59+
status: 'Hi Satismeter',
60+
});
61+
});
62+
```
63+
64+
Replace the `WRITE_KEY` with the one found in SatisMeter settings / Integrations / API Keys.
65+
66+
Replace `USER_ID` with the ones of the currently logged-in user.
67+
68+
69+
## Contributors
70+
71+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
72+
<!-- prettier-ignore -->
73+
<table>
74+
<tr>
75+
<td align="center"><a href="https://jamesjara.me"><img src="https://avatars2.githubusercontent.com/u/780219?v=4" width="100px;" alt="James Jara"/><br /><sub><b>James Jara</b></sub></a><br /><a href="#infra-jamesjara" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/React-Native-Nation/react-native-satismeter/commits?author=jamesjara" title="Code">💻</a> <a href="https://github.com/React-Native-Nation/react-native-satismeter/commits?author=jamesjara" title="Tests">⚠️</a> <a href="https://github.com/React-Native-Nation/react-native-satismeter/commits?author=jamesjara" title="Documentation">📖</a></td>
76+
</tr>
77+
</table>
78+
79+
## Contributing
80+
81+
<!-- START contributing -->
82+
83+
If you have any question, suggestion or recommendation, please [open an issue](issues/new) about it.
84+
85+
If you decided you want to introduce something to the project, please read [contribution guidelines](./docs/contributing.md) first.
4686

47-
RNSatismeter.setKey("your-api-key")
48-
RNSatismeter.setUserId("your-user-id")
49-
RNSatismeter.setUserTraits({
50-
date: "01-01-1990",
51-
color: "red",
52-
foo: "bar"
53-
})
5487

55-
// Bool to force the survey
56-
RNSatismeter.run(false)
88+
## License
5789

58-
```
90+
react-native-satismeter is available under the MIT license. See the LICENSE file for more info.

android/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
README
2+
======
3+
4+
If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
5+
6+
1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
7+
2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
8+
```
9+
ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
10+
sdk.dir=/Users/{username}/Library/Android/sdk
11+
```
12+
3. Delete the `maven` folder
13+
4. Run `./gradlew installArchives`
14+
5. Verify that latest set of generated files is in the maven folder with the correct version number

android/build.gradle

Lines changed: 128 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,52 @@
1+
// android/build.gradle
12

2-
buildscript {
3-
repositories {
4-
jcenter()
5-
}
3+
// based on:
4+
//
5+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
6+
// original location:
7+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
8+
//
9+
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
10+
// original location:
11+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
12+
13+
def DEFAULT_COMPILE_SDK_VERSION = 28
14+
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
15+
def DEFAULT_MIN_SDK_VERSION = 16
16+
def DEFAULT_TARGET_SDK_VERSION = 28
17+
18+
def safeExtGet(prop, fallback) {
19+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
20+
}
21+
22+
apply plugin: 'com.android.library'
23+
apply plugin: 'maven'
624

7-
dependencies {
8-
classpath 'com.android.tools.build:gradle:1.3.1'
25+
buildscript {
26+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
27+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
28+
// module dependency in an application project.
29+
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
30+
if (project == rootProject) {
31+
repositories {
32+
google()
33+
jcenter()
34+
}
35+
dependencies {
36+
classpath 'com.android.tools.build:gradle:3.4.1'
37+
}
938
}
1039
}
1140

1241
apply plugin: 'com.android.library'
42+
apply plugin: 'maven'
1343

1444
android {
15-
compileSdkVersion 23
16-
buildToolsVersion "23.0.1"
17-
45+
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
46+
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
1847
defaultConfig {
19-
minSdkVersion 16
20-
targetSdkVersion 22
48+
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
49+
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
2150
versionCode 1
2251
versionName "1.0"
2352
}
@@ -27,11 +56,95 @@ android {
2756
}
2857

2958
repositories {
30-
mavenCentral()
59+
// ref: https://www.baeldung.com/maven-local-repository
60+
mavenLocal()
61+
maven {
62+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
63+
url "$rootDir/../node_modules/react-native/android"
64+
}
65+
maven {
66+
// Android JSC is installed from npm
67+
url "$rootDir/../node_modules/jsc-android/dist"
68+
}
69+
google()
70+
jcenter()
3171
}
3272

3373
dependencies {
34-
compile 'com.satismeter:SatisMeter:1.1.3'
35-
compile 'com.facebook.react:react-native:+'
74+
//noinspection GradleDynamicVersion
75+
implementation 'com.facebook.react:react-native:+' // From node_modules
76+
compile 'com.satismeter:SatisMeter:1.2.0'
77+
}
78+
79+
def configureReactNativePom(def pom) {
80+
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
81+
82+
pom.project {
83+
name packageJson.title
84+
artifactId packageJson.name
85+
version = packageJson.version
86+
group = "com.jamesjara.reactnativenation"
87+
description packageJson.description
88+
url packageJson.repository.baseUrl
89+
90+
licenses {
91+
license {
92+
name packageJson.license
93+
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
94+
distribution 'repo'
95+
}
96+
}
97+
98+
developers {
99+
developer {
100+
id packageJson.author.username
101+
name packageJson.author.name
102+
}
103+
}
104+
}
105+
}
106+
107+
afterEvaluate { project ->
108+
// some Gradle build hooks ref:
109+
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
110+
task androidJavadoc(type: Javadoc) {
111+
source = android.sourceSets.main.java.srcDirs
112+
classpath += files(android.bootClasspath)
113+
classpath += files(project.getConfigurations().getByName('compile').asList())
114+
include '**/*.java'
115+
}
116+
117+
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
118+
classifier = 'javadoc'
119+
from androidJavadoc.destinationDir
120+
}
121+
122+
task androidSourcesJar(type: Jar) {
123+
classifier = 'sources'
124+
from android.sourceSets.main.java.srcDirs
125+
include '**/*.java'
126+
}
127+
128+
android.libraryVariants.all { variant ->
129+
def name = variant.name.capitalize()
130+
def javaCompileTask = variant.javaCompileProvider.get()
131+
132+
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
133+
from javaCompileTask.destinationDir
134+
}
135+
}
136+
137+
artifacts {
138+
archives androidSourcesJar
139+
archives androidJavadocJar
140+
}
141+
142+
task installArchives(type: Upload) {
143+
configuration = configurations.archives
144+
repositories.mavenDeployer {
145+
// Deploy to react-native-event-bridge/maven, ready to publish to npm
146+
repository url: "file://${projectDir}/../android/maven"
147+
configureReactNativePom pom
148+
}
149+
}
36150
}
37-

android/src/main/AndroidManifest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
21
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.jamesjara.rnsatismeter">
2+
package="com.jamesjara.reactnativenation">
43

54
</manifest>
6-
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.jamesjara.reactnativenation;
2+
3+
import android.app.Activity;
4+
5+
import com.facebook.react.bridge.Callback;
6+
import com.facebook.react.bridge.ReactApplicationContext;
7+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
8+
import com.facebook.react.bridge.ReactMethod;
9+
import com.facebook.react.bridge.Callback;
10+
import com.facebook.react.bridge.ReadableMap;
11+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
12+
import com.facebook.react.bridge.ReadableType;
13+
import com.satismeter.SatisMeter;
14+
15+
import java.util.HashMap;
16+
17+
public class SatismeterModule extends ReactContextBaseJavaModule {
18+
19+
private final ReactApplicationContext reactContext;
20+
21+
public SatismeterModule(ReactApplicationContext reactContext) {
22+
super(reactContext);
23+
this.reactContext = reactContext;
24+
}
25+
26+
@Override
27+
public String getName() {
28+
return "Satismeter";
29+
}
30+
31+
@ReactMethod
32+
public void hook(String userId, String writeKey, String next, Callback callback){
33+
final Activity activity = getCurrentActivity();
34+
callback.invoke("Received userId: " + userId + " writeKey: " + writeKey);
35+
HashMap<String, Object> trait = new HashMap();
36+
/*
37+
if(traits!=null) {
38+
HashMap<String, Object> trait = new HashMap();
39+
ReadableMapKeySetIterator iterator = traits.keySetIterator();
40+
while (iterator.hasNextKey()) {
41+
String key = iterator.nextKey();
42+
ReadableType type = traits.getType(key);
43+
if (type == ReadableType.String) {
44+
trait.put((String) key, (String) traits.getString(key));
45+
}
46+
}
47+
}
48+
*/
49+
SatisMeter.identify(activity, writeKey, userId, trait);
50+
}
51+
}

0 commit comments

Comments
 (0)