Skip to content

Commit 1a73544

Browse files
Merge pull request #364 from THEOplayer/bugfix/adobe-edge/bitrate-change
Bugfix/adobe edge/bitrate change
2 parents 4c5d381 + 6bd2f26 commit 1a73544

25 files changed

Lines changed: 9409 additions & 3608 deletions

File tree

.changeset/khaki-maps-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@theoplayer/react-native-analytics-adobe-edge': patch
3+
---
4+
5+
Fixed an issue on Web where the `bitRate` property would not be passed as an integer value.

.changeset/sixty-beds-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@theoplayer/react-native-analytics-adobe-edge': patch
3+
---
4+
5+
Fixed an issue where the metadata set with `updateMetadata` would not be passed when starting a session.

.github/workflows/pr_android.yml

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@ on:
44
pull_request:
55
types: [opened, reopened, synchronize]
66

7+
# Cancel in-progress runs on the same PR to avoid wasting runner minutes.
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
NDK_VERSION: 29.0.14033849
14+
715
jobs:
816
build:
917
runs-on: ubuntu-latest
1018
strategy:
19+
fail-fast: false
1120
matrix:
1221
api-level: [ 34 ]
1322
newArchEnabled: [ true ]
14-
name: Build for API Level ${{ matrix.api-level }} using ${{matrix.newArchEnabled == true && 'New' || 'Old' }} Architecture
23+
name: Build for API Level ${{ matrix.api-level }} using ${{matrix.newArchEnabled == true && 'New' || 'Old' }} Architecture
1524
steps:
1625
- name: Checkout repository
1726
uses: actions/checkout@v4
@@ -21,7 +30,9 @@ jobs:
2130
with:
2231
java-version: 17
2332
distribution: adopt
24-
cache: gradle
33+
34+
- name: Setup Gradle
35+
uses: gradle/actions/setup-gradle@v4
2536

2637
- name: Validate Gradle wrapper
2738
uses: gradle/actions/wrapper-validation@v4
@@ -33,9 +44,7 @@ jobs:
3344
cache: 'npm'
3445

3546
- name: Run npm install
36-
run: |
37-
npm i -g corepack
38-
npm ci --workspaces --include-workspace-root
47+
run: npm ci --workspaces --include-workspace-root
3948

4049
- name: Build workspaces
4150
run: npm run build
@@ -44,20 +53,15 @@ jobs:
4453
run: npm test
4554

4655
- name: Install & update e2e app with latest react-native-theoplayer
47-
run: |
48-
cd apps/e2e
49-
npm update react-native-theoplayer
50-
npm ci
56+
working-directory: apps/e2e
57+
run: npm install react-native-theoplayer@latest
5158

5259
- name: Enable KVM
5360
run: |
5461
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
5562
sudo udevadm control --reload-rules
5663
sudo udevadm trigger --name-match=kvm
5764
58-
- name: Gradle cache
59-
uses: gradle/actions/setup-gradle@v3
60-
6165
- name: AVD cache
6266
uses: actions/cache@v4
6367
id: avd-cache
@@ -68,7 +72,7 @@ jobs:
6872
key: avd-${{ matrix.api-level }}
6973

7074
- name: Create AVD and generate snapshot for caching
71-
if: steps.avd-cache.outputs.cache-hit != 'true' #check previous step output
75+
if: steps.avd-cache.outputs.cache-hit != 'true'
7276
uses: reactivecircus/android-emulator-runner@v2
7377
with:
7478
api-level: ${{ matrix.api-level }}
@@ -81,18 +85,25 @@ jobs:
8185
disable-animations: true
8286
script: echo "Generated AVD snapshot for caching."
8387

84-
- name: Modify gradle.properties with repository secrets
88+
- name: Cache NDK
89+
uses: actions/cache@v4
90+
id: ndk-cache
91+
with:
92+
path: /usr/local/lib/android/sdk/ndk/${{ env.NDK_VERSION }}
93+
key: ndk-${{ env.NDK_VERSION }}
94+
95+
- name: Install NDK
96+
if: steps.ndk-cache.outputs.cache-hit != 'true'
97+
run: echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "ndk;${{ env.NDK_VERSION }}"
98+
99+
- name: Configure gradle.properties
85100
working-directory: apps/e2e/android
86101
run: |
87102
echo "YOSPACE_USERNAME=${{ secrets.YOSPACE_USERNAME }}" >> ./gradle.properties
88103
echo "YOSPACE_PASSWORD=${{ secrets.YOSPACE_PASSWORD }}" >> ./gradle.properties
89-
90-
- name: Modify gradle.properties for newArchEnabled
91-
working-directory: apps/e2e/android
92-
run: |
93-
# Modify or add the newArchEnabled property in gradle.properties
94-
echo "newArchEnabled=${{ matrix.newArchEnabled }}" >> ./gradle.properties
95-
cat ./gradle.properties
104+
echo "newArchEnabled=${{ matrix.newArchEnabled }}" >> ./gradle.properties
105+
# Only build the x86_64 ABI needed by the CI emulator.
106+
echo "reactNativeArchitectures=x86_64" >> ./gradle.properties
96107
97108
- name: Run e2e tests
98109
uses: reactivecircus/android-emulator-runner@v2
@@ -102,10 +113,17 @@ jobs:
102113
arch: x86_64
103114
cores: 2
104115
ram-size: 3072M
105-
force-avd-creation: true
116+
force-avd-creation: false
106117
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
107118
disable-animations: true
108-
script: |
109-
npm run test:e2e:android
110-
cat cavy_results.md >> $GITHUB_STEP_SUMMARY
119+
script: npm run test:e2e:android
111120
working-directory: apps/e2e
121+
122+
- name: Summarize results
123+
working-directory: apps/e2e
124+
if: always()
125+
run: |
126+
if [ -f cavy_results.md ]; then
127+
cat cavy_results.md >> $GITHUB_STEP_SUMMARY
128+
fi
129+

.github/workflows/pr_ios.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ on:
44
pull_request:
55
types: [opened, reopened, synchronize]
66

7+
# Cancel in-progress runs on the same PR to avoid wasting runner minutes.
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
712
jobs:
813
build:
914
runs-on: macos-14
1015
strategy:
16+
fail-fast: false
1117
matrix:
1218
xcode_version: [ '16.1.0' ]
1319
newArchEnabled: [ 1 ]
@@ -41,9 +47,9 @@ jobs:
4147
uses: actions/cache@v4
4248
with:
4349
path: apps/e2e/ios/Pods
44-
key: pods-${{ runner.os }}-${{ hashFiles('Podfile.lock') }}-${{ matrix.newArchEnabled }}
50+
key: pods-${{ runner.os }}-${{ matrix.platform }}-${{ matrix.newArchEnabled }}-${{ hashFiles('apps/e2e/ios/Podfile.lock') }}
4551
restore-keys: |
46-
pods-${{ runner.os }}-
52+
pods-${{ runner.os }}-${{ matrix.platform }}-${{ matrix.newArchEnabled }}-
4753
4854
- name: Run npm install
4955
run: |
@@ -57,19 +63,18 @@ jobs:
5763
run: npm test
5864

5965
- name: Install & update e2e app with latest react-native-theoplayer
60-
run: |
61-
cd apps/e2e
62-
npm update react-native-theoplayer
63-
npm ci
66+
working-directory: apps/e2e
67+
run: npm install react-native-theoplayer@latest
6468

6569
- name: Install Ruby dependencies
6670
working-directory: apps/e2e
67-
run: bundle install
71+
run: |
72+
bundle config set path 'vendor/bundle'
73+
bundle install
6874
6975
- name: Run pod install & update dependencies
7076
working-directory: apps/e2e/ios
71-
run: |
72-
RCT_NEW_ARCH_ENABLED=${{ matrix.newArchEnabled }} bundle exec pod update
77+
run: RCT_NEW_ARCH_ENABLED=${{ matrix.newArchEnabled }} bundle exec pod update
7378

7479
- name: Start iOS simulator
7580
uses: futureware-tech/simulator-action@v4
@@ -85,4 +90,7 @@ jobs:
8590
- name: Summarize results
8691
working-directory: apps/e2e
8792
if: always()
88-
run: cat cavy_results.md >> $GITHUB_STEP_SUMMARY
93+
run: |
94+
if [ -f cavy_results.md ]; then
95+
cat cavy_results.md >> $GITHUB_STEP_SUMMARY
96+
fi

.github/workflows/pr_web.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: Build Web on PRs
22
on:
3+
workflow_dispatch:
34
push:
45
branches:
56
- main
@@ -9,21 +10,31 @@ on:
910
types: [opened, reopened, synchronize]
1011
paths-ignore:
1112
- '**.md'
13+
14+
# Cancel in-progress runs on the same PR to avoid wasting runner minutes.
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
1219
jobs:
1320
test:
1421
name: Test
1522
runs-on: ubuntu-latest
1623
steps:
17-
- name: Checkout
24+
- name: Checkout repository
1825
uses: actions/checkout@v4
19-
- name: Setup Node.js 20
26+
27+
- name: Setup Node
2028
uses: actions/setup-node@v4
2129
with:
2230
node-version: 22
2331
cache: 'npm'
32+
2433
- name: Install dependencies
2534
run: npm ci --workspaces --include-workspace-root
35+
2636
- name: Build
2737
run: npm run build
38+
2839
- name: Test
2940
run: npm test

adobe-edge/android/src/main/java/com/theoplayer/reactnative/adobe/edge/AdobeEdgeHandler.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ class AdobeEdgeHandler(
374374
chapterCue.endTime.toInt(),
375375
(chapterCue.endTime - chapterCue.startTime).toInt()
376376
),
377-
customMetadata
378377
)
379378
currentChapter = chapterCue
380379
}
@@ -428,7 +427,6 @@ class AdobeEdgeHandler(
428427
adPodPosition,
429428
(event.ad as? LinearAd)?.duration ?: 0
430429
),
431-
customMetadata
432430
)
433431
adPodPosition++
434432
}
@@ -504,6 +502,9 @@ class AdobeEdgeHandler(
504502
customMetadata
505503
)
506504

505+
// Clear used custom metadata after starting the session to avoid accidentally reusing it for the next session.
506+
customMetadata.clear()
507+
507508
sessionInProgress = true
508509

509510
if (eventQueue.isNotEmpty()) {
@@ -534,7 +535,6 @@ class AdobeEdgeHandler(
534535
isPlayingAd = false
535536
sessionInProgress = false
536537
currentChapter = null
537-
customMetadata = mutableMapOf()
538538
}
539539

540540
fun destroy() {

adobe-edge/ios/Connector/AdobeEdgeHandler.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,10 @@ class AdobeEdgeHandler {
427427
mediaType: MediaType.Video
428428
) {
429429
self.tracker.trackSessionStart(info: mediaObject, metadata: self.customMetadata)
430+
431+
// Clear used custom metadata after starting the session to avoid accidentally reusing it for the next session.
432+
self.customMetadata.removeAll()
433+
430434
self.sessionInProgress = true
431435
self.logDebug("maybeStartSession - STARTED")
432436

@@ -486,7 +490,6 @@ class AdobeEdgeHandler {
486490
self.sessionInProgress = false
487491
self.currentChapter = nil
488492
self.eventQueue.removeAll()
489-
self.customMetadata.removeAll()
490493
}
491494

492495
func destroy() -> Void {

adobe-edge/jest.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @type {import('jest').Config} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: 'node',
5+
testMatch: ['**/__tests__/**/*.test.ts'],
6+
moduleNameMapper: {
7+
'^@theoplayer/react-native-analytics-adobe-edge$': '<rootDir>/src/index',
8+
},
9+
};
10+

adobe-edge/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"manifest": "node manifest.js > src/manifest.json",
3535
"prepare": "npm run manifest && npm run build",
3636
"clean": "rimraf lib android/build example/android/build example/android/app/build example/ios/build",
37-
"generate-types": "openapi-typescript src/internal/web/media-edge-0.1.json -o src/internal/web/MediaEdge.d.ts"
37+
"generate-types": "openapi-typescript src/internal/web/media-edge-0.1.json -o src/internal/web/MediaEdge.d.ts",
38+
"test": "jest"
3839
},
3940
"keywords": [
4041
"react-native",
@@ -88,6 +89,9 @@
8889
"openapi-fetch": "^0.9.8"
8990
},
9091
"devDependencies": {
91-
"metro-react-native-babel-preset": "^0.77.0"
92+
"@types/jest": "^30.0.0",
93+
"jest": "^30.2.0",
94+
"metro-react-native-babel-preset": "^0.77.0",
95+
"ts-jest": "^29.4.6"
9296
}
9397
}

adobe-edge/src/internal/web/AdobeEdgeHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ class AdobeEdgeHandler {
310310
Math.trunc(chapterCue.endTime),
311311
Math.trunc(chapterCue.endTime - chapterCue.startTime),
312312
),
313-
this._customMetadata,
314313
);
315314
this._currentChapter = chapterCue;
316315
};
@@ -350,7 +349,6 @@ class AdobeEdgeHandler {
350349
this.queueOrSendEvent(
351350
EventType.adStart,
352351
this._media?.createAdObject(PROP_NA, PROP_NA, this._adPodPosition, event.ad.duration ? Math.trunc(event.ad.duration) : 0),
353-
this._customMetadata,
354352
);
355353
this._adPodPosition++;
356354
};
@@ -420,6 +418,9 @@ class AdobeEdgeHandler {
420418
this._customMetadata,
421419
);
422420

421+
// Clear used custom metadata after starting the session to avoid accidentally reusing it for the next session.
422+
this._customMetadata = {};
423+
423424
this._sessionInProgress = true;
424425

425426
// Post any queued events now that the session has started.
@@ -466,7 +467,6 @@ class AdobeEdgeHandler {
466467
this._adPodPosition = 1;
467468
this._sessionInProgress = false;
468469
this._currentChapter = undefined;
469-
this._customMetadata = {};
470470
}
471471

472472
destroy() {

0 commit comments

Comments
 (0)