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
| import Segment from "analytics-react-native"; | |
| export const instance = new Segment( | |
| 'YOUR_WRITE_KEY', | |
| { | |
| proxy: { | |
| scheme: 'http', | |
| host: 'localhost', | |
| port: 3000, | |
| path: '/analytics/segment' |
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
| import { instance } from './analytics'; | |
| // These events will be sent to your server instead of Segment's | |
| instance.identify('some-user-id', { customProperty: 'custom value' }); | |
| instance.track('Custom Event', { userId: 'some-user-id' }); |
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
| import express from 'express'; | |
| import Segment from 'analytics-node'; | |
| const instance = new Segment('YOUR_WRITE_KEY'); | |
| const port = 3000; | |
| const app = express(); | |
| // Enables JSON parsing middleware | |
| app.use(express.json()) |
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
| import { useReducer } from 'react'; | |
| /** | |
| * There are much better ways to type this | |
| * but this is not the focus of this gist. | |
| */ | |
| interface HTTPState<T> { | |
| status: 'loading' | 'error' | 'success' | |
| error?: string | |
| data?: T |