Skip to content

Commit b6b396a

Browse files
fix: for Unable to configure Custom Domain for React-Native (#1043)
* fix: Unable to configure Custom Domain for React-Native * chore(tests): updated and added new test cases - updated test cases in fetchSettings.test.ts and SegmentDestination.test.ts - added new test cases in util.test.ts * fix: Unable to configure Custom Domain for React-Native update business logic to configure custom proxy, updated test cases and tested e2e test cases * fix: removed write key from example app * fix: lint errors and warnings * refactor: lint issues * refactor: to handle the case suggested by wzenxi and updated readme
1 parent 6153e20 commit b6b396a

File tree

18 files changed

+583
-240
lines changed

18 files changed

+583
-240
lines changed

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,26 @@ You must pass at least the `writeKey`. Additional configuration options are list
118118

119119
### Client Options
120120

121-
| Name | Default | Description |
122-
| -------------------------- | --------- | -----------------------------------------------------------------------------------------------------------------------------------------------|
123-
| `writeKey` **(REQUIRED)** | '' | Your Segment API key. |
124-
| `collectDeviceId` | false | Set to true to automatically collect the device Id.from the DRM API on Android devices. |
125-
| `debug` | true\* | When set to false, it will not generate any logs. |
126-
| `logger` | undefined | Custom logger instance to expose internal Segment client logging. |
127-
| `flushAt` | 20 | How many events to accumulate before sending events to the backend. |
128-
| `flushInterval` | 30 | In seconds, how often to send events to the backend. |
129-
| `flushPolicies` | undefined | Add more granular control for when to flush, see [Adding or removing policies](#adding-or-removing-policies). **Mutually exclusive with flushAt/flushInterval** |
130-
| `maxBatchSize` | 1000 | How many events to send to the API at once |
131-
| `trackAppLifecycleEvents` | false | Enable automatic tracking for [app lifecycle events](https://segment.com/docs/connections/spec/mobile/#lifecycle-events): application installed, opened, updated, backgrounded) |
132-
| `trackDeepLinks` | false | Enable automatic tracking for when the user opens the app via a deep link (Note: Requires additional setup on iOS, [see instructions](#ios-deep-link-tracking-setup)) |
133-
| `defaultSettings` | undefined | Settings that will be used if the request to get the settings from Segment fails. Type: [SegmentAPISettings](https://github.com/segmentio/analytics-react-native/blob/c0a5895c0c57375f18dd20e492b7d984393b7bc4/packages/core/src/types.ts#L293-L299) |
134-
| `autoAddSegmentDestination`| true | Set to false to skip adding the SegmentDestination plugin |
135-
| `storePersistor` | undefined | A custom persistor for the store that `analytics-react-native` leverages. Must match [`Persistor`](https://github.com/segmentio/analytics-react-native/blob/master/packages/sovran/src/persistor/persistor.ts#L1-L18) interface exported from [sovran-react-native](https://github.com/segmentio/analytics-react-native/blob/master/packages/sovran).|
136-
| `proxy` | undefined | `proxy` is a batch url to post to instead of 'https://api.segment.io/v1/b'. |
137-
| `errorHandler` | undefined | Create custom actions when errors happen, see [Handling errors](#handling-errors) |
138-
| `cdnProxy` | undefined | Sets an alternative CDN host for settings retrieval |
121+
| **Name** | **Default** | **Description** |
122+
|----------------------------|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
123+
| `writeKey` **(REQUIRED)** | '' | Your Segment API key. |
124+
| `collectDeviceId` | false | Set to true to automatically collect the device Id from the DRM API on Android devices. |
125+
| `debug` | true\* | When set to false, it will not generate any logs. |
126+
| `logger` | undefined | Custom logger instance to expose internal Segment client logging. |
127+
| `flushAt` | 20 | How many events to accumulate before sending events to the backend. |
128+
| `flushInterval` | 30 | In seconds, how often to send events to the backend. |
129+
| `flushPolicies` | undefined | Add more granular control for when to flush, see [Adding or removing policies](#adding-or-removing-policies). **Mutually exclusive with flushAt/flushInterval** |
130+
| `maxBatchSize` | 1000 | How many events to send to the API at once |
131+
| `trackAppLifecycleEvents` | false | Enable automatic tracking for [app lifecycle events](https://segment.com/docs/connections/spec/mobile/#lifecycle-events): application installed, opened, updated, backgrounded. |
132+
| `trackDeepLinks` | false | Enable automatic tracking for when the user opens the app via a deep link (Note: Requires additional setup on iOS, [see instructions](#ios-deep-link-tracking-setup)). |
133+
| `defaultSettings` | undefined | Settings that will be used if the request to get the settings from Segment fails. Type: [SegmentAPISettings](https://github.com/segmentio/analytics-react-native/blob/c0a5895c0c57375f18dd20e492b7d984393b7bc4/packages/core/src/types.ts#L293-L299) |
134+
| `autoAddSegmentDestination` | true | Set to false to skip adding the SegmentDestination plugin. |
135+
| `storePersistor` | undefined | A custom persistor for the store that `analytics-react-native` leverages. Must match [`Persistor`](https://github.com/segmentio/analytics-react-native/blob/master/packages/sovran/src/persistor/persistor.ts#L1-L18) interface exported from [sovran-react-native](https://github.com/segmentio/analytics-react-native/blob/master/packages/sovran). |
136+
| `proxy` | undefined | `proxy` is a batch URL to post the events. Enable `useSegmentEndpoint` if proxy domain is provided and you want to append the Segment endpoints automatically. If you want to completely customize the proxy by providing a custom URL, disable `useSegmentEndpoint`. Default value is `false`. |
137+
| `errorHandler` | undefined | Create custom actions when errors happen, see [Handling errors](#handling-errors). |
138+
| `cdnProxy` | undefined | Sets an alternative CDN host for settings retrieval. Enable `useSegmentEndpoint` if cdnProxy domain is provided and you want to append the Segment endpoints automatically. |
139+
| `useSegmentEndpoint` | false | Set to `true` to automatically append the Segment endpoints when using `proxy` or `cdnProxy` to send or fetch settings. This will enable automatic routing to the appropriate endpoints. |
140+
139141

140142

141143
\* The default value of `debug` will be false in production.

examples/AnalyticsReactNativeExample/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {useState} from 'react';
3232
// import { BrazePlugin } from '@segment/analytics-react-native-plugin-braze';
3333

3434
const segmentClient = createClient({
35-
writeKey: '<WRITE_KEY>',
35+
writeKey: '<write-key>',
3636
trackAppLifecycleEvents: true,
3737
collectDeviceId: true,
3838
debug: true,

examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample/PrivacyInfo.xcprivacy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
<array>
77
<dict>
88
<key>NSPrivacyAccessedAPIType</key>
9-
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
9+
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
1010
<key>NSPrivacyAccessedAPITypeReasons</key>
1111
<array>
12-
<string>C617.1</string>
12+
<string>CA92.1</string>
1313
</array>
1414
</dict>
1515
<dict>
1616
<key>NSPrivacyAccessedAPIType</key>
17-
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
17+
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
1818
<key>NSPrivacyAccessedAPITypeReasons</key>
1919
<array>
20-
<string>CA92.1</string>
20+
<string>C617.1</string>
2121
</array>
2222
</dict>
2323
<dict>

0 commit comments

Comments
 (0)