Skip to content

Commit

Permalink
Merge pull request #6 from tenjin/dg/release-1.0.5
Browse files Browse the repository at this point in the history
Release 1.0.5
  • Loading branch information
giraldogdiego authored May 17, 2023
2 parents 2c4c2c7 + 4c9a52b commit bcf3f30
Show file tree
Hide file tree
Showing 39 changed files with 484 additions and 254 deletions.
70 changes: 57 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# React Native Tenjin Plugin

# Summary
Tenjin's SDK allows users to track events and installs in their apps. To learn more about Tenjin and our product offering, please visit https://www.tenjin.com.

The Tenjin React Native Plugin allows users to track events and installs in their iOS/Android apps. To learn more about Tenjin and our product offering, please visit https://www.tenjin.com.

### Notes:

Expand Down Expand Up @@ -101,31 +102,74 @@ Parameters:
- `name`: String
- `value`: String

### Get attribution info
```javascript
Tenjin.getAttributionInfo(
(success) => {
console.log(`Attibution info found! ${success}`);
},
() => {
console.error(`Attribution info failed`);
}
)
```
Parameters:
- `successCallback`: Callback
- `errorCallback`: Callback

### Append app subversion
```javascript
Tenjin.appendAppSubversion(subversion)
```
Parameters:
- `subversion`: Number

### <a id="ilrd"></a>Impression Level Ad Revenue Integration
### Customer User ID
```javascript
Tenjin.setCustomerUserId(userId)
```
Parameters:
- `userId`: string

Tenjin supports the ability to integrate with the Impression Level Ad Revenue (ILRD) feature from,
- AppLovin
- IronSource
- HyperBid
- AdMob
- TopOn
```javascript
Tenjin.getCustomerUserId()
```
Returns: callback -> `string`

This feature allows you to receive events which correspond to your ad revenue that is affected by each advertisement show to a user. To enable this feature, follow the below instructions.
### Send AdMob impression (ILRD)
```javascript
Tenjin.eventAdImpressionAdMob(json)
```
Parameters:
- `json`: JSON

:warning: **NOTE: ILRD is a paid feature, so please contact your Tenjin account manager to discuss the price at first before sending ILRD events.**
### Send AppLovin impression (ILRD)
```javascript
Tenjin.eventAdImpressionAppLovin(json)
```
Parameters:
- `json`: JSON

### <a id="attributionInfo"></a>Attribution Info
### Send HyperBid impression (ILRD)
```javascript
Tenjin.eventAdImpressionHyperBid(json)
```
Parameters:
- `json`: JSON

Tenjin supports retrieving of attributes, which are required for developers to get analytics installation id (previously known as tenjin reference id). This parameter can be used when there is no advertising id.
### Send IronSource impression (ILRD)
```javascript
Tenjin.eventAdImpressionIronSource(json)
```
Parameters:
- `json`: JSON

:warning: **NOTE: Attribution Info is a paid feature, so please contact your Tenjin account manager if you are interested in.**
### Send TopOn impression (ILRD)
```javascript
Tenjin.eventAdImpressionTopOn(json)
```
Parameters:
- `json`: JSON

## Support
If you have any issues with the plugin integration or usage, please contact us to [email protected]
153 changes: 46 additions & 107 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,139 +1,78 @@
buildscript {
repositories {
google()
mavenCentral()
}
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
}
dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
}
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: 'com.android.library'
apply plugin: "com.android.library"


def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }

if (isNewArchitectureEnabled()) {
apply plugin: 'com.facebook.react'
apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['TenjinSdk_' + name]
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Tenjin_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['TenjinSdk_' + name]).toInteger()
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Tenjin_" + name]).toInteger()
}

android {
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')

defaultConfig {
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}
buildTypes {
release {
minifyEnabled false
}
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}
buildTypes {
release {
minifyEnabled false
}
}

lintOptions {
disable 'GradleCompatible'
}
lintOptions {
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

repositories {
mavenCentral()
google()

def found = false
def defaultDir = null
def androidSourcesName = 'React Native sources'

if (rootProject.ext.has('reactNativeAndroidRoot')) {
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
} else {
defaultDir = new File(
projectDir,
'/../../../node_modules/react-native/android'
)
}

if (defaultDir.exists()) {
maven {
url defaultDir.toString()
name androidSourcesName
}

logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
found = true
} else {
def parentDir = rootProject.projectDir

1.upto(5, {
if (found) return true
parentDir = parentDir.parentFile

def androidSourcesDir = new File(
parentDir,
'node_modules/react-native'
)

def androidPrebuiltBinaryDir = new File(
parentDir,
'node_modules/react-native/android'
)

if (androidPrebuiltBinaryDir.exists()) {
maven {
url androidPrebuiltBinaryDir.toString()
name androidSourcesName
}

logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
found = true
} else if (androidSourcesDir.exists()) {
maven {
url androidSourcesDir.toString()
name androidSourcesName
}

logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
found = true
}
})
}

if (!found) {
throw new GradleException(
"${project.name}: unable to locate React Native android sources. " +
"Ensure you have you installed React Native as a dependency in your project and try again."
)
}
mavenCentral()
google()
}


dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation files('libs/tenjin.aar')
// From node_modules
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation 'com.tenjin:android-sdk:1.12.20'
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "Tenjin"
codegenJavaPackageName = "com.reactnativetenjinsdk"
}
react {
jsRootDir = file("../src/")
libraryName = "Tenjin"
codegenJavaPackageName = "com.tenjin"
}
}
5 changes: 5 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Tenjin_kotlinVersion=1.7.0
Tenjin_minSdkVersion=21
Tenjin_targetSdkVersion=31
Tenjin_compileSdkVersion=31
Tenjin_ndkversion=21.4.7075529
Binary file removed android/libs/.DS_Store
Binary file not shown.
Binary file removed android/libs/tenjin.aar
Binary file not shown.
Binary file modified android/src/main/.DS_Store
Binary file not shown.
4 changes: 1 addition & 3 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<!-- AndroidManifest.xml -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.reactlibrary">
package="com.tenjin">

</manifest>
Binary file modified android/src/main/java/.DS_Store
Binary file not shown.
Binary file modified android/src/main/java/com/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// TenjinModule.java

package com.reactlibrary;
package com.tenjin;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Expand Down Expand Up @@ -161,6 +161,16 @@ public void eventAdImpressionTopOn(ReadableMap json) {
}
}

@ReactMethod
public void setCustomerUserId(String userId) {
instance.setCustomerUserId(userId);
}

@ReactMethod
public void getCustomerUserId(com.facebook.react.bridge.Callback callback) {
callback.invoke(instance.getCustomerUserId());
}

private String[] readableToArray(ReadableArray readableArray) {
String[] array = new String[readableArray.size()];
for (int i = 0; i < readableArray.size(); i++) {
Expand Down Expand Up @@ -276,4 +286,4 @@ public WritableArray convertJsonToArray(JSONArray jsonArray) throws JSONExceptio
}
return array;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// TenjinPackage.java

package com.reactlibrary;
package com.tenjin;

import java.util.Arrays;
import java.util.Collections;
Expand Down
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
7 changes: 0 additions & 7 deletions index.js

This file was deleted.

Binary file modified ios/.DS_Store
Binary file not shown.
7 changes: 6 additions & 1 deletion ios/Tenjin.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// Tenjin.h

#ifdef RCT_NEW_ARCH_ENABLED
#import "RNTenjinSpec.h"

@interface Tenjin : NSObject <NativeTenjinSpec>
#else
#import <React/RCTBridgeModule.h>

@interface Tenjin : NSObject <RCTBridgeModule>
#endif

@end
Loading

0 comments on commit bcf3f30

Please sign in to comment.