Skip to content

Commit 0a00be2

Browse files
Add new tracker for React Native (#1371)
1 parent 967733d commit 0a00be2

File tree

291 files changed

+14235
-4597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+14235
-4597
lines changed

.github/workflows/change_check.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ jobs:
5050
working-directory: ./trackers/node-tracker
5151
run: api-extractor run
5252

53+
- name: Check for API changes to @snowplow/react-native-tracker
54+
working-directory: ./trackers/react-native-tracker
55+
run: api-extractor run
56+
5357
- name: Check bundle size using bundlemon
5458
5559
env:

.github/workflows/publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,17 @@ jobs:
7575
api-extractor run
7676
api-documenter markdown --input-folder temp --output-folder ../../api-docs/docs/node-tracker/markdown
7777
78+
- name: Create API documentation for @snowplow/react-native-tracker
79+
working-directory: ./trackers/react-native-tracker
80+
run: |
81+
api-extractor run
82+
api-documenter markdown --input-folder temp --output-folder ../../api-docs/docs/node-tracker/markdown
83+
7884
- name: Apply API documentation updates
7985
run: |
8086
git add api-docs/docs/browser-tracker
8187
git add api-docs/docs/node-tracker
88+
git add api-docs/docs/react-native-tracker
8289
git commit --no-verify --allow-empty -m "Applying documentation updates."
8390
git push
8491

.github/workflows/publish_prerelease.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ jobs:
7575
api-extractor run
7676
api-documenter markdown --input-folder temp --output-folder docs/markdown
7777
78+
- name: Create API documentation for @snowplow/react-native-tracker
79+
working-directory: ./trackers/react-native-tracker
80+
run: |
81+
api-extractor run
82+
api-documenter markdown --input-folder temp --output-folder docs/markdown
83+
7884
- name: Rush Publish
7985
run: node common/scripts/install-run-rush.js publish --apply --include-all --publish --tag next --set-access-level public --ignore-git-hooks
8086

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ common/autoinstallers/*/.npmrc
6767
# API Extractor
6868
trackers/browser-tracker/temp/
6969
trackers/node-tracker/temp/
70+
trackers/react-native-tracker/temp/
7071

7172
# Distribution files
7273
dist
@@ -80,4 +81,4 @@ trackers/javascript-tracker/test/local/serve/
8081
.DS_Store
8182

8283
# gitleaks file
83-
findings.json
84+
findings.json

api-docs/docs/browser-tracker/browser-tracker.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export interface CorePlugin {
170170
afterTrack?: (payload: Payload) => void;
171171
beforeTrack?: (payloadBuilder: PayloadBuilder) => void;
172172
contexts?: () => SelfDescribingJson[];
173+
deactivatePlugin?: (core: TrackerCore) => void;
173174
filter?: (payload: Payload) => boolean;
174175
logger?: (logger: Logger) => void;
175176
}
@@ -545,6 +546,7 @@ export interface TrackerCore {
545546
addPayloadPair: (key: string, value: unknown) => void;
546547
addPlugin(configuration: CorePluginConfiguration): void;
547548
clearGlobalContexts(): void;
549+
deactivate(): void;
548550
getBase64Encoding(): boolean;
549551
removeGlobalContexts(contexts: Array<ConditionalContextProvider | ContextPrimitive | string>): void;
550552
resetPayloadPairs(dict: Payload): void;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/browser-tracker](./browser-tracker.md) &gt; [CorePlugin](./browser-tracker.coreplugin.md) &gt; [deactivatePlugin](./browser-tracker.coreplugin.deactivateplugin.md)
4+
5+
## CorePlugin.deactivatePlugin property
6+
7+
Called when the tracker is being destroyed. Should be used to clean up any resources or listeners that the plugin has created.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
deactivatePlugin?: (core: TrackerCore) => void;
13+
```

api-docs/docs/browser-tracker/markdown/browser-tracker.coreplugin.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface CorePlugin
2020
| [afterTrack?](./browser-tracker.coreplugin.aftertrack.md) | (payload: Payload) =&gt; void | <i>(Optional)</i> Called just after the trackerCore callback fires |
2121
| [beforeTrack?](./browser-tracker.coreplugin.beforetrack.md) | (payloadBuilder: PayloadBuilder) =&gt; void | <i>(Optional)</i> Called before the <code>filter</code> method is called and before the trackerCore callback fires (if the filter passes) |
2222
| [contexts?](./browser-tracker.coreplugin.contexts.md) | () =&gt; SelfDescribingJson\[\] | <i>(Optional)</i> Called when constructing the context for each event Useful for adding additional context to events |
23+
| [deactivatePlugin?](./browser-tracker.coreplugin.deactivateplugin.md) | (core: TrackerCore) =&gt; void | <i>(Optional)</i> Called when the tracker is being destroyed. Should be used to clean up any resources or listeners that the plugin has created. |
2324
| [filter?](./browser-tracker.coreplugin.filter.md) | (payload: Payload) =&gt; boolean | <i>(Optional)</i> Called before the payload is sent to the callback to decide whether to send the payload or skip it |
2425
| [logger?](./browser-tracker.coreplugin.logger.md) | (logger: Logger) =&gt; void | <i>(Optional)</i> Passed a logger instance which can be used to send log information to the active logger |
2526

api-docs/docs/browser-tracker/markdown/browser-tracker.trackerconfiguration.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,5 @@ newTracker('sp1', 'collector.my-website.com', {
4444
plugins: [ PerformanceTimingPlugin(), AdTrackingPlugin() ],
4545
stateStorageStrategy: 'cookieAndLocalStorage'
4646
});
47-
4847
```
4948

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/browser-tracker](./browser-tracker.md) &gt; [TrackerCore](./browser-tracker.trackercore.md) &gt; [deactivate](./browser-tracker.trackercore.deactivate.md)
4+
5+
## TrackerCore.deactivate() method
6+
7+
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.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
deactivate(): void;
13+
```
14+
<b>Returns:</b>
15+
16+
void
17+

api-docs/docs/browser-tracker/markdown/browser-tracker.trackercore.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface TrackerCore
2727
| [addPayloadDict(dict)](./browser-tracker.trackercore.addpayloaddict.md) | Merges a dictionary into payloadPairs |
2828
| [addPlugin(configuration)](./browser-tracker.trackercore.addplugin.md) | Add a plugin into the plugin collection after Core has already been initialised |
2929
| [clearGlobalContexts()](./browser-tracker.trackercore.clearglobalcontexts.md) | Removes all global contexts |
30+
| [deactivate()](./browser-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. |
3031
| [getBase64Encoding()](./browser-tracker.trackercore.getbase64encoding.md) | Get current base64 encoding state |
3132
| [removeGlobalContexts(contexts)](./browser-tracker.trackercore.removeglobalcontexts.md) | Removes previously added global context, performs a deep comparison of the contexts or conditional contexts |
3233
| [resetPayloadPairs(dict)](./browser-tracker.trackercore.resetpayloadpairs.md) | Replace payloadPairs with a new dictionary |
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/node-tracker](./node-tracker.md) &gt; [CorePlugin](./node-tracker.coreplugin.md) &gt; [deactivatePlugin](./node-tracker.coreplugin.deactivateplugin.md)
4+
5+
## CorePlugin.deactivatePlugin property
6+
7+
Called when the tracker is being destroyed. Should be used to clean up any resources or listeners that the plugin has created.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
deactivatePlugin?: (core: TrackerCore) => void;
13+
```

api-docs/docs/node-tracker/markdown/node-tracker.coreplugin.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface CorePlugin
2020
| [afterTrack?](./node-tracker.coreplugin.aftertrack.md) | (payload: Payload) =&gt; void | <i>(Optional)</i> Called just after the trackerCore callback fires |
2121
| [beforeTrack?](./node-tracker.coreplugin.beforetrack.md) | (payloadBuilder: PayloadBuilder) =&gt; void | <i>(Optional)</i> Called before the <code>filter</code> method is called and before the trackerCore callback fires (if the filter passes) |
2222
| [contexts?](./node-tracker.coreplugin.contexts.md) | () =&gt; SelfDescribingJson\[\] | <i>(Optional)</i> Called when constructing the context for each event Useful for adding additional context to events |
23+
| [deactivatePlugin?](./node-tracker.coreplugin.deactivateplugin.md) | (core: TrackerCore) =&gt; void | <i>(Optional)</i> Called when the tracker is being destroyed. Should be used to clean up any resources or listeners that the plugin has created. |
2324
| [filter?](./node-tracker.coreplugin.filter.md) | (payload: Payload) =&gt; boolean | <i>(Optional)</i> Called before the payload is sent to the callback to decide whether to send the payload or skip it |
2425
| [logger?](./node-tracker.coreplugin.logger.md) | (logger: Logger) =&gt; void | <i>(Optional)</i> Passed a logger instance which can be used to send log information to the active logger |
2526

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/node-tracker](./node-tracker.md) &gt; [TrackerCore](./node-tracker.trackercore.md) &gt; [deactivate](./node-tracker.trackercore.deactivate.md)
4+
5+
## TrackerCore.deactivate() method
6+
7+
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.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
deactivate(): void;
13+
```
14+
<b>Returns:</b>
15+
16+
void
17+

api-docs/docs/node-tracker/markdown/node-tracker.trackercore.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ interface TrackerCore
2727
| [addPayloadDict(dict)](./node-tracker.trackercore.addpayloaddict.md) | Merges a dictionary into payloadPairs |
2828
| [addPlugin(configuration)](./node-tracker.trackercore.addplugin.md) | Add a plugin into the plugin collection after Core has already been initialised |
2929
| [clearGlobalContexts()](./node-tracker.trackercore.clearglobalcontexts.md) | Removes all global contexts |
30+
| [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. |
3031
| [getBase64Encoding()](./node-tracker.trackercore.getbase64encoding.md) | Get current base64 encoding state |
3132
| [removeGlobalContexts(contexts)](./node-tracker.trackercore.removeglobalcontexts.md) | Removes previously added global context, performs a deep comparison of the contexts or conditional contexts |
3233
| [resetPayloadPairs(dict)](./node-tracker.trackercore.resetpayloadpairs.md) | Replace payloadPairs with a new dictionary |

api-docs/docs/node-tracker/node-tracker.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export interface CorePlugin {
165165
afterTrack?: (payload: Payload) => void;
166166
beforeTrack?: (payloadBuilder: PayloadBuilder) => void;
167167
contexts?: () => SelfDescribingJson[];
168+
deactivatePlugin?: (core: TrackerCore) => void;
168169
filter?: (payload: Payload) => boolean;
169170
logger?: (logger: Logger) => void;
170171
}
@@ -527,6 +528,7 @@ export interface TrackerCore {
527528
addPayloadPair: (key: string, value: unknown) => void;
528529
addPlugin(configuration: CorePluginConfiguration): void;
529530
clearGlobalContexts(): void;
531+
deactivate(): void;
530532
getBase64Encoding(): boolean;
531533
removeGlobalContexts(contexts: Array<ConditionalContextProvider | ContextPrimitive | string>): void;
532534
resetPayloadPairs(dict: Payload): void;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md)
4+
5+
## API Reference
6+
7+
## Packages
8+
9+
| Package | Description |
10+
| --- | --- |
11+
| [@snowplow/react-native-tracker](./react-native-tracker.md) | |
12+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [ConditionalContextProvider](./react-native-tracker.conditionalcontextprovider.md)
4+
5+
## ConditionalContextProvider type
6+
7+
Conditional context providers are two element arrays used to decide when to attach contexts, where: - the first element is some conditional criterion - the second element is any number of context primitives
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
type ConditionalContextProvider = FilterProvider | RuleSetProvider;
13+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [ContextFilter](./react-native-tracker.contextfilter.md)
4+
5+
## ContextFilter type
6+
7+
A context filter is a user-supplied callback that is evaluated for each event to determine if the context associated with the filter should be attached to the event
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
type ContextFilter = (args?: ContextEvent) => boolean;
13+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [ContextGenerator](./react-native-tracker.contextgenerator.md)
4+
5+
## ContextGenerator type
6+
7+
A context generator is a user-supplied callback that is evaluated for each event to allow an additional context to be dynamically attached to the event
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
type ContextGenerator = (args?: ContextEvent) => SelfDescribingJson | SelfDescribingJson[] | undefined;
13+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [ContextPrimitive](./react-native-tracker.contextprimitive.md)
4+
5+
## ContextPrimitive type
6+
7+
A context primitive is either a self-describing JSON or a context generator
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
type ContextPrimitive = SelfDescribingJson | ContextGenerator;
13+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [CoreConfiguration](./react-native-tracker.coreconfiguration.md) &gt; [base64](./react-native-tracker.coreconfiguration.base64.md)
4+
5+
## CoreConfiguration.base64 property
6+
7+
<b>Signature:</b>
8+
9+
```typescript
10+
base64?: boolean;
11+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [CoreConfiguration](./react-native-tracker.coreconfiguration.md) &gt; [callback](./react-native-tracker.coreconfiguration.callback.md)
4+
5+
## CoreConfiguration.callback property
6+
7+
<b>Signature:</b>
8+
9+
```typescript
10+
callback?: (PayloadData: PayloadBuilder) => void;
11+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [CoreConfiguration](./react-native-tracker.coreconfiguration.md) &gt; [corePlugins](./react-native-tracker.coreconfiguration.coreplugins.md)
4+
5+
## CoreConfiguration.corePlugins property
6+
7+
<b>Signature:</b>
8+
9+
```typescript
10+
corePlugins?: Array<CorePlugin>;
11+
```
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [CoreConfiguration](./react-native-tracker.coreconfiguration.md)
4+
5+
## CoreConfiguration interface
6+
7+
The configuration object for the tracker core library
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
interface CoreConfiguration
13+
```
14+
15+
## Properties
16+
17+
| Property | Type | Description |
18+
| --- | --- | --- |
19+
| [base64?](./react-native-tracker.coreconfiguration.base64.md) | boolean | <i>(Optional)</i> |
20+
| [callback?](./react-native-tracker.coreconfiguration.callback.md) | (PayloadData: PayloadBuilder) =&gt; void | <i>(Optional)</i> |
21+
| [corePlugins?](./react-native-tracker.coreconfiguration.coreplugins.md) | Array&lt;CorePlugin&gt; | <i>(Optional)</i> |
22+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [CorePlugin](./react-native-tracker.coreplugin.md) &gt; [activateCorePlugin](./react-native-tracker.coreplugin.activatecoreplugin.md)
4+
5+
## CorePlugin.activateCorePlugin property
6+
7+
Called when the plugin is initialised during the trackerCore construction
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
activateCorePlugin?: (core: TrackerCore) => void;
13+
```
14+
15+
## Remarks
16+
17+
Use to capture the specific core instance for each instance of a core plugin
18+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [CorePlugin](./react-native-tracker.coreplugin.md) &gt; [afterTrack](./react-native-tracker.coreplugin.aftertrack.md)
4+
5+
## CorePlugin.afterTrack property
6+
7+
Called just after the trackerCore callback fires
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
afterTrack?: (payload: Payload) => void;
13+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [CorePlugin](./react-native-tracker.coreplugin.md) &gt; [beforeTrack](./react-native-tracker.coreplugin.beforetrack.md)
4+
5+
## CorePlugin.beforeTrack property
6+
7+
Called before the `filter` method is called and before the trackerCore callback fires (if the filter passes)
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
beforeTrack?: (payloadBuilder: PayloadBuilder) => void;
13+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [CorePlugin](./react-native-tracker.coreplugin.md) &gt; [contexts](./react-native-tracker.coreplugin.contexts.md)
4+
5+
## CorePlugin.contexts property
6+
7+
Called when constructing the context for each event Useful for adding additional context to events
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
contexts?: () => SelfDescribingJson[];
13+
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@snowplow/react-native-tracker](./react-native-tracker.md) &gt; [CorePlugin](./react-native-tracker.coreplugin.md) &gt; [deactivatePlugin](./react-native-tracker.coreplugin.deactivateplugin.md)
4+
5+
## CorePlugin.deactivatePlugin property
6+
7+
Called when the tracker is being destroyed. Should be used to clean up any resources or listeners that the plugin has created.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
deactivatePlugin?: (core: TrackerCore) => void;
13+
```

0 commit comments

Comments
 (0)