@@ -52,6 +52,7 @@ tuist generate
5252## Overview
5353
5454This project provides tools for recording mParticle SDK API requests by:
55+
5556- Building mParticle SDK as an xcframework for iOS Simulator
5657- Generating a test iOS app using Tuist that links to the built framework
5758- Running the app in iOS Simulator
@@ -70,6 +71,7 @@ Records all mParticle SDK API requests using WireMock for later use in integrati
7071```
7172
7273** What it does:**
74+
73751 . Builds mParticle SDK as xcframework for iOS Simulator
74762 . Generates Tuist project linked to the built framework
75773 . Builds the integration test application
@@ -84,10 +86,12 @@ Records all mParticle SDK API requests using WireMock for later use in integrati
848612 . Stops WireMock and shows results
8587
8688** Recorded Files:**
89+
8790- ` wiremock-recordings/mappings/*.json ` - API request/response mappings
8891- ` wiremock-recordings/__files/* ` - Response body files
8992
9093** Build Artifacts:**
94+
9195- ` temp_artifacts/mParticle_Apple_SDK.xcframework ` - Compiled SDK framework (auto-generated, not committed to git)
9296
9397### ` sanitize_mapping.py ` - Remove API Keys and Rename WireMock Mappings
@@ -102,18 +106,21 @@ python3 sanitize_mapping.py \
102106```
103107
104108** What it does:**
109+
105110- Replaces API keys in URLs with regex pattern ` us1-[a-f0-9]+ ` (matches any mParticle API key)
106111- Renames mapping file based on test name
107112- Renames response body file based on test name
108113- Updates body filename reference in mapping JSON
109114- Creates clean, sanitized recordings without sensitive information
110115
111116** Example transformations with ` --test-name identify ` :**
117+
112118- URL: ` /v2/us1-abc123def456.../events ` → ` /v2/us1-[a-f0-9]+/events `
113119- File: ` mapping-v1-us1-abc123-identify.json ` → ` mapping-v1-identify.json `
114120- Body: ` body-v1-us1-abc123-identify.json ` → ` body-v1-identify.json `
115121
116122** Example with ` --test-name log-event ` :**
123+
117124- URL: ` /v2/us1-xyz789.../events ` → ` /v2/us1-[a-f0-9]+/events `
118125- File: ` mapping-v2-us1-xyz789-events.json ` → ` mapping-v2-log-event.json `
119126- Body: ` body-v2-us1-xyz789-events.json ` → ` body-v2-log-event.json `
@@ -179,19 +186,20 @@ If another application is using the ports, terminate it before running the scrip
179186 - Edit ` IntegrationTests/Sources/main.swift ` to test your new or existing SDK functionality
180187 - Add code to call the specific SDK methods you want to record
181188 - ** Best practice:** Temporary comment out calls to unrelated your new code to record only relevant API requests
182-
1831892 . ** Run the WireMock recorder:**
190+
184191 ``` bash
185192 ./run_wiremock_recorder.sh
186193 ```
194+
187195 The script automatically builds the SDK as an xcframework with your latest changes, runs the app, and records all API traffic
188196
1891973 . ** Review and filter recorded mappings:**
190198 - All recordings are saved to ` wiremock-recordings/mappings/ `
191199 - The script records ** all** API requests made during the test run
192200 - ** Keep only the mappings related to your new test code**
193201 - Delete any unrelated or duplicate recordings
194-
202+
195203 ** Tip:** To get cleaner recordings, modify ` main.swift ` to call only the specific SDK method you're testing, avoiding unrelated API calls
196204
1972054 . ** Verify the recordings:**
@@ -204,39 +212,42 @@ If another application is using the ports, terminate it before running the scrip
204212After recording, you should sanitize and process mappings to remove sensitive data and handle dynamic values:
205213
2062141 . ** Sanitize and rename mapping file:**
215+
207216 ``` bash
208217 python3 sanitize_mapping.py \
209218 wiremock-recordings/mappings/mapping-v1-us1-abc123-identify.json \
210219 --test-name identify
211220 ```
212-
221+
213222 This automatically:
214223 - Replaces API keys in URLs with regex pattern ` us1-[a-f0-9]+ `
215224 - Renames the mapping file to ` mapping-v1-identify.json ` (or based on your test name)
216225 - Renames the response body file to ` body-v1-identify.json `
217226 - Updates all references in the mapping JSON
218227
2192282 . ** Transform request body (replace dynamic fields):**
229+
220230 ``` bash
221231 # Replace dynamic fields and save
222232 python3 transform_mapping_body.py \
223233 wiremock-recordings/mappings/mapping-v1-identify.json \
224234 unescape+update
225235 ```
226-
236+
227237 This replaces dynamic fields (timestamps, IDs, device info) with ` ${json-unit.ignore} `
228238
2292393 . ** Verify the changes:**
240+
230241 ``` bash
231242 # Check that API keys are replaced with regex pattern
232243 grep " us1-\[a-f0-9\]+" wiremock-recordings/mappings/mapping-v1-identify.json
233-
244+
234245 # Should show the regex pattern us1-[a-f0-9]+
235-
246+
236247 # Verify files were renamed correctly
237248 ls -l wiremock-recordings/mappings/mapping-v1-identify.json
238249 ls -l wiremock-recordings/__files/body-v1-identify.json
239-
250+
240251 # View the transformed request body
241252 wiremock-recordings/mappings/mapping-identify.json
242253 ```
@@ -253,6 +264,7 @@ After recording, you should sanitize and process mappings to remove sensitive da
253264If you need to manually edit the request body:
254265
2552661 . ** Edit the request body manually:**
267+
256268 ``` bash
257269 open wiremock-recordings/mappings/mapping-identify.json
258270 ```
@@ -283,4 +295,3 @@ Use the verification script to run full end-to-end integration tests:
2832958 . ** Returns exit code:** Exits with code 1 if any verification fails (CI/CD compatible)
284296
285297** Note:** The SDK xcframework is built fresh on each run, stored in ` temp_artifacts/mParticle_Apple_SDK.xcframework ` . This ensures tests always use your latest code changes.
286-
0 commit comments