- For my app, I am attempting to incorporate intercom for monitoring user activity.
- It functions correctly when placed inside a script tag in index.html.
- However, I encounter an error when trying to use it in a .ts file as shown below: app/components/rocket/rocket-search.ts(63,10): error TS2339: Property 'intercomSettings' does not exist on type 'Window'.
- Could you please advise on how to rectify this issue?
- Below is the code snippet that I have provided:
Code that isn't functioning:
import { Component, ElementRef, Input, Output, EventEmitter, Inject, OnInit, ViewChild } from '@angular/core';
import { KendoGridComponent } from '../grid/grid.component'
import { Router } from '@angular/router';
import { sportsService } from '../../services/sports.service';
@Component({
selector: 'rocketSearch',
templateUrl: "./app/components/rocket/rocket-search.html",
})
export class rocketSearch {
/* Localization variables */
@Output() rocketSearchEmitter: EventEmitter<any> = new EventEmitter<any>();
private dataSourceVal;
private MainGrid;
private grid;
private titles;
public rocketRef;
constructor( public elementRef: ElementRef, public router: Router, public sportsService: sportsService) {
}
private kendocommand = {
edit: { createAt: "bottom" },
autoBind: false,
excelFileName: {
fileName: "",
allPages: true
}
}
ngOnInit() {
let that = this;
let attributes = this.sportsService.getSeesionStorageValue();
window.intercomSettings = {
app_id: 'irgooiqb',
name: "Jane Doe", // Full name
email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="25465056514a48405765405d54416056487453954c4054">[email protected]</a>", // Email address
created_at: 1312182000 // Signup date as a Unix timestamp
};
}
}
Functioning code within index.html:
<script>
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/APP_ID';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()
</script>
<script>
let players=this.sportsService.marksSession();
console.log("players--->" + players);
if(players) {
this.userId = players.user_players.SSO[0];
}
Intercom('trackEvent', 'share-link');
window.intercomSettings = {
app_id: 'APP_ID',
name: "Jane Doe", // Full name
email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a7c4d2d4d3c8cac2d5e7c2efc891cdc1c3">[email protected]</a>", // Email address
created_at: 1312182000 // Signup date as a Unix timestamp
};
</script>