如何将mixpanel与angular2整合 [英] How to integrate mixpanel with angular2
本文介绍了如何将mixpanel与angular2整合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在index.html中,我添加了 https://mixpanel.com/help/reference/中的mixpanel代码javascript 。
In index.html I have added mixpanel code from https://mixpanel.com/help/reference/javascript.
在我的
export class MixpanelService {
constructor() {
mixpanel.init("sdfsdf", '', "development");
}
public track() {
mixpanel.track('click', {pageName:'login'})
}
}
收到以下错误:
Cannot find name 'mixpanel'.
mixpanel.init("sdfsdf", '', "development");
有人可以帮我这个。
推荐答案
- 在全局级别安装Typings,这将有助于我们安装JS库的定义。
npm install -g typings - 安装mixpaneljs
npm install mixpanel --save-dev - 运行以下命令创建打字defincation到typings.json
typings install dt~mixpanel --save --global
在您的mixpanelService.ts文件中
In your mixpanelService.ts file
import * as Mixpanel from "mixpanel";
this.mixpanel = Mixpanel.default.init(token, properties);
这篇关于如何将mixpanel与angular2整合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文