Skip to content

Support setting url and referrer in RN tracker #1437

@Mookiies

Description

@Mookiies

Is your feature request related to a problem? Please describe.
The v4 react native tracker if used on web misses out on browser context information. There's no way to set the url or refr on the react native tracker. This blocks me from simplifying down to just the react-native-tracker for all platforms.

Having a way to set those on mobile environment would also be helpful. (I use expo-router so even on mobile everything maps cleanly to a URL).

Describe the solution you'd like
Add support for setReferrerUrl & setCustomUrl.

Maybe also support other fields that the getBrowserDataPlugin does for browser tracker.

Describe alternatives you've considered
DIYing the plugin

  function browserDataPlugin() {
    let customUrl: string | undefined | null = undefined;
    const beforeTrack = (payloadBuilder: PayloadBuilder) => {
      customUrl && payloadBuilder.add('url', customUrl);
    };

    const setCustomUrl = (url: string | null) => {
      customUrl = url;
    };

    return {
      setCustomUrl,
      plugin: {
        beforeTrack,
      },
    };
  }
  tracker.addPlugin(browserDataPlugin());

Additional context
Setting url in any capacity on mobile seems like it may some conflict with the deeplink plugins way of doing this

if (url) {
payload.add(PAGE_URL_PROPERTY, url);
}
if (referrer) {
payload.add(PAGE_REFERRER_PROPERTY, referrer);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:enhancementNew features or improvements to existing features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions