-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e13ce3
commit 081a5ef
Showing
14 changed files
with
105 additions
and
25 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
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import useIDKit from './hooks/useIDKit' | ||
import type { Config } from '@/types/config' | ||
import IDKitWidget from '@/components/IDKitWidget' | ||
import type { WidgetProps, Config } from '@/types/config' | ||
import type { ISuccessResult, SignalType, PhoneSignalProof, OrbSignalProof } from '@/types' | ||
|
||
export { IDKitWidget, useIDKit } | ||
export type { ISuccessResult, Config, SignalType, PhoneSignalProof, OrbSignalProof } | ||
export type { ISuccessResult, Config, SignalType, PhoneSignalProof, OrbSignalProof, WidgetProps } |
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,55 @@ | ||
import PostHog from 'posthog-js-lite' | ||
|
||
// Set at build time | ||
declare const IDKitVersion: string | ||
|
||
function factoryPostHogFetchError(error: unknown) { | ||
return { name: 'telemetry-error', error } | ||
} | ||
|
||
if (typeof window !== 'undefined') { | ||
window.onunhandledrejection = function (event) { | ||
return (event.reason as Record<string, any>).name !== 'telemetry-error' | ||
} | ||
} | ||
|
||
async function posthogFetch(input: RequestInfo, init?: RequestInit): Promise<Response> { | ||
try { | ||
return await fetch(input, init) | ||
} catch (error) { | ||
throw factoryPostHogFetchError(error) | ||
} | ||
} | ||
|
||
let posthog: PostHog | null = null | ||
|
||
if (typeof window !== 'undefined') { | ||
posthog = new PostHog( | ||
'phc_QttqgDbMQDYHX1EMH7FnT6ECBVzdp0kGUq92aQaVQ6I', // cspell:disable-line | ||
{ persistence: 'memory' } | ||
) | ||
posthog.fetch = posthogFetch | ||
} | ||
|
||
// Attributes sent on all events | ||
const SUPER_PROPS = { version: IDKitVersion, package: 'idkit-js' } | ||
|
||
export const getTelemetryId = (): string => { | ||
return posthog?.getDistinctId() ?? '' | ||
} | ||
|
||
export const initTelemetry = (enableTelemetry?: boolean): void => { | ||
if (enableTelemetry) { | ||
posthog?.capture('idkit loaded', SUPER_PROPS) | ||
} else { | ||
posthog?.optOut() | ||
} | ||
} | ||
|
||
export const telemetryModalOpened = (): void => { | ||
posthog?.capture('idkit opened', SUPER_PROPS) | ||
} | ||
|
||
export const telemetryPhoneTyped = (): void => { | ||
posthog?.capture('idkit phone typed', SUPER_PROPS) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9987,6 +9987,11 @@ postcss@^8.3.5, postcss@^8.4.12, postcss@^8.4.18, postcss@^8.4.19, postcss@^8.4. | |
picocolors "^1.0.0" | ||
source-map-js "^1.0.2" | ||
|
||
[email protected]: | ||
version "2.0.0-alpha5" | ||
resolved "https://registry.yarnpkg.com/posthog-js-lite/-/posthog-js-lite-2.0.0-alpha5.tgz#60cff1b756ba2723ebb0222ca132fd0de8036210" | ||
integrity sha512-tlkBdypJuvK/s00n4EiQjwYVfuuZv6vt8BF3g1ooIQa2Gz9Vz80p8q3qsPLZ0V5ErGRy6i3Q4fWC9TDzR7GNRQ== | ||
|
||
prelude-ls@^1.2.1: | ||
version "1.2.1" | ||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" | ||
|