import json


def scrub_profile_info(text):
    """Gigya auth and the account pages contain personal info. Scrub it."""
    try:
        parsed = json.loads(text)
    except ValueError:
        return text

    for i in ['profile', 'billing']:
        try:
            if parsed[i]:
                parsed[i] = 'REDACTED'
        except (KeyError, TypeError):
            pass

    text = json.dumps(parsed)
    return text