Skip to content

Commit

Permalink
Merge pull request #75 from CaliStyle/wilson-app-id
Browse files Browse the repository at this point in the history
(fix): allow app_id to be passed into Boot (fixes #72)
  • Loading branch information
scott-wyatt authored Nov 12, 2018
2 parents 9eef71c + 826dafe commit ed36fe6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/app/ng-intercom-testing/intercom-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Router } from '@angular/router'
import { isPlatformBrowser } from '@angular/common'

import { IntercomConfig } from '../ng-intercom/shared/intercom-config'
import { Any, BootInput } from '../ng-intercom/types/boot-input'
import { BootInput } from '../ng-intercom/types/boot-input'
import { Intercom } from '../ng-intercom/intercom/intercom'

/**
Expand Down Expand Up @@ -61,7 +61,7 @@ export class IntercomMocks extends Intercom {
* Calling the update method with a JSON object of user details will update those fields on the current user
* in addition to logging an impression at the current URL and looking for new messages for the user.
*/
public update(data?: Any): void {
public update(data?: any): void {
return
}

Expand Down
8 changes: 4 additions & 4 deletions src/app/ng-intercom/intercom/intercom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Router } from '@angular/router'
import { isPlatformBrowser } from '@angular/common'

import { IntercomConfig } from '../shared/intercom-config'
import { Any, BootInput } from '../types/boot-input'
import { BootInput } from '../types/boot-input'

/**
* A provider with every Intercom.JS method
Expand Down Expand Up @@ -59,13 +59,13 @@ export class Intercom {
if (!isPlatformBrowser(this.platformId)) {
return
}

const app_id = intercomData.app_id ? intercomData.app_id : this.config.appId
// Run load and attach to window
this.loadIntercom(this.config, (event?: Event) => {
// then boot the intercom js
const data = {
...intercomData,
app_id: this.config.appId
app_id
}

return this.callIntercom('boot', data)
Expand Down Expand Up @@ -95,7 +95,7 @@ export class Intercom {
* Calling the update method with a JSON object of user details will update those fields on the current user
* in addition to logging an impression at the current URL and looking for new messages for the user.
*/
public update(data?: Any): void {
public update(data?: any): void {
if (!isPlatformBrowser(this.platformId)) {
return
}
Expand Down
22 changes: 7 additions & 15 deletions src/app/ng-intercom/types/boot-input.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
export interface UserWithEmail {
email?: string;
}

export interface UserWithUid {
export interface BootInput {
custom_launcher_selector?: string;
user_id?: string;
}

export interface Any {
email?: string;
/**
* If no app_id is passed, the value on config will be used
*/
app_id?: string;
[propName: string]: any;
}

export interface DefaultBootInput {
custom_launcher_selector?: string;
}

export type BootInput = ((UserWithEmail | UserWithUid) & DefaultBootInput & Any) | DefaultBootInput

0 comments on commit ed36fe6

Please sign in to comment.