segmentio/analytics.js-integrations

Braze deduplication middleware not available when using obfuscated bundle fetches

cysp opened this issue · 0 comments

cysp commented

Analytics.js 2.0 fails to fetch the Braze deduplication middleware (analytics.js-middleware-braze-deduplicate) when obfuscation is enabled.
This appears to be caused by a bug in the asset uploading script in this repository which assumes that there are no interior . characters in the base part of integration filenames:

const clientName = file.substring(0, file.indexOf('.'));
const bufferClientName = Buffer.from(clientName).toString('base64').replace(/=/g, '');
const bufferFile = file.replace(clientName, bufferClientName);

Analytics.js 2.0 expects to find the integration script at https://cdn.segment.com/next-integrations/middleware/YW5hbHl0aWNzLmpzLW1pZGRsZXdhcmUtYnJhemUtZGVkdXBsaWNhdGU/latest/YW5hbHl0aWNzLmpzLW1pZGRsZXdhcmUtYnJhemUtZGVkdXBsaWNhdGU.js.gz (the obfuscated equivalent of https://cdn.segment.com/next-integrations/middleware/analytics.js-middleware-braze-deduplicate/latest/analytics.js-middleware-braze-deduplicate.js.gz), which currently gives a 404 response.

The obfuscation logic in the uploading script in this repository has resulted in the file incorrectly being uploaded as https://cdn.segment.com/next-integrations/middleware/YW5hbHl0aWNz/latest/YW5hbHl0aWNz.js-middleware-braze-deduplicate.js.gz