Skip to content

feat(npaw): add @theoplayer/react-native-analytics-npaw connector#447

Merged
tvanlaerhoven merged 16 commits into
mainfrom
feature/npaw-connector
Jul 23, 2026
Merged

feat(npaw): add @theoplayer/react-native-analytics-npaw connector#447
tvanlaerhoven merged 16 commits into
mainfrom
feature/npaw-connector

Conversation

@tvanlaerhoven

@tvanlaerhoven tvanlaerhoven commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

New JS-only analytics connector @theoplayer/react-native-analytics-npaw (under npaw/), structured like the youbora connector but stripped of all native iOS/Android/web modules. It integrates NPAW through the npaw-plugin-react-native JS plugin only, so it works on iOS, Android and web via the unified react-native-theoplayer facade.

The core idea: NPAW's bundled Theoplayer adapter (in the separate npaw-plugin-adapters package) is web-only — it hooks web-THEOplayer DOM events and reads web-only props. Instead, this package ships its own cross-platform adapter classes that NPAW instantiates via registerAdapterFromClass / registerAdsAdapterFromClass. NPAW copies our methods onto its own runtime adapter object and assigns this.player, so our getters/listeners run against NPAW's adapter with the RN player attached — no native code required.

What's here

  • NpawConnector(player, config) + useNpaw(config) hook. Config:

    interface NpawConnectorConfig {
      accountCode: string;
      analytics?: NpawAnalyticsOptions; // per-video content.* options
      plugin?: NpawPluginOptions;       // host, sessionRecovery, ...
      logLevel?: LogLevel;
    }

    Runtime option APIs: setVideoOptions(options, videoKey?) (per-video), setAnalyticsOptions(options) (global), setLogLevel(level), destroy().

  • TheoplayerAdapter — video adapter. Subscribes to unified PlayerEventType events and maps them to NPAW's fire* API:

    • PLAY/PLAYINGfireStart/fireJoin/fireResume, PAUSEfirePause, WAITINGfireBufferBegin, SEEKING/SEEKEDfireSeekBegin/fireSeekEnd, TIME_UPDATE establishes start/join + ends seek/buffer, SOURCE_CHANGE/ENDEDfireStop, ERRORfireError.
    • Getters: playhead, duration, isLive, resource, rendition, bitrate, getSubtitles() (active showing subtitle/caption track language) and getVideoLanguage() (active audio track language) — both feed NPAW's auto-detection of subtitle/audio-language usage.
    • getVersion() is player-independent (static, manifest-based) because NPAW calls it during adapter construction before this.player is set.
  • TheoplayerAdsAdapter — ads adapter. Subscribes to AD_EVENT and maps subtypes: AD_BREAK_BEGIN/ENDfireBreakStart/fireBreakStop, AD_BEGINfireStart+fireJoin, quartiles → fireQuartile(1|2|3), AD_SKIPfireSkip, AD_CLICKEDfireClick, AD_ENDfireStop, AD_ERRORfireError. Getters serve ad duration/resource/title/position(pre|mid|post)/skippable. AD_BUFFERING is intentionally skipped (THEOplayer has no reliable matching buffer-end event).

  • Registered in the root workspaces; only dependency is npaw-plugin-react-native.

  • e2e app (apps/e2e): useNpawConnector() wired into App.tsx like the other connectors, Npaw.spec.ts create/use/destroy test with a dummy account code, NPAW_ACCOUNT_CODE in .env.example, tsconfig path + metro connector entry. Sample analytics demonstrates content.title + a content.metadata object.

Scope / gap check

Reviewed against NPAW's shipped plugin API + option registry. Content metadata, subtitles and audio language are wired; all other NPAW options (the full content.*/user.*/ad.*/parse.*/… set) are supported generically via analytics / setVideoOptions / setAnalyticsOptions. Getters NPAW can't be reliably fed from the RN facade cross-platform (throughput, dropped frames, fps, codecs) are intentionally left to NPAW defaults.

Notes / caveats

  • Not runtime-tested against a live NPAW account or a real ad source from here — the event→fire* mappings are verified against NPAW's shipped types and the plugin source, but a smoke test in an app (playback + ads) is worth doing before release.
  • LogLevel is a local enum mirroring the plugin's numeric values, since the RN entry only default-exports NpawPlugin.

Link to Devin session: https://dolby.devinenterprise.com/sessions/6d52b6e8bd134e5caaa3d268e991711e
Requested by: @tvanlaerhoven


Open in Devin Review

devin-ai-integration Bot and others added 9 commits July 22, 2026 08:58
…ctor

Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
…AW via PlayerEventType

Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
…se members

Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
…dapter construction

Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
…adata

Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
…ssthrough

Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
@tvanlaerhoven tvanlaerhoven self-assigned this Jul 22, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@changeset-bot

changeset-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9a0359d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 4 potential issues.

Open in Devin Review

Comment thread npaw/src/internal/TheoplayerAdapter.ts Outdated
Comment thread npaw/src/internal/TheoplayerAdapter.ts
Comment thread npaw/src/internal/TheoplayerAdsAdapter.ts Outdated
Comment thread npaw/src/internal/TheoplayerAdapter.ts
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

Open in Devin Review

Comment thread npaw/src/internal/TheoplayerAdapter.ts Outdated
Comment thread npaw/src/internal/NpawConnectorAdapter.ts
…sion end

Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread npaw/src/internal/TheoplayerAdapter.ts
devin-ai-integration Bot and others added 3 commits July 23, 2026 08:59
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>
Co-Authored-By: tom.vanlaerhoven <tom.vanlaerhoven@dolby.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread npaw/src/internal/TheoplayerAdapter.ts
@tvanlaerhoven
tvanlaerhoven merged commit 47c30cc into main Jul 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant