Add a snippet class for generating the Intercom snippet#164
Merged
Conversation
e4eaa7a to
aa21597
Compare
238ef4b to
6bc6066
Compare
| } | ||
| } | ||
| }); | ||
| return intercomSettings.join(', '); |
Contributor
There was a problem hiding this comment.
intercomSettings needs to be an array?
Member
Author
There was a problem hiding this comment.
Doesn't have to be. I figured keeping each key / value pair as an element in an array makes it much easier to join them into a string and not have to worry about where you need to add commas.
Member
Author
There was a problem hiding this comment.
No, JSON.stringify will quote literally everything (including the braces for the hash), so you'd get this:
const settings = {
app_id: 'abc123',
name: 'Peter McKenna',
user_id: 1
};
// Returns '{"app_id":"abc123","name":"Peter McKenna","user_id":1}'
JSON.stringify(settings);It also quotes the key values, which I guess isn't a big deal.
49da5e5 to
cce0788
Compare
kmiyashiro
reviewed
Oct 18, 2017
| if (!settings.verificationSecret) { | ||
| throw new Error('You must provide your verification secret in your Intercom settings'); | ||
| } | ||
| if (!settings.user_id && !settings.email) { |
There was a problem hiding this comment.
Can we make this snippet work for logged out mode as well?
Member
Author
There was a problem hiding this comment.
This supports logged out now.
cce0788 to
46eff5b
Compare
kmiyashiro
approved these changes
Oct 18, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a
Snippetclass to the Node client, which is exposed through the client like so:It returns the full snippet, including the
user_hash.