Skip to content

js interop works, but analyzer doesn't like it #25321

Closed
@kasperpeulen

Description

@kasperpeulen

So I basically trying to write a interop for the ga function of google analytics.
The problem is that it is not only a function, but also exposes properties (l and q).

The following code, actually runs, and sends pageview events to google analytics. The only way to make the analyzer happy is add a call method. However, if I do that, dart2js breaks.

So basically, this codes works fine, but I just want to silence the analyzer.

import 'package:js/js.dart';

@JS('ga')
external Ga get ga;

@JS('ga')
class Ga {
  external int get l;

  external set l(int l);

  external List get q;

  external set q(List q);
}

class Analytics {
  Analytics(String trackingNumber) {
    ga.l = new DateTime.now().millisecondsSinceEpoch;
    ga('create', trackingNumber, 'auto');
  }

  send(String event) {
    ga('send', event);
  }
}

Metadata

Metadata

Assignees

Labels

web-js-interopIssues that impact all js interop

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions