Skip to content

Instantly share code, notes, and snippets.

@diegodfsd
Created April 24, 2017 14:18
Show Gist options
  • Save diegodfsd/0038d80cf653187eb30dce503285d5b1 to your computer and use it in GitHub Desktop.
Save diegodfsd/0038d80cf653187eb30dce503285d5b1 to your computer and use it in GitHub Desktop.
<script data-cfasync="false">
window.civchat = {
apiKey: "RnPwwO6i9FjR2jfUUZ25ojfvXBWZiYDdC0dzy2XNrj1MQIk8gjTRozQiXlRHcm30",
name: "",
email: ""
};
</script>
<script data-cfasync="false" src="https://widget.userengage.io/widget.js"></script>
import { Component, OnInit } from '@angular/core';
import { SessionService } from '../shared/session.service';
@Component({
selector: 'user-engage',
templateUrl: './user-engage.component.html',
styleUrls: ['./user-engage.component.scss']
})
export class UserEngageComponent implements OnInit {
private apiKey: string = 'user-engage-key';
constructor(private userSession: SessionService) { }
ngOnInit() {
this.userSession.currentUser.subscribe(profile => {
const w: any = window;
w.UE.resetAuth(this.getAuth(profile));
});
}
private getAuth(profile: any): any {
if (!profile) {
return {
apiKey: this.apiKey,
name: "",
email: ""
};
}
return {
apiKey: this.apiKey,
name: profile.fullname,
email: profile.email
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment