Skip to content

Commit

Permalink
feat: add config option for cdn proxy (#834)
Browse files Browse the repository at this point in the history
* feat: add config option for cdn proxy

* fix: add writekey and settings to cdn proxy

* fix: make conditional one line add to readme

---------

Co-authored-by: Alan Charles <[email protected]>
  • Loading branch information
alanjcharles and alanjcharles authored May 22, 2023
1 parent b6a319a commit 95562ed
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 25 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ You must pass at least the `writeKey`. Additional configuration options are list
| `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).|
| `proxy` | undefined | `proxy` is a batch url to post to instead of 'https://api.segment.io/v1/b'. |
| `errorHandler` | undefined | Create custom actions when errors happen, see [Handling errors](#handling-errors) |
| `cdnProxy` | undefined | Sets an alternative CDN host for settings retrieval |


\* The default value of `debug` will be false in production.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,10 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-AnalyticsReactNativeExample/Pods-AnalyticsReactNativeExample-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/BrazeKit/BrazeKit.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/BrazeUI/BrazeUI.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/BrazeKit.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/BrazeUI.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
20 changes: 0 additions & 20 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
PODS:
- boost (1.76.0)
- braze-react-native-sdk (4.1.0):
- BrazeKit (~> 5.13.0)
- BrazeLocation (~> 5.13.0)
- BrazeUI (~> 5.13.0)
- React-Core
- BrazeKit (5.13.0)
- BrazeLocation (5.13.0):
- BrazeKit (= 5.13.0)
- BrazeUI (5.13.0):
- BrazeKit (= 5.13.0)
- DoubleConversion (1.1.6)
- FBLazyVector (0.69.7)
- FBReactNativeSpec (0.69.7):
Expand Down Expand Up @@ -321,7 +311,6 @@ PODS:

DEPENDENCIES:
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
- "braze-react-native-sdk (from `../node_modules/@braze/react-native-sdk`)"
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
Expand Down Expand Up @@ -367,16 +356,11 @@ DEPENDENCIES:

SPEC REPOS:
trunk:
- BrazeKit
- BrazeLocation
- BrazeUI
- fmt

EXTERNAL SOURCES:
boost:
:podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec"
braze-react-native-sdk:
:path: "../node_modules/@braze/react-native-sdk"
DoubleConversion:
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
FBLazyVector:
Expand Down Expand Up @@ -462,10 +446,6 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
boost: a7c83b31436843459a1961bfd74b96033dc77234
braze-react-native-sdk: 686da10a997500422984bd4b39c78fc19fcd701a
BrazeKit: 97f6875bf05920a46a2f0c9d0e452b6b840c5f99
BrazeLocation: 571ee6bf6b2f5c1aba20d9a75e4da190f8db7e5b
BrazeUI: 31dd9f0235149f05d6f7e37f273be7293e000587
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: 6b7f5692909b4300d50e7359cdefbcd09dd30faa
FBReactNativeSpec: affcf71d996f6b0c01f68883482588297b9d5e6e
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ export class SegmentClient {
}

async fetchSettings() {
const settingsEndpoint = `${settingsCDN}/${this.config.writeKey}/settings`;
const settingsPrefix: string = this.config.cdnProxy ?? settingsCDN;
const settingsEndpoint = `${settingsPrefix}/${this.config.writeKey}/settings`;

try {
const res = await fetch(settingsEndpoint);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export type Config = {
collectDeviceId?: boolean;
storePersistor?: Persistor;
proxy?: string;
cdnProxy?: string;
errorHandler?: (error: SegmentError) => void;
};

Expand Down

0 comments on commit 95562ed

Please sign in to comment.