Skip to content

feat: add config option for cdn proxy #834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 11 additions & 1 deletion packages/core/src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,17 @@ export class SegmentClient {
}

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

if (this.config.cdnProxy !== undefined && this.config.cdnProxy !== null) {
// Sets an alternative CDN host for settings retrieval. This is useful when
// a proxy is in use, or settings need to be queried from certain locales at
// all times (such as the EU). The default value is `https://cdn-settings.segment.com/v1/projects`.

settingsEndpoint = `${this.config.cdnProxy}}/${this.config.writeKey}/settings`;
} else {
settingsEndpoint = `${settingsCDN}/${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