Skip to content

Commit

Permalink
Merge pull request #315 from backbonelabs/firehose
Browse files Browse the repository at this point in the history
Firehose
  • Loading branch information
kevhuang authored Jun 16, 2017
2 parents b78ec7b + 0fefd8e commit 86e3ace
Show file tree
Hide file tree
Showing 465 changed files with 65,572 additions and 630 deletions.
2 changes: 2 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ dependencies {
compile "com.mixpanel.android:mixpanel-android:4.+"
compile "com.jakewharton.timber:timber:4.3.1"
compile "com.facebook.fresco:animated-gif:0.11.0"
compile "com.amazonaws:aws-android-sdk-core:2.2.+"
compile "com.amazonaws:aws-android-sdk-kinesis:2.2.+"
}

// Run this once to be able to run the application with BUCK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new EnvironmentModule(reactContext));
modules.add(UserService.getInstance(reactContext));
modules.add(new Mixpanel(reactContext));
modules.add(BluetoothService.getInstance(reactContext));
modules.add(BootLoaderService.getInstance(reactContext));
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package co.backbonelabs.backbone;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

public class UserService extends ReactContextBaseJavaModule {
private static UserService instance = null;
private ReactApplicationContext reactContext;

private String id;

public static UserService getInstance() {
return instance;
}

public static UserService getInstance(ReactApplicationContext reactContext) {
if (instance == null) {
instance = new UserService(reactContext);
}
return instance;
}

private UserService(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
}

@Override
public String getName() {
return "UserService";
}

public String getUserId() {
return id;
}

@ReactMethod
public void setUserId(String userId) {
id = userId;
}

@ReactMethod
public void unsetUserId() {
id = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,14 @@ public interface MapCallBack {
public static final String NOTIFICATION_PARAMETER_SCHEDULED_MINUTE = "scheduledMinute";
public static final String NOTIFICATION_PARAMETER_SCHEDULED_SECOND = "scheduledSecond";
public static final String NOTIFICATION_PARAMETER_SCHEDULED_TIMESTAMP = "scheduledTimestamp";

public static final String POSTURE_SESSION_PREFERENCES = "co.backbonelabs.backbone.POSTURE_SESSION_PREFERENCES";
public static final String POSTURE_SESSION_PREFERENCE_SESSION_ID = "sessionId";
public static final String POSTURE_SESSION_PREFERENCE_START_TIMESTAMP = "startTimestamp";

public static final String AMAZON_COGNITO_IDENTITY_POOL = "us-west-2:70f7284b-3235-4b4d-82d5-bab9df3d80f5";
public interface FIREHOSE_STREAMS {
String POSTURE_SESSION_STREAM = "PostureSessionAccelerometerDeliveryStream";
String POSTURE_SESSION = "PostureSessionDeliveryStream";
}
}
20 changes: 15 additions & 5 deletions app/actions/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import constants from '../utils/constants';
import Bugsnag from '../utils/Bugsnag';
import Mixpanel from '../utils/Mixpanel';

const { Environment } = NativeModules;
const { Environment, UserService } = NativeModules;
const { storageKeys, errorMessages } = constants;

const handleNetworkError = mixpanelEvent => {
Expand Down Expand Up @@ -42,12 +42,16 @@ export default {
throw new Error(body.error);
} else {
const { accessToken, ...userObj } = body;
const id = userObj._id;

// Store user id on the native side
UserService.setUserId(id);

// Identify user for Bugsnag
Bugsnag.setUser(userObj._id, userObj.nickname, userObj.email);
Bugsnag.setUser(id, userObj.nickname, userObj.email);

// Identify user for Mixpanel tracking
Mixpanel.identify(userObj._id);
Mixpanel.identify(id);

// Update user profile on Mixpanel
Mixpanel.setUserProperties(userObj);
Expand Down Expand Up @@ -83,11 +87,16 @@ export default {

throw new Error(body.error);
} else {
const id = body.user._id;

// Store user id on the native side
UserService.setUserId(id);

// Identify user for Bugsnag
Bugsnag.setUser(body.user._id, body.user.nickname, body.user.email);
Bugsnag.setUser(id, body.user.nickname, body.user.email);

// Identify user for Mixpanel tracking
Mixpanel.identify(body.user._id);
Mixpanel.identify(id);

// Update user profile in Mixpanel
Mixpanel.setUserProperties(body.user);
Expand Down Expand Up @@ -135,6 +144,7 @@ export default {
},

signOut() {
UserService.unsetUserId();
Bugsnag.clearUser();
Mixpanel.track('signOut');

Expand Down
10 changes: 8 additions & 2 deletions app/containers/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const {
Environment,
SessionControlService,
DeviceInformationService,
UserService,
} = NativeModules;

const BluetoothServiceEvents = new NativeEventEmitter(BluetoothService);
Expand Down Expand Up @@ -368,11 +369,16 @@ class Application extends Component {
payload: user,
});

const id = user._id;

// Store user id on the native side
UserService.setUserId(id);

// Identify user for Bugsnag
Bugsnag.setUser(user._id, user.nickname, user.email);
Bugsnag.setUser(id, user.nickname, user.email);

// Identify user for Mixpanel
Mixpanel.identify(user._id);
Mixpanel.identify(id);

if (user.hasOnboarded) {
// User completed onboarding
Expand Down
10 changes: 8 additions & 2 deletions ios/Backbone.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
6625BB8B1DB1E5E9009B4941 /* MixpanelModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 6625BB8A1DB1E5E9009B4941 /* MixpanelModule.m */; };
662BD3491DFC92E900CF71D1 /* Debug.local.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 662BD3481DFC92E900CF71D1 /* Debug.local.xcconfig */; };
662BD36F1DFC933F00CF71D1 /* Release.local.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 662BD36E1DFC933F00CF71D1 /* Release.local.xcconfig */; };
66351EB31EE098B200383F23 /* UserService.m in Sources */ = {isa = PBXBuildFile; fileRef = 66351EB21EE098B200383F23 /* UserService.m */; };
665924E81DD430FA00F5C2C1 /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 665924E71DD430FA00F5C2C1 /* MaterialIcons.ttf */; };
667641271D63B90800D45761 /* Environment.m in Sources */ = {isa = PBXBuildFile; fileRef = 667641261D63B90800D45761 /* Environment.m */; };
66F9187B1DA9F82B00649391 /* Lato.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 66F918791DA9F82B00649391 /* Lato.ttf */; };
Expand Down Expand Up @@ -332,6 +333,8 @@
6625BB8A1DB1E5E9009B4941 /* MixpanelModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MixpanelModule.m; path = backbone/MixpanelModule.m; sourceTree = "<group>"; };
662BD3481DFC92E900CF71D1 /* Debug.local.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.local.xcconfig; path = backbone/config/Debug.local.xcconfig; sourceTree = "<group>"; };
662BD36E1DFC933F00CF71D1 /* Release.local.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Release.local.xcconfig; path = backbone/config/Release.local.xcconfig; sourceTree = "<group>"; };
66351E8E1EE093AE00383F23 /* UserService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserService.h; path = backbone/UserService.h; sourceTree = "<group>"; };
66351EB21EE098B200383F23 /* UserService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UserService.m; path = backbone/UserService.m; sourceTree = "<group>"; };
665924E71DD430FA00F5C2C1 /* MaterialIcons.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = MaterialIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf"; sourceTree = "<group>"; };
667641251D63B8F900D45761 /* Environment.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Environment.h; path = backbone/Environment.h; sourceTree = "<group>"; };
667641261D63B90800D45761 /* Environment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Environment.m; path = backbone/Environment.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -521,6 +524,8 @@
699262611DE58A28003FBBC7 /* SessionControlService.m */,
690301FC1EA7A68C00A59FD4 /* VibrationMotorService.h */,
690301FD1EA7A68D00A59FD4 /* VibrationMotorService.m */,
66351E8E1EE093AE00383F23 /* UserService.h */,
66351EB21EE098B200383F23 /* UserService.m */,
);
name = Backbone;
sourceTree = "<group>";
Expand Down Expand Up @@ -1265,7 +1270,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
C759A8355A6451A7CFEF9959 /* [CP] Check Pods Manifest.lock */ = {
Expand All @@ -1280,7 +1285,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand All @@ -1300,6 +1305,7 @@
files = (
699262621DE58A28003FBBC7 /* SessionControlService.m in Sources */,
667641271D63B90800D45761 /* Environment.m in Sources */,
66351EB31EE098B200383F23 /* UserService.m in Sources */,
69EB80551E0170E200A29ADA /* BootLoaderService.m in Sources */,
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
690301FE1EA7A68D00A59FD4 /* VibrationMotorService.m in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ target 'Backbone' do

# Pods for Backbone
pod 'Mixpanel'
pod 'AWSCognito'
pod 'AWSKinesis'

target 'BackboneTests' do
inherit! :search_paths
Expand Down
14 changes: 12 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
PODS:
- AWSCognito (2.5.6):
- AWSCore (= 2.5.6)
- AWSCore (2.5.6)
- AWSKinesis (2.5.6):
- AWSCore (= 2.5.6)
- Mixpanel (3.0.8):
- Mixpanel/Mixpanel (= 3.0.8)
- Mixpanel/Mixpanel (3.0.8)

DEPENDENCIES:
- AWSCognito
- AWSKinesis
- Mixpanel

SPEC CHECKSUMS:
AWSCognito: 18edcf80780d45229371dc954c77c825c617f9c4
AWSCore: 47109d026cdbc1272624caa73114fbdd2ba3ad66
AWSKinesis: fcd6511b82be0b48c423838de52519e158ba46eb
Mixpanel: 550a23d5dd95f8e9cda21e697661ffddbc8da46b

PODFILE CHECKSUM: 4c137f7b98316ab4d541a1b3fb02f3cbcfd9be85
PODFILE CHECKSUM: bdbd7a22b2cc0156b6967f496ab6ded18243ad73

COCOAPODS: 1.1.1
COCOAPODS: 1.2.1
31 changes: 31 additions & 0 deletions ios/Pods/AWSCognito/AWSCognito/AWSCognito.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions ios/Pods/AWSCognito/AWSCognito/AWSCognitoConflict.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 86e3ace

Please sign in to comment.