@satisfactor/web-integration-angular
Version:
This package helps you integrate the satisfaction survey into any website implemented in angular
93 lines (85 loc) • 3.16 kB
JavaScript
import { __decorate } from 'tslib';
import { ɵɵdefineInjectable, Injectable, Input, Component, NgModule } from '@angular/core';
let SatisfactorService = class SatisfactorService {
constructor() {
}
};
SatisfactorService.ɵprov = ɵɵdefineInjectable({ factory: function SatisfactorService_Factory() { return new SatisfactorService(); }, token: SatisfactorService, providedIn: "root" });
SatisfactorService = __decorate([
Injectable({
providedIn: 'root'
})
], SatisfactorService);
/**
* UserSurvey
*/
class UserSurveyModel {
constructor(id, name, email, cellPhone, company) {
this.id = id;
this.name = name !== undefined ? name : null;
this.email = email !== undefined ? email : null;
this.cellPhone = cellPhone !== undefined ? cellPhone : null;
this.company = company !== undefined ? company : null;
}
isValid() {
return this.id !== undefined;
}
}
let SatisfactorComponent = class SatisfactorComponent {
constructor() {
}
loadScript() {
console.log(this.userSurvey);
console.log(this.projectToken);
if (this.userSurvey instanceof UserSurveyModel && this.userSurvey.isValid()) {
const script = document.createElement('script');
script.type = 'text/javascript';
script.innerHTML = `!function(){window.satisfactor=window.satisfactor||function(){(window.satisfactor.value=window.satisfactor.value||[]).push(arguments)};var e=document.createElement("script"),t=document.getElementsByTagName("script")[0].parentNode;e.async=1,e.src="https://app.satisfactor.io/js/nps.min.js",t.appendChild(e);var s=document.createElement("link"),a=document.getElementsByTagName("head")[0];s.type="text/css",s.rel="stylesheet",s.href="https://app.satisfactor.io/css/nps.min.css",a.appendChild(s)}();
satisfactor({
token: "${this.projectToken}",
userId: "${this.userSurvey.id}",
traits: {
name: "${this.userSurvey.name}",
email: "${this.userSurvey.email}",
cell_phone: "${this.userSurvey.cellPhone}",
company: "${this.userSurvey.company}"
}
});`;
document.getElementsByTagName('body')[0].appendChild(script);
}
}
ngOnInit() {
this.loadScript();
}
};
__decorate([
Input()
], SatisfactorComponent.prototype, "userSurvey", void 0);
__decorate([
Input()
], SatisfactorComponent.prototype, "projectToken", void 0);
SatisfactorComponent = __decorate([
Component({
selector: 'satisfactor',
template: ``
})
], SatisfactorComponent);
let SatisfactorModule = class SatisfactorModule {
};
SatisfactorModule = __decorate([
NgModule({
declarations: [SatisfactorComponent],
imports: [],
exports: [
SatisfactorComponent,
]
})
], SatisfactorModule);
/*
* Public API Surface of satisfactor
*/
/**
* Generated bundle index. Do not edit.
*/
export { SatisfactorComponent, SatisfactorModule, SatisfactorService, UserSurveyModel };
//# sourceMappingURL=satisfactor-web-integration-angular.js.map