-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tryIdentifyFromParams API to SDK. (#14)
* Add tryIdentifyFromParams API to SDK. This function looks for an `oeid` parameter in the query string of the page and, if found and appears to be a valid sha256 hash-length hex string, automatically try identify("e:"+oeid) Lives in lib/addons/try_identify, now along with gpt_events. * Update README with docs on oeid
- Loading branch information
Showing
6 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import SDK from "../sdk"; | ||
|
||
declare module "../sdk" { | ||
export interface SDK { | ||
tryIdentifyFromParams: () => void; | ||
} | ||
} | ||
|
||
function maybeValidEID(eid: string): boolean { | ||
return eid.match(/^[a-f0-9]{64}$/i) !== null; | ||
} | ||
|
||
SDK.prototype.tryIdentifyFromParams = function () { | ||
const qstr = new URLSearchParams(window.location.search); | ||
const eid = qstr.get("oeid"); | ||
if (maybeValidEID(eid || "")) { | ||
this.identify(["e:" + eid]); | ||
} | ||
}; |