Skip to content

Commit bba9c2c

Browse files
committed
feat: Add sideloaded kit example (#494)
1 parent 10b5803 commit bba9c2c

23 files changed

Lines changed: 44943 additions & 26765 deletions

core-sdk-samples/higgs-shop-sample-app/package-lock.json

Lines changed: 27987 additions & 24412 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core-sdk-samples/higgs-shop-sample-app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"@emotion/react": "^11.10.6",
77
"@emotion/styled": "^11.10.6",
88
"@fontsource/lato": "^4.5.10",
9-
"@mparticle/web-sdk": "^2.19.1",
9+
"@mparticle/web-sdk": "^2.20.0",
1010
"@mui/icons-material": "^5.11.9",
1111
"@mui/material": "^5.11.10",
1212
"@testing-library/dom": "^9.0.0",
@@ -18,6 +18,7 @@
1818
"@types/react": "^17.0.43",
1919
"@types/react-dom": "^17.0.0",
2020
"gh-pages": "^5.0.0",
21+
"sideloaded-kit-example": "file:../../kit-samples/sideloaded-kit-example",
2122
"react": "^17.0.2",
2223
"react-dom": "^17.0.2",
2324
"react-router-dom": "^6.8.1",
@@ -50,7 +51,7 @@
5051
]
5152
},
5253
"devDependencies": {
53-
"@types/mparticle__web-sdk": "^2.18.0",
54+
"@types/mparticle__web-sdk": "^2.20.0",
5455
"@typescript-eslint/eslint-plugin": "^5.53.0",
5556
"@typescript-eslint/parser": "^5.53.0",
5657
"eslint": "^8.34.0",

core-sdk-samples/higgs-shop-sample-app/src/layouts/App/index.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('mParticle Web Sample App', () => {
1515
isDevelopmentMode: true,
1616
logLevel: 'verbose',
1717
identityCallback: expect.any(Function),
18+
sideloadedKits: expect.any(Array),
1819
});
1920
});
2021
});

core-sdk-samples/higgs-shop-sample-app/src/layouts/App/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable no-console */
22
import { useEffect } from 'react';
33
import mParticle from '@mparticle/web-sdk';
4+
import sideloadedKit from 'sideloaded-kit-example';
45
import { HashRouter, Routes, Route } from 'react-router-dom';
56
import { ThemeProvider } from '@mui/material/styles';
67
import { NavigationMenu } from '../../components/NavigationMenu';
@@ -27,7 +28,6 @@ const App = () => {
2728
// and are included in all event uploads
2829
appName: 'Higgs Shop',
2930
appVersion: version,
30-
3131
// `package` is an optional analytics attribute that mParticle
3232
// uses to measure usage and diagnostics of the Sample Apps.
3333
// In a production application, you can safely remove this, or set
@@ -72,6 +72,18 @@ const App = () => {
7272
// the IDSync call failed
7373
}
7474
},
75+
76+
// Sideloaded kits can be used to receive callbacks when various things
77+
// happen such as events being logged. You can use them to debug the
78+
// events going to your forwarders, or if you want to create a kit for a
79+
// third party SDK that we don't yet support.
80+
// This example is a simple implementation that only logs the callbacks
81+
// and event received to the console, but the data in the callbacks can
82+
// be used for anything.
83+
// Please read our docs about sideloaded kits at
84+
// https://docs.mparticle.com/developers/sdk/web/kits/#sideloaded-kits-custom-kits
85+
// NOTE: Sideloaded kits are always active.
86+
sideloadedKits: [sideloadedKit],
7587
};
7688

7789
// In a true production implementation, you should load your mParticle API Key via
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Our kit builder does not currently have types, so we declare this here to avoid TS compilation errors
2+
declare module 'sideloaded-kit-example';

core-sdk-samples/higgs-shop-sample-app/yarn.lock

Lines changed: 3546 additions & 2350 deletions
Large diffs are not rendered by default.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"es2021": true
6+
},
7+
"globals": {
8+
"mParticle": true
9+
},
10+
"extends": ["plugin:prettier/recommended", "eslint:recommended"],
11+
"plugins": ["prettier"],
12+
"rules": {
13+
"indent": ["error", 4, { "SwitchCase": 1 }],
14+
"prettier/prettier": "error",
15+
"no-prototype-builtins": "off",
16+
"no-empty": "off",
17+
"no-useless-escape": "off",
18+
"no-unexpected-multiline": "off",
19+
"no-unused-vars": "off",
20+
"comma-dangle": ["error", "always-multiline"]
21+
}
22+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"jsxSingleQuote": true,
5+
"tabWidth": 4,
6+
"trailingComma": "all",
7+
"endOfLine": "auto"
8+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# mParticle Sideloaded Kit Example
2+
3+
This repository has an example of a sideloaded kit. It was built using the [mParticle Web Integration Builder](https://github.com/mparticle-integrations/mparticle-javascript-integration-example). In this example, every mapped function simply logs that it was called.
4+
5+
## Create Your Own Sideloaded Kit
6+
7+
Detailed instructions on how to implement your own sideloaded kit can be found at our [doc site](URL TO BE ADDED).
8+
9+
## Support
10+
11+
Questions? Give us a shout at <support@mparticle.com>
12+
13+
## License
14+
15+
This mParticle Web Kit is available under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0). See the LICENSE file for more info.

0 commit comments

Comments
 (0)