-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from WunderbarNetwork/sdk-v1.2.0
SDK v1.2.0
- Loading branch information
Showing
19 changed files
with
1,525 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Node.js CI | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Using Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'yarn' | ||
- run: yarn --network-concurrency 8 || yarn --check-files --cache-folder .ycache && rm -rf .ycache | ||
- run: yarn test | ||
- run: yarn lint | ||
|
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 @@ | ||
@wunderbar-network:registry=https://registry.npmjs.org/ |
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,45 +1,66 @@ | ||
# @wunderbar-network/mini-digital-sdk-js | ||
# @wunderbar-network/mini-digital-sdk | ||
|
||
Shared library that provides an interface for Event Tracking using the **Mini Digital Events API** to Node or browser-based TS/JS implementations. | ||
Library that provides an interface to capture analytics events, and send them to [Mini Digital](https://mini.digital). This library can be used in either Node.js or browser-based TypeScript/JavaScript implementations (including frameworks like React or Vue). | ||
|
||
## Usage | ||
## Installation | ||
|
||
### Node.js | ||
To install the library, you can use npm or yarn. Run the following command: | ||
|
||
Add the following to your `package.json`: | ||
```shell | ||
npm install @wunderbar-network/mini-digital-sdk | ||
``` | ||
|
||
or | ||
|
||
```json | ||
{ | ||
// ... | ||
"dependencies": { | ||
"@wunderbar-network/mini-digital-sdk-js": "https://github.com/WunderbarNetwork/mini-digital-sdk-js.git", | ||
}, | ||
// ... | ||
} | ||
```shell | ||
yarn add @wunderbar-network/mini-digital-sdk | ||
``` | ||
|
||
You can also include a specific branch by doing `repo.git#branch-name` at the end (e.g. `#v1.1.0`). | ||
### Usage | ||
|
||
You can then import classes and types directly into your project like so: | ||
To send a quick event using the Mini Digital SDK, do the following: | ||
|
||
```ts | ||
import { EventTrackingService, EventTrackingUtil } from "@wunderbar-network/mini-digital-sdk-js"; | ||
import type { AnalyticsEvent } from "@wunderbar-network/mini-digital-sdk-js"; | ||
// Import the library | ||
import { type AnalyticsEvent, EventTrackingService } from "@wunderbar-network/mini-digital-sdk"; | ||
|
||
// Declare event | ||
const event: AnalyticsEvent = { | ||
eventName: "my_first_mini_digital_event", | ||
eventCategory: "system_outcome_event", | ||
eventSource: "MyProject.EventTestingPlayground", | ||
anonymousUser: true, | ||
}; | ||
|
||
// Send event! | ||
EventTrackingService.postEvent(event); | ||
``` | ||
|
||
The `EventTrackingUtil` class has methods that could make capturing some of the fields for the `AnalyticsEvent` easier. | ||
See our API reference to get a deeper understanding of the event schema. | ||
|
||
### Browser | ||
### Browser builds | ||
|
||
If you are capturing events from the browser and want a browser-friendly build, this can be found in the `lib/browser` folder. | ||
If you want a browser-friendly build to use directly into your HTML code, browser builds (CJS/ESM) can be found in the `lib/browser` folder. | ||
|
||
### Mini Digital URL | ||
### Config | ||
|
||
If you wish to override the default Mini Digital URL (to point to e.g. a testing instance), you can do so by overriding the config namespace variable: | ||
By default, the config is set to send events to the production Mini Digital endpoint. If you wish to override the default Mini Digital URL (to point to e.g. a testing instance), you can do so by overriding the config namespace variable: | ||
|
||
```ts | ||
import { EventTrackingConfig } from "@wunderbar-network/mini-digital-sdk-js"; | ||
import { EventTrackingConfig } from "@wunderbar-network/mini-digital-sdk"; | ||
|
||
// Override the default value | ||
EventTrackingConfig.miniDigitalUrl = "https://test.api.mini.digital/"; | ||
EventTrackingConfig.miniDigitalUrl = "http://localhost:3333/"; | ||
``` | ||
|
||
You can also choose to _pause_ sending events (e.g. in your test suites), or not use cookies (to store anonymous tracking IDs): | ||
|
||
```ts | ||
import { EventTrackingConfig } from "@wunderbar-network/mini-digital-sdk"; | ||
|
||
// Override the default value | ||
EventTrackingConfig.pauseTracking = true; | ||
EventTrackingConfig.useCookies = false; | ||
``` | ||
|
||
See our API reference for the full list of configuration options. |
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,10 @@ | ||
import { type AnalyticsEvent } from "./types/AnalyticsEvent.js"; | ||
import type { AnalyticsEvent } from "./types/AnalyticsEvent.js"; | ||
import type { EnrichedAnalyticsEvent } from "./types/EnrichedAnalyticsEvent.js"; | ||
|
||
import { config as EventTrackingConfig } from "./util/Config.js"; | ||
|
||
import * as EventTrackingService from "./services/EventTrackingService.js"; | ||
import * as EventTrackingUtil from "./util/ConsumerUtil.js"; | ||
|
||
export { type AnalyticsEvent, EventTrackingService, EventTrackingConfig, EventTrackingUtil }; | ||
export type { AnalyticsEvent, EnrichedAnalyticsEvent }; | ||
export { EventTrackingService, EventTrackingConfig, EventTrackingUtil }; |
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
Oops, something went wrong.