Skip to content

Instantly share code, notes, and snippets.

@unity
unity / capture-calendly.js
Created May 22, 2019 09:43
Capture Calendly Webhooks and track them as User Events
const { payload = {}, event: event_action = {} } = body;
const { event = {}, event_type = {}, invitee = {}, questions_and_answers, time } = payload;
const { name: event_name } = event_type;
const { email } = invitee;
const ident = {
email,
anonymous_id: email
}
@unity
unity / main.yml
Last active June 17, 2022 08:17
Homeassistant-ansible
#########################################################################
# Title: Cloudbox: Homeassistant Role #
# Author(s): l3uddz, desimaniac #
# URL: https://github.com/cloudbox/cloudbox #
# Docker Image: homeassistant/home-assistant #
# -- #
# Part of the Cloudbox project: https://cloudbox.works #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
@unity
unity / new-node8-.circleci-config.yml
Created August 28, 2018 08:36 — forked from michaloo/legacy-node6-.circleci-config.yml
Connector engines definition and CircleCI configuration
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
- image: circleci/node:8.9
working_directory: ~/repo
// Check if they have a Twitter handle
const { twitter_handle } = user.clearbit || {};
const { fetched_at } = user.social_profiles || {};
if (fetched_at || !twitter_handle) return true;
const fetched_at = new Date().toISOString();
hull.traits({ fetched_at }, { source: 'social_profiles' });
const unlessError = callback => (error, response) => {
@unity
unity / post_nps.js
Last active August 10, 2018 14:47
Writes an attribute at the user level indicating the direction the NPS score is going. This way you can easily find all users who are decreasing in nps rating
//Returns the category of the customer based on the NPS score,
const getCategory = nps => {
if (nps > 8) return "promoter";
if (nps > 6) return "passive";
return "detractor";
}
if (changes && changes.user) {
const { nps_rating } = changes.user;
// If the NPS Rating Changes
if (isInSegment("Highly Qualified") && isInSegment("Connected This week")) {
traits({ category: 'active' });
} else if (isInSegment("Not Qualified") && !isInSegment("Connected This week")) {
traits({ category: 'no_fit' });
} else if (isInSegment("Highly Qualified") && !isInSegment("Connected This week")) {
traits({ category: 'churn_risk' });
} else if (isInSegment("Not Qualified") && isInSegment("Connected This week")) {
traits({ category: 'needs_onboarding' });
} else {
traits({ category: 'manual_operation' });
//Create an array of all the points we give
const scores = [];
//Helper method to push to the scores array.
const addToScore = points => points && scores.push(points);
//Scoring based on User Attributes.
const {
is_beta,
type FirehoseEvent = {
claims: FirehoseClaim,
params: TrackParams | TraitsParams | AliasParams,
context: TrackContext | TrackContext | AliasContext
};
type Metric: {
[ToBeDetermined]: any
};