Skip to content

Commit 6d03034

Browse files
Merge pull request #280 from THEOplayer/feature/gemius-adscript-analytics
Feature/gemius adscript analytics
2 parents db62dfa + 5d70b84 commit 6d03034

81 files changed

Lines changed: 4495 additions & 296 deletions

File tree

Some content is hidden

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

.github/workflows/pr_ios.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Run pod install & update dependencies
7070
working-directory: apps/e2e/ios
7171
run: |
72-
RCT_NEW_ARCH_ENABLED=${{ matrix.newArchEnabled }} bundle exec pod install
72+
RCT_NEW_ARCH_ENABLED=${{ matrix.newArchEnabled }} bundle exec pod update
7373
7474
- name: Start iOS simulator
7575
uses: futureware-tech/simulator-action@v4

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ the official THEOplayer React Native video player.
1515
| Content protection (DRM) | [![%40theoplayer/react-native-drm](https://img.shields.io/npm/v/%40theoplayer%2Freact-native-drm?label=%40theoplayer/react-native-drm)](https://www.npmjs.com/package/%40theoplayer%2Freact-native-drm) | [`DRM`](https://github.com/THEOplayer/react-native-connectors/tree/main/drm) |
1616
| Conviva analytics | [![%40theoplayer/react-native-analytics-conviva](https://img.shields.io/npm/v/%40theoplayer%2Freact-native-analytics-conviva?label=%40theoplayer/react-native-analytics-conviva)](https://www.npmjs.com/package/%40theoplayer%2Freact-native-analytics-conviva) | [`Conviva`](https://github.com/THEOplayer/react-native-connectors/tree/main/conviva) |
1717
| Engage | [![%40theoplayer/react-native-engage](https://img.shields.io/npm/v/%40theoplayer%2Freact-native-engage?label=%40theoplayer/react-native-engage)](https://www.npmjs.com/package/%40theoplayer%2Freact-native-engage) | [`Engage`](https://github.com/THEOplayer/react-native-connectors/tree/main/engage) |
18+
| Gemius | [![%40theoplayer/react-native-analytics-gemius](https://img.shields.io/npm/v/%40theoplayer%2Freact-native-analytics-gemius?label=%40theoplayer/react-native-analytics-gemius)](https://www.npmjs.com/package/%40theoplayer%2Freact-native-analytics-engage) | [`Gemius`](https://github.com/THEOplayer/react-native-connectors/tree/main/engage) |
1819
| Mux analytics | [![%40theoplayer/react-native-analytics-mux](https://img.shields.io/npm/v/%40theoplayer%2Freact-native-analytics-mux?label=%40theoplayer/react-native-analytics-mux)](https://www.npmjs.com/package/%40theoplayer%2Freact-native-analytics-mux) | [`Mux`](https://github.com/THEOplayer/react-native-connectors/tree/main/mux) |
1920
| Nielsen analytics | [![%40theoplayer/react-native-analytics-nielsen](https://img.shields.io/npm/v/%40theoplayer%2Freact-native-analytics-nielsen?label=%40theoplayer/react-native-analytics-nielsen)](https://www.npmjs.com/package/%40theoplayer%2Freact-native-analytics-nielsen) | [`Nielsen`](https://github.com/THEOplayer/react-native-connectors/tree/main/nielsen) |
21+
| Nielsen AdScript analytics | [![%40theoplayer/react-native-analytics-adscript](https://img.shields.io/npm/v/%40theoplayer%2Freact-native-analytics-adscript?label=%40theoplayer/react-native-analytics-adscript)](https://www.npmjs.com/package/%40theoplayer%2Freact-native-analytics-adscript) | [`AdScript`](https://github.com/THEOplayer/react-native-connectors/tree/main/adscript) |
2022
| Yospace SSAI | [![%40theoplayer/react-native-yospace](https://img.shields.io/npm/v/%40theoplayer%2Freact-native-yospace?label=%40theoplayer/react-native-yospace=)](https://www.npmjs.com/package/%40theoplayer%2Freact-native-yospace) | [`Yospace`](https://github.com/THEOplayer/react-native-connectors/tree/main/yospace) |
2123
| Youbora analytics | [![%40theoplayer/react-native-analytics-youbora](https://img.shields.io/npm/v/%40theoplayer%2Freact-native-analytics-youbora?label=%40theoplayer/react-native-analytics-youbora=)](https://www.npmjs.com/package/%40theoplayer%2Freact-native-analytics-youbora) | [`Youbora`](https://github.com/THEOplayer/react-native-connectors/tree/main/youbora) |
2224

adscript/.gitignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# XDE
6+
.expo/
7+
8+
# VSCode
9+
.vscode/
10+
jsconfig.json
11+
12+
# Xcode
13+
#
14+
build/
15+
*.pbxuser
16+
!default.pbxuser
17+
*.mode1v3
18+
!default.mode1v3
19+
*.mode2v3
20+
!default.mode2v3
21+
*.perspectivev3
22+
!default.perspectivev3
23+
xcuserdata
24+
*.xccheckout
25+
*.moved-aside
26+
DerivedData
27+
*.hmap
28+
*.ipa
29+
*.xcuserstate
30+
project.xcworkspace
31+
32+
# Android/IJ
33+
#
34+
.classpath
35+
.cxx
36+
.gradle
37+
.idea
38+
.project
39+
.settings
40+
local.properties
41+
android.iml
42+
43+
# Cocoapods
44+
#
45+
example/ios/Pods
46+
47+
# Ruby
48+
example/vendor/
49+
50+
# node.js
51+
#
52+
node_modules/
53+
npm-debug.log
54+
yarn-debug.log
55+
yarn-error.log
56+
57+
# BUCK
58+
buck-out/
59+
\.buckd/
60+
android/app/libs
61+
android/keystores/debug.keystore
62+
63+
# Expo
64+
.expo/
65+
66+
# Turborepo
67+
.turbo/
68+
69+
# generated by bob
70+
lib/

adscript/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# @theoplayer/react-native-analytics-adscript
2+
3+
## 1.0.0
4+
5+
### ✨ Features
6+
7+
- Initial release

adscript/README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# THEOplayer React-Native AdScript Connector
2+
3+
A [Nielsen AdScript](https://adscript.admosphere.cz/) analytics connector for `@theoplayer/react-native`.
4+
5+
## Installation
6+
7+
```sh
8+
npm install @theoplayer/react-native-analytics-adscript
9+
```
10+
11+
[//]: # (npm install @theoplayer/react-native-analytics-adscript)
12+
13+
## Prerequisites
14+
15+
### Android
16+
17+
On Android, the connector requires downloading the private
18+
[AdScript client library](https://adscript.admosphere.cz/download/AdScriptApiClient_v1.0.10.aar.gz)
19+
module into the app's `libs/` folder. Pass the SDK location to the connector
20+
by setting the `adScriptSdkDir` in your app's `gradle.properties` file:
21+
22+
```bash
23+
# Location of the AdScript SDK
24+
adScriptSdkDir=./app/libs/
25+
```
26+
27+
### iOS & tvOS
28+
29+
On Apple platforms, the connector requires downloading the private `AdScriptAPIClient` archive.
30+
31+
Create a `Frameworks` folder in your app's `ios` folder, copy the Adscript SDK XCFramework in it
32+
and add this `AdScriptApiClient.podspec` file inside, which describes the structure and metadata of Adscript's CocoaPod:
33+
34+
```ruby
35+
Pod::Spec.new do |spec|
36+
spec.name = "AdScriptApiClient"
37+
spec.version = "1.0.8"
38+
spec.summary = "The Adscript Api Client for iOS"
39+
40+
spec.homepage = 'https://github.com/THEOplayer/iOS-Connector'
41+
spec.license = { :type => 'MIT', :file => 'LICENSE' }
42+
spec.author = "THEO technologies"
43+
spec.source = { :git => 'https://github.com/THEOplayer/iOS-Connector.git', :tag => spec.version.to_s }
44+
45+
spec.source_files = "Classes", "Classes/**/*.{h,m}"
46+
spec.ios.vendored_frameworks = "AdScriptApiClient.xcframework"
47+
end
48+
```
49+
50+
To enable IDFA (Identifier for Advertisers), replace the framework reference:
51+
52+
```
53+
spec.ios.vendored_frameworks = "AdScriptApiClient.xcframework"
54+
```
55+
56+
with
57+
58+
```
59+
spec.ios.vendored_frameworks = "AdScriptApiClient_withidfa.xcframework"
60+
```
61+
62+
Finally, include the AdScript SDK as dependency in your app's `Podfile`:
63+
64+
```ruby
65+
pod 'AdScriptApiClient', :path => 'Frameworks/'
66+
```
67+
68+
## Usage
69+
70+
### Configuring the connector
71+
72+
Create the connector by providing the `THEOplayer` instance, an `implementationId`, and a `metadata` object.
73+
74+
```tsx
75+
import { useAdScript, AdScriptMetadata } from '@theoplayer/react-native-analytics-adscript';
76+
77+
const adscriptImplementationId = "myImplementionId";
78+
const adscriptContentMetadata: AdScriptMetadata = {
79+
assetId: "abc98731568435405",
80+
type: "content"
81+
};
82+
83+
const App = () => {
84+
const [adscript, initAdScript] = useAdScript(adscriptImplementationId, adscriptContentMetadata, true /*debug*/);
85+
86+
const onPlayerReady = (player: THEOplayer) => {
87+
// Initialize AdScript connector
88+
initAdScript(player);
89+
};
90+
91+
return <THEOplayerView config={playerConfig} onPlayerReady={onPlayerReady} />;
92+
};
93+
```
94+
95+
### Passing metadata dynamically
96+
97+
The connector allows passing or updating the current asset's metadata at any time:
98+
99+
```typescript
100+
const onUpdateMetadata = () => {
101+
adscript.current?.updateMetadata({
102+
assetId: 'updatedId',
103+
type: "content",
104+
// ...
105+
});
106+
}
107+
```
108+
109+
### Passing additional information
110+
111+
Additional information about the logged-in user from the client database:
112+
113+
```typescript
114+
const onUpdateUser = () => {
115+
adscript.current?.updateUser([
116+
"866d3a3c-aa87-4fe7-9066-8286641edd17", // client-side user identifier (customerId)
117+
"cf895a00-a987-4501-ac00-6adb57014129", // client-side user device identifier (Android_ID)
118+
"9530321a-d3d0-4bda-8704-1eb94a5940c3", // client-side profile identifier of the logged-in user (profileId)
119+
"jsg75682-k276t-kw82-k8d5-8926sh6528j2", // optional - SW device identifier for a situation where there are multiple device IDs in the client DB (typically a) HW ID - fill in i2, b) SW ID - fill in i4).
120+
"ef3c6dc72a26912f07f0e733d51b46c771d807bf" // fingerprint of the user's email address
121+
]);
122+
}
123+
```

adscript/android/build.gradle

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import java.util.zip.GZIPInputStream
2+
3+
buildscript {
4+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
5+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : '1.9.10'
6+
7+
repositories {
8+
google()
9+
mavenCentral()
10+
}
11+
12+
dependencies {
13+
classpath "com.android.tools.build:gradle:7.2.2"
14+
// noinspection DifferentKotlinGradleVersion
15+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16+
}
17+
}
18+
19+
def isNewArchitectureEnabled() {
20+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
21+
}
22+
23+
apply plugin: 'com.android.library'
24+
apply plugin: 'kotlin-android'
25+
26+
if (isNewArchitectureEnabled()) {
27+
apply plugin: "com.facebook.react"
28+
}
29+
30+
def safeExtGet(prop, fallback) {
31+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
32+
}
33+
34+
android {
35+
namespace = "com.theoplayer.reactnative.adscript"
36+
compileSdkVersion safeExtGet("THEOplayerAdScript_compileSdkVersion", 35)
37+
38+
defaultConfig {
39+
minSdkVersion safeExtGet("THEOplayerAdScript_minSdkVersion", 21)
40+
targetSdkVersion safeExtGet("THEOplayerAdScript_targetSdkVersion", 35)
41+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
42+
versionCode 1
43+
versionName "1.0"
44+
}
45+
46+
buildTypes {
47+
release {
48+
minifyEnabled false
49+
}
50+
}
51+
52+
lintOptions {
53+
disable "GradleCompatible"
54+
}
55+
56+
compileOptions {
57+
sourceCompatibility JavaVersion.VERSION_1_8
58+
targetCompatibility JavaVersion.VERSION_1_8
59+
}
60+
}
61+
62+
repositories {
63+
mavenLocal()
64+
google()
65+
mavenCentral()
66+
// Local Maven repo
67+
maven { url("local") }
68+
maven { url "https://maven.theoplayer.com/releases" }
69+
}
70+
71+
rootProject.allprojects {
72+
repositories {
73+
maven { url("$rootDir/../node_modules/@theoplayer/react-native-analytics-adscript/android/local") }
74+
}
75+
}
76+
77+
// The AdScript connector requires at least THEOplayer SDK v5.11.0.
78+
def theoplayer_sdk_version = safeExtGet('THEOplayer_sdk', '[5.11.0, 10.0.0)')
79+
def kotlin_version = safeExtGet("THEOplayerAdScript_kotlinVersion", "1.9.10")
80+
def adscript_version = safeExtGet("THEOplayerAdScript_adscriptVersion", "1.0.10")
81+
82+
dependencies {
83+
// For < 0.71, this will be from the local maven repo
84+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
85+
//noinspection GradleDynamicVersion
86+
implementation "com.facebook.react:react-native"
87+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
88+
implementation 'androidx.lifecycle:lifecycle-process:2.5.1'
89+
90+
// THEOplayer dependencies
91+
compileOnly "com.theoplayer.theoplayer-sdk-android:core:$theoplayer_sdk_version"
92+
compileOnly "com.theoplayer.theoplayer-sdk-android:integration-ads-ima:$theoplayer_sdk_version"
93+
implementation project(':react-native-theoplayer')
94+
95+
// TEMP: replace this once the native connector has been published
96+
// implementation "com.theoplayer.android-connector:adscript:$adscript_version"
97+
implementation files("./libs/adscript.aar")
98+
def aarFileName = "AdScriptApiClient_v${adscript_version}.aar"
99+
def adScriptSdkDir = rootProject.properties['adScriptSdkDir']
100+
if (!adScriptSdkDir) {
101+
logger.warn("⚠️ WARNING: adScriptSdkDir not set.")
102+
} else if (!rootProject.file(adScriptSdkDir).exists()) {
103+
logger.warn("⚠️ WARNING: adScriptSdkDir does not exist at: ${adScriptSdkDir}")
104+
} else {
105+
def aarFile = new File(adScriptSdkDir, aarFileName)
106+
107+
// The AdScript aar file is typically provided as .gz, check if we still need to extract.
108+
def gzFile = new File("${aarFile}.gz")
109+
if (!aarFile.exists() && gzFile.exists()) {
110+
new FileInputStream(gzFile).withCloseable { fis ->
111+
new GZIPInputStream(fis).withCloseable { gis ->
112+
new FileOutputStream(aarFile).withCloseable { fos ->
113+
fos << gis
114+
}
115+
}
116+
}
117+
}
118+
dependencies {
119+
implementation fileTree(dir: "${rootProject.file(adScriptSdkDir)}/$aarFileName", include: ['*.aar', '*.jar'], exclude: [])
120+
}
121+
}
122+
123+
// Align the Kotlin SDK libraries with the same version.
124+
implementation(platform("org.jetbrains.kotlin:kotlin-bom:$kotlin_version"))
125+
}
58.4 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)