-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 45b2578
Showing
128 changed files
with
45,880 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['universe/native', 'universe/web'], | ||
ignorePatterns: ['dist'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# VSCode | ||
.vscode/ | ||
jsconfig.json | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
# Android/IJ | ||
# | ||
.classpath | ||
.cxx | ||
.gradle | ||
.idea | ||
.project | ||
.settings | ||
local.properties | ||
android.iml | ||
|
||
# Cocoapods | ||
# | ||
example/ios/Pods | ||
|
||
# Ruby | ||
example/vendor/ | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
yarn-debug.log | ||
yarn-error.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
android/app/libs | ||
android/keystores/debug.keystore | ||
|
||
# Expo | ||
.expo/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Exclude all top-level hidden directories by convention | ||
/.*/ | ||
|
||
__mocks__ | ||
__tests__ | ||
|
||
/babel.config.js | ||
/android/src/androidTest/ | ||
/android/src/test/ | ||
/android/build/ | ||
/example/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"printWidth": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.1.0 (2023/07/04) | ||
|
||
- Initial version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) PMU | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# @pmu-tech/react-native-piano-analytics | ||
|
||
React Native Piano Analytics | ||
|
||
# Installation in managed Expo projects | ||
|
||
For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release. | ||
|
||
# Installation in bare React Native projects | ||
|
||
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing. | ||
|
||
### Add the package to your npm dependencies | ||
|
||
``` | ||
npm install @pmu-tech/react-native-piano-analytics | ||
``` | ||
|
||
### Configure for iOS | ||
|
||
Run `npx pod-install` after installing the npm package. | ||
|
||
# Usage | ||
|
||
You may want to give a try? Run example application in `./example`. | ||
|
||
## import react-native-piano-analytics | ||
|
||
```javascript | ||
import * as PianoAnalytics from '@pmu-tech/react-native-piano-analytics'; | ||
``` | ||
|
||
## Set a configuration (mandatory) | ||
|
||
```javascript | ||
function setConfiguration(collectionName: string, siteId: number): void | ||
``` | ||
|
||
## Set Privacy consent (mandatory) | ||
|
||
By default Piano Analytics will set **"no-consent"** mode. | ||
|
||
```javascript | ||
type PrivacyMode = 'optin' | 'exempt' | 'no-storage' | 'no-consent' | 'optout'; | ||
|
||
// SET: | ||
function privacySetMode(mode: PrivacyMode): void | ||
|
||
// GET: | ||
function privacyGetMode(): PrivacyMode | ||
``` | ||
|
||
## Set User | ||
|
||
```javascript | ||
// SET USER: | ||
function setUser(userId: string, category?: string, enableStorage?: boolean): void | ||
|
||
// REMOVE USER: | ||
function deleteUser(): void | ||
``` | ||
|
||
## Send events | ||
|
||
```javascript | ||
function sendEvent(eventName: string, params: Record<string, string>): void | ||
``` | ||
|
||
# Contributing | ||
|
||
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'maven-publish' | ||
|
||
group = 'piano.analytics' | ||
version = '0.1.0' | ||
|
||
buildscript { | ||
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle") | ||
if (expoModulesCorePlugin.exists()) { | ||
apply from: expoModulesCorePlugin | ||
applyKotlinExpoModulesCorePlugin() | ||
} | ||
|
||
// Simple helper that allows the root project to override versions declared by this library. | ||
ext.safeExtGet = { prop, fallback -> | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
} | ||
|
||
// Ensures backward compatibility | ||
ext.getKotlinVersion = { | ||
if (ext.has("kotlinVersion")) { | ||
ext.kotlinVersion() | ||
} else { | ||
ext.safeExtGet("kotlinVersion", "1.6.10") | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}") | ||
} | ||
} | ||
|
||
// Creating sources with comments | ||
task androidSourcesJar(type: Jar) { | ||
classifier = 'sources' | ||
from android.sourceSets.main.java.srcDirs | ||
} | ||
|
||
afterEvaluate { | ||
publishing { | ||
publications { | ||
release(MavenPublication) { | ||
from components.release | ||
// Add additional sourcesJar to artifacts | ||
artifact(androidSourcesJar) | ||
} | ||
} | ||
repositories { | ||
maven { | ||
url = mavenLocal().url | ||
} | ||
} | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion safeExtGet("compileSdkVersion", 31) | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_11 | ||
targetCompatibility JavaVersion.VERSION_11 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_11.majorVersion | ||
} | ||
|
||
defaultConfig { | ||
minSdkVersion safeExtGet("minSdkVersion", 21) | ||
targetSdkVersion safeExtGet("targetSdkVersion", 31) | ||
versionCode 1 | ||
versionName "0.1.0" | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation project(':expo-modules-core') | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" | ||
|
||
// https://mvnrepository.com/artifact/io.piano/analytics | ||
implementation group: 'io.piano', name: 'analytics', version: '3.2.1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<manifest package="piano.analytics"> | ||
</manifest> |
21 changes: 21 additions & 0 deletions
21
android/src/main/java/piano/analytics/RNPianoAnalyticsApplicationLifecycleListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package piano.analytics | ||
|
||
import android.content.Context | ||
import android.app.Application | ||
import expo.modules.core.interfaces.ApplicationLifecycleListener | ||
|
||
// Piano | ||
import io.piano.analytics.PianoAnalytics; | ||
import io.piano.analytics.Configuration; | ||
|
||
|
||
class RNPianoAnalyticsApplicationLifecycleListener(context: Context) : ApplicationLifecycleListener { | ||
var context = context | ||
|
||
override fun onCreate(application: Application) { | ||
super.onCreate(application) | ||
|
||
var piano = PianoAnalytics.getInstance(this.context); | ||
RNPianoAnalyticsSingleton.set(piano); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
android/src/main/java/piano/analytics/RNPianoAnalyticsModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package piano.analytics | ||
|
||
import RNPianoAnalyticsSingleton | ||
import expo.modules.kotlin.modules.Module | ||
import expo.modules.kotlin.modules.ModuleDefinition | ||
import io.piano.analytics.Event; | ||
import io.piano.analytics.Configuration; | ||
|
||
|
||
|
||
class RNPianoAnalyticsModule() : Module() { | ||
var piano = RNPianoAnalyticsSingleton.get(); | ||
// Each module class must implement the definition function. The definition consists of components | ||
// that describes the module's functionality and behavior. | ||
// See https://docs.expo.dev/modules/module-api for more details about available components. | ||
override fun definition() = ModuleDefinition { | ||
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument. | ||
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity. | ||
// The module will be accessible from `requireNativeModule('RNPianoAnalytics')` in JavaScript. | ||
Name("RNPianoAnalytics") | ||
|
||
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread. | ||
Function("sendEvent") { eventName: String, params: Map<String, String> -> | ||
piano.sendEvent(Event(eventName, params)); | ||
} | ||
|
||
Function("setUser") { id: String, category: String?, enableStorage: Boolean -> | ||
piano.setUser(id, category, enableStorage); | ||
} | ||
|
||
Function("deleteUser") { | ||
piano.deleteUser(); | ||
} | ||
|
||
Function("privacySetMode") { mode: String -> | ||
piano.privacySetMode(mode); | ||
} | ||
|
||
Function("privacyGetMode") { | ||
var result = "" | ||
piano.privacyGetMode { mode: String -> | ||
result = mode | ||
} | ||
result | ||
} | ||
|
||
Function("setConfiguration") { collectDomain: String, siteId: Int -> | ||
var config = Configuration.Builder() | ||
.withCollectDomain(collectDomain) | ||
.withSite(siteId) | ||
.build(); | ||
piano.setConfiguration(config); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
android/src/main/java/piano/analytics/RNPianoAnalyticsPackage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package piano.analytics | ||
|
||
import android.content.Context | ||
import expo.modules.core.interfaces.ApplicationLifecycleListener | ||
import expo.modules.core.interfaces.Package | ||
|
||
class RNPianoAnalyticsPackage : Package { | ||
override fun createApplicationLifecycleListeners(context: Context): List<ApplicationLifecycleListener> { | ||
return listOf(RNPianoAnalyticsApplicationLifecycleListener(context)) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
android/src/main/java/piano/analytics/RNPianoAnalyticsSingleton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import io.piano.analytics.PianoAnalytics; | ||
|
||
|
||
abstract class RNPianoAnalyticsSingleton { | ||
|
||
companion object { | ||
|
||
private lateinit var piano: PianoAnalytics | ||
|
||
fun set(pa: PianoAnalytics) { | ||
piano = pa | ||
} | ||
|
||
fun get(): PianoAnalytics { | ||
return piano | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare const _default: any; | ||
export default _default; | ||
//# sourceMappingURL=RNPianoAnalyticsModule.d.ts.map |
Oops, something went wrong.