angulartics / angulartics2

Vendor-agnostic analytics for Angular2 applications.
MIT License
1.01k stars 193 forks source link

AOT compilation breaks RegExp in idsRegExp #339

Open Sturgelose opened 5 years ago

Sturgelose commented 5 years ago

For support questions, please consider using Gitter - Chat

I'm submitting a ...

And compile the application with AOT.

Then, check any URL matching this regex

NOTE: I'm using this RegEx as example, but this happens with any other Regex as well

The ids matching the regex to be filtered out. However, this does not happen. I've ben debugging in lower level, and it seems that using a regular expression with new Regex() ends with Angulartics2 loading the default value instead.

A workaround is to write it as a string and skipping the typescript checks.

// @ts-ignore
    idsRegExp: '^(([a-z0-9]{14}(:[a-z0-9]{6})?)|DEMO)$',

I have also seen that I'm not the only one with the same issue: https://stackoverflow.com/questions/54826529/angulartics-new-regexp-doesnt-appear-in-aot

Package Version

@angular-devkit/architect 0.13.3 @angular-devkit/build-angular 0.13.3 @angular-devkit/build-optimizer 0.13.3 @angular-devkit/build-webpack 0.13.3 @angular-devkit/core 7.3.3 @angular-devkit/schematics 7.3.3 @angular/cdk 7.3.3 @angular/cli 7.3.3 @angular/flex-layout 7.0.0-beta.23 @angular/material 7.3.3 @angular/pwa 0.13.3 @ngtools/webpack 7.3.3 @schematics/angular 7.3.3 @schematics/update 0.13.3 rxjs 6.4.0 typescript 3.2.4 webpack 4.29.0

mtraynham commented 5 years ago

I ran into this as well. I've reported it to the Angular repo here https://github.com/angular/angular/issues/29668

Thanks for the string workaround though, seems like it should work for the regex match here.