Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/vtex/angular-intercom

Intercom wrapper for Angular
https://github.com/vtex/angular-intercom

srv-oms-ui xp-post-purchase

Last synced: about 1 month ago
JSON representation

Intercom wrapper for Angular

Awesome Lists containing this project

README

        

# Angular Intercom
Intercom wrapper for Angular

## Usage

### Reference script
```html

```

### Inject `vtex.intercom`
```coffeescript
angular.module 'yourApp', ['vtex.intercom']
```

### Fill `intercomConfig`
This object should contain at least your Intercom application credentials (`app_id`) and main user data, such as name, email, age, etc.

```coffeescript
.config (intercomConfig) ->
intercomConfig.app_id = 'bs8us8hw'
intercomConfig.user = window.vtex.topbar.utils.user # `Object`

# e.g.: Custom widget/button that pops Intercom conversation modal:
# intercomConfig.widget =
# activator: '#vtex-intercom-widget'
# See Intercom docs for more
```

##### Send all user data you want by extending `intercomUserData` as well
This is mainly for extra user data, such as environment of access and all other info your `user` object lacks. Feel free to send whatever back to your Intercom.

```coffeescript
.value 'intercomUserData',
'Store': vtex.topbar.utils.config.store
'Environment': vtex.topbar.topbar.environment.match(/beta|stable/)[0] ? 'stable'
```

### Directive and binding
Defaults and shortcuts:
- `intercom-event`: Event name, be creative. ( `String` )
- `intercom-on`: "click" ( *this is what fires events to Intercom*, e.g.: "hover", "mouseleave" )
- `intercom-metadata`: Whatever extra info to send along

Example:
```html

```

### API `intercomService`
#### trigger eventName, data
- string `eventName`, Object `data` with any information you want to be registered within the event

#### updateUser data
- Object `data` with new (full or partial) user data to be updated and send

### Development
Inside `src` you can find this module source code, written in **CoffeeScript**. To build the `.js` and uglify it, install npm dev-dependencies and run grunt:

(sudo) npm i
grunt

**Don't forget to build after updating the version and before committing any changes, since it's version appears in minified files.**