snowplow / snowplow/snowplow-javascript-tracker

Support setting url and referrer in RN tracker

Open
#1,437 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:enhancement
Dominant language
TypeScript
Stars
590
Forks
232
Avg merge
2h 22m
Merged PRs (30d)
3

Description

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

https://github.com/snowplow/snowplow-javascript-tracker/blob/33ef906538b59fb9fca698d7f895c90676f56fad/trackers/react-native-tracker/src/plugins/deep_links/index.ts#L52-L57

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the React Native tracker and the getBrowserDataPlugin behavior described in the issue, then inspect trackers/react-native-tracker/src/plugins/deep_links/index.ts around the referenced lines. Determine how setReferrerUrl and setCustomUrl should interact with deep-link URL handling; done means the React Native tracker can set url and referrer values without conflicting with that plugin.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.