Turn whatever a marketer has on their clipboard into credentials.
The problem this solves
A settings form that asks for pixel_code on one row, measurement_id on
the next and ad_account_id on the third is asking the person filling it in
to already know the answer. What they actually have is the block of
JavaScript Events Manager told them to paste into their site — and every one
of those blocks contains the id, in a position a regex can reach.
Detect.detect(~s|<script>fbq('init', '1234567890123456');</script>|)
#=> %{meta: %{pixel_id: "1234567890123456"}}
Detect.detect("G-ABC1234XYZ")
#=> %{ga4: %{measurement_id: "G-ABC1234XYZ"}}Two entry points
detect/1 scans free text and reports every platform it recognises — the
"paste anything" box. clean/3 knows which platform and field it is filling
and pulls that one value out, so pasting a snippet into the Pixel ID field
works exactly as well as typing the id.
What it deliberately does not detect
Access tokens, API secrets and Pinterest ad-account ids have no distinguishing
shape — Meta's EAA… prefix is the one exception and it is here. Guessing at
the rest would mean writing a token into the wrong platform's row, which fails
as a 401 weeks later with nothing pointing at the cause. Anything ambiguous
stays a field the human fills in.
Detection is a suggestion: it populates the form, the human saves it.
Summary
Functions
Pull key for platform out of value, which may be a bare id or a whole
snippet.
Every credential recognisable in text, grouped by platform.
Functions
Pull key for platform out of value, which may be a bare id or a whole
snippet.
Falls through to the trimmed input when nothing matches: the person typing knows more about their account than a regex does, and a field that refuses what it does not recognise is a field that cannot be filled.
Every credential recognisable in text, grouped by platform.
Returns %{} for anything unrecognised — never raises, never guesses.