From 66e3eeeb84209e13396ab81fc1219d232e2702ba Mon Sep 17 00:00:00 2001 From: internetisaiah <95643215+internetisaiah@users.noreply.github.com> Date: Fri, 11 Oct 2024 15:39:49 -0700 Subject: [PATCH 1/9] Random bdocs improvements (during time off) --- bdocs | 64 ++++++++++-------------- scripts/create_release_text.sh | 6 ++- scripts/remove_unused_reference_links.rb | 2 + scripts/transform_reference_links.py | 2 + 4 files changed, 35 insertions(+), 39 deletions(-) mode change 100644 => 100755 scripts/remove_unused_reference_links.rb diff --git a/bdocs b/bdocs index 38c1f3014f0..ac887e5235a 100755 --- a/bdocs +++ b/bdocs @@ -1,14 +1,20 @@ #!/bin/bash -# This is a bash script for interacting with the various files in './scripts/'. +# This is a wrapper script for interacting with the files in './scripts/'. # # Usage: ./bdocs [option] set -e # The project's root directory. -export PROJECT_ROOT -PROJECT_ROOT="$(dirname "$(realpath "$0")")" +export PROJECT_ROOT="$(dirname "$(realpath "$0")")" + +# All scripts exported so they can source bdocs and call each other if needed. +export DEPLOY="$PROJECT_ROOT/scripts/create_deploy_text.sh" +export RELEASE="$PROJECT_ROOT/scripts/create_release_text.sh" +export TLINKS="$PROJECT_ROOT/scripts/transform_reference_links.py" +export RLINKS="$PROJECT_ROOT/scripts/remove_unused_reference_links.rb" +export REDIRECTS="$PROJECT_ROOT/scripts/list_redirect_urls.sh" # Displays usage for bdocs display_help() { @@ -29,6 +35,14 @@ OPTIONS: EOF } +# If a file or directory is required, check if it was passed and block if not. +require_path_or_file() { + if [[ -z "$1" ]]; then + echo "Error: A file or directory path is required." + exit 1 + fi +} + # Check if no arguments were provided if [[ $# -eq 0 ]]; then display_help @@ -39,52 +53,28 @@ fi case $1 in deploy) if [[ $# -eq 3 ]]; then - "$PROJECT_ROOT/scripts/create_deploy_text.sh" "$2" "$3" + "$DEPLOY" "$2" "$3" else - "$PROJECT_ROOT/scripts/create_deploy_text.sh" + "$DEPLOY" fi ;; release) - "$PROJECT_ROOT/scripts/create_release_text.sh" + "$RELEASE" ;; tlinks) - if [[ -z "$2" ]]; then - echo "Error: A file or directory path is required." - exit 1 - fi - python3 "$PROJECT_ROOT/scripts/transform_reference_links.py" "$2" - echo "Success!" - while true; do - echo "Do you want to remove the unused reference links? [Y/n]." - read -r opt - case $opt in - y*|Y*) - ruby "$PROJECT_ROOT/scripts/remove_unused_reference_links.rb" "$2" - echo "Success!" - break - ;; - n*|N*) - echo "The unused reference links were left untouched." - break - ;; - *) echo "Error: Invalid choice." - echo "" - ;; - esac - done + require_path_or_file "$2" && "$TLINKS" "$2" + + # Run rlinks next to clean up unused reference links. + "$RLINKS" "$2" ;; rlinks) - if [[ -z "$2" ]]; then - echo "Error: The path to file or directory is required." - exit 1 - fi - ruby "$PROJECT_ROOT/scripts/remove_unused_reference_links.rb" "$2" + require_path_or_file "$2" && "$RLINKS" "$2" ;; redirects) if [[ $# -eq 2 ]]; then - "$PROJECT_ROOT/scripts/list_redirect_urls.sh" "$2" + "$REDIRECTS" "$2" else - "$PROJECT_ROOT/scripts/list_redirect_urls.sh" + "$REDIRECTS" fi ;; help) diff --git a/scripts/create_release_text.sh b/scripts/create_release_text.sh index 25a148f13ac..ec132e37b4f 100755 --- a/scripts/create_release_text.sh +++ b/scripts/create_release_text.sh @@ -5,6 +5,8 @@ # # Usage: ./bdocs release +source "$PROJECT_ROOT/bdocs" + main() { # Run script from the root of the git repository. cd "$PROJECT_ROOT" @@ -38,9 +40,9 @@ main() { COMMIT_TITLE=$(echo "$commit" | jq -r '.title') COMMIT_BODY=$(echo "$commit" | jq -r '.body') - # Print the deploy text for each deployment. + # Print the deploy text for each deployment using the sourced DEPLOY. echo "## $COMMIT_BODY" - ./scripts/create_deploy_text.sh "$PREV_COMMIT_DATE" "$COMMIT_DATE" + "$DEPLOY" "$PREV_COMMIT_DATE" "$COMMIT_DATE" echo "" # Get the next range of commits by increasing 'PREV_COMMIT_DATE'. diff --git a/scripts/remove_unused_reference_links.rb b/scripts/remove_unused_reference_links.rb old mode 100644 new mode 100755 index 795ed331de7..20ab1b47a29 --- a/scripts/remove_unused_reference_links.rb +++ b/scripts/remove_unused_reference_links.rb @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby + # Removes unused reference-style links from the bottom of a file, such as: # [1]: {{site.baseurl}}/contributing/your_first_contribution/ # diff --git a/scripts/transform_reference_links.py b/scripts/transform_reference_links.py index 12d0fa23c8e..da23215def2 100755 --- a/scripts/transform_reference_links.py +++ b/scripts/transform_reference_links.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # Converts Markdown reference links to in-line links. Created because # reference links cannot be placed inside Liquid {% tab %} tags. # From b18c690e35bd0de5431b71e2b271322497627a61 Mon Sep 17 00:00:00 2001 From: internetisaiah <95643215+internetisaiah@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:25:50 -0700 Subject: [PATCH 2/9] adding credirects v1 --- bdocs | 55 ++++++++++++++++-------- scripts/create_redirects.sh | 47 ++++++++++++++++++++ scripts/create_release_text.sh | 2 - scripts/list_redirect_urls.sh | 5 +-- scripts/remove_unused_reference_links.rb | 2 +- scripts/transform_reference_links.py | 2 +- 6 files changed, 88 insertions(+), 25 deletions(-) create mode 100755 scripts/create_redirects.sh diff --git a/bdocs b/bdocs index ac887e5235a..acf6125bf5e 100755 --- a/bdocs +++ b/bdocs @@ -6,15 +6,17 @@ set -e -# The project's root directory. +# The project's root directory and redirect file. export PROJECT_ROOT="$(dirname "$(realpath "$0")")" +export REDIRECT_FILE="./assets/js/broken_redirect_list.js" # All scripts exported so they can source bdocs and call each other if needed. export DEPLOY="$PROJECT_ROOT/scripts/create_deploy_text.sh" export RELEASE="$PROJECT_ROOT/scripts/create_release_text.sh" export TLINKS="$PROJECT_ROOT/scripts/transform_reference_links.py" export RLINKS="$PROJECT_ROOT/scripts/remove_unused_reference_links.rb" -export REDIRECTS="$PROJECT_ROOT/scripts/list_redirect_urls.sh" +export CREDIRECTS="$PROJECT_ROOT/scripts/create_redirects.sh" +export LREDIRECTS="$PROJECT_ROOT/scripts/list_redirect_urls.sh" # Displays usage for bdocs display_help() { @@ -25,17 +27,18 @@ USAGE: ./bdocs [option] OPTIONS: - deploy Create the deploy body text for weekly deployments - release Create the release body text for monthly releases - tlinks Transform reference links to inline links on 1 or more pages - rlinks Remove reference links that are not being used on 1 or more pages - redirects List the old URLs for all new redirects in this branch - help Display this help message and exit + deploy Create the deploy body text for weekly deployments + release Create the release body text for monthly releases + tlinks Transform reference links to inline links on 1 or more pages + rlinks Remove unused reference links on 1 or more pages + credirects Create redirects for all changed files in _docs + lredirects List the old URLs for all new redirects in this branch + help Display this help message and exit EOF } -# If a file or directory is required, check if it was passed and block if not. +# If a file or directory is required, pass or fail. require_path_or_file() { if [[ -z "$1" ]]; then echo "Error: A file or directory path is required." @@ -43,15 +46,29 @@ require_path_or_file() { fi } +# If new merges into 'develop' are required, pass or fail. +require_new_merges() { + LATEST_COMMIT_HASH=$(git log --max-count=1 --format="%H" origin/master ^origin/develop) + COMMIT_LOGS=$(git log --first-parent "$LATEST_COMMIT_HASH"..origin/develop) + if [ -z "$COMMIT_LOGS" ]; then + echo "Error: No new merges into 'develop' since the last deployment." + exit 1 + fi +} + # Check if no arguments were provided if [[ $# -eq 0 ]]; then display_help exit 1 fi +# Fetch the latest changes from the remote quietly. +git fetch origin develop --quiet + # Argument parsing case $1 in deploy) + require_new_merges if [[ $# -eq 3 ]]; then "$DEPLOY" "$2" "$3" else @@ -59,22 +76,26 @@ case $1 in fi ;; release) + require_new_merges "$RELEASE" ;; tlinks) - require_path_or_file "$2" && "$TLINKS" "$2" - - # Run rlinks next to clean up unused reference links. - "$RLINKS" "$2" + require_path_or_file "$2" + "$TLINKS" "$2" + "$RLINKS" "$2" # Run rlinks next, to clean up unused reference links. ;; rlinks) - require_path_or_file "$2" && "$RLINKS" "$2" + require_path_or_file "$2" + "$RLINKS" "$2" + ;; + credirects) + "$CREDIRECTS" ;; - redirects) + lredirects) if [[ $# -eq 2 ]]; then - "$REDIRECTS" "$2" + "$LREDIRECTS" "$2" else - "$REDIRECTS" + "$LREDIRECTS" fi ;; help) diff --git a/scripts/create_redirects.sh b/scripts/create_redirects.sh new file mode 100755 index 00000000000..b59b2fafe03 --- /dev/null +++ b/scripts/create_redirects.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# DESCRIPTION +# +# Usage: ./bdocs redirects -c + +# Get the list of renamed files in `_docs` directory from `develop` branch +CHANGED_FILES=$(git diff --name-status origin/develop -- "$PROJECT_ROOT/_docs" | awk '$1 == "R" {print $2 " " $3}') + +# Check if there are any renamed files +require_changed_files() { + if [ -z "$CHANGED_FILES" ]; then + echo "Error: No files or directories changed in the '_docs' directory." + exit 1 + fi +} + +# Function to format paths to remove underscores and `.md` extension +format_path() { + echo "$1" | sed -E 's|/_|/|g' | sed -E 's|\.md$||g' +} + +main() { + # Create redirects + redirects="" + while IFS= read -r line; do + old_path=$(echo "$line" | awk '{print $1}') + new_path=$(echo "$line" | awk '{print $2}') + + # Format the paths + formatted_old_path=$(format_path "$old_path") + formatted_new_path=$(format_path "$new_path") + + # Create the redirect entry + redirect="validurls['$formatted_old_path'] = '$formatted_new_path';" + redirects+="$redirect"$'\n' + done <<< "$CHANGED_FILES" + + # Write redirects to the redirect file + echo "Appending redirects to $REDIRECT_FILE..." + echo "$redirects" >> "$REDIRECT_FILE" + + echo "Redirects added successfully!" +} + +require_changed_files +main diff --git a/scripts/create_release_text.sh b/scripts/create_release_text.sh index ec132e37b4f..87daa8bbfdd 100755 --- a/scripts/create_release_text.sh +++ b/scripts/create_release_text.sh @@ -5,8 +5,6 @@ # # Usage: ./bdocs release -source "$PROJECT_ROOT/bdocs" - main() { # Run script from the root of the git repository. cd "$PROJECT_ROOT" diff --git a/scripts/list_redirect_urls.sh b/scripts/list_redirect_urls.sh index 5acc2380fea..13be3e05c20 100755 --- a/scripts/list_redirect_urls.sh +++ b/scripts/list_redirect_urls.sh @@ -4,10 +4,7 @@ # base URL to list all old URLs so the user can open old links directly from # the terminal to test redirects. # -# Usage: ./bdocs redirects - -# Fetch the latest changes from the remote. -git fetch origin develop --quiet +# Usage: ./bdocs redirects -l # Check new redirects by comparing the current branch to develop. NEW_REDIRECTS=$(git diff develop -- $PROJECT_ROOT/assets/js/broken_redirect_list.js) diff --git a/scripts/remove_unused_reference_links.rb b/scripts/remove_unused_reference_links.rb index 20ab1b47a29..a1823248f18 100755 --- a/scripts/remove_unused_reference_links.rb +++ b/scripts/remove_unused_reference_links.rb @@ -3,7 +3,7 @@ # Removes unused reference-style links from the bottom of a file, such as: # [1]: {{site.baseurl}}/contributing/your_first_contribution/ # -# Usage: ./bdocs rlinks [FILE|DIRECTORY] +# Usage: ./bdocs links -r [FILE|DIRECTORY] # # Options: # FILE Delete unused reference links in a single file. diff --git a/scripts/transform_reference_links.py b/scripts/transform_reference_links.py index da23215def2..c2a1370b257 100755 --- a/scripts/transform_reference_links.py +++ b/scripts/transform_reference_links.py @@ -6,7 +6,7 @@ # For more information, see: # https://www.braze.com/docs/contributing/content_management/cross_referencing/ # -# Usage: ./bdocs tlinks [FILE|DIRECTORY] +# Usage: ./bdocs links -t [FILE|DIRECTORY] # # Options: # FILE Transform reference links in a single file. From 6b8c35248c608ac8d9338bea5346a3a8f2302f28 Mon Sep 17 00:00:00 2001 From: internetisaiah <95643215+internetisaiah@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:24:43 -0700 Subject: [PATCH 3/9] test commit --- _docs/_contributing/{home.md => homeward.md} | 0 bdocs | 2 +- scripts/create_redirects.py | 70 ++++++++++++++++++++ scripts/create_redirects.sh | 47 ------------- 4 files changed, 71 insertions(+), 48 deletions(-) rename _docs/_contributing/{home.md => homeward.md} (100%) create mode 100755 scripts/create_redirects.py delete mode 100755 scripts/create_redirects.sh diff --git a/_docs/_contributing/home.md b/_docs/_contributing/homeward.md similarity index 100% rename from _docs/_contributing/home.md rename to _docs/_contributing/homeward.md diff --git a/bdocs b/bdocs index acf6125bf5e..f8709a6ba13 100755 --- a/bdocs +++ b/bdocs @@ -15,7 +15,7 @@ export DEPLOY="$PROJECT_ROOT/scripts/create_deploy_text.sh" export RELEASE="$PROJECT_ROOT/scripts/create_release_text.sh" export TLINKS="$PROJECT_ROOT/scripts/transform_reference_links.py" export RLINKS="$PROJECT_ROOT/scripts/remove_unused_reference_links.rb" -export CREDIRECTS="$PROJECT_ROOT/scripts/create_redirects.sh" +export CREDIRECTS="$PROJECT_ROOT/scripts/create_redirects.py" export LREDIRECTS="$PROJECT_ROOT/scripts/list_redirect_urls.sh" # Displays usage for bdocs diff --git a/scripts/create_redirects.py b/scripts/create_redirects.py new file mode 100755 index 00000000000..18ccc37650a --- /dev/null +++ b/scripts/create_redirects.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 + +# DESCRIPTION +# +# Usage: ./bdocs credirects + +import re +import subprocess + +# Paths (assuming these are sourced or set elsewhere in your environment) +redirect_file = "./assets/js/broken_redirect_list.js" +project_root = "./" # Adjust to your actual root if needed + +# Using Git, get the list of files that have been renamed. +def get_changed_files(): + cmd = f"git diff -M --summary develop HEAD -- {project_root}_docs" + result = subprocess.run(cmd, shell=True, capture_output=True, text=True) + # Filter lines that start with "rename" or " rename" + return [line.strip() for line in result.stdout.splitlines() if line.startswith("rename") or line.startswith(" rename")] + +def create_redirect(line): + # Remove everything up to and including the first space, but keep the initial underscore + line = line.split(" ", 1)[1] + + # Remove any trailing `(NUM%)` from the line + line = re.sub(r"\s\(\d+%\)$", "", line) + + # Get the relative paths for the old and new filenames + line_separator = line.split("{")[0].strip() + + # Check if this is a directory rename (no `.md` in `{old => }/new.md` portion) + if re.search(r"{([^{}]+) => }/[^\s]+\.md", line): + # Directory-only rename handling + old_path_part, new_filename = re.search(r"{([^{}]+) => }/(.+)", line).groups() + + # Construct the paths for old and new locations + old_path = f"/{line_separator}{old_path_part}/{new_filename}" + new_path = f"/{line_separator}{new_filename}" + elif re.search(r"{(.+?) => (.+?)}", line): + # Standard file rename handling with `{old => new}` pattern + unformatted_old_path, unformatted_new_path = re.search(r"{(.+?) => (.+?)}", line).groups() + old_path = f"/{line_separator}{unformatted_old_path}" + new_path = f"/{line_separator}{unformatted_new_path}" + else: + return None + + # Remove leading underscores and .md extensions, and format paths + old_path = old_path.replace("/_", "/").replace(".md", "") + new_path = new_path.replace("/_", "/").replace(".md", "") + + # Convert paths to the redirect syntax: validurls['OLD'] = 'NEW'; + redirect = f"validurls['{old_path}'] = '{new_path}';" + + return redirect + +def main(): + # Fetch changed files + changed_files = get_changed_files() + + # Process each line and write to redirect file + with open(redirect_file, 'a') as f: + for line in changed_files: + formatted_redirect = create_redirect(line) + if formatted_redirect: + f.write(formatted_redirect + "\n") + + print("Redirects added successfully!") + +if __name__ == "__main__": + main() diff --git a/scripts/create_redirects.sh b/scripts/create_redirects.sh deleted file mode 100755 index b59b2fafe03..00000000000 --- a/scripts/create_redirects.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# -# DESCRIPTION -# -# Usage: ./bdocs redirects -c - -# Get the list of renamed files in `_docs` directory from `develop` branch -CHANGED_FILES=$(git diff --name-status origin/develop -- "$PROJECT_ROOT/_docs" | awk '$1 == "R" {print $2 " " $3}') - -# Check if there are any renamed files -require_changed_files() { - if [ -z "$CHANGED_FILES" ]; then - echo "Error: No files or directories changed in the '_docs' directory." - exit 1 - fi -} - -# Function to format paths to remove underscores and `.md` extension -format_path() { - echo "$1" | sed -E 's|/_|/|g' | sed -E 's|\.md$||g' -} - -main() { - # Create redirects - redirects="" - while IFS= read -r line; do - old_path=$(echo "$line" | awk '{print $1}') - new_path=$(echo "$line" | awk '{print $2}') - - # Format the paths - formatted_old_path=$(format_path "$old_path") - formatted_new_path=$(format_path "$new_path") - - # Create the redirect entry - redirect="validurls['$formatted_old_path'] = '$formatted_new_path';" - redirects+="$redirect"$'\n' - done <<< "$CHANGED_FILES" - - # Write redirects to the redirect file - echo "Appending redirects to $REDIRECT_FILE..." - echo "$redirects" >> "$REDIRECT_FILE" - - echo "Redirects added successfully!" -} - -require_changed_files -main From 061acf0884761e0669bab2c878f579aebf2cdb15 Mon Sep 17 00:00:00 2001 From: internetisaiah <95643215+internetisaiah@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:41:57 -0700 Subject: [PATCH 4/9] undoing test --- _docs/_contributing/{homeward.md => home.md} | 0 .../message_engagement_events.md | 360 +++++++++++++++++- 2 files changed, 359 insertions(+), 1 deletion(-) rename _docs/_contributing/{homeward.md => home.md} (100%) diff --git a/_docs/_contributing/homeward.md b/_docs/_contributing/home.md similarity index 100% rename from _docs/_contributing/homeward.md rename to _docs/_contributing/home.md diff --git a/_docs/_user_guide/data_and_analytics/braze_currents/event_glossary/message_engagement_events.md b/_docs/_user_guide/data_and_analytics/braze_currents/event_glossary/message_engagement_events.md index d9eb8e29fff..bf666f867e7 100644 --- a/_docs/_user_guide/data_and_analytics/braze_currents/event_glossary/message_engagement_events.md +++ b/_docs/_user_guide/data_and_analytics/braze_currents/event_glossary/message_engagement_events.md @@ -8429,7 +8429,203 @@ This event occures whenever a user has had an opportunity to interact with your Feature flag impressions are only logged once per session. +{% tabs %} +{% tab Mixpanel %} +```json +// Feature Flag Experiment Impression: users.messages.featureflag.Impression + +{ + "event" : "(required, string) The event type name, as it is exported to Mixpanel", + "properties" : { + "$partner_id" : "braze", + "app_id" : "(optional, string) API ID of the app on which this event occurred", + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "browser" : "(optional, string) Device browser - extracted from user_agent - on which the open occurred", + "campaign_id" : "(optional, string) API ID of the campaign this event belongs to", + "campaign_name" : "(optional, string) Name of the campaign", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "device_id" : "(optional, string) ID of the device on which the event occurred", + "$device" : "(optional, string) Model of the device", + "distinct_id" : "(required, string) External ID of the user", + "feature_flag_id_name" : "(optional, string) The Feature Flag Rollout identifier", + "$insert_id" : "(required, string) Globally unique ID for this event", + "message_variation_id" : "(optional, string) API ID of the message variation this user received", + "message_variation_name" : "(optional, string) Name of the message variation", + "$os" : "(optional, string) Version of the operating system of the device", + "platform" : "(optional, string) Platform of the device", + "time" : "(required, int) UNIX timestamp at which the event happened", + "token" : "(required, string) The Mixpanel API token" + } +} +``` +{% endtab %} + +{% tab Cloud Storage %} +```json +// Feature Flag Experiment Impression: users.messages.featureflag.Impression + +{ + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "app_id" : "(optional, string) API ID of the app on which this event occurred", + "browser" : "(optional, string) Device browser - extracted from user_agent - on which the open occurred", + "campaign_id" : "(optional, string) API ID of the campaign this event belongs to", + "campaign_name" : "(optional, string) Name of the campaign", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_message_variation_id" : "(optional, string) API ID of the Canvas step message variation this user received", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "carrier" : "(optional, string) Carrier of the device", + "country" : "(optional, string) Country of the user", + "device_id" : "(optional, string) ID of the device on which the event occurred", + "device_model" : "(optional, string) Model of the device", + "external_user_id" : "(optional, string) External ID of the user", + "feature_flag_id_name" : "(optional, string) The Feature Flag Rollout identifier", + "gender" : "(optional, string) Gender of the user, one of ['M', 'F', 'O', 'N', 'P']", + "id" : "(required, string) Globally unique ID for this event", + "language" : "(optional, string) Language of the user", + "message_variation_id" : "(optional, string) API ID of the message variation this user received", + "message_variation_name" : "(optional, string) Name of the message variation", + "os_version" : "(optional, string) Version of the operating system of the device", + "platform" : "(optional, string) Platform of the device", + "resolution" : "(optional, string) Resolution of the device", + "sdk_version" : "(optional, string) Version of the Braze SDK in use during the event", + "time" : "(required, int) UNIX timestamp at which the event happened", + "timezone" : "(optional, string) Time zone of the user", + "user_id" : "(required, string) Braze user ID of the user who performed this event" +} +``` +{% endtab %} + +{% tab mParticle %} +```json +// Feature Flag Experiment Impression: users.messages.featureflag.Impression + +{ + "device_info" : { + "ios_idfv" : "(optional, string) ID of the device on which the event occurred", + "device_model" : "(optional, string) Model of the device", + "platform" : "(optional, string) Platform of the device" + }, + "environment" : "(required, string) The mParticle environment (either 'development' or 'production')", + "events" : [ + { + "data" : { + "custom_attributes" : { + "app_id" : "(optional, string) API ID of the app on which this event occurred", + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "browser" : "(optional, string) Device browser - extracted from user_agent - on which the open occurred", + "campaign_id" : "(optional, string) API ID of the campaign this event belongs to", + "campaign_name" : "(optional, string) Name of the campaign", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "device_id" : "(optional, string) ID of the device on which the event occurred", + "feature_flag_id_name" : "(optional, string) The Feature Flag Rollout identifier", + "message_variation_id" : "(optional, string) API ID of the message variation this user received", + "message_variation_name" : "(optional, string) Name of the message variation" + }, + "custom_event_type" : "(required, string) The mParticle custom event type if the event_type is 'custom_event' (always 'other')", + "event_name" : "(required, string) The event type name, as it is exported to mParticle", + "source_message_id" : "(required, string) Globally unique ID for this event", + "timestamp_unixtime_ms" : "(required, int) UNIX timestamp at which the event happened" + }, + "event_type" : "(required, string) mParticle event type (either 'uninstall' or 'custom_event')" + } + ], + "schema_version" : 2, + "user_attributes" : { }, + "user_identities" : { + "customerid" : "(required, string) External ID of the user" + } +} +``` +{% endtab %} + +{% tab Amplitude %} +```json +// Feature Flag Experiment Impression: users.messages.featureflag.Impression + +{ + "device_id" : "(optional, string) ID of the device on which the event occurred", + "event_properties" : { + "app_id" : "(optional, string) API ID of the app on which this event occurred", + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "browser" : "(optional, string) Device browser - extracted from user_agent - on which the open occurred", + "campaign_id" : "(optional, string) API ID of the campaign this event belongs to", + "campaign_name" : "(optional, string) Name of the campaign", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "device_model" : "(optional, string) Model of the device", + "feature_flag_id_name" : "(optional, string) The Feature Flag Rollout identifier", + "message_variation_id" : "(optional, string) API ID of the message variation this user received", + "message_variation_name" : "(optional, string) Name of the message variation", + "os_version" : "(optional, string) Version of the operating system of the device", + "platform" : "(optional, string) Platform of the device", + "timezone" : "(optional, string) Time zone of the user" + }, + "event_type" : "(required, string) The event type name, as it is exported to Amplitude", + "insert_id" : "(required, string) Globally unique ID for this event", + "library" : "Braze", + "time" : "(required, int) UNIX timestamp at which the event happened", + "user_id" : "(optional, string) External ID of the user" +} +``` +{% endtab %} +{% tab Segment %} +```json +// Feature Flag Experiment Impression: users.messages.featureflag.Impression + +{ + "context" : { + "traits" : { }, + "device" : { + "model" : "(optional, string) Model of the device", + "type" : "(optional, string) Platform of the device" + } + }, + "event" : "(required, string) The event type name, as it is exported to Segment", + "messageId" : "(required, string) Globally unique ID for this event", + "properties" : { + "app_id" : "(optional, string) API ID of the app on which this event occurred", + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "browser" : "(optional, string) Device browser - extracted from user_agent - on which the open occurred", + "campaign_id" : "(optional, string) API ID of the campaign this event belongs to", + "campaign_name" : "(optional, string) Name of the campaign", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "device_id" : "(optional, string) ID of the device on which the event occurred", + "feature_flag_id_name" : "(optional, string) The Feature Flag Rollout identifier", + "message_variation_id" : "(optional, string) API ID of the message variation this user received", + "message_variation_name" : "(optional, string) Name of the message variation", + "platform" : "(optional, string) Platform of the device" + }, + "timestamp" : "(required, int) UNIX timestamp at which the event happened", + "type" : "track", + "userId" : "(required, string) External ID of the user" +} +``` +{% endtab %} +{% endtabs %} {% endapi %} @@ -8934,11 +9130,173 @@ This event occurs when a user enters into the Canvas. This event tells you which ## Canvas step progression events {% apitags %} -Canvas, StepProgression +CanvasStep, Progression {% endapitags %} This event occurs when a user progresses through a step in a Canvas with some outcome. Currently, only split steps – Audience Paths, Decision Split, Action Paths, Experiment – and Advance outcomes generate Step Progression events. +{% tabs %} +{% tab Mixpanel %} +```json +// Canvas Step Progression: users.canvasstep.Progression + +{ + "event" : "(required, string) The event type name, as it is exported to Mixpanel", + "properties" : { + "$partner_id" : "braze", + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_entry_id" : "(required, string) Unique identifier for this instance of a user in a canvas", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "device_id" : "(optional, string) ID of the device on which the event occurred", + "exit_reason" : "(optional, string) If this is an exit, the reason a user exited the canvas during the step", + "distinct_id" : "(required, string) External ID of the user", + "$insert_id" : "(required, string) Globally unique ID for this event", + "is_canvas_entry" : "(optional, boolean) Whether this is entry into a first step in a canvas", + "next_step_id" : "(optional, string) API ID of the next step in the canvas", + "progression_type" : "(required, string) What type of step progression event this is", + "time" : "(required, int) UNIX timestamp at which the event happened", + "token" : "(required, string) The Mixpanel API token" + } +} +``` +{% endtab %} + +{% tab Cloud Storage %} +```json +// Canvas Step Progression: users.canvasstep.Progression +{ + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "canvas_entry_id" : "(required, string) Unique identifier for this instance of a user in a canvas", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "device_id" : "(optional, string) ID of the device on which the event occurred", + "exit_reason" : "(optional, string) If this is an exit, the reason a user exited the canvas during the step", + "external_user_id" : "(optional, string) External ID of the user", + "id" : "(required, string) Globally unique ID for this event", + "is_canvas_entry" : "(optional, boolean) Whether this is entry into a first step in a canvas", + "next_step_id" : "(optional, string) API ID of the next step in the canvas", + "progression_type" : "(required, string) What type of step progression event this is", + "time" : "(required, int) UNIX timestamp at which the event happened", + "user_id" : "(required, string) Braze user ID of the user who performed this event" +} +``` +{% endtab %} + +{% tab mParticle %} +```json +// Canvas Step Progression: users.canvasstep.Progression + +{ + "device_info" : { + "ios_idfv" : "(optional, string) ID of the device on which the event occurred" + }, + "environment" : "(required, string) The mParticle environment (either 'development' or 'production')", + "events" : [ + { + "data" : { + "custom_attributes" : { + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_entry_id" : "(required, string) Unique identifier for this instance of a user in a canvas", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "device_id" : "(optional, string) ID of the device on which the event occurred", + "exit_reason" : "(optional, string) If this is an exit, the reason a user exited the canvas during the step", + "is_canvas_entry" : "(optional, boolean) Whether this is entry into a first step in a canvas", + "next_step_id" : "(optional, string) API ID of the next step in the canvas", + "progression_type" : "(required, string) What type of step progression event this is" + }, + "custom_event_type" : "(required, string) The mParticle custom event type if the event_type is 'custom_event' (always 'other')", + "event_name" : "(required, string) The event type name, as it is exported to mParticle", + "source_message_id" : "(required, string) Globally unique ID for this event", + "timestamp_unixtime_ms" : "(required, int) UNIX timestamp at which the event happened" + }, + "event_type" : "(required, string) mParticle event type (either 'uninstall' or 'custom_event')" + } + ], + "schema_version" : 2, + "user_attributes" : { }, + "user_identities" : { + "customerid" : "(required, string) External ID of the user" + } +} +``` +{% endtab %} + +{% tab Amplitude %} +```json +// Canvas Step Progression: users.canvasstep.Progression + +{ + "device_id" : "(optional, string) ID of the device on which the event occurred", + "event_properties" : { + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_entry_id" : "(required, string) Unique identifier for this instance of a user in a canvas", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "exit_reason" : "(optional, string) If this is an exit, the reason a user exited the canvas during the step", + "is_canvas_entry" : "(optional, boolean) Whether this is entry into a first step in a canvas", + "next_step_id" : "(optional, string) API ID of the next step in the canvas", + "progression_type" : "(required, string) What type of step progression event this is" + }, + "event_type" : "(required, string) The event type name, as it is exported to Amplitude", + "insert_id" : "(required, string) Globally unique ID for this event", + "library" : "Braze", + "time" : "(required, int) UNIX timestamp at which the event happened", + "user_id" : "(optional, string) External ID of the user" +} +``` +{% endtab %} + +{% tab Segment %} +```json +// Canvas Step Progression: users.canvasstep.Progression + +{ + "context" : { + "traits" : { }, + "device" : { } + }, + "event" : "(required, string) The event type name, as it is exported to Segment", + "messageId" : "(required, string) Globally unique ID for this event", + "properties" : { + "app_group_id" : "(optional, string) API ID of the app group this user belongs to", + "canvas_id" : "(optional, string) API ID of the Canvas this event belongs to", + "canvas_entry_id" : "(required, string) Unique identifier for this instance of a user in a canvas", + "canvas_name" : "(optional, string) Name of the Canvas", + "canvas_step_id" : "(optional, string) API ID of the Canvas step this event belongs to", + "canvas_step_name" : "(optional, string) Name of the Canvas step", + "canvas_variation_id" : "(optional, string) API ID of the Canvas variation this event belongs to", + "canvas_variation_name" : "(optional, string) Name of the Canvas variation this user received", + "device_id" : "(optional, string) ID of the device on which the event occurred", + "exit_reason" : "(optional, string) If this is an exit, the reason a user exited the canvas during the step", + "is_canvas_entry" : "(optional, boolean) Whether this is entry into a first step in a canvas", + "next_step_id" : "(optional, string) API ID of the next step in the canvas", + "progression_type" : "(required, string) What type of step progression event this is" + }, + "timestamp" : "(required, int) UNIX timestamp at which the event happened", + "type" : "track", + "userId" : "(required, string) External ID of the user" +} +``` +{% endtab %} +{% endtabs %} {% endapi %} From 39d2b1652226194b35f6a51b18e55e5a3a41260c Mon Sep 17 00:00:00 2001 From: internetisaiah <95643215+internetisaiah@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:56:08 -0700 Subject: [PATCH 5/9] fixing usage comments --- scripts/list_redirect_urls.sh | 2 +- scripts/remove_unused_reference_links.rb | 2 +- scripts/transform_reference_links.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/list_redirect_urls.sh b/scripts/list_redirect_urls.sh index 13be3e05c20..d427e3d66b4 100755 --- a/scripts/list_redirect_urls.sh +++ b/scripts/list_redirect_urls.sh @@ -4,7 +4,7 @@ # base URL to list all old URLs so the user can open old links directly from # the terminal to test redirects. # -# Usage: ./bdocs redirects -l +# Usage: ./bdocs lredirects # Check new redirects by comparing the current branch to develop. NEW_REDIRECTS=$(git diff develop -- $PROJECT_ROOT/assets/js/broken_redirect_list.js) diff --git a/scripts/remove_unused_reference_links.rb b/scripts/remove_unused_reference_links.rb index a1823248f18..20ab1b47a29 100755 --- a/scripts/remove_unused_reference_links.rb +++ b/scripts/remove_unused_reference_links.rb @@ -3,7 +3,7 @@ # Removes unused reference-style links from the bottom of a file, such as: # [1]: {{site.baseurl}}/contributing/your_first_contribution/ # -# Usage: ./bdocs links -r [FILE|DIRECTORY] +# Usage: ./bdocs rlinks [FILE|DIRECTORY] # # Options: # FILE Delete unused reference links in a single file. diff --git a/scripts/transform_reference_links.py b/scripts/transform_reference_links.py index c2a1370b257..da23215def2 100755 --- a/scripts/transform_reference_links.py +++ b/scripts/transform_reference_links.py @@ -6,7 +6,7 @@ # For more information, see: # https://www.braze.com/docs/contributing/content_management/cross_referencing/ # -# Usage: ./bdocs links -t [FILE|DIRECTORY] +# Usage: ./bdocs tlinks [FILE|DIRECTORY] # # Options: # FILE Transform reference links in a single file. From 13d1ee6ca4c7699ffc39c9714edb922d0f514f34 Mon Sep 17 00:00:00 2001 From: internetisaiah <95643215+internetisaiah@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:25:11 -0800 Subject: [PATCH 6/9] removing work that was done in another branch --- bdocs | 101 ++++++++++------------- scripts/create_release_text.sh | 4 +- scripts/list_redirect_urls.sh | 5 +- scripts/remove_unused_reference_links.rb | 2 - scripts/transform_reference_links.py | 2 - 5 files changed, 51 insertions(+), 63 deletions(-) mode change 100755 => 100644 scripts/remove_unused_reference_links.rb diff --git a/bdocs b/bdocs index f8709a6ba13..38c1f3014f0 100755 --- a/bdocs +++ b/bdocs @@ -1,22 +1,14 @@ #!/bin/bash -# This is a wrapper script for interacting with the files in './scripts/'. +# This is a bash script for interacting with the various files in './scripts/'. # # Usage: ./bdocs [option] set -e -# The project's root directory and redirect file. -export PROJECT_ROOT="$(dirname "$(realpath "$0")")" -export REDIRECT_FILE="./assets/js/broken_redirect_list.js" - -# All scripts exported so they can source bdocs and call each other if needed. -export DEPLOY="$PROJECT_ROOT/scripts/create_deploy_text.sh" -export RELEASE="$PROJECT_ROOT/scripts/create_release_text.sh" -export TLINKS="$PROJECT_ROOT/scripts/transform_reference_links.py" -export RLINKS="$PROJECT_ROOT/scripts/remove_unused_reference_links.rb" -export CREDIRECTS="$PROJECT_ROOT/scripts/create_redirects.py" -export LREDIRECTS="$PROJECT_ROOT/scripts/list_redirect_urls.sh" +# The project's root directory. +export PROJECT_ROOT +PROJECT_ROOT="$(dirname "$(realpath "$0")")" # Displays usage for bdocs display_help() { @@ -27,75 +19,72 @@ USAGE: ./bdocs [option] OPTIONS: - deploy Create the deploy body text for weekly deployments - release Create the release body text for monthly releases - tlinks Transform reference links to inline links on 1 or more pages - rlinks Remove unused reference links on 1 or more pages - credirects Create redirects for all changed files in _docs - lredirects List the old URLs for all new redirects in this branch - help Display this help message and exit + deploy Create the deploy body text for weekly deployments + release Create the release body text for monthly releases + tlinks Transform reference links to inline links on 1 or more pages + rlinks Remove reference links that are not being used on 1 or more pages + redirects List the old URLs for all new redirects in this branch + help Display this help message and exit EOF } -# If a file or directory is required, pass or fail. -require_path_or_file() { - if [[ -z "$1" ]]; then - echo "Error: A file or directory path is required." - exit 1 - fi -} - -# If new merges into 'develop' are required, pass or fail. -require_new_merges() { - LATEST_COMMIT_HASH=$(git log --max-count=1 --format="%H" origin/master ^origin/develop) - COMMIT_LOGS=$(git log --first-parent "$LATEST_COMMIT_HASH"..origin/develop) - if [ -z "$COMMIT_LOGS" ]; then - echo "Error: No new merges into 'develop' since the last deployment." - exit 1 - fi -} - # Check if no arguments were provided if [[ $# -eq 0 ]]; then display_help exit 1 fi -# Fetch the latest changes from the remote quietly. -git fetch origin develop --quiet - # Argument parsing case $1 in deploy) - require_new_merges if [[ $# -eq 3 ]]; then - "$DEPLOY" "$2" "$3" + "$PROJECT_ROOT/scripts/create_deploy_text.sh" "$2" "$3" else - "$DEPLOY" + "$PROJECT_ROOT/scripts/create_deploy_text.sh" fi ;; release) - require_new_merges - "$RELEASE" + "$PROJECT_ROOT/scripts/create_release_text.sh" ;; tlinks) - require_path_or_file "$2" - "$TLINKS" "$2" - "$RLINKS" "$2" # Run rlinks next, to clean up unused reference links. + if [[ -z "$2" ]]; then + echo "Error: A file or directory path is required." + exit 1 + fi + python3 "$PROJECT_ROOT/scripts/transform_reference_links.py" "$2" + echo "Success!" + while true; do + echo "Do you want to remove the unused reference links? [Y/n]." + read -r opt + case $opt in + y*|Y*) + ruby "$PROJECT_ROOT/scripts/remove_unused_reference_links.rb" "$2" + echo "Success!" + break + ;; + n*|N*) + echo "The unused reference links were left untouched." + break + ;; + *) echo "Error: Invalid choice." + echo "" + ;; + esac + done ;; rlinks) - require_path_or_file "$2" - "$RLINKS" "$2" - ;; - credirects) - "$CREDIRECTS" + if [[ -z "$2" ]]; then + echo "Error: The path to file or directory is required." + exit 1 + fi + ruby "$PROJECT_ROOT/scripts/remove_unused_reference_links.rb" "$2" ;; - lredirects) + redirects) if [[ $# -eq 2 ]]; then - "$LREDIRECTS" "$2" + "$PROJECT_ROOT/scripts/list_redirect_urls.sh" "$2" else - "$LREDIRECTS" + "$PROJECT_ROOT/scripts/list_redirect_urls.sh" fi ;; help) diff --git a/scripts/create_release_text.sh b/scripts/create_release_text.sh index 9acb433f500..33eebece9b2 100755 --- a/scripts/create_release_text.sh +++ b/scripts/create_release_text.sh @@ -44,9 +44,9 @@ main() { COMMIT_TITLE=$(echo "$commit" | jq -r '.title') COMMIT_BODY=$(echo "$commit" | jq -r '.body') - # Print the deploy text for each deployment using the sourced DEPLOY. + # Print the deploy text for each deployment. echo "## $COMMIT_BODY" - "$DEPLOY" "$PREV_COMMIT_DATE" "$COMMIT_DATE" + ./scripts/create_deploy_text.sh "$PREV_COMMIT_DATE" "$COMMIT_DATE" echo "" # Get the next range of commits by increasing 'PREV_COMMIT_DATE'. diff --git a/scripts/list_redirect_urls.sh b/scripts/list_redirect_urls.sh index d427e3d66b4..5acc2380fea 100755 --- a/scripts/list_redirect_urls.sh +++ b/scripts/list_redirect_urls.sh @@ -4,7 +4,10 @@ # base URL to list all old URLs so the user can open old links directly from # the terminal to test redirects. # -# Usage: ./bdocs lredirects +# Usage: ./bdocs redirects + +# Fetch the latest changes from the remote. +git fetch origin develop --quiet # Check new redirects by comparing the current branch to develop. NEW_REDIRECTS=$(git diff develop -- $PROJECT_ROOT/assets/js/broken_redirect_list.js) diff --git a/scripts/remove_unused_reference_links.rb b/scripts/remove_unused_reference_links.rb old mode 100755 new mode 100644 index 20ab1b47a29..795ed331de7 --- a/scripts/remove_unused_reference_links.rb +++ b/scripts/remove_unused_reference_links.rb @@ -1,5 +1,3 @@ -#!/usr/bin/env ruby - # Removes unused reference-style links from the bottom of a file, such as: # [1]: {{site.baseurl}}/contributing/your_first_contribution/ # diff --git a/scripts/transform_reference_links.py b/scripts/transform_reference_links.py index da23215def2..12d0fa23c8e 100755 --- a/scripts/transform_reference_links.py +++ b/scripts/transform_reference_links.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python3 - # Converts Markdown reference links to in-line links. Created because # reference links cannot be placed inside Liquid {% tab %} tags. # From a5087f05d7ec4b00b1f394d321401280f9bd79d3 Mon Sep 17 00:00:00 2001 From: internetisaiah <95643215+internetisaiah@users.noreply.github.com> Date: Mon, 23 Dec 2024 12:27:54 -0800 Subject: [PATCH 7/9] adding script to bdocs again --- bdocs | 5 +++++ scripts/{create_redirects.py => make_redirects.py} | 0 2 files changed, 5 insertions(+) rename scripts/{create_redirects.py => make_redirects.py} (100%) diff --git a/bdocs b/bdocs index 6ea1777f27e..86d613775fb 100755 --- a/bdocs +++ b/bdocs @@ -17,6 +17,7 @@ export RELEASE="$PROJECT_ROOT/scripts/create_release_text.sh" export TLINKS="$PROJECT_ROOT/scripts/transform_reference_links.py" export RLINKS="$PROJECT_ROOT/scripts/remove_unused_reference_links.rb" export ULINKS="$PROJECT_ROOT/scripts/update_old_links.py" +export MREDIRECTS="$PROJECT_ROOT/scripts/make_redirects.py" export LREDIRECTS="$PROJECT_ROOT/scripts/list_new_redirect_urls.sh" # Utility scripts that are not directly used in bdocs: export MRD="$PROJECT_ROOT/scripts/utils/merge_redirect_descendants.py" @@ -36,6 +37,7 @@ OPTIONS: tlinks Transform reference links to inline links on 1 or more pages rlinks Remove unused reference links on 1 or more pages ulinks Update old links using newest redirect on 1 or more pages + mredirects Make redirects for all renamed files in this branch lredirects Test new redirects by listing old URLs in this branch help Display this help message and exit @@ -104,6 +106,9 @@ case $1 in "$ULINKS" "$2" # rm "$REDIRECT_MATCHES" ;; + mredirects + "$MREDIRECTS" + ;; lredirects) if [[ $# -eq 2 ]]; then "$LREDIRECTS" "$2" diff --git a/scripts/create_redirects.py b/scripts/make_redirects.py similarity index 100% rename from scripts/create_redirects.py rename to scripts/make_redirects.py From 8fd2c1a5632773934ff307e722223cf3614018ef Mon Sep 17 00:00:00 2001 From: isaiah robinson <95643215+internetisaiah@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:36:15 -0800 Subject: [PATCH 8/9] Fix syntax error on bdocs --- bdocs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bdocs b/bdocs index 86d613775fb..d50df33cacd 100755 --- a/bdocs +++ b/bdocs @@ -106,7 +106,7 @@ case $1 in "$ULINKS" "$2" # rm "$REDIRECT_MATCHES" ;; - mredirects + mredirects) "$MREDIRECTS" ;; lredirects) From 54c994a163543c14e5aa16bdb0d45c00248232f0 Mon Sep 17 00:00:00 2001 From: isaiah robinson <95643215+internetisaiah@users.noreply.github.com> Date: Fri, 10 Jan 2025 15:36:39 -0800 Subject: [PATCH 9/9] Update make_redirects.py --- scripts/make_redirects.py | 60 +++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/scripts/make_redirects.py b/scripts/make_redirects.py index 18ccc37650a..06e49948105 100755 --- a/scripts/make_redirects.py +++ b/scripts/make_redirects.py @@ -16,42 +16,48 @@ def get_changed_files(): cmd = f"git diff -M --summary develop HEAD -- {project_root}_docs" result = subprocess.run(cmd, shell=True, capture_output=True, text=True) # Filter lines that start with "rename" or " rename" - return [line.strip() for line in result.stdout.splitlines() if line.startswith("rename") or line.startswith(" rename")] + changed_files = [line.strip() for line in result.stdout.splitlines() if line.startswith("rename") or line.startswith(" rename")] + + return changed_files def create_redirect(line): - # Remove everything up to and including the first space, but keep the initial underscore + # Strip "rename " and the trailing percentage line = line.split(" ", 1)[1] - - # Remove any trailing `(NUM%)` from the line line = re.sub(r"\s\(\d+%\)$", "", line) - # Get the relative paths for the old and new filenames - line_separator = line.split("{")[0].strip() - - # Check if this is a directory rename (no `.md` in `{old => }/new.md` portion) - if re.search(r"{([^{}]+) => }/[^\s]+\.md", line): - # Directory-only rename handling - old_path_part, new_filename = re.search(r"{([^{}]+) => }/(.+)", line).groups() - - # Construct the paths for old and new locations - old_path = f"/{line_separator}{old_path_part}/{new_filename}" - new_path = f"/{line_separator}{new_filename}" - elif re.search(r"{(.+?) => (.+?)}", line): - # Standard file rename handling with `{old => new}` pattern - unformatted_old_path, unformatted_new_path = re.search(r"{(.+?) => (.+?)}", line).groups() - old_path = f"/{line_separator}{unformatted_old_path}" - new_path = f"/{line_separator}{unformatted_new_path}" - else: + # Extract the `{old => new}` part. + brace_match = re.search(r"{([^}]+) => ([^}]+)}", line) + if not brace_match: return None + + old_in_braces = brace_match.group(1) + new_in_braces = brace_match.group(2) + + # Grab everything before and after the braces + before_braces = line.split("{")[0] + after_braces = line.split("}")[1] # everything after the closing brace - # Remove leading underscores and .md extensions, and format paths - old_path = old_path.replace("/_", "/").replace(".md", "") - new_path = new_path.replace("/_", "/").replace(".md", "") + # Build the leading path (before the '{') + leading_path = before_braces.strip() + + # The trailing part after the '}' (e.g. "/catalogs.md") + # (strip leading slash, if any) + trailing_path = after_braces.strip() + + # Combine to form full old & new + # old_in_braces, new_in_braces might still have .md in them + # trailing_path might also have .md + + old_full_path = f"/{leading_path}{old_in_braces}{trailing_path}" + new_full_path = f"/{leading_path}{new_in_braces}{trailing_path}" + + # Clean underscores and strip .md + old_full_path = old_full_path.replace("/_", "/").replace(".md", "") + new_full_path = new_full_path.replace("/_", "/").replace(".md", "") - # Convert paths to the redirect syntax: validurls['OLD'] = 'NEW'; - redirect = f"validurls['{old_path}'] = '{new_path}';" + # Return the final redirect line + return f"validurls['{old_full_path}'] = '{new_full_path}';" - return redirect def main(): # Fetch changed files