Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Uncaught TypeError: Cannot read property 'replace' of undefined #634

Open
AvocadoVenom opened this issue Aug 26, 2020 · 1 comment
Open

Comments

@AvocadoVenom
Copy link

Hello team,

I get a strange error at the first Page Datalayer in my app.

My application is a Vue CLI 2.6 with Typescript.

I send event with the following:

;(window as any).analytics &&
    (window as any).analytics.track(eventName, payload, { Intercom: false })

eventName is a string like undefined_event or any other custom string.

payload is a key-value pair dictionary which may contain null value.

My code to send the Page Datalayer:

const options = {
   name: to.path,
   title: document.title,
   path: to.fullPath,
   search: JSON.stringify(to.query)
 }

;(window as any).analytics.track('Page Datalayer', options)

Here is the warning I get:

[Amplitude] Invalid eventType input type. Expected string but received undefined

Here is the stackTrace:

cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:8 Uncaught TypeError: Cannot read property 'replace' of undefined
    at a (cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:8)
    at o (cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:8)
    at t.n.map (cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:1)
    at t.<computed> [as standardEvents] (cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:2)
    at t.f.track (cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:7)
    at track (cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:1)
    at cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:1
    at u (cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:3)
    at c (cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:3)
    at t.n.flush (cdn.segment.com/analytics.js/v1/jExWYocq8leIbsvVJRF9eymTCah0P4qr/analytics.min.js:1)

My events have the following data structure:

{
  "timestamp": "2020-08-26T15:05:58.289Z",
  "integrations": {
    "Intercom": false
  },
  "context": {
    "page": {
      "path": "/my-path/",
      "referrer": "my-referrer",
      "search": "",
      "title": "Title",
      "url": "my-url"
    },
    "userAgent": "something",
    "locale": "en-GB",
    "library": {
      "name": "analytics.js",
      "version": "3.13.6"
    }
  },
  "properties": {
    "id": "A-Dasherized-Custom-Id",
    "type": "undefined_event",
    "properties": {
      "a": "a",
      "key": "key",
      "value": "value",
      "pair": "pair",
      "dico": "dico"
      "with": "with",
      "string": "string",
      "null": null,
      "int": 0,
      "values": "values"
    }
  },
  "event": "Undefined Event",
  "messageId": "messageId",
  "anonymousId": "anonymousId",
  "type": "track",
  "writeKey": "my-write-key",
  "userId": 1234,
  "sentAt": "2020-08-26T15:05:58.295Z",
  "_metadata": {
    "bundled": [
      "Amplitude",
      "Facebook Pixel",
      "Google Analytics",
      "Google Tag Manager",
      "Intercom",
      "Segment.io"
    ],
    "unbundled": []
  }
}

I guess you will need further information so feel free to ask

Many thanks

@pooyaj
Copy link
Contributor

pooyaj commented Sep 10, 2020

Hi @AvocadoVenom, do you have the app accessible somewhere so I can reproduce/debug the issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants