From 879d40c9d333caf30dc69210b09d9ab07b33b915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matu=CC=81s=CC=8C=20Tomlein?= Date: Wed, 13 Nov 2024 13:23:15 +0100 Subject: [PATCH] Update docs --- ...ode-tracker.coreplugin.deactivateplugin.md | 13 ++++++++++ .../markdown/node-tracker.coreplugin.md | 1 + .../node-tracker.trackercore.deactivate.md | 17 ++++++++++++ .../markdown/node-tracker.trackercore.md | 1 + .../docs/node-tracker/node-tracker.api.md | 2 ++ ...ive-tracker.coreplugin.deactivateplugin.md | 13 ++++++++++ .../react-native-tracker.coreplugin.md | 1 + .../react-native-tracker.gettracker.md | 26 +++++++++++++++++++ .../markdown/react-native-tracker.md | 3 +++ .../react-native-tracker.removealltrackers.md | 19 ++++++++++++++ .../react-native-tracker.removetracker.md | 24 +++++++++++++++++ ...t-native-tracker.trackercore.deactivate.md | 17 ++++++++++++ .../react-native-tracker.trackercore.md | 1 + .../react-native-tracker.api.md | 11 ++++++++ trackers/react-native-tracker/src/tracker.ts | 4 +-- 15 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 api-docs/docs/node-tracker/markdown/node-tracker.coreplugin.deactivateplugin.md create mode 100644 api-docs/docs/node-tracker/markdown/node-tracker.trackercore.deactivate.md create mode 100644 api-docs/docs/react-native-tracker/markdown/react-native-tracker.coreplugin.deactivateplugin.md create mode 100644 api-docs/docs/react-native-tracker/markdown/react-native-tracker.gettracker.md create mode 100644 api-docs/docs/react-native-tracker/markdown/react-native-tracker.removealltrackers.md create mode 100644 api-docs/docs/react-native-tracker/markdown/react-native-tracker.removetracker.md create mode 100644 api-docs/docs/react-native-tracker/markdown/react-native-tracker.trackercore.deactivate.md diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.coreplugin.deactivateplugin.md b/api-docs/docs/node-tracker/markdown/node-tracker.coreplugin.deactivateplugin.md new file mode 100644 index 000000000..811a13c07 --- /dev/null +++ b/api-docs/docs/node-tracker/markdown/node-tracker.coreplugin.deactivateplugin.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@snowplow/node-tracker](./node-tracker.md) > [CorePlugin](./node-tracker.coreplugin.md) > [deactivatePlugin](./node-tracker.coreplugin.deactivateplugin.md) + +## CorePlugin.deactivatePlugin property + +Called when the tracker is being destroyed. Should be used to clean up any resources or listeners that the plugin has created. + +Signature: + +```typescript +deactivatePlugin?: (core: TrackerCore) => void; +``` diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.coreplugin.md b/api-docs/docs/node-tracker/markdown/node-tracker.coreplugin.md index 37513de7d..65e4f9ae4 100644 --- a/api-docs/docs/node-tracker/markdown/node-tracker.coreplugin.md +++ b/api-docs/docs/node-tracker/markdown/node-tracker.coreplugin.md @@ -20,6 +20,7 @@ interface CorePlugin | [afterTrack?](./node-tracker.coreplugin.aftertrack.md) | (payload: Payload) => void | (Optional) Called just after the trackerCore callback fires | | [beforeTrack?](./node-tracker.coreplugin.beforetrack.md) | (payloadBuilder: PayloadBuilder) => void | (Optional) Called before the filter method is called and before the trackerCore callback fires (if the filter passes) | | [contexts?](./node-tracker.coreplugin.contexts.md) | () => SelfDescribingJson\[\] | (Optional) Called when constructing the context for each event Useful for adding additional context to events | +| [deactivatePlugin?](./node-tracker.coreplugin.deactivateplugin.md) | (core: TrackerCore) => void | (Optional) Called when the tracker is being destroyed. Should be used to clean up any resources or listeners that the plugin has created. | | [filter?](./node-tracker.coreplugin.filter.md) | (payload: Payload) => boolean | (Optional) Called before the payload is sent to the callback to decide whether to send the payload or skip it | | [logger?](./node-tracker.coreplugin.logger.md) | (logger: Logger) => void | (Optional) Passed a logger instance which can be used to send log information to the active logger | diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.trackercore.deactivate.md b/api-docs/docs/node-tracker/markdown/node-tracker.trackercore.deactivate.md new file mode 100644 index 000000000..d3b1daf9f --- /dev/null +++ b/api-docs/docs/node-tracker/markdown/node-tracker.trackercore.deactivate.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [@snowplow/node-tracker](./node-tracker.md) > [TrackerCore](./node-tracker.trackercore.md) > [deactivate](./node-tracker.trackercore.deactivate.md) + +## TrackerCore.deactivate() method + +Deactivate tracker core including all plugins. This is useful for cleaning up resources or listeners that have been created. Once deactivated, the tracker won't be able to track any events. + +Signature: + +```typescript +deactivate(): void; +``` +Returns: + +void + diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.trackercore.md b/api-docs/docs/node-tracker/markdown/node-tracker.trackercore.md index be6ea7a79..d63fc8419 100644 --- a/api-docs/docs/node-tracker/markdown/node-tracker.trackercore.md +++ b/api-docs/docs/node-tracker/markdown/node-tracker.trackercore.md @@ -27,6 +27,7 @@ interface TrackerCore | [addPayloadDict(dict)](./node-tracker.trackercore.addpayloaddict.md) | Merges a dictionary into payloadPairs | | [addPlugin(configuration)](./node-tracker.trackercore.addplugin.md) | Add a plugin into the plugin collection after Core has already been initialised | | [clearGlobalContexts()](./node-tracker.trackercore.clearglobalcontexts.md) | Removes all global contexts | +| [deactivate()](./node-tracker.trackercore.deactivate.md) | Deactivate tracker core including all plugins. This is useful for cleaning up resources or listeners that have been created. Once deactivated, the tracker won't be able to track any events. | | [getBase64Encoding()](./node-tracker.trackercore.getbase64encoding.md) | Get current base64 encoding state | | [removeGlobalContexts(contexts)](./node-tracker.trackercore.removeglobalcontexts.md) | Removes previously added global context, performs a deep comparison of the contexts or conditional contexts | | [resetPayloadPairs(dict)](./node-tracker.trackercore.resetpayloadpairs.md) | Replace payloadPairs with a new dictionary | diff --git a/api-docs/docs/node-tracker/node-tracker.api.md b/api-docs/docs/node-tracker/node-tracker.api.md index e8df083bf..5a9b6fd16 100644 --- a/api-docs/docs/node-tracker/node-tracker.api.md +++ b/api-docs/docs/node-tracker/node-tracker.api.md @@ -165,6 +165,7 @@ export interface CorePlugin { afterTrack?: (payload: Payload) => void; beforeTrack?: (payloadBuilder: PayloadBuilder) => void; contexts?: () => SelfDescribingJson[]; + deactivatePlugin?: (core: TrackerCore) => void; filter?: (payload: Payload) => boolean; logger?: (logger: Logger) => void; } @@ -527,6 +528,7 @@ export interface TrackerCore { addPayloadPair: (key: string, value: unknown) => void; addPlugin(configuration: CorePluginConfiguration): void; clearGlobalContexts(): void; + deactivate(): void; getBase64Encoding(): boolean; removeGlobalContexts(contexts: Array): void; resetPayloadPairs(dict: Payload): void; diff --git a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.coreplugin.deactivateplugin.md b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.coreplugin.deactivateplugin.md new file mode 100644 index 000000000..72db41582 --- /dev/null +++ b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.coreplugin.deactivateplugin.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@snowplow/react-native-tracker](./react-native-tracker.md) > [CorePlugin](./react-native-tracker.coreplugin.md) > [deactivatePlugin](./react-native-tracker.coreplugin.deactivateplugin.md) + +## CorePlugin.deactivatePlugin property + +Called when the tracker is being destroyed. Should be used to clean up any resources or listeners that the plugin has created. + +Signature: + +```typescript +deactivatePlugin?: (core: TrackerCore) => void; +``` diff --git a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.coreplugin.md b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.coreplugin.md index 53ad13b14..9e767ed1b 100644 --- a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.coreplugin.md +++ b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.coreplugin.md @@ -20,6 +20,7 @@ interface CorePlugin | [afterTrack?](./react-native-tracker.coreplugin.aftertrack.md) | (payload: Payload) => void | (Optional) Called just after the trackerCore callback fires | | [beforeTrack?](./react-native-tracker.coreplugin.beforetrack.md) | (payloadBuilder: PayloadBuilder) => void | (Optional) Called before the filter method is called and before the trackerCore callback fires (if the filter passes) | | [contexts?](./react-native-tracker.coreplugin.contexts.md) | () => SelfDescribingJson\[\] | (Optional) Called when constructing the context for each event Useful for adding additional context to events | +| [deactivatePlugin?](./react-native-tracker.coreplugin.deactivateplugin.md) | (core: TrackerCore) => void | (Optional) Called when the tracker is being destroyed. Should be used to clean up any resources or listeners that the plugin has created. | | [filter?](./react-native-tracker.coreplugin.filter.md) | (payload: Payload) => boolean | (Optional) Called before the payload is sent to the callback to decide whether to send the payload or skip it | | [logger?](./react-native-tracker.coreplugin.logger.md) | (logger: Logger) => void | (Optional) Passed a logger instance which can be used to send log information to the active logger | diff --git a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.gettracker.md b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.gettracker.md new file mode 100644 index 000000000..273ba4165 --- /dev/null +++ b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.gettracker.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [@snowplow/react-native-tracker](./react-native-tracker.md) > [getTracker](./react-native-tracker.gettracker.md) + +## getTracker() function + +Retrieves an initialized tracker given its namespace + +Signature: + +```typescript +export declare function getTracker(trackerNamespace: string): ReactNativeTracker | undefined; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| trackerNamespace | string | Tracker namespace | + +Returns: + +[ReactNativeTracker](./react-native-tracker.reactnativetracker.md) \| undefined + +Tracker instance if exists + diff --git a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.md b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.md index 387847779..10f2ebe20 100644 --- a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.md +++ b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.md @@ -14,7 +14,10 @@ | Function | Description | | --- | --- | +| [getTracker(trackerNamespace)](./react-native-tracker.gettracker.md) | Retrieves an initialized tracker given its namespace | | [newTracker(configuration)](./react-native-tracker.newtracker.md) | Creates a new tracker instance with the given configuration | +| [removeAllTrackers()](./react-native-tracker.removealltrackers.md) | Removes all initialized trackers | +| [removeTracker(trackerNamespace)](./react-native-tracker.removetracker.md) | Removes a tracker given its namespace | ## Interfaces diff --git a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.removealltrackers.md b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.removealltrackers.md new file mode 100644 index 000000000..ac760d48d --- /dev/null +++ b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.removealltrackers.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [@snowplow/react-native-tracker](./react-native-tracker.md) > [removeAllTrackers](./react-native-tracker.removealltrackers.md) + +## removeAllTrackers() function + +Removes all initialized trackers + +Signature: + +```typescript +export declare function removeAllTrackers(): void; +``` +Returns: + +void + +- A boolean promise + diff --git a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.removetracker.md b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.removetracker.md new file mode 100644 index 000000000..5e8504ebe --- /dev/null +++ b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.removetracker.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [@snowplow/react-native-tracker](./react-native-tracker.md) > [removeTracker](./react-native-tracker.removetracker.md) + +## removeTracker() function + +Removes a tracker given its namespace + +Signature: + +```typescript +export declare function removeTracker(trackerNamespace: string): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| trackerNamespace | string | Tracker namespace | + +Returns: + +void + diff --git a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.trackercore.deactivate.md b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.trackercore.deactivate.md new file mode 100644 index 000000000..a06091c47 --- /dev/null +++ b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.trackercore.deactivate.md @@ -0,0 +1,17 @@ + + +[Home](./index.md) > [@snowplow/react-native-tracker](./react-native-tracker.md) > [TrackerCore](./react-native-tracker.trackercore.md) > [deactivate](./react-native-tracker.trackercore.deactivate.md) + +## TrackerCore.deactivate() method + +Deactivate tracker core including all plugins. This is useful for cleaning up resources or listeners that have been created. Once deactivated, the tracker won't be able to track any events. + +Signature: + +```typescript +deactivate(): void; +``` +Returns: + +void + diff --git a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.trackercore.md b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.trackercore.md index 5ae8f884a..de989a360 100644 --- a/api-docs/docs/react-native-tracker/markdown/react-native-tracker.trackercore.md +++ b/api-docs/docs/react-native-tracker/markdown/react-native-tracker.trackercore.md @@ -27,6 +27,7 @@ interface TrackerCore | [addPayloadDict(dict)](./react-native-tracker.trackercore.addpayloaddict.md) | Merges a dictionary into payloadPairs | | [addPlugin(configuration)](./react-native-tracker.trackercore.addplugin.md) | Add a plugin into the plugin collection after Core has already been initialised | | [clearGlobalContexts()](./react-native-tracker.trackercore.clearglobalcontexts.md) | Removes all global contexts | +| [deactivate()](./react-native-tracker.trackercore.deactivate.md) | Deactivate tracker core including all plugins. This is useful for cleaning up resources or listeners that have been created. Once deactivated, the tracker won't be able to track any events. | | [getBase64Encoding()](./react-native-tracker.trackercore.getbase64encoding.md) | Get current base64 encoding state | | [removeGlobalContexts(contexts)](./react-native-tracker.trackercore.removeglobalcontexts.md) | Removes previously added global context, performs a deep comparison of the contexts or conditional contexts | | [resetPayloadPairs(dict)](./react-native-tracker.trackercore.resetpayloadpairs.md) | Replace payloadPairs with a new dictionary | diff --git a/api-docs/docs/react-native-tracker/react-native-tracker.api.md b/api-docs/docs/react-native-tracker/react-native-tracker.api.md index 8d268ff60..a48e04ddf 100644 --- a/api-docs/docs/react-native-tracker/react-native-tracker.api.md +++ b/api-docs/docs/react-native-tracker/react-native-tracker.api.md @@ -37,6 +37,7 @@ export interface CorePlugin { afterTrack?: (payload: Payload) => void; beforeTrack?: (payloadBuilder: PayloadBuilder) => void; contexts?: () => SelfDescribingJson[]; + deactivatePlugin?: (core: TrackerCore) => void; filter?: (payload: Payload) => boolean; logger?: (logger: Logger) => void; } @@ -179,6 +180,9 @@ export interface FormFocusOrChangeEvent { value: string | null; } +// @public +export function getTracker(trackerNamespace: string): ReactNativeTracker | undefined; + // @public export type JsonProcessor = (payloadBuilder: PayloadBuilder, jsonForProcessing: EventJson, contextEntitiesForProcessing: SelfDescribingJson[]) => void; @@ -298,6 +302,12 @@ export type ReactNativeTracker = { readonly setSubjectData: (config: SubjectConfiguration) => void; }; +// @public +export function removeAllTrackers(): void; + +// @public +export function removeTracker(trackerNamespace: string): void; + // @public export type RequestFailure = { events: EventBatch; @@ -409,6 +419,7 @@ export interface TrackerCore { addPayloadPair: (key: string, value: unknown) => void; addPlugin(configuration: CorePluginConfiguration): void; clearGlobalContexts(): void; + deactivate(): void; getBase64Encoding(): boolean; removeGlobalContexts(contexts: Array): void; resetPayloadPairs(dict: Payload): void; diff --git a/trackers/react-native-tracker/src/tracker.ts b/trackers/react-native-tracker/src/tracker.ts index b451947b3..fca43fc5c 100644 --- a/trackers/react-native-tracker/src/tracker.ts +++ b/trackers/react-native-tracker/src/tracker.ts @@ -64,7 +64,7 @@ export async function newTracker( /** * Retrieves an initialized tracker given its namespace - * @param trackerNamespace Tracker namespace + * @param trackerNamespace - Tracker namespace * @returns Tracker instance if exists */ export function getTracker(trackerNamespace: string): ReactNativeTracker | undefined { @@ -74,7 +74,7 @@ export function getTracker(trackerNamespace: string): ReactNativeTracker | undef /** * Removes a tracker given its namespace * - * @param trackerNamespace {string} + * @param trackerNamespace - Tracker namespace */ export function removeTracker(trackerNamespace: string): void { if (initializedTrackers[trackerNamespace]) {