Skip to content
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

Initial Implementation #7

Merged
merged 114 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
58096d4
Run yarn
mgacy Aug 20, 2023
f29ddd5
Update organization
mgacy Sep 24, 2023
3c4c13e
First pass at bridge
mgacy Sep 24, 2023
68f2b15
Declare dependency on LyticsSDK
mgacy Oct 13, 2023
d17934e
Update version to match SDK
mgacy Oct 13, 2023
53edfb5
Set platform version to 14 or higher
mgacy Oct 13, 2023
90d4aca
Install LyticsSDK
mgacy Oct 13, 2023
120123f
First pass at importing, using SDK
mgacy Oct 13, 2023
42bd17b
Remove default code; link LyticsBridge
mgacy Oct 13, 2023
88d42b8
Support properties, configuration
mgacy Oct 16, 2023
0398d17
Support events
mgacy Oct 16, 2023
57bef24
Support personalization
mgacy Oct 16, 2023
07158f4
Support tracking
mgacy Oct 16, 2023
dab0067
Support utility methods
mgacy Oct 16, 2023
a11c72c
Remove example method, update app
mgacy Oct 16, 2023
3d5011f
Example app tweak
mgacy Oct 16, 2023
680c7d0
Declare type for configuration
mgacy Oct 16, 2023
309bf6d
Fix imprecise documentation
mgacy Oct 16, 2023
7398e08
Merge pull request #2 from lytics/intermediary/interface/1-bootstrap
mgacy Oct 29, 2023
1d7bf12
Merge pull request #3 from lytics/intermediary/interface/2-ios-bridge
mgacy Oct 30, 2023
78bc87d
Stub methods from ReactNative module
mgacy Nov 6, 2023
0c4d182
Add Android SDK as dependency
mgacy Nov 6, 2023
c5aee5e
Reformat
mgacy Nov 6, 2023
4bf1dd1
Implement events
mgacy Nov 6, 2023
44cc02d
Implement tracking and utility methods
mgacy Nov 6, 2023
7584564
Implement start and tracking methods
mgacy Nov 8, 2023
488d56b
Fix remaining uses of getBoolean
mgacy Nov 8, 2023
4212d61
Rename methods
mgacy Nov 8, 2023
a75828e
Support getProfile
mgacy Nov 22, 2023
615a0af
Add remaining properties, use general prop name
mgacy Nov 23, 2023
33e2c57
Suggested changes, fixes
mgacy Nov 23, 2023
77608af
Rename classes
mgacy Nov 23, 2023
1d70562
Change namespace
mgacy Nov 24, 2023
8088a80
Use current snapshot of Android SDK
mgacy Nov 24, 2023
c4681e8
Update example app namespace
mgacy Nov 28, 2023
7176538
Install React Navigation
mgacy Dec 5, 2023
59f75b9
Install additional dependencies
mgacy Dec 5, 2023
5a148ba
Install iOS dependencies
mgacy Dec 5, 2023
2e3ebc0
Additional Android config
mgacy Dec 5, 2023
7b4292f
Add navigation container
mgacy Dec 5, 2023
9e29123
Install additional dependency; use yarn
mgacy Dec 5, 2023
7d0d6b8
Install bottom-tabs
mgacy Dec 5, 2023
48c04dc
Define basic navigation
mgacy Dec 5, 2023
e3222eb
Additional dependencies
mgacy Dec 5, 2023
693932f
Additional screens and navigation support
mgacy Dec 5, 2023
45b7910
Fix type warnings
mgacy Dec 6, 2023
0c80166
UI tweaks
mgacy Dec 6, 2023
1867433
Try to fix duplicate name warning
mgacy Dec 6, 2023
e961433
Declare configuration types
mgacy Dec 19, 2023
35bc2ea
Support track methods
mgacy Dec 20, 2023
fb2714e
Fix LogLevel handling on Android
mgacy Dec 20, 2023
1b0663b
Simplify JSON types
mgacy Dec 20, 2023
263f98c
Support personalization
mgacy Dec 20, 2023
9c42655
Remove old configuration definition
mgacy Dec 20, 2023
35dcc3f
Merge pull request #4 from lytics/intermediary/interface/3-android-br…
mgacy Jan 3, 2024
32ae625
Merge pull request #5 from lytics/intermediary/interface/4-demo-app
mgacy Jan 3, 2024
130958a
Add tracking usage description
mgacy Jan 11, 2024
885e025
Fix method name
mgacy Jan 11, 2024
333a411
Use SDK in Event Detail
mgacy Jan 11, 2024
c25f103
Use SDK in Login, SignUp
mgacy Jan 11, 2024
14d0fbb
Implement remaining method and props
mgacy Jan 11, 2024
45004d1
Fix handling of logLevel
mgacy Jan 11, 2024
9440061
Update LyticsUser to work with both SDKs
mgacy Jan 11, 2024
da7b68f
Support remaining properties
mgacy Jan 11, 2024
fa7d0d6
Support tracking and utility methods
mgacy Jan 11, 2024
deb4332
Fix typo
mgacy Jan 12, 2024
6e934fe
Fix Android crash
mgacy Jan 12, 2024
d6f9a80
Simplify getProfile
mgacy Jan 15, 2024
a331b23
Use SDK in Profile
mgacy Jan 15, 2024
cfdcc02
Enable strict null checks
mgacy Jan 15, 2024
ce7e647
Additional configuration support
mgacy Jan 16, 2024
0625758
Update start method
mgacy Jan 16, 2024
a3ab394
Update for start() changes
mgacy Jan 16, 2024
bb92123
Fix duplicate name warnings
mgacy Jan 16, 2024
2875c2f
Update definition for start() changes
mgacy Jan 16, 2024
f319405
Fix TS warning
mgacy Jan 16, 2024
0eafd07
Remove default values
mgacy Jan 16, 2024
b2ca228
Support scope cancellation
mgacy Jan 16, 2024
019a0b8
Use standard param names
mgacy Jan 16, 2024
7a90dea
First pass at README
mgacy Jan 16, 2024
33183a1
Use consistent parameter names
mgacy Jan 17, 2024
0f1fc17
Use current package name
mgacy Jan 17, 2024
bf58295
Merge pull request #6 from lytics/intermediary/interface/5-type-script
mgacy Jan 17, 2024
a0a6d73
Merge pull request #8 from lytics/intermediary/interface/6-bridge-imp…
mgacy Jan 17, 2024
efb011c
Merge pull request #9 from lytics/intermediary/interface/7-documentation
mgacy Jan 17, 2024
a1c358f
Remove `packageManager` config
mgacy Feb 5, 2024
525dfe0
Add manual trigger
mgacy Feb 5, 2024
9e0c9fb
Restore package manager with different version
mgacy Feb 5, 2024
cd56260
Merge pull request #12 from lytics/intermediary/interface/8-fix-workf…
mgacy Feb 10, 2024
f14ed38
Rename
mgacy Feb 13, 2024
8ade5f0
Update yarn and other JS stuff
mgacy Feb 13, 2024
4f17b8f
Remove bootstrap script
mgacy Feb 13, 2024
b93a66a
iOS project changes
mgacy Feb 13, 2024
6544185
Update Android build config
mgacy Feb 13, 2024
040ec89
Update example project config
mgacy Feb 13, 2024
4a67fcc
Example Android updates
mgacy Feb 13, 2024
249bd1e
Example iOS updates
mgacy Feb 13, 2024
e4cdba4
Add yarn plugins and releases
mgacy Feb 13, 2024
5e65082
Update
mgacy Feb 13, 2024
259d88e
Pod install
mgacy Feb 13, 2024
8d8ca3e
Update workflow and action
mgacy Feb 13, 2024
e64edf3
Remove
mgacy Feb 13, 2024
35c6942
Merge pull request #14 from lytics/intermediary/interface/9-upgrade-bob
mgacy Feb 22, 2024
8ea31fc
Add recent workflow changes
mgacy Feb 22, 2024
1320130
Remove mention of npm as installation method
mgacy Feb 22, 2024
a1baf4d
Update package name
mgacy Feb 22, 2024
698687e
Rename pod
mgacy Feb 22, 2024
ad78a96
Disable commit message
mgacy Feb 22, 2024
daddcd5
More name changes
mgacy Feb 22, 2024
34f2990
Update install command
mgacy Feb 22, 2024
ef13a01
Update linking error message
mgacy Feb 22, 2024
ee3e7fe
Run workflow on all PRs
mgacy Feb 22, 2024
c525f2a
Upgrade actions
mgacy Feb 22, 2024
3ef8101
Merge pull request #16 from lytics/intermediary/interface/9-update-name
mgacy Feb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{kt,swift}]
indent_size = 4
9 changes: 4 additions & 5 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ runs:
with:
path: |
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
.yarn/install-state.gz
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
${{ runner.os }}-yarn-

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: |
yarn install --cwd example --frozen-lockfile
yarn install --frozen-lockfile
run: yarn install --immutable
shell: bash
38 changes: 19 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name: CI
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -27,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -39,36 +38,36 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Build package
run: yarn prepack
run: yarn prepare

build-android:
runs-on: ubuntu-latest
env:
TURBO_CACHE_DIR: .turbo/android
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Cache turborepo for Android
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-android-

- name: Check turborepo cache for Android
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
Expand All @@ -79,7 +78,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
java-version: '17'

- name: Finalize Android SDK
if: env.turbo_cache_hit != 1
Expand All @@ -88,7 +87,7 @@ jobs:

- name: Cache Gradle
if: env.turbo_cache_hit != 1
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.gradle/wrapper
Expand All @@ -102,27 +101,27 @@ jobs:
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"

build-ios:
runs-on: macos-latest
runs-on: macos-14
env:
TURBO_CACHE_DIR: .turbo/ios
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Cache turborepo for iOS
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.TURBO_CACHE_DIR }}
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-turborepo-ios-

- name: Check turborepo cache for iOS
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn --silent turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
Expand All @@ -131,7 +130,7 @@ jobs:
- name: Cache cocoapods
if: env.turbo_cache_hit != 1
id: cocoapods-cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
**/ios/Pods
Expand All @@ -142,7 +141,8 @@ jobs:
- name: Install cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
run: |
yarn example pods
cd example/ios
pod install
env:
NO_FLIPPER: 1

Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ buck-out/
android/app/libs
android/keystores/debug.keystore

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Expo
.expo/

Expand All @@ -68,3 +76,5 @@ android/keystores/debug.keystore

# generated by bob
lib/

example/ios/.xcode.env.local
541 changes: 541 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.1.cjs

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions .yarnrc

This file was deleted.

10 changes: 10 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
nodeLinker: node-modules
nmHoistingLimits: workspaces

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.6.1.cjs
123 changes: 122 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,125 @@

## Installation

## Usage
Install the SDK:

```sh
yarn add react-native-lytics
```

### Android

Add the following permissions to your `AndroidManifest.xml` file:

```xml
<uses-permission android:name="android.permission.INTERNET" />
```

This permission is required to send events to the Lytics API.

```xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
```

This permission is technically optional but highly recommended to allow the library to determine the best time to send events to the API.

### iOS

Install native modules:

```sh
npx pod-install
```

## Configuration

You must initialize the Lytics SDK with your [API token](https://learn.lytics.com/documentation/product/features/account-management/managing-api-tokens) before using it.

```jsx
import { start } from 'react-native-lytics';

start({
apiToken: 'xxxxxx',
...
});
```

## Sending Data

### Identity Events

Tracking identity events provides an interface for updating the current user's properties stored on device as well as emitting an identify event to the downstream collections API.

```jsx
import { identify } from 'react-native-lytics';

identify({ identifiers: { email: 'jdoe@email.com' } });
```

### Consent Events

Consent events provide an interface for configuring and emitting a special event that represents an app users explicit consent. This event does everything a normal event does in addition to providing a special payload for consent details at the discretion of the developer.

```jsx
import { consent } from 'react-native-lytics';

consent({
consent: {
documents: ['terms_aug_2022', 'privacy_may_2022'],
consented: true,
},
});
```

### Track Custom Events

Track custom events provides an interface for configuring and emitting a custom event at the customers discretion throughout their application (e.g. made a purchase or logged in).

```jsx
import { track } from 'react-native-lytics';

track({ name: 'Event_Tap', properties: { event: 'Event_Tap' } });
```

### Screen Events

Screen events provide an interface for configuring and emitting a special event that represents a screen or page view. It should be seen as an extension of the track method.

```jsx
import { screen } from 'react-native-lytics';

screen({
name: 'Event_Detail',
properties: { artistID: 123, eventID: 345 },
});
```

## Advertising ID

### Android

To support collecting the Android Advertising ID, add the following to the application's gradle dependencies:

`implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'`

Additionally, declare a Google Play services normal permission in the manifest file as follows:

`<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>`

After confirming with the user and getting their consent, enable Advertiser ID collection via `Lytics.enableGAID()`.

The user's Android Advertising ID will be sent with each event's identifiers.

Note, the user can disable or change the Advertising ID via the Android system privacy settings.

### iOS

Before collecting the IDFA you must first add a [`NSUserTrackingUsageDescription`](https://developer.apple.com/documentation/bundleresources/information_property_list/nsusertrackingusagedescription) to your app's `Info.plist`. You can then call `requestTrackingAuthorization()` to have iOS request authorization to access the IDFA. Note that the alert will not be displayed if the user has turned off “Allow Apps to Request to Track” in the system privacy settings and that authorization can be revoked at any time.

### Usage

```jsx
import { requestTrackingAuthorization } from 'react-native-lytics';

requestTrackingAuthorization();
```
24 changes: 6 additions & 18 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ def isNewArchitectureEnabled() {
apply plugin: "com.android.library"
apply plugin: "kotlin-android"


def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}
Expand All @@ -42,16 +39,12 @@ def supportsNamespace() {
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
if (major == 7 && minor >= 3) {
return true
}

return major >= 8
return (major == 7 && minor >= 3) || major >= 8
}

android {
if (supportsNamespace()) {
namespace "com.sdk"
namespace "com.lytics.react_native"

sourceSets {
main {
Expand All @@ -65,8 +58,9 @@ android {
defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

}

buildTypes {
release {
minifyEnabled false
Expand All @@ -81,7 +75,6 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

}

repositories {
Expand All @@ -97,12 +90,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// FIXME: specify stable version
implementation 'com.github.lytics:android-sdk:main-SNAPSHOT'
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "Sdk"
codegenJavaPackageName = "com.sdk"
}
}
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sdk">
package="com.lytics.react_native">
</manifest>
Loading
Loading