Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error when using trackerAssist #172

Closed
hishtadlut opened this issue Sep 12, 2021 · 3 comments
Closed

Compile error when using trackerAssist #172

hishtadlut opened this issue Sep 12, 2021 · 3 comments
Assignees
Labels
assist bug Something isn't working

Comments

@hishtadlut
Copy link

I was trying to update OpenReplay so I will have the ability to use the trackerAssist plugin.

After using

$ npm i @openreplay/tracker@latest
$ npm i @openreplay/tracker-assist

And after running the app I gut this error message on the console:

peerjs.min.js:1 Uncaught ReferenceError: parcelRequire is not defined
    at push.oLy0.parcelRequire.EgBh (peerjs.min.js:1)
    at Object.oLy0 (peerjs.min.js:1)
    at __webpack_require__ (bootstrap:79)
    at Module.sj1N (index.js:1)
    at __webpack_require__ (bootstrap:79)
    at Module.WO6z (index.ts:2)
    at __webpack_require__ (bootstrap:79)
    at Module.3LUQ (google-auth.service.ts:11)
    at __webpack_require__ (bootstrap:79)
    at Module.N+K7 (visa-type.enum.ts:35)

main.ts

import OpenReplay from '@openreplay/tracker';

platformBrowserDynamic().bootstrapModule(AppModule).then((ref) => {
  const tracker = new OpenReplay({
    projectKey: '********************'
  });
  tracker.start();

  ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production, registrationStrategy: 'registerImmediately' })
  ref.injector.get(ReplaySessionService).tracker = tracker;
}).catch(err => console.log(err));

replay-session.service.ts

import { Injectable } from '@angular/core';
import OpenReplay from '@openreplay/tracker';
import trackerAssist from '@openreplay/tracker-assist';

@Injectable({
  providedIn: 'root'
})
export class ReplaySessionService {
  tracker: OpenReplay

  sendErrorToReplaySession = (error: Error) => {
    this.tracker.handleError(error);
  }

  sendIssueToReplaySession = (key: string, payload: any) => {
    this.tracker.issue(key, payload);
  }

  assist = () => {
    this.tracker.use(trackerAssist({ confirmText: 'Live assistant'}));
  }
}

The project is running:

"webpack": "^4.46.0",
"@angular/compiler": "^10.2.5"
@PandaCodes
Copy link
Contributor

PandaCodes commented Sep 13, 2021

Hello, @hishtadlut , thank you for reporting this. There is apparently a bug in peerjs library when it is compiled with the angular compiler.
Here is the living issue. People there propose a hack to declare var parcelRequire; before importing peerjs (in our case tracker-assist) package.

You could try it. If it works, I'll add it to the package on the next release for angular users.

@hishtadlut
Copy link
Author

I can confirm that after adding to index.html:

<script>
    var parcelRequire;
</script>

The compile error has disappeared

@PandaCodes
Copy link
Contributor

This fix-hack was added in version 3.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assist bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants