This file contains 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
import eventTracking from './events'; | |
import { createStore, combineReducers, applyMiddleware } from 'redux'; | |
const trackEvent = (properties, state) => { | |
ReactGA.event(properties); // Track event to google analytics | |
// Here we can get extra data from our state to attach to the event. | |
const bigQueryRecord = createRecord(buildRecordParam(properties, state)); | |
postBigQueryEvent(bigQueryRecord); // Track event to BigQuery | |
}; |
This file contains 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
const events = { | |
'AUTH/LOGIN_SUCCESS': { | |
category: 'auth', | |
action: 'login', | |
eventDataOne: 'user.name', | |
}, | |
'AUTH/INVALID_LOGIN_ATTEMPT': { | |
category: 'auth', | |
action: 'invalid login attempt', | |
eventDataOne: 'user.email', |
This file contains 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
const trackingMiddleware = (store: Store<any>) => (next: Dispatch<any>) => (action: Action) => { | |
if (action.type === '@@router/LOCATION_CHANGE') { | |
const nextPage = `${action.payload.pathname}${action.payload.search}`; | |
trackPage(nextPage, store.getState()); | |
} | |
return next(action); | |
}; | |
function trackPage(page: string, state: any) { | |
ReactGA.set({ |
This file contains 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
const translator = { | |
"Hello": "Hola" | |
}; | |
function spanish(strings, ...values) { | |
return strings.reduce(function(str, val, idx) { | |
return str + (idx > 0 ? translator[values[idx - 1]] : '') + val; | |
}, ''); | |
} |
This file contains 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
function foo(strings, ...values) { | |
return strings.reduce(function(str, val, idx) { | |
/* | |
We do the 'idx > 0 ? values[idx - 1]' part because of the starting point in the accumlator (''). | |
That will be the first section of the string. | |
*/ | |
return str + (idx > 0 ? values[idx - 1] : '') + val | |
}, ''); | |
} | |
const name = 'Marques'; |
This file contains 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
function foo(strings, ...values) { | |
console.log("Strings - ", strings); | |
console.log("Values - ", values); | |
} | |
const name = 'marques'; | |
foo`My name is ${name}.`; | |
// Strings - ["My name is ", "."] | |
// Values - ["marques"] |
This file contains 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
import { | |
Component, | |
Template, | |
For, | |
If, | |
bootstrap, | |
Parent, | |
DynamicComponent} from 'angular2/angular2'; | |
import MovieFactory from './services/movieFactory'; |
This file contains 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
var jobs = { | |
generatorCC(chargeId, amount) { | |
stripe.charges.capture(chargeId, {amount}, function(err, charge) { | |
if (err) { | |
it.throw(err); | |
} | |
it.next(charge); | |
}.bind(this)); | |
}, |