@@ -5,9 +5,18 @@ export default {
55 key : "intercom-new-conversation-rating-added" ,
66 name : "New Conversation Rating Added" ,
77 description : "Emit new event each time a new rating is added to a conversation." ,
8- version : "0.0.3 " ,
8+ version : "0.0.4 " ,
99 type : "source" ,
1010 dedupe : "unique" ,
11+ props : {
12+ ...common . props ,
13+ newConversationsOnly : {
14+ type : "boolean" ,
15+ label : "New Conversations Only" ,
16+ description : "Set to `true` to only emit events for new conversations" ,
17+ optional : true ,
18+ } ,
19+ } ,
1120 methods : {
1221 ...common . methods ,
1322 generateMeta ( conversation ) {
@@ -20,7 +29,8 @@ export default {
2029 } ,
2130 } ,
2231 async run ( ) {
23- let lastRatingCreatedAt = this . _getLastUpdate ( ) ;
32+ const lastRatingCreatedAt = this . _getLastUpdate ( ) ;
33+ let maxLastRatingCreatedAt = lastRatingCreatedAt ;
2434 const data = {
2535 query : {
2636 field : "conversation_rating.requested_at" ,
@@ -32,12 +42,14 @@ export default {
3242 const results = await this . intercom . searchConversations ( data ) ;
3343 for ( const conversation of results ) {
3444 const createdAt = conversation . conversation_rating . created_at ;
35- if ( createdAt > lastRatingCreatedAt )
36- lastRatingCreatedAt = createdAt ;
37- const meta = this . generateMeta ( conversation ) ;
38- this . $emit ( conversation , meta ) ;
45+ if ( createdAt > maxLastRatingCreatedAt )
46+ maxLastRatingCreatedAt = createdAt ;
47+ if ( ! this . newConversationsOnly || conversation . created_at > lastRatingCreatedAt ) {
48+ const meta = this . generateMeta ( conversation ) ;
49+ this . $emit ( conversation , meta ) ;
50+ }
3951 }
4052
41- this . _setLastUpdate ( lastRatingCreatedAt ) ;
53+ this . _setLastUpdate ( maxLastRatingCreatedAt ) ;
4254 } ,
4355} ;
0 commit comments