@ht-sdks/events-sdk-react-native-plugin-braze-middleware 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +45 -0
- package/lib/commonjs/BrazeMiddlewarePlugin.js +33 -0
- package/lib/commonjs/BrazeMiddlewarePlugin.js.map +1 -0
- package/lib/commonjs/index.js +17 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/BrazeMiddlewarePlugin.js +26 -0
- package/lib/module/BrazeMiddlewarePlugin.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/src/BrazeMiddlewarePlugin.d.ts +8 -0
- package/lib/typescript/src/BrazeMiddlewarePlugin.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +72 -0
- package/src/BrazeMiddlewarePlugin.tsx +38 -0
- package/src/index.ts +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Hightouch
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
MIT License
|
|
26
|
+
|
|
27
|
+
Copyright (c) 2020 Segment
|
|
28
|
+
|
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
30
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
31
|
+
in the Software without restriction, including without limitation the rights
|
|
32
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
33
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
34
|
+
furnished to do so, subject to the following conditions:
|
|
35
|
+
|
|
36
|
+
The above copyright notice and this permission notice shall be included in all
|
|
37
|
+
copies or substantial portions of the Software.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
40
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
41
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
42
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
43
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
44
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
45
|
+
SOFTWARE.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BrazeMiddlewarePlugin = void 0;
|
|
7
|
+
var _eventsSdkReactNative = require("@ht-sdks/events-sdk-react-native");
|
|
8
|
+
class BrazeMiddlewarePlugin extends _eventsSdkReactNative.Plugin {
|
|
9
|
+
type = _eventsSdkReactNative.PluginType.before;
|
|
10
|
+
key = 'Appboy';
|
|
11
|
+
lastSeenTraits = undefined;
|
|
12
|
+
execute(event) {
|
|
13
|
+
//check to see if anything has changed
|
|
14
|
+
//if it hasn't changed disable integration
|
|
15
|
+
if (event.type === _eventsSdkReactNative.EventType.IdentifyEvent) {
|
|
16
|
+
if (this.lastSeenTraits?.userId === event.userId && this.lastSeenTraits?.anonymousId === event.anonymousId && this.lastSeenTraits?.traits === event.traits) {
|
|
17
|
+
const integrations = event.integrations;
|
|
18
|
+
if (integrations !== undefined) {
|
|
19
|
+
integrations[this.key] = false;
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
this.lastSeenTraits = {
|
|
23
|
+
anonymousId: event.anonymousId ?? '',
|
|
24
|
+
userId: event.userId,
|
|
25
|
+
traits: event.traits
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return event;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.BrazeMiddlewarePlugin = BrazeMiddlewarePlugin;
|
|
33
|
+
//# sourceMappingURL=BrazeMiddlewarePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_eventsSdkReactNative","require","BrazeMiddlewarePlugin","Plugin","type","PluginType","before","key","lastSeenTraits","undefined","execute","event","EventType","IdentifyEvent","userId","anonymousId","traits","integrations","exports"],"sourceRoot":"../../src","sources":["BrazeMiddlewarePlugin.tsx"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAQO,MAAMC,qBAAqB,SAASC,4BAAM,CAAC;EAChDC,IAAI,GAAGC,gCAAU,CAACC,MAAM;EACxBC,GAAG,GAAG,QAAQ;EACNC,cAAc,GAA8BC,SAAS;EAE7DC,OAAOA,CAACC,KAAqB,EAA8B;IACzD;IACA;IACA,IAAIA,KAAK,CAACP,IAAI,KAAKQ,+BAAS,CAACC,aAAa,EAAE;MAC1C,IACE,IAAI,CAACL,cAAc,EAAEM,MAAM,KAAKH,KAAK,CAACG,MAAM,IAC5C,IAAI,CAACN,cAAc,EAAEO,WAAW,KAAKJ,KAAK,CAACI,WAAW,IACtD,IAAI,CAACP,cAAc,EAAEQ,MAAM,KAAKL,KAAK,CAACK,MAAM,EAC5C;QACA,MAAMC,YAAY,GAAGN,KAAK,CAACM,YAAY;QAEvC,IAAIA,YAAY,KAAKR,SAAS,EAAE;UAC9BQ,YAAY,CAAC,IAAI,CAACV,GAAG,CAAC,GAAG,KAAK;QAChC;MACF,CAAC,MAAM;QACL,IAAI,CAACC,cAAc,GAAG;UACpBO,WAAW,EAAEJ,KAAK,CAACI,WAAW,IAAI,EAAE;UACpCD,MAAM,EAAEH,KAAK,CAACG,MAAM;UACpBE,MAAM,EAAEL,KAAK,CAACK;QAChB,CAAC;MACH;IACF;IACA,OAAOL,KAAK;EACd;AACF;AAACO,OAAA,CAAAhB,qBAAA,GAAAA,qBAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _BrazeMiddlewarePlugin = require("./BrazeMiddlewarePlugin");
|
|
7
|
+
Object.keys(_BrazeMiddlewarePlugin).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _BrazeMiddlewarePlugin[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _BrazeMiddlewarePlugin[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_BrazeMiddlewarePlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;AAAA,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,sBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,sBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,sBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Plugin, PluginType, EventType } from '@ht-sdks/events-sdk-react-native';
|
|
2
|
+
export class BrazeMiddlewarePlugin extends Plugin {
|
|
3
|
+
type = PluginType.before;
|
|
4
|
+
key = 'Appboy';
|
|
5
|
+
lastSeenTraits = undefined;
|
|
6
|
+
execute(event) {
|
|
7
|
+
//check to see if anything has changed
|
|
8
|
+
//if it hasn't changed disable integration
|
|
9
|
+
if (event.type === EventType.IdentifyEvent) {
|
|
10
|
+
if (this.lastSeenTraits?.userId === event.userId && this.lastSeenTraits?.anonymousId === event.anonymousId && this.lastSeenTraits?.traits === event.traits) {
|
|
11
|
+
const integrations = event.integrations;
|
|
12
|
+
if (integrations !== undefined) {
|
|
13
|
+
integrations[this.key] = false;
|
|
14
|
+
}
|
|
15
|
+
} else {
|
|
16
|
+
this.lastSeenTraits = {
|
|
17
|
+
anonymousId: event.anonymousId ?? '',
|
|
18
|
+
userId: event.userId,
|
|
19
|
+
traits: event.traits
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return event;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=BrazeMiddlewarePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Plugin","PluginType","EventType","BrazeMiddlewarePlugin","type","before","key","lastSeenTraits","undefined","execute","event","IdentifyEvent","userId","anonymousId","traits","integrations"],"sourceRoot":"../../src","sources":["BrazeMiddlewarePlugin.tsx"],"mappings":"AAAA,SACEA,MAAM,EACNC,UAAU,EAGVC,SAAS,QACJ,kCAAkC;AAEzC,OAAO,MAAMC,qBAAqB,SAASH,MAAM,CAAC;EAChDI,IAAI,GAAGH,UAAU,CAACI,MAAM;EACxBC,GAAG,GAAG,QAAQ;EACNC,cAAc,GAA8BC,SAAS;EAE7DC,OAAOA,CAACC,KAAqB,EAA8B;IACzD;IACA;IACA,IAAIA,KAAK,CAACN,IAAI,KAAKF,SAAS,CAACS,aAAa,EAAE;MAC1C,IACE,IAAI,CAACJ,cAAc,EAAEK,MAAM,KAAKF,KAAK,CAACE,MAAM,IAC5C,IAAI,CAACL,cAAc,EAAEM,WAAW,KAAKH,KAAK,CAACG,WAAW,IACtD,IAAI,CAACN,cAAc,EAAEO,MAAM,KAAKJ,KAAK,CAACI,MAAM,EAC5C;QACA,MAAMC,YAAY,GAAGL,KAAK,CAACK,YAAY;QAEvC,IAAIA,YAAY,KAAKP,SAAS,EAAE;UAC9BO,YAAY,CAAC,IAAI,CAACT,GAAG,CAAC,GAAG,KAAK;QAChC;MACF,CAAC,MAAM;QACL,IAAI,CAACC,cAAc,GAAG;UACpBM,WAAW,EAAEH,KAAK,CAACG,WAAW,IAAI,EAAE;UACpCD,MAAM,EAAEF,KAAK,CAACE,MAAM;UACpBE,MAAM,EAAEJ,KAAK,CAACI;QAChB,CAAC;MACH;IACF;IACA,OAAOJ,KAAK;EACd;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,cAAc,yBAAyB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Plugin, PluginType, HightouchEvent } from '@ht-sdks/events-sdk-react-native';
|
|
2
|
+
export declare class BrazeMiddlewarePlugin extends Plugin {
|
|
3
|
+
type: PluginType;
|
|
4
|
+
key: string;
|
|
5
|
+
private lastSeenTraits;
|
|
6
|
+
execute(event: HightouchEvent): HightouchEvent | undefined;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=BrazeMiddlewarePlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrazeMiddlewarePlugin.d.ts","sourceRoot":"","sources":["../../../src/BrazeMiddlewarePlugin.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,UAAU,EAEV,cAAc,EAEf,MAAM,kCAAkC,CAAC;AAE1C,qBAAa,qBAAsB,SAAQ,MAAM;IAC/C,IAAI,aAAqB;IACzB,GAAG,SAAY;IACf,OAAO,CAAC,cAAc,CAAwC;IAE9D,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,GAAG,SAAS;CAwB3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ht-sdks/events-sdk-react-native-plugin-braze-middleware",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "The hassle-free way to add Hightouch analytics to your React-Native app.",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "bob build",
|
|
8
|
+
"test": "jest",
|
|
9
|
+
"typescript": "tsc --noEmit",
|
|
10
|
+
"clean": "rimraf lib node_modules"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"hightouch",
|
|
14
|
+
"react-native",
|
|
15
|
+
"ios",
|
|
16
|
+
"android"
|
|
17
|
+
],
|
|
18
|
+
"module": "lib/module/index",
|
|
19
|
+
"types": "lib/typescript/src/index.d.ts",
|
|
20
|
+
"react-native": "src/index",
|
|
21
|
+
"source": "src/index",
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"lib",
|
|
25
|
+
"android",
|
|
26
|
+
"ios",
|
|
27
|
+
"cpp",
|
|
28
|
+
"hightouch-events-sdk-react-native.podspec",
|
|
29
|
+
"package.json",
|
|
30
|
+
"!src/**/*.e2e.mock.js",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!android/.gradle",
|
|
35
|
+
"!android/.idea"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/ht-sdks/events-sdk-react-native.git",
|
|
40
|
+
"directory": "packages/core"
|
|
41
|
+
},
|
|
42
|
+
"author": "Hightouch <hello@hightouch.com> (https://hightouch.com/)",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/ht-sdks/events-sdk-react-native/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/ht-sdks/events-sdk-react-native/tree/master/packages/plugins/plugin-braze-middleware#readme",
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@ht-sdks/events-sdk-react-native": "^2.18.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@ht-sdks/analytics-rn-shared": "workspace:^",
|
|
53
|
+
"@ht-sdks/events-sdk-react-native": "^2.18.0",
|
|
54
|
+
"@ht-sdks/sovran-react-native": "^1.1.0",
|
|
55
|
+
"jest": "^29.7.0",
|
|
56
|
+
"react-native-builder-bob": "^0.23.1",
|
|
57
|
+
"rimraf": "^5.0.5",
|
|
58
|
+
"typescript": "^5.2.2"
|
|
59
|
+
},
|
|
60
|
+
"react-native-builder-bob": {
|
|
61
|
+
"source": "src",
|
|
62
|
+
"output": "lib",
|
|
63
|
+
"targets": [
|
|
64
|
+
"commonjs",
|
|
65
|
+
"module",
|
|
66
|
+
"typescript"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=12"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Plugin,
|
|
3
|
+
PluginType,
|
|
4
|
+
UserInfoState,
|
|
5
|
+
HightouchEvent,
|
|
6
|
+
EventType,
|
|
7
|
+
} from '@ht-sdks/events-sdk-react-native';
|
|
8
|
+
|
|
9
|
+
export class BrazeMiddlewarePlugin extends Plugin {
|
|
10
|
+
type = PluginType.before;
|
|
11
|
+
key = 'Appboy';
|
|
12
|
+
private lastSeenTraits: UserInfoState | undefined = undefined;
|
|
13
|
+
|
|
14
|
+
execute(event: HightouchEvent): HightouchEvent | undefined {
|
|
15
|
+
//check to see if anything has changed
|
|
16
|
+
//if it hasn't changed disable integration
|
|
17
|
+
if (event.type === EventType.IdentifyEvent) {
|
|
18
|
+
if (
|
|
19
|
+
this.lastSeenTraits?.userId === event.userId &&
|
|
20
|
+
this.lastSeenTraits?.anonymousId === event.anonymousId &&
|
|
21
|
+
this.lastSeenTraits?.traits === event.traits
|
|
22
|
+
) {
|
|
23
|
+
const integrations = event.integrations;
|
|
24
|
+
|
|
25
|
+
if (integrations !== undefined) {
|
|
26
|
+
integrations[this.key] = false;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
this.lastSeenTraits = {
|
|
30
|
+
anonymousId: event.anonymousId ?? '',
|
|
31
|
+
userId: event.userId,
|
|
32
|
+
traits: event.traits,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return event;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BrazeMiddlewarePlugin';
|