From 2acf4782e52a57955afe1930c742e676b8c17db4 Mon Sep 17 00:00:00 2001 From: Austin Riendeau Date: Tue, 19 Oct 2021 14:17:15 -0600 Subject: [PATCH 1/2] Update proxy to support analytics 2.0 --- main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 3516ca2..cae8d6c 100644 --- a/main.go +++ b/main.go @@ -32,10 +32,20 @@ func singleJoiningSlash(a, b string) string { func NewSegmentReverseProxy(cdn *url.URL, trackingAPI *url.URL) http.Handler { director := func(req *http.Request) { // Figure out which server to redirect to based on the incoming request. + // https://segment-cdn.dayforward.com/analytics-next/bundles/130.bundle.9457873b007a93e16765.js + // https://segment-cdn.dayforward.com/analytics-next/bundles/ajs-destination.bundle.c473a3426ccbc3cdfba0.js + // https://prod-segment-cdn.dayforward.com/next-integrations/integrations/facebook-pixel/2.11.4/facebook-pixel.dynamic.js.gz var target *url.URL - if strings.HasPrefix(req.URL.String(), "/v1/projects") || strings.HasPrefix(req.URL.String(), "/analytics.js/v1") { + switch { + case strings.HasPrefix(req.URL.String(), "/v1/projects"): + fallthrough + case strings.HasPrefix(req.URL.String(), "/analytics.js/v1"): + fallthrough + case strings.HasPrefix(req.URL.String(), "/next-integrations"): + fallthrough + case strings.HasPrefix(req.URL.String(), "/analytics-next/bundles"): target = cdn - } else { + default: target = trackingAPI } From b13b796e9b1f3002766b686775f2b47b9fb6ba56 Mon Sep 17 00:00:00 2001 From: Austin Riendeau Date: Tue, 19 Oct 2021 14:19:34 -0600 Subject: [PATCH 2/2] Update proxy to support analytics 2.0 --- main.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/main.go b/main.go index cae8d6c..168a8c4 100644 --- a/main.go +++ b/main.go @@ -32,9 +32,6 @@ func singleJoiningSlash(a, b string) string { func NewSegmentReverseProxy(cdn *url.URL, trackingAPI *url.URL) http.Handler { director := func(req *http.Request) { // Figure out which server to redirect to based on the incoming request. - // https://segment-cdn.dayforward.com/analytics-next/bundles/130.bundle.9457873b007a93e16765.js - // https://segment-cdn.dayforward.com/analytics-next/bundles/ajs-destination.bundle.c473a3426ccbc3cdfba0.js - // https://prod-segment-cdn.dayforward.com/next-integrations/integrations/facebook-pixel/2.11.4/facebook-pixel.dynamic.js.gz var target *url.URL switch { case strings.HasPrefix(req.URL.String(), "/v1/projects"):