Skip to content

feat: device locale helpers, privacy string accessors, and rule triggers - #139

Open
ethanpschoen wants to merge 6 commits into
mainfrom
ethanpschoen/feat/rule-triggers
Open

feat: device locale helpers, privacy string accessors, and rule triggers#139
ethanpschoen wants to merge 6 commits into
mainfrom
ethanpschoen/feat/rule-triggers

Conversation

@ethanpschoen

@ethanpschoen ethanpschoen commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description of this change

Bottom layer of a 2-PR stack for the headless SDK surface. Review this PR's diff against main.

main
 └── #139  locale helpers + privacy strings + triggers   ← this PR
  └── #141  headless CDN client + provider wiring
  • Extract device locale helpers and default languageCode to a BCP-47 device locale tag
  • Privacy string accessors with a configurable reader
  • Rule triggers and experience parity enums; carry a queued trigger() call across a WebView remount

Why is this change being made?

  • Chore (non-functional changes)
  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How was this tested? How can the reviewer verify your testing?

  • Reviewer: check CI on this PR.

Related issues

None.

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have evaluated the security impact of this change, and OWASP Secure Coding Practices have been observed.
  • I have informed stakeholders of my changes.

Extracts the raw device-locale lookup and a BCP-47 formatter into their own module, replacing the module-level deviceLanguage const in the provider. Pure refactor, no behavior change.

Part 1/5 of the split of #126.
Adds accessors for the IAB privacy strings the tag writes to native storage (TCF TC string, US Privacy string, GPP header string) and a generic getSavedString helper.

The util barrel export also picks up the device-locale module from the prior PR in this stack, since both additions land in the same import block.

Part 2/5 of the split of #126.
@ethanpschoen ethanpschoen changed the title ethanpschoen/feat/rule triggers feat: add rule triggers and experience parity enums Aug 6, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 590fde6. Configure here.

Comment thread package/src/KetchServiceProvider/KetchServiceProvider.tsx
Comment thread package/src/KetchServiceProvider/KetchServiceProvider.tsx
Comment thread package/src/KetchServiceProvider/KetchServiceProvider.tsx
getSavedString and the IAB helpers always read through nativeStorage.read, so they never saw values persisted via a custom preferenceStorage backend. That backend is required for Expo Android in the README, and on that setup crossPlatformRead falls back to React Native Settings, which is a no-op on Android — so these accessors returned empty strings after consent updates whenever preferenceStorage was configured.

This PR adds the capability (an optional reader parameter, defaulting to the existing nativeStorage.read). The provider wiring that actually builds a reader from the configured preferenceStorage and binds these accessors to it lands in #141, alongside the rest of the KetchService exposure.

Refs #126.
Adds an imperative trigger() method that fires an onFunction rule trigger and queues until the tag's config has loaded, plus enum values for normalizing the hide/show experience callbacks. onHideExperience now receives a normalized enum, falling back to none, instead of the raw tag payload.

Also carries the ketch_mobilesdk_url URL-param override, which lives in the same helpers.ts region as the new trigger helpers.

Part 3/5 of the split of #126.
The webViewMountKey reset effect nulled the pending trigger on every mount-key change, including the async ATT-driven change that always fires once on iOS before the WebView's first mount. trigger() had already returned true by then, so the call was silently swallowed instead of firing once the tag booted.

Refs #126.
getDeviceLanguage() returns the raw platform identifier, underscore-separated on Android (en_US) and on iOS whenever AppleLocale is used. Every default-configured install therefore sent language=en_US to both the headless CDN client and the WebView, since the headless client's own BCP-47 formatting is only reached when languageCode is falsy — and the provider always supplied one.

Refs #126.
@ethanpschoen
ethanpschoen force-pushed the ethanpschoen/feat/rule-triggers branch from 590fde6 to 738c2b1 Compare August 6, 2026 21:22
@ethanpschoen ethanpschoen changed the title feat: add rule triggers and experience parity enums feat: device locale helpers, privacy string accessors, and rule triggers Aug 7, 2026
@ethanpschoen
ethanpschoen deleted the branch main August 7, 2026 23:29
@ethanpschoen ethanpschoen reopened this Aug 7, 2026
@ethanpschoen ethanpschoen changed the title feat: device locale helpers, privacy string accessors, and rule triggers feat: add rule triggers and experience parity enums Aug 7, 2026
@ethanpschoen ethanpschoen changed the title feat: add rule triggers and experience parity enums feat: device locale helpers, privacy string accessors, and rule triggers Aug 7, 2026
@ethanpschoen
ethanpschoen changed the base branch from ethanpschoen/feat/privacy-string-accessors to main August 7, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant