-
Notifications
You must be signed in to change notification settings - Fork 12
feature: add onFullstoryDidStartSession lifecycle API #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,19 @@ | ||
| import type { TurboModule } from 'react-native'; | ||
| import { TurboModuleRegistry } from 'react-native'; | ||
| import { OnReadyResponse } from './fullstoryInterface'; | ||
| import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes'; | ||
|
|
||
| // needs to be defined here, cannot be imported | ||
| export type FSSessionData = { | ||
| replayStartUrl: string; | ||
| replayNowUrl: string; | ||
| sessionId: string; | ||
| }; | ||
|
|
||
| export interface Spec extends TurboModule { | ||
| anonymize(): void; | ||
| identify(uid: string, userVars?: Object): void; | ||
| setUserVars(userVars: Object): void; | ||
| onReady(): Promise<OnReadyResponse>; | ||
| onReady(): Promise<FSSessionData>; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wont this break existing code?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No it won't because:
|
||
| getCurrentSession(): Promise<string>; | ||
| getCurrentSessionURL(): Promise<string>; | ||
| consent(userConsents: boolean): void; | ||
|
|
@@ -18,6 +25,10 @@ export interface Spec extends TurboModule { | |
| startPage(nonce: string, pageName: string, pageProperties?: Object): void; | ||
| endPage(uuid: string): void; | ||
| updatePage(uuid: string, pageProperties: Object): void; | ||
| // Not exposed in the public API. Must be declared here because TurboModule codegen | ||
| // requires all native event emitters to be defined on the Spec interface. Used | ||
| // internally by onReady() to support the listener-based overload. | ||
| readonly onSessionStarted: EventEmitter<FSSessionData>; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to confirm @RyanCommits - this isn't exposed, correct? If so, can we add a comment here. Just confusing that this is an exported interface.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes exactly, it is not exposed. It's defined for the purposes of codegen in React Native, and exported for the purposes of us picking off the methods we DO want to expose with: |
||
| } | ||
|
|
||
| export default TurboModuleRegistry.get<Spec>('FullStory'); | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now set the delegate on app start, whereas before we set it when we call
onReadyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we prefer to use load instead to be sure that this is set as early as possible, or can we be sure that this function is called at an appropriate time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, I think you're right, since we do actually use the instance variables, init makes sense.