Skip to content

Commit 8dbadad

Browse files
authored
feat(android): allow opt-out for new lifecycle methods (#256)
1 parent 226a9e4 commit 8dbadad

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

packages/core/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ repositories {
3939
}
4040

4141
dependencies {
42-
api 'com.segment.analytics.android:analytics:4.9.0'
42+
api 'com.segment.analytics.android:analytics:4.9.1-beta'
4343

4444
api 'com.facebook.react:react-native:+'
4545
api "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : defaultKotlinVersion}"

packages/core/android/src/main/java/com/segment/analytics/reactnative/core/RNAnalyticsModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
139139
if(androidOptions.hasKey("collectDeviceId")) {
140140
builder.collectDeviceId(androidOptions.getBoolean("collectDeviceId"))
141141
}
142+
if(androidOptions.hasKey("experimentalUseNewLifecycleMethods")) {
143+
builder.experimentalUseNewLifecycleMethods(androidOptions.getBoolean("experimentalUseNewLifecycleMethods"))
144+
}
142145
}
143146

144147
if(options.getBoolean("debug")) {

packages/core/docs/classes/analytics.client.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
**● ready**: *`false`* = false
4242

43-
*Defined in [analytics.ts:146](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L146)*
43+
*Defined in [analytics.ts:152](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L152)*
4444

4545
Whether the client is ready to send events to Segment.
4646

@@ -56,7 +56,7 @@ ___
5656

5757
**alias**(newId: *`string`*, options?: *[Options]()*): `Promise`<`void`>
5858

59-
*Defined in [analytics.ts:324](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L324)*
59+
*Defined in [analytics.ts:330](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L330)*
6060

6161
Merge two user identities, effectively connecting two sets of user data as one. This may not be supported by all integrations.
6262

@@ -78,7 +78,7 @@ ___
7878

7979
**catch**(handler: *[ErrorHandler]()*): `this`
8080

81-
*Defined in [analytics.ts:161](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L161)*
81+
*Defined in [analytics.ts:167](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L167)*
8282

8383
Catch React-Native bridge errors
8484

@@ -99,7 +99,7 @@ ___
9999

100100
**disable**(): `Promise`<`void`>
101101

102-
*Defined in [analytics.ts:363](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L363)*
102+
*Defined in [analytics.ts:369](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L369)*
103103

104104
Completely disable the sending of any analytics data.
105105

@@ -114,7 +114,7 @@ ___
114114

115115
**enable**(): `Promise`<`void`>
116116

117-
*Defined in [analytics.ts:353](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L353)*
117+
*Defined in [analytics.ts:359](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L359)*
118118

119119
Enable the sending of analytics data. Enabled by default.
120120

@@ -129,7 +129,7 @@ ___
129129

130130
**flush**(): `Promise`<`void`>
131131

132-
*Defined in [analytics.ts:344](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L344)*
132+
*Defined in [analytics.ts:350](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L350)*
133133

134134
Trigger an upload of all queued events.
135135

@@ -144,7 +144,7 @@ ___
144144

145145
**getAnonymousId**(): `Promise`<`string`>
146146

147-
*Defined in [analytics.ts:368](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L368)*
147+
*Defined in [analytics.ts:374](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L374)*
148148

149149
Retrieve the anonymousId.
150150

@@ -157,7 +157,7 @@ ___
157157

158158
**group**(groupId: *`string`*, traits?: *[JsonMap]()*, options?: *[Options]()*): `Promise`<`void`>
159159

160-
*Defined in [analytics.ts:311](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L311)*
160+
*Defined in [analytics.ts:317](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L317)*
161161

162162
Associate a user with a group, organization, company, project, or w/e _you_ call them.
163163

@@ -180,7 +180,7 @@ ___
180180

181181
**identify**(user: *`string`*, traits?: *[JsonMap]()*, options?: *[Options]()*): `Promise`<`void`>
182182

183-
*Defined in [analytics.ts:298](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L298)*
183+
*Defined in [analytics.ts:304](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L304)*
184184

185185
Associate a user with their unique ID and record traits about them.
186186

@@ -203,7 +203,7 @@ ___
203203

204204
**middleware**(middleware: *[Middleware]()*): `this`
205205

206-
*Defined in [analytics.ts:207](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L207)*
206+
*Defined in [analytics.ts:213](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L213)*
207207

208208
Append a new middleware to the middleware chain.
209209

@@ -241,7 +241,7 @@ ___
241241

242242
**reset**(): `Promise`<`void`>
243243

244-
*Defined in [analytics.ts:334](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L334)*
244+
*Defined in [analytics.ts:340](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L340)*
245245

246246
Reset any user state that is cached on the device.
247247

@@ -256,7 +256,7 @@ ___
256256

257257
**screen**(name: *`string`*, properties?: *[JsonMap]()*, options?: *[Options]()*): `Promise`<`void`>
258258

259-
*Defined in [analytics.ts:283](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L283)*
259+
*Defined in [analytics.ts:289](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L289)*
260260

261261
Record the screens or views your users see.
262262

@@ -279,7 +279,7 @@ ___
279279

280280
**setIDFA**(idfa: *`string`*): `void`
281281

282-
*Defined in [analytics.ts:171](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L171)*
282+
*Defined in [analytics.ts:177](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L177)*
283283

284284
Sets the IDFA value on iOS. Customers are now responsible for collecting IDFA on their own.
285285

@@ -298,7 +298,7 @@ ___
298298

299299
**setup**(writeKey: *`string`*, configuration?: *[Configuration](../interfaces/analytics.configuration.md)*): `Promise`<`void`>
300300

301-
*Defined in [analytics.ts:246](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L246)*
301+
*Defined in [analytics.ts:252](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L252)*
302302

303303
Setup the Analytics module. All calls made before are queued and only executed if the configuration was successful.
304304

@@ -328,7 +328,7 @@ ___
328328

329329
**track**(event: *`string`*, properties?: *[JsonMap]()*, options?: *[Options]()*): `Promise`<`void`>
330330

331-
*Defined in [analytics.ts:265](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L265)*
331+
*Defined in [analytics.ts:271](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L271)*
332332

333333
Record the actions your users perform.
334334

@@ -351,7 +351,7 @@ ___
351351

352352
**useNativeConfiguration**(): `this`
353353

354-
*Defined in [analytics.ts:219](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L219)*
354+
*Defined in [analytics.ts:225](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L225)*
355355

356356
Use the native configuration.
357357

packages/core/src/analytics.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,14 @@ export module Analytics {
133133
* Enabled by default.
134134
*/
135135
collectDeviceId?: boolean
136-
}
137-
}
136+
137+
/**
138+
* Whether the analytics client should use the new lifecycle methods. This option is enabled by default.
139+
* If the new lifecycle methods cause issue, you should disable this config option
140+
*/
141+
experimentalUseNewLifecycleMethods?: boolean
142+
}
143+
}
138144

139145
export class Client {
140146
/**

0 commit comments

Comments
 (0)