# Elastic APM js agent for angular throws console error Cannot read property 'events'

**URL:** <https://discuss.elastic.co/t/elastic-apm-js-agent-for-angular-throws-console-error-cannot-read-property-events/202405>\
**Category:** APM\
**Tags:** rum\
**Created:** [October 5, 2019, 12:11am UTC](https://discuss.elastic.co/t/elastic-apm-js-agent-for-angular-throws-console-error-cannot-read-property-events/202405 "2019-10-05T00:11:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartheek\_Mannepalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kartheek_mannepalli/32/55290_2.png) [@Kartheek\_Mannepalli](https://discuss.elastic.co/u/Kartheek_Mannepalli)\
**Post date:** [October 5, 2019, 12:11am UTC](https://discuss.elastic.co/t/elastic-apm-js-agent-for-angular-throws-console-error-cannot-read-property-events/202405/1 "2019-10-05T00:11:08Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

**Kibana version** : 7.4.0

**Elasticsearch version** : 7.4.0

**APM Server version** : 7.4.0

**APM Agent language and version** : JS agent 4.5.0. Angular 0.2.0.

**Browser version** :

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: windows

**Fresh install or upgraded from other version?** fresh install

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.  
No just the default

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
I have followed the instuctions on how to install the APM agent for angular and I saw this errro first.

> [@Has anyone been able to use @elastic/apm-rum-angular with aot?](https://discuss.elastic.co/t/has-anyone-been-able-to-use-elastic-apm-rum-angular-with-aot/198456):
>
> First, thanks for the initial Angular integration. This might be premature, given it's not full ready and was just released 3 days ago, but I had some issues integrating it. Kibana version: 7.3.1 Elasticsearch version: 7.3.1 APM Server version: 7.3.1 APM Agent language and version: @elastic/apm-rum-angular 0.1.0. Angular 8.2.5. Browser version: Original install method (e.g. download page, yum, deb, from source, etc.) and version: yarn Fresh install or upgraded from other version? Fr…

based on this discussion I changed my polyfills to core-js/es7/reflect and now I see a new error.

> Uncaught TypeError: Cannot read property 'events' of undefined
> 
> ![o%20Warehousing](https://us1.discourse-cdn.com/elastic/original/3X/8/7/87288f26d02757b4ffa7339243dfdb57ce97eb78.jpeg)

any idea how I can fix this?  
**Steps to reproduce** :  
1.  
2.  
3.

**Errors in browser console (if relevant)**:  
Uncaught TypeError: Cannot read property 'events' of undefined

**Provide logs and/or server output (if relevant)**:

---

<div class="post-metadata">

**Author:** ![vigneshshanmugam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vigneshshanmugam/32/40324_2.png) [@vigneshshanmugam](https://discuss.elastic.co/u/vigneshshanmugam)\
**Post date:** [October 7, 2019, 9:01am UTC](https://discuss.elastic.co/t/elastic-apm-js-agent-for-angular-throws-console-error-cannot-read-property-events/202405/2 "2019-10-07T09:01:27Z")

</div>

Hi Kartheek,

There seems to be a bug in the way we publish our Angular module and hence the dependency injection does not work properly.

I am already on it, Please follow it along here for the update [https://github.com/elastic/apm-agent-rum-js/issues/437](https://github.com/elastic/apm-agent-rum-js/issues/437)

Thanks,  
Vignesh

---

<div class="post-metadata">

**Author:** ![Kartheek\_Mannepalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kartheek_mannepalli/32/55290_2.png) [@Kartheek\_Mannepalli](https://discuss.elastic.co/u/Kartheek_Mannepalli)\
**Post date:** [October 8, 2019, 4:36pm UTC](https://discuss.elastic.co/t/elastic-apm-js-agent-for-angular-throws-console-error-cannot-read-property-events/202405/3 "2019-10-08T16:36:49Z")

</div>

@vigneshshanmugam thank you for your response. One question I have is do you recommend using this version of angular-rum in production environment or would be recommend us waiting for a stable version?

---

<div class="post-metadata">

**Author:** ![vigneshshanmugam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vigneshshanmugam/32/40324_2.png) [@vigneshshanmugam](https://discuss.elastic.co/u/vigneshshanmugam)\
**Post date:** [October 9, 2019, 8:27am UTC](https://discuss.elastic.co/t/elastic-apm-js-agent-for-angular-throws-console-error-cannot-read-property-events/202405/4 "2019-10-09T08:27:52Z")

</div>

Hi Kartheek,

We have released a new version of `@elastic/apm-rum-angular@0.2.1` which should fix the above issue. The `ApmService` provider would need explicit injection to make it work with Angular CLI. Please refer to the doc - [https://www.elastic.co/guide/en/apm/agent/rum-js/master/angular-integration.html](https://www.elastic.co/guide/en/apm/agent/rum-js/master/angular-integration.html)

You can use it in production right now, we did not release a major version `1.x` since we might explore API changes in the future if required.

Let us know how it works out for you.

Thanks,  
Vignesh

---

<div class="post-metadata">

**Author:** ![Kartheek\_Mannepalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kartheek_mannepalli/32/55290_2.png) [@Kartheek\_Mannepalli](https://discuss.elastic.co/u/Kartheek_Mannepalli)\
**Post date:** [October 10, 2019, 12:49am UTC](https://discuss.elastic.co/t/elastic-apm-js-agent-for-angular-throws-console-error-cannot-read-property-events/202405/5 "2019-10-10T00:49:00Z")

</div>

Thank you I will try the new version now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 30, 2019, 8:49pm UTC](https://discuss.elastic.co/t/elastic-apm-js-agent-for-angular-throws-console-error-cannot-read-property-events/202405/6 "2019-10-30T20:49:06Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
