Skip to content

configureAutoTrack option "urlProvider" not working #14548

@takapiroid88

Description

@takapiroid88

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Analytics

Amplify Version

v6

Amplify Categories

analytics

Backend

None

Environment information

# Put output below this line
System:
    OS: macOS 13.6.1
    CPU: (8) arm64 Apple M1
    Memory: 59.52 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.15.0 - ~/.nodebrew/current/bin/node
    Yarn: 1.22.22 - ~/.nodebrew/current/bin/yarn
    npm: 10.9.2 - ~/.nodebrew/current/bin/npm
  Browsers:
    Chrome: 140.0.7339.133
    Safari: 16.6
  npmPackages:
    @chatscope/chat-ui-kit-react: ^2.1.1 => 2.1.1 
    @chatscope/chat-ui-kit-styles: ^1.4.0 => 1.4.0 
    @emotion/react: ^11.7.1 => 11.14.0 
    @emotion/styled: ^11.6.0 => 11.14.1 
    @eslint/js: ^9.32.0 => 9.34.0 
    @hello-pangea/dnd: ^18.0.1 => 18.0.1 
    @mui/icons-material: ^7.3.2 => 7.3.2 
    @mui/lab: ^7.0.0-beta.17 => 7.0.0-beta.17 
    @mui/material: ^5.14.8 => 5.18.0 
    @mui/system: ^7.3.2 => 7.3.2 (5.18.0)
    @mui/x-date-pickers: ^8.11.1 => 8.11.1 
    @svgr/plugin-jsx: ^8.1.0 => 8.1.0 
    @svgr/plugin-svgo: ^8.1.0 => 8.1.0 
    @testing-library/jest-dom: ^6.1.5 => 6.8.0 
    @testing-library/react: ^14.1.2 => 14.3.1 
    @testing-library/user-event: ^14.5.1 => 14.6.1 
    @types/cookie: ^1.0.0 => 1.0.0 
    @types/debug: ^4.1.5 => 4.1.12 
    @types/encoding-japanese: ^2.2.1 => 2.2.1 
    @types/node: ^24.3.1 => 24.3.1 
    @types/qrcode: ^1.4.2 => 1.5.5 
    @types/query-string: ^6.3.0 => 6.3.0 
    @types/react: ^19.1.12 => 19.1.12 
    @types/react-beautiful-dnd: ^13.0.0 => 13.1.8 
    @types/react-beforeunload: ^2.1.1 => 2.1.5 
    @types/react-big-calendar: ^1.16.2 => 1.16.2 
    @types/react-dom: ^19.1.9 => 19.1.9 (18.3.7)
    @types/react-helmet: ^6.1.5 => 6.1.11 
    @types/react-infinite-scroller: ^1.2.1 => 1.2.5 
    @types/react-redux: ^7.1.21 => 7.1.34 
    @types/react-router-dom: ^5.1.3 => 5.3.3 
    @types/redux-mock-store: ^1.0.2 => 1.5.0 
    @types/validator: ^13.7.1 => 13.15.3 
    @types/video.js: ^7.3.29 => 7.3.58 
    @videojs/http-streaming: ^3.17.2 => 3.17.2 
    @vitejs/plugin-react: ^4.7.0 => 4.7.0 
    aws-amplify: ^6.15.5 => 6.15.5 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/adapter-core/internals:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/internals:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/data:  undefined ()
    aws-amplify/data/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    codemods:  0.0.0 
    cookie: ^1.0.2 => 1.0.2 
    csv-parse: ^4.16.0 => 4.16.3 
    date-fns: ^4.1.0 => 4.1.0 
    date-fns-tz: ^3.2.0 => 3.2.0 
    eslint: ^9.32.0 => 9.34.0 
    eslint-config-prettier: ^10.1.8 => 10.1.8 
    eslint-plugin-promise: ^7.2.1 => 7.2.1 
    eslint-plugin-react-hooks: ^5.2.0 => 5.2.0 
    eslint-plugin-react-refresh: ^0.4.20 => 0.4.20 
    globals: ^16.3.0 => 16.3.0 (14.0.0)
    graphql: ^16.2.0 => 16.11.0 (15.8.0)
    https-proxy-agent: ^7.0.6 => 7.0.6 
    jsdom: ^26.1.0 => 26.1.0 
    limiter: ^2.1.0 => 2.1.0 
    prettier: ^3.6.2 => 3.6.2 
    qrcode: ^1.4.4 => 1.5.4 
    query-string: ^7.1.0 => 7.1.3 (9.2.2)
    react: ^19.1.1 => 19.1.1 
    react-beforeunload: ^2.6.0 => 2.6.0 
    react-device-detect: ^2.2.2 => 2.2.3 
    react-dom: ^19.1.1 => 19.1.1 
    react-helmet-async: ^1.3.0 => 1.3.0 
    react-infinite-scroller: ^1.2.6 => 1.2.6 
    react-redux: ^8.1.2 => 8.1.3 (9.2.0)
    react-router-dom: ^6.15.0 => 6.30.1 
    react-string-replace: ^0.4.4 => 0.4.4 
    recharts: ^2.8.0 => 2.15.4 
    redux: ^4.0.5 => 4.2.1 (5.0.1)
    redux-mock-store: ^1.5.4 => 1.5.5 
    source-map-explorer: ^2.5.0 => 2.5.3 
    typescript: ~5.8.3 => 5.8.3 
    typescript-eslint: ^8.38.0 => 8.42.0 
    typescript-fsa: ^3.0.0 => 3.0.0 
    typescript-fsa-reducers: ^1.2.1 => 1.2.2 
    validator: ^13.1.1 => 13.15.15 
    vite: ^7.0.6 => 7.1.4 
    vite-plugin-node-polyfills: ^0.24.0 => 0.24.0 
    vite-plugin-svgr: ^4.3.0 => 4.5.0 
    vitest: ^3.2.4 => 3.2.4 
  npmGlobalPackages:
    corepack: 0.32.0
    npm: 10.9.2
    yarn: 1.22.22

Describe the bug

package version: 6.15.5

If you run configureAutoTrack() with a urlProvider, the urlProvider will behave in the default way (window.location.origin + window.location.pathname).

sample

configureAutoTrack({
  type: "pageView",
  enable: true,
  options: {
    eventName: "path",
    urlProvider: () => window.location.origin + "test", // custom function
  },
});

payload (result)

{
  "BatchItem": {
    "7dc1d84e-8411-4154-864c-27f00d013889": {
      "Endpoint": {},
      "Events": {
        "5e556e97-6dc1-46a9-a786-259fed241134": {
          "EventType": "pageView",
          "Timestamp": "2025-09-10T03:02:26.254Z",
          "Attributes": {
            "url": "http://localhost:3000/myPage",
          },
        }
      }
    }
  }
}

Looking at the code, the following in src/trackers/PageViewTracker.ts seems suspicious:
Image

I think,
not: this.options?.urlProvider ?? DEFAULT_URL_PROVIDER
expect: options?.urlProvider ?? DEFAULT_URL_PROVIDER

Is there any intention behind it being this.options?

thanks.

Expected behavior

payload contains url is window.location.origin + "test"

Reproduction steps

  1. execute
configureAutoTrack({
  type: "pageView",
  enable: true,
  options: {
    eventName: "path",
    urlProvider: () => window.location.origin + "test", // custom function
  },
});
  1. transition web app page

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions