Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit a78c94e

Browse files
authored
fix(core): React-Native 0.59 Support (segmentio#50)
- React-Native 0.59 support - Upgrade Detox 9 -> 12 - Upgrade test-app to React-Native 0.59.2 - Commit test-app to git Fixes segmentio#46 Closes segmentio#44 --- Ref: LIB-909
1 parent 9c9faf1 commit a78c94e

File tree

87 files changed

+11955
-1297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+11955
-1297
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ jobs:
100100
- checkout
101101
- *getDeps
102102
- *attach
103-
104103
- run: yarn test-app test:android
105104

106105
test-ios-vanilla:

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
packages/core/docs/
22
build/
33
node_modules/
4+
packages/test-app/seed/

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
]
5959
},
6060
"devDependencies": {
61+
"@babel/core": "^7.4.0",
6162
"@commitlint/cli": "^7.0.0",
6263
"@commitlint/config-conventional": "^7.0.1",
6364
"codecov": "^3.0.4",
@@ -68,8 +69,8 @@
6869
"lint-staged": "^7.2.0",
6970
"npm-run-all": "^4.1.3",
7071
"prettier": "^1.14.2",
71-
"react": "16.6.1",
72-
"react-native": "^0.57.3",
72+
"react": "16.8.3",
73+
"react-native": "0.59.2",
7374
"rimraf": "^2.6.2"
7475
}
7576
}

packages/core/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99
dependencies {
1010
classpath 'com.android.tools.build:gradle:3.1.4'
11-
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60'
11+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21'
1212
}
1313
}
1414

@@ -41,5 +41,5 @@ dependencies {
4141
api 'com.segment.analytics.android:analytics:4.+'
4242

4343
api 'com.facebook.react:react-native:+'
44-
api 'org.jetbrains.kotlin:kotlin-stdlib:1.2.+'
44+
api 'org.jetbrains.kotlin:kotlin-stdlib:1.3.21'
4545
}

packages/core/docs/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222

2323
### Integration
2424

25-
**Ƭ Integration**: * `function` | `object`
26-
*
25+
**Ƭ Integration**: *`function` \| `object`*
2726

28-
*Defined in analytics.ts:8*
27+
*Defined in [analytics.ts:8](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L8)*
2928

3029
___
3130

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
**● ready**: *`false`* = false
4040

41-
*Defined in analytics.ts:96*
41+
*Defined in [analytics.ts:96](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L96)*
4242

4343
Whether the client is ready to send events to Segment.
4444

@@ -54,7 +54,7 @@ ___
5454

5555
**alias**(newId: *`string`*): `Promise`<`void`>
5656

57-
*Defined in analytics.ts:260*
57+
*Defined in [analytics.ts:260](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L260)*
5858

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

@@ -75,7 +75,7 @@ ___
7575

7676
**catch**(handler: *[ErrorHandler]()*): `this`
7777

78-
*Defined in analytics.ts:109*
78+
*Defined in [analytics.ts:109](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L109)*
7979

8080
Catch React-Native bridge errors
8181

@@ -96,7 +96,7 @@ ___
9696

9797
**disable**(): `Promise`<`void`>
9898

99-
*Defined in analytics.ts:299*
99+
*Defined in [analytics.ts:299](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L299)*
100100

101101
Completely disable the sending of any analytics data.
102102

@@ -111,7 +111,7 @@ ___
111111

112112
**enable**(): `Promise`<`void`>
113113

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

116116
Enable the sending of analytics data. Enabled by default.
117117

@@ -126,7 +126,7 @@ ___
126126

127127
**flush**(): `Promise`<`void`>
128128

129-
*Defined in analytics.ts:280*
129+
*Defined in [analytics.ts:280](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L280)*
130130

131131
Trigger an upload of all queued events.
132132

@@ -141,7 +141,7 @@ ___
141141

142142
**group**(groupId: *`string`*, traits?: *[JsonMap]()*): `Promise`<`void`>
143143

144-
*Defined in analytics.ts:247*
144+
*Defined in [analytics.ts:247](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L247)*
145145

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

@@ -163,7 +163,7 @@ ___
163163

164164
**identify**(user: *`string`*, traits?: *[JsonMap]()*): `Promise`<`void`>
165165

166-
*Defined in analytics.ts:235*
166+
*Defined in [analytics.ts:235](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L235)*
167167

168168
Associate a user with their unique ID and record traits about them.
169169

@@ -185,7 +185,7 @@ ___
185185

186186
**middleware**(middleware: *[Middleware]()*): `this`
187187

188-
*Defined in analytics.ts:147*
188+
*Defined in [analytics.ts:147](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L147)*
189189

190190
Append a new middleware to the middleware chain.
191191

@@ -223,7 +223,7 @@ ___
223223

224224
**reset**(): `Promise`<`void`>
225225

226-
*Defined in analytics.ts:270*
226+
*Defined in [analytics.ts:270](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L270)*
227227

228228
Reset any user state that is cached on the device.
229229

@@ -238,7 +238,7 @@ ___
238238

239239
**screen**(name: *`string`*, properties?: *[JsonMap]()*): `Promise`<`void`>
240240

241-
*Defined in analytics.ts:221*
241+
*Defined in [analytics.ts:221](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L221)*
242242

243243
Record the screens or views your users see.
244244

@@ -260,7 +260,7 @@ ___
260260

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

263-
*Defined in analytics.ts:186*
263+
*Defined in [analytics.ts:186](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L186)*
264264

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

@@ -290,7 +290,7 @@ ___
290290

291291
**track**(event: *`string`*, properties?: *[JsonMap]()*): `Promise`<`void`>
292292

293-
*Defined in analytics.ts:203*
293+
*Defined in [analytics.ts:203](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L203)*
294294

295295
Record the actions your users perform.
296296

@@ -312,7 +312,7 @@ ___
312312

313313
**useNativeConfiguration**(): `this`
314314

315-
*Defined in analytics.ts:159*
315+
*Defined in [analytics.ts:159](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L159)*
316316

317317
Use the native configuration.
318318

packages/core/docs/interfaces/analytics.configuration.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727

2828
### `<Optional>` android
2929

30-
**● android**: * `undefined` &#124; `object`
31-
*
30+
**● android**: *`undefined` \| `object`*
3231

33-
*Defined in analytics.ts:69*
32+
*Defined in [analytics.ts:69](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L69)*
3433

3534
Android specific settings.
3635

@@ -39,20 +38,18 @@ ___
3938

4039
### `<Optional>` debug
4140

42-
**● debug**: * `undefined` &#124; `false` &#124; `true`
43-
*
41+
**● debug**: *`undefined` \| `false` \| `true`*
4442

45-
*Defined in analytics.ts:38*
43+
*Defined in [analytics.ts:38](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L38)*
4644

4745
___
4846
<a id="flushat"></a>
4947

5048
### `<Optional>` flushAt
5149

52-
**● flushAt**: * `undefined` &#124; `number`
53-
*
50+
**● flushAt**: *`undefined` \| `number`*
5451

55-
*Defined in analytics.ts:46*
52+
*Defined in [analytics.ts:46](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L46)*
5653

5754
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.
5855

@@ -63,10 +60,9 @@ ___
6360

6461
### `<Optional>` ios
6562

66-
**● ios**: * `undefined` &#124; `object`
67-
*
63+
**● ios**: *`undefined` \| `object`*
6864

69-
*Defined in analytics.ts:51*
65+
*Defined in [analytics.ts:51](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L51)*
7066

7167
iOS specific settings.
7268

@@ -75,10 +71,9 @@ ___
7571

7672
### `<Optional>` recordScreenViews
7773

78-
**● recordScreenViews**: * `undefined` &#124; `false` &#124; `true`
79-
*
74+
**● recordScreenViews**: *`undefined` \| `false` \| `true`*
8075

81-
*Defined in analytics.ts:17*
76+
*Defined in [analytics.ts:19](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L19)*
8277

8378
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.
8479

@@ -89,10 +84,9 @@ ___
8984

9085
### `<Optional>` trackAppLifecycleEvents
9186

92-
**● trackAppLifecycleEvents**: * `undefined` &#124; `false` &#124; `true`
93-
*
87+
**● trackAppLifecycleEvents**: *`undefined` \| `false` \| `true`*
9488

95-
*Defined in analytics.ts:26*
89+
*Defined in [analytics.ts:26](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L26)*
9690

9791
Whether the analytics client should automatically track application lifecycle events, such as "Application Installed", "Application Updated" and "Application Opened".
9892

@@ -103,10 +97,9 @@ ___
10397

10498
### `<Optional>` trackAttributionData
10599

106-
**● trackAttributionData**: * `undefined` &#124; `false` &#124; `true`
107-
*
100+
**● trackAttributionData**: *`undefined` \| `false` \| `true`*
108101

109-
*Defined in analytics.ts:32*
102+
*Defined in [analytics.ts:32](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L32)*
110103

111104
Whether the analytics client should automatically track attribution data from enabled providers using the mobile service.
112105

@@ -119,7 +112,7 @@ ___
119112

120113
**● using**: *[Integration](../#integration)[]*
121114

122-
*Defined in analytics.ts:37*
115+
*Defined in [analytics.ts:37](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L37)*
123116

124117
Register a set of integrations to be used with this Analytics instance.
125118

packages/core/src/__tests__/analytics.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ it('catches bridge errors', async () => {
3737
const error = new Error('test-error')
3838
const onError = jest.fn()
3939

40-
getBridgeStub('track').mockImplementationOnce(() => Promise.reject(error))
40+
getBridgeStub('track').mockImplementationOnce(
41+
() => Promise.reject(error) as any
42+
)
4143
analytics.catch(onError)
4244
analytics.track('test')
4345

@@ -82,7 +84,9 @@ it('logs uncaught bridge errors', async () => {
8284
message: 'test-error'
8385
}
8486

85-
getBridgeStub('track').mockImplementationOnce(() => Promise.reject(error))
87+
getBridgeStub('track').mockImplementationOnce(
88+
() => Promise.reject(error) as any
89+
)
8690

8791
expect(analytics.track('test')).rejects.toBe(error)
8892
expect(console.error).not.toHaveBeenCalled()

packages/core/src/__tests__/configuration.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ it('produces a valid configuration', async () => {
6060
})
6161

6262
it('waits for integrations to register', async () => {
63-
const stub = jest.fn(t => setTimeout(t, 500))
63+
const stub: any = jest.fn(t => setTimeout(t, 500))
6464

6565
await configure(writeKey, {
6666
using: [() => ({ then: stub })]

packages/integrations/template/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99
dependencies {
1010
classpath 'com.android.tools.build:gradle:3.1.4'
11-
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.60'
11+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.0'
1212
}
1313
}
1414

packages/test-app/android-workaround.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/test-app/e2e/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"setupFilesAfterEnv": ["./init.js"],
3+
"testEnvironment": "node"
4+
}

packages/test-app/e2e/init.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
const detox = require('detox')
22
const config = require('../package.json').detox
3-
const adapter = require('detox/runners/mocha/adapter')
3+
const adapter = require('detox/runners/jest/adapter')
44

55
require('isomorphic-fetch')
66

7-
before(async () => {
8-
await detox.init(config)
9-
})
7+
jest.setTimeout(120000)
8+
jasmine.getEnv().addReporter(adapter)
109

11-
beforeEach(async function() {
12-
await adapter.beforeEach(this)
10+
beforeAll(async () => {
11+
await detox.init(config)
1312
})
1413

15-
afterEach(async function() {
16-
await adapter.afterEach(this)
14+
beforeEach(async () => {
15+
await adapter.beforeEach()
1716
})
1817

19-
after(async () => {
18+
afterAll(async () => {
19+
await adapter.afterAll()
2020
await detox.cleanup()
2121
})

packages/test-app/e2e/main.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if (CIRCLE_WORKFLOW_ID) {
2020
await element(by.text('Flush')).tap()
2121

2222
await Promise.all(
23-
require('../src/calls.json').map(([type, ...args]) =>
23+
require('../seed/calls.json').map(([type, ...args]) =>
2424
hasMatchingCall(type, ...args)
2525
)
2626
)

packages/test-app/e2e/mocha.opts

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)