From 8d02cd7e587350e8363ea942ff91328b44c830d5 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Mon, 6 Apr 2020 15:42:51 -0700 Subject: [PATCH 1/3] fix(android): fixed issued with defautKotlinVersion not being found --- packages/core/android/build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index d621a67c4..10802d172 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -1,19 +1,20 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' -def defaultKotlinVersion = '1.3.21' def safeExtGet(prop, fallback) { - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback + return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } buildscript { + def defaultKotlinVersion = '1.3.21' + repositories { jcenter() maven { url 'https://maven.google.com' } } dependencies { classpath 'com.android.tools.build:gradle:3.1.4' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet("kotlinVersion", defaultKotlinVersion)}" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : defaultKotlinVersion}" } } @@ -37,10 +38,9 @@ repositories { mavenCentral() } - dependencies { api 'com.segment.analytics.android:analytics:4.5.0-beta.0' api 'com.facebook.react:react-native:+' - api "org.jetbrains.kotlin:kotlin-stdlib:${safeExtGet("kotlinVersion", defaultKotlinVersion)}" + api "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : defaultKotlinVersion}" } From e1c32f9613c643b063c939e2b65b63b8d9261506 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Mon, 6 Apr 2020 15:49:21 -0700 Subject: [PATCH 2/3] fix(android): fixed dependency reference --- packages/integrations/template/android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/template/android/build.gradle b/packages/integrations/template/android/build.gradle index bfb01e301..e306eebeb 100644 --- a/packages/integrations/template/android/build.gradle +++ b/packages/integrations/template/android/build.gradle @@ -41,7 +41,7 @@ repositories { dependencies { - api project(":@segment/analytics-react-native") + api project(":@segment_analytics-react-native") api('{{{dependency}}}') { transitive = true } From 8e26e2107c76ac74115ad94a756c329aeb055864 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Mon, 6 Apr 2020 17:24:27 -0700 Subject: [PATCH 3/3] fix(android): correct segment reference in integration generator --- .../core/docs/classes/analytics.client.md | 83 +++++++++++++++++++ .../interfaces/analytics.configuration.md | 22 +++++ packages/integrations/src/gen-integrations.ts | 2 +- 3 files changed, 106 insertions(+), 1 deletion(-) diff --git a/packages/core/docs/classes/analytics.client.md b/packages/core/docs/classes/analytics.client.md index c41f78018..db9fd229d 100644 --- a/packages/core/docs/classes/analytics.client.md +++ b/packages/core/docs/classes/analytics.client.md @@ -41,6 +41,10 @@ *Defined in analytics.ts:96* +Whether the client is ready to send events to Segment. + +This becomes `true` when `.setup()` succeeds. All calls will be queued until it becomes `true`. + ___ ## Methods @@ -53,6 +57,10 @@ ___ *Defined in analytics.ts:266* +Merge two user identities, effectively connecting two sets of user data as one. This may not be supported by all integrations. + +When you learn more about who the group is, you can record that information with group. + **Parameters:** | Name | Type | Default value | Description | @@ -71,6 +79,10 @@ ___ *Defined in analytics.ts:111* +Catch React-Native bridge errors + +These errors are emitted when calling the native counterpart. This only applies to methods with no return value (`Promise`), methods like `getAnonymousId` do reject promises. + **Parameters:** | Name | Type | @@ -88,6 +100,10 @@ ___ *Defined in analytics.ts:305* +Completely disable the sending of any analytics data. + +If you have a way for users to actively or passively (sometimes based on location) opt-out of analytics data collection, you can use this method to turn off all data collection. + **Returns:** `Promise`<`void`> ___ @@ -99,6 +115,10 @@ ___ *Defined in analytics.ts:295* +Enable the sending of analytics data. Enabled by default. + +Occasionally used in conjunction with disable user opt-out handling. + **Returns:** `Promise`<`void`> ___ @@ -110,6 +130,10 @@ ___ *Defined in analytics.ts:286* +Trigger an upload of all queued events. + +This is useful when you want to force all messages queued on the device to be uploaded. Please note that not all integrations respond to this method. + **Returns:** `Promise`<`void`> ___ @@ -121,6 +145,8 @@ ___ *Defined in analytics.ts:310* +Retrieve the anonymousId. + **Returns:** `Promise`<`string`> ___ @@ -132,6 +158,10 @@ ___ *Defined in analytics.ts:253* +Associate a user with a group, organization, company, project, or w/e _you_ call them. + +When you learn more about who the group is, you can record that information with group. + **Parameters:** | Name | Type | Default value | Description | @@ -151,6 +181,10 @@ ___ *Defined in analytics.ts:240* +Associate a user with their unique ID and record traits about them. + +When you learn more about who your user is, you can record that information with identify. + **Parameters:** | Name | Type | Default value | Description | @@ -170,6 +204,27 @@ ___ *Defined in analytics.ts:149* +Append a new middleware to the middleware chain. + +Middlewares are a powerful mechanism that can augment the events collected by the SDK. A middleware is a simple function that is invoked by the Segment SDK and can be used to monitor, modify or reject events. + +Middlewares are invoked for all events, including automatically tracked events, and external event sources like Adjust and Optimizely. This offers you the ability the customize those messages to fit your use case even if the event was sent outside your source code. + +The key thing to observe here is that the output produced by the first middleware feeds into the second. This allows you to chain and compose independent middlewares! + +For example, you might want to record the device year class with your events. Previously, you would have to do this everywhere you trigger an event with the Segment SDK. With middlewares, you can do this in a single place : + +```js +import DeviceYearClass from 'react-native-device-year-class' + +analytics.middleware(async ({next, context}) => + next({ + ...context, + device_year_class: await DeviceYearClass() + }) +) +``` + **Parameters:** | Name | Type | Description | @@ -187,6 +242,10 @@ ___ *Defined in analytics.ts:276* +Reset any user state that is cached on the device. + +This is useful when a user logs out and you want to clear the identity. It will clear any traits or userId's cached on the device. + **Returns:** `Promise`<`void`> ___ @@ -198,6 +257,10 @@ ___ *Defined in analytics.ts:225* +Record the screens or views your users see. + +When a user views a screen in your app, you'll want to record that here. For some tools like Google Analytics and Flurry, screen views are treated specially, and are different from "events" kind of like "page views" on the web. For services that don't treat "screen views" specially, we map "screen" straight to "track" with the same parameters. For example, Mixpanel doesn't treat "screen views" any differently. So a call to "screen" will be tracked as a normal event in Mixpanel, but get sent to Google Analytics and Flurry as a "screen". + **Parameters:** | Name | Type | Default value | Description | @@ -217,6 +280,18 @@ ___ *Defined in analytics.ts:188* +Setup the Analytics module. All calls made before are queued and only executed if the configuration was successful. + +```js +await analytics.setup('YOUR_WRITE_KEY', { + using: [Mixpanel, GoogleAnalytics], + trackAppLifecycleEvents: true, + ios: { + trackDeepLinks: true + } +}) +``` + **Parameters:** | Name | Type | Default value | Description | @@ -235,6 +310,10 @@ ___ *Defined in analytics.ts:207* +Record the actions your users perform. + +When a user performs an action in your app, you'll want to track that action for later analysis. Use the event name to say what the user did, and properties to specify any interesting details of the action. + **Parameters:** | Name | Type | Default value | Description | @@ -254,6 +333,10 @@ ___ *Defined in analytics.ts:161* +Use the native configuration. + +You'll need to call this method when you configure Analytics's singleton using the native API. + **Returns:** `this` ___ diff --git a/packages/core/docs/interfaces/analytics.configuration.md b/packages/core/docs/interfaces/analytics.configuration.md index 3dbb97b8a..86ad65e78 100644 --- a/packages/core/docs/interfaces/analytics.configuration.md +++ b/packages/core/docs/interfaces/analytics.configuration.md @@ -31,6 +31,8 @@ *Defined in analytics.ts:69* +Android specific settings. + ___ @@ -49,6 +51,10 @@ ___ *Defined in analytics.ts:46* +The number of queued events that the analytics client should flush at. Setting this to `1` will not queue any events and will use more battery. + +`20` by default. + ___ @@ -58,6 +64,8 @@ ___ *Defined in analytics.ts:51* +iOS specific settings. + ___ @@ -67,6 +75,10 @@ ___ *Defined in analytics.ts:19* +Whether the analytics client should automatically make a screen call when a view controller is added to a view hierarchy. Because the iOS underlying implementation uses method swizzling, we recommend initializing the analytics client as early as possible. + +Disabled by default. + ___ @@ -76,6 +88,10 @@ ___ *Defined in analytics.ts:26* +Whether the analytics client should automatically track application lifecycle events, such as "Application Installed", "Application Updated" and "Application Opened". + +Disabled by default. + ___ @@ -85,6 +101,10 @@ ___ *Defined in analytics.ts:32* +Whether the analytics client should automatically track attribution data from enabled providers using the mobile service. + +Disabled by default. + ___ @@ -94,5 +114,7 @@ ___ *Defined in analytics.ts:37* +Register a set of integrations to be used with this Analytics instance. + ___ diff --git a/packages/integrations/src/gen-integrations.ts b/packages/integrations/src/gen-integrations.ts index 0405274a8..89bc19652 100644 --- a/packages/integrations/src/gen-integrations.ts +++ b/packages/integrations/src/gen-integrations.ts @@ -69,7 +69,7 @@ async function prepareiOS({ const xcodeProject = 'ios/RNAnalyticsIntegration.xcodeproj' const targetXcodeProject = `ios/${nativeModule}.xcodeproj` const pod_name = `RNAnalyticsIntegration-${slug('-')}` - const framework_name = `Segment_${slug()}` + const framework_name = `Segment-${slug()}` const { pod: { name: pod_dependency = `Segment-${slug()}`,